Clover Git
OpenCL 1.1 software implementation
Public Types | Public Member Functions | Private Attributes

Coal::Object Class Reference

Base class of all the Clover objects. More...

#include <object.h>

Inheritance diagram for Coal::Object:
Collaboration diagram for Coal::Object:

List of all members.

Public Types

enum  Type {
  T_Device, T_CommandQueue, T_Event, T_Context,
  T_Kernel, T_MemObject, T_Program, T_Sampler
}
 

Type of object the inherited class actually is.

More...

Public Member Functions

 Object (Type type, Object *parent=0)
 Constructor.
virtual ~Object ()
void reference ()
 Increments the reference counter.
bool dereference ()
 Decrements the reference counter.
unsigned int references () const
 Reference counter.
void setReleaseParent (bool release)
 Set if the parent object has to be deleted if its reference count reaches 0.
Objectparent () const
 Parent object.
Type type () const
 Type.
bool isA (Type type) const
 Returns whether this object is an instance of type.

Private Attributes

unsigned int p_references
Objectp_parent
Type p_type
std::list< Object * >::iterator p_it
bool p_release_parent

Detailed Description

Base class of all the Clover objects.

This class implements functions needed by all the Clover objects, like reference counting, the object tree (parents/children), etc.

It also uses a special list of known objects, used to check that a pointer passed by the user to an OpenCL function actually is an object of the correct type. See isA().

Definition at line 51 of file object.h.


Member Enumeration Documentation

Type of object the inherited class actually is.

Enumerator:
T_Device 

Coal::DeviceInterface

T_CommandQueue 

Coal::CommandQueue

T_Event 

Coal::Event

T_Context 

Coal::Context

T_Kernel 

Coal::Kernel

T_MemObject 

Coal::MemObject

T_Program 

Coal::Program

T_Sampler 

Coal::Sampler

Reimplemented in Coal::Event, Coal::MemObject, and Coal::Program.

Definition at line 57 of file object.h.


Constructor & Destructor Documentation

Object::Object ( Type  type,
Object parent = 0 
)

Constructor.

Parameters:
typetype of the child class calling this constructor
parentparent object

Definition at line 44 of file object.cpp.

References getKnownObjects(), p_it, and reference().

Object::~Object ( ) [virtual]

Definition at line 55 of file object.cpp.

References dereference(), getKnownObjects(), p_it, p_parent, and p_release_parent.


Member Function Documentation

bool Object::dereference ( )

Decrements the reference counter.

Returns:
true if the reference counter has reached 0

Definition at line 69 of file object.cpp.

References p_references.

Referenced by clEnqueueMarker(), and ~Object().

bool Object::isA ( Object::Type  type) const

Returns whether this object is an instance of type.

Note:
This function begins with a NULL-check on the this pointer, so it's safe to use even when this is not guaranteed not to be NULL.
Parameters:
typetype this object must have for the check to pass
Returns:
true if this object exists and has the correct type

Definition at line 95 of file object.cpp.

References getKnownObjects(), and type().

Referenced by clSetUserEventStatus(), and Coal::Kernel::setArg().

Object * Object::parent ( ) const
void Object::reference ( )

Increments the reference counter.

Definition at line 64 of file object.cpp.

References p_references.

Referenced by clEnqueueMapBuffer(), clEnqueueMapImage(), Coal::CommandQueue::events(), Object(), and queueEvent().

unsigned int Object::references ( ) const

Reference counter.

Returns:
the number of references of this class currently in use

Definition at line 80 of file object.cpp.

References p_references.

Referenced by Coal::CommandQueue::cleanEvents(), Coal::Sampler::info(), Coal::Program::info(), Coal::MemObject::info(), Coal::Kernel::info(), Coal::Context::info(), Coal::Event::info(), and Coal::CommandQueue::info().

void Object::setReleaseParent ( bool  release)

Set if the parent object has to be deleted if its reference count reaches 0.

The destructor of Coal::Object dereferences its parent object. This is done in order to correctly free objects when no object has a reference to it anymore.

Some objects such as Coal::CommandQueue need to do some operations before being deleted. This function tells Coal::Object to dereference its parent object, but not to call delete on it.

Parameters:
releasetrue to have delete called on the parent object when its reference count reaches 0, false to keep it

Definition at line 75 of file object.cpp.

References p_release_parent.

Referenced by Coal::CommandQueue::cleanEvents().

Object::Type Object::type ( ) const

Member Data Documentation

std::list<Object *>::iterator Coal::Object::p_it [private]

Definition at line 127 of file object.h.

Referenced by Object(), and ~Object().

Reimplemented in Coal::SubBuffer.

Definition at line 125 of file object.h.

Referenced by parent(), and ~Object().

unsigned int Coal::Object::p_references [private]

Definition at line 124 of file object.h.

Referenced by dereference(), reference(), and references().

Definition at line 128 of file object.h.

Referenced by setReleaseParent(), and ~Object().

Reimplemented in Coal::Program.

Definition at line 126 of file object.h.

Referenced by Coal::Kernel::addFunction(), and type().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines