Clover Git
OpenCL 1.1 software implementation
|
Base class of all the Clover objects. More...
#include <object.h>
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. | |
Object * | parent () 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 |
Object * | p_parent |
Type | p_type |
std::list< Object * >::iterator | p_it |
bool | p_release_parent |
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()
.
enum Coal::Object::Type |
Type of object the inherited class actually is.
Reimplemented in Coal::Event, Coal::MemObject, and Coal::Program.
Constructor.
type | type of the child class calling this constructor |
parent | parent 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.
bool Object::dereference | ( | ) |
Decrements the reference counter.
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
.
this
pointer, so it's safe to use even when this
is not guaranteed not to be NULL. type | type this object must have for the check to pass |
Definition at line 95 of file object.cpp.
References getKnownObjects(), and type().
Referenced by clSetUserEventStatus(), and Coal::Kernel::setArg().
Object * Object::parent | ( | ) | const |
Parent object.
Reimplemented in Coal::SubBuffer.
Definition at line 85 of file object.cpp.
References p_parent.
Referenced by Coal::BufferEvent::BufferEvent(), Coal::Sampler::checkImageAvailability(), clBuildProgram(), Coal::Event::freeDeviceData(), Coal::Sampler::info(), Coal::Program::info(), Coal::MemObject::info(), Coal::Kernel::info(), Coal::Event::info(), Coal::CommandQueue::info(), Coal::MemObject::init(), Coal::CPUDevice::initEventDeviceData(), Coal::Event::profilingInfo(), Coal::CPUKernelWorkGroup::run(), and Coal::Event::setStatus().
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.
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.
release | true 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 |
Type.
Reimplemented in Coal::Event, Coal::ReadBufferEvent, Coal::WriteBufferEvent, Coal::MapBufferEvent, Coal::MapImageEvent, Coal::UnmapBufferEvent, Coal::CopyBufferEvent, Coal::CopyBufferRectEvent, Coal::ReadBufferRectEvent, Coal::WriteBufferRectEvent, Coal::ReadImageEvent, Coal::WriteImageEvent, Coal::CopyImageEvent, Coal::CopyImageToBufferEvent, Coal::CopyBufferToImageEvent, Coal::NativeKernelEvent, Coal::KernelEvent, Coal::TaskEvent, Coal::UserEvent, Coal::BarrierEvent, Coal::WaitForEventsEvent, Coal::MarkerEvent, Coal::MemObject, Coal::Buffer, Coal::SubBuffer, Coal::Image2D, Coal::Image3D, and Coal::Program.
Definition at line 90 of file object.cpp.
References p_type.
Referenced by isA().
std::list<Object *>::iterator Coal::Object::p_it [private] |
Object* Coal::Object::p_parent [private] |
Reimplemented in Coal::SubBuffer.
unsigned int Coal::Object::p_references [private] |
Definition at line 124 of file object.h.
Referenced by dereference(), reference(), and references().
bool Coal::Object::p_release_parent [private] |
Definition at line 128 of file object.h.
Referenced by setReleaseParent(), and ~Object().
Type Coal::Object::p_type [private] |
Reimplemented in Coal::Program.
Definition at line 126 of file object.h.
Referenced by Coal::Kernel::addFunction(), and type().