ParCompMark::Pointer< T, Lock > Class Template Reference

#include <PCMPointer.h>

Inheritance diagram for ParCompMark::Pointer< T, Lock >:

Inheritance graph
[legend]
Collaboration diagram for ParCompMark::Pointer< T, Lock >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<typename T, class Lock>
class ParCompMark::Pointer< T, Lock >

Template smart pointer class.

Remarks:
This class provides: exception safe, garbage colletion, thread safeness, and more efficiency

Definition at line 55 of file PCMPointer.h.


Methods

virtual bool isNull () const
 Return true if the pointer does not reference anything.
virtual bool isNotNull () const
 Return true if the pointer does reference something.
virtual void assignWithLock (Pointer< T, Lock > &pointer)
 Assign another smart pointer with keeping it locked.
virtual void reference (const T *pointer)
 Take reference from a C style pointer (does not delete referenced object when smart pointer dies).
virtual T * getPtr ()
 Return a C style pointer to the referenced object.
virtual void kill (const bool &force=false)
 Force deallocating referenced object.
virtual void setNull (const bool &force=false)
 Set the referenced object to null without trying to deallocate the actual object.
virtual void lock ()
 Lock the referenced object.
virtual bool trylock ()
 Try locking referenced object.
virtual void unlock ()
 Unlock the referenced object.
virtual bool getLocked () const
 Return true, if the object is locked.
virtual void _deletePointer (const bool &force=false, const bool &keepLock=false)
 Delete the pointer.
virtual void _assignCPointer (const T *pointer, const bool &takeOwnership=true)
 Assign a C style pointer.
virtual void _assignPointer (Pointer< T, Lock > &pointer, const bool &keepLock=false)
 Assign another smart pointer.
virtual void _switchPointer (Pointer< T, Lock > &pointer, const bool &keepLock=false)
 Switch to another smart pointer.
virtual bool _equalsCPointer (const T *pointer) const
 Test indentity.
virtual bool _equalsPointer (Pointer< T, Lock > &pointer) const
 Test indentity.

Public Member Functions

Constructors & destructor
 Pointer ()
 Create a NULL pointer.
 Pointer (const T *pointer, const bool &takeOwnership=true)
 Create smart pointer from a C style pointer.
 Pointer (Pointer< T, Lock > &pointer)
 Create smart pointer from an another smart pointer.
 Pointer (const Pointer< T, Lock > &pointer)
 Create smart pointer from an another const smart pointer.
virtual ~Pointer ()
 The destructor.
Operators
virtual const Pointer< T,
Lock > & 
operator= (const T *pointer)
 Assign a C style pointer.
virtual const Pointer< T,
Lock > & 
operator= (Pointer< T, Lock > &pointer)
 Assign another smart pointer.
virtual const Pointer< T,
Lock > & 
operator= (const Pointer< T, Lock > &pointer)
 Assign another smart pointer (const version).
virtual T * operator-> ()
 Get referenced object.
virtual bool operator== (const T *pointer)
 template < typename T, class Lock > inline T Pointer < T, Lock >operator*() Implementation of operator * { Assert(isNotNull(), NULL_POINTER_ERROR, "Pointer::operator()"); return *(mMeta->ptr); }
virtual bool operator== (Pointer< T, Lock > &pointer)
 Equality test operator.
virtual bool operator!= (const T *pointer)
 Equality test operator on a C style pointer.
virtual bool operator!= (Pointer< T, Lock > &pointer)
 Equality test operator.

Static Public Attributes

Class constants
static const Pointer< T, Lock > * NULLPTR
 Null pointer constant.

Protected Attributes

Variables
MetamMeta
 Meta field for the referenced object.

Classes

struct  Meta
 Meta field type for the referenced object. More...

Constructor & Destructor Documentation

template<typename T, class Lock>
ParCompMark::Pointer< T, Lock >::Pointer (  )  [inline]

Create a NULL pointer.

Definition at line 394 of file PCMPointer.h.

template<typename T, class Lock>
ParCompMark::Pointer< T, Lock >::Pointer ( const T *  pointer,
const bool &  takeOwnership = true 
) [inline, explicit]

Create smart pointer from a C style pointer.

Parameters:
[in] pointer C style pointer
[in] takeOwnership Takes ownership of the assigned object. It will be deleted when smart pointer dies.

Definition at line 407 of file PCMPointer.h.

template<typename T, class Lock>
ParCompMark::Pointer< T, Lock >::Pointer ( Pointer< T, Lock > &  pointer  )  [inline]

Create smart pointer from an another smart pointer.

(Copy constructor)

Parameters:
[out] pointer Another smart pointer to assign.

Definition at line 417 of file PCMPointer.h.

template<typename T, class Lock>
ParCompMark::Pointer< T, Lock >::Pointer ( const Pointer< T, Lock > &  pointer  )  [inline]

Create smart pointer from an another const smart pointer.

(Constantant copy constructor)

Parameters:
[in] pointer Another smart pointer to assign.

Definition at line 426 of file PCMPointer.h.

template<typename T, class Lock>
ParCompMark::Pointer< T, Lock >::~Pointer (  )  [virtual]

The destructor.

This class has virtual destructor.

Definition at line 436 of file PCMPointer.h.


Member Function Documentation

template<typename T, class Lock>
void ParCompMark::Pointer< T, Lock >::_assignCPointer ( const T *  pointer,
const bool &  takeOwnership = true 
) [inline, protected, virtual]

Assign a C style pointer.

Parameters:
[in] pointer C style pointer
[in] takeOwnership Takes ownership of the assigned object. It will be deleted when smart pointer dies.

Definition at line 705 of file PCMPointer.h.

template<typename T, class Lock>
void ParCompMark::Pointer< T, Lock >::_assignPointer ( Pointer< T, Lock > &  pointer,
const bool &  keepLock = false 
) [inline, protected, virtual]

Assign another smart pointer.

Parameters:
[out] pointer Another smart pointer to assign.
[in] keepLock Keep the pointer locked.

Definition at line 718 of file PCMPointer.h.

template<typename T, class Lock>
void ParCompMark::Pointer< T, Lock >::_deletePointer ( const bool &  force = false,
const bool &  keepLock = false 
) [inline, protected, virtual]

Delete the pointer.

Decrease reference counter, relese lock, free memory if needed.

Parameters:
[in] force If false, the object will only be deallocated when one it has one reference.
[in] keepLock Keep the pointer locked.

Definition at line 677 of file PCMPointer.h.

template<typename T, class Lock>
bool ParCompMark::Pointer< T, Lock >::_equalsCPointer ( const T *  pointer  )  const [inline, protected, virtual]

Test indentity.

Parameters:
[in] pointer C style pointer
Returns:
True if the data in parameter is identical to the smart pointer.

Definition at line 751 of file PCMPointer.h.

template<typename T, class Lock>
bool ParCompMark::Pointer< T, Lock >::_equalsPointer ( Pointer< T, Lock > &  pointer  )  const [inline, protected, virtual]

Test indentity.

Parameters:
[out] pointer Another smart pointer to assign.
Returns:
True if the data in parameter is identical to the smart pointer.

Definition at line 758 of file PCMPointer.h.

template<typename T, class Lock>
void ParCompMark::Pointer< T, Lock >::_switchPointer ( Pointer< T, Lock > &  pointer,
const bool &  keepLock = false 
) [inline, protected, virtual]

Switch to another smart pointer.

Helps changing reference under continous lock.

Parameters:
[out] pointer Another smart pointer to assign.
[in] keepLock Keep the pointer locked.

Definition at line 732 of file PCMPointer.h.

template<typename T, class Lock>
void ParCompMark::Pointer< T, Lock >::assignWithLock ( Pointer< T, Lock > &  pointer  )  [inline, virtual]

Assign another smart pointer with keeping it locked.

Parameters:
[out] pointer Another smart pointer to assign.

Definition at line 590 of file PCMPointer.h.

template<typename T, class Lock>
bool ParCompMark::Pointer< T, Lock >::getLocked (  )  const [inline, virtual]

template<typename T, class Lock>
bool ParCompMark::Pointer< T, Lock >::isNotNull (  )  const [inline, virtual]

template<typename T, class Lock>
bool ParCompMark::Pointer< T, Lock >::isNull (  )  const [inline, virtual]

Return true if the pointer does not reference anything.

Returns:
True if the pointer does not reference anything.

Definition at line 575 of file PCMPointer.h.

Referenced by ParCompMark::Network::getIP().

template<typename T, class Lock>
void ParCompMark::Pointer< T, Lock >::lock (  )  [inline, virtual]

Lock the referenced object.

Definition at line 647 of file PCMPointer.h.

Referenced by ParCompMark::PluginManager::_loadPlugin(), ParCompMark::GLXRenderWindow::_setCaption(), ParCompMark::Application::_start(), ParCompMark::Application::_stop(), ParCompMark::Process::actualizeRenderWindow(), ParCompMark::FileSystemManager::closeFile(), ParCompMark::Application::commanderOperation(), ParCompMark::Node::createBuffer(), ParCompMark::Application::createLowLevelScript(), ParCompMark::Host::createNode(), ParCompMark::Node::createProcess(), ParCompMark::RendererPlugin::createRenderer(), ParCompMark::Application::createVirtualMachines(), ParCompMark::GLXRenderWindow::createWindow(), ParCompMark::GLXRenderWindow::destroyWindow(), ParCompMark::Application::executeUserCommand(), ParCompMark::GLXRenderWindow::finalize(), ParCompMark::GLXGLContext::finalize(), ParCompMark::SqVM::findOrAddScript(), ParCompMark::SqVM::findScript(), ParCompMark::PluginManager::getPlugin(), ParCompMark::ConfigOptions::getValue(), ParCompMark::Client::handleMessage(), ParCompMark::ConfigOptions::hasOption(), ParCompMark::NetServer::initialize(), ParCompMark::Host::initialize(), ParCompMark::GLXGLContext::initialize(), ParCompMark::Application::initializeDynamicScriptParameters(), ParCompMark::Process::initProcess(), ParCompMark::Process::openRenderWindow(), ParCompMark::Host::openXDisplay(), ParCompMark::Application::processScenarioScript(), ParCompMark::GLXRenderWindow::releaseCurrent(), ParCompMark::GLXGLContext::releaseCurrent(), ParCompMark::ConfigOptions::removeOption(), ParCompMark::Application::retrieveDynamicScriptParameters(), ParCompMark::Process::runningProcess(), ParCompMark::NetServer::sendBroadcastMessage(), ParCompMark::GLXRenderWindow::setCurrent(), ParCompMark::GLXGLContext::setCurrent(), ParCompMark::Application::setEnvironmentVariablesToSquirrel(), ParCompMark::ConfigOptions::setValue(), ParCompMark::Process::task(), ParCompMark::HandleClient::task(), ParCompMark::Process::threadFinalize(), ParCompMark::Process::threadInitialize(), and ParCompMark::Application::writeOutput().

template<typename T, class Lock>
bool ParCompMark::Pointer< T, Lock >::operator!= ( Pointer< T, Lock > &  pointer  )  [inline, virtual]

Equality test operator.

Parameters:
[out] pointer Another smart pointer to test.
Returns:
True if the referenced objects are not identical.

Definition at line 563 of file PCMPointer.h.

template<typename T, class Lock>
bool ParCompMark::Pointer< T, Lock >::operator!= ( const T *  pointer  )  [inline, virtual]

Equality test operator on a C style pointer.

Parameters:
[in] pointer C style pointer
Returns:
True if the referenced object is not identical to the parameter.

Definition at line 555 of file PCMPointer.h.

template<typename T, class Lock>
T * ParCompMark::Pointer< T, Lock >::operator-> (  )  [inline, virtual]

Get referenced object.

Returns:
Referenced object.

Definition at line 498 of file PCMPointer.h.

template<typename T, class Lock>
const Pointer< T, Lock > & ParCompMark::Pointer< T, Lock >::operator= ( const Pointer< T, Lock > &  pointer  )  [inline, virtual]

Assign another smart pointer (const version).

Parameters:
[in] pointer Another smart pointer to assign.
Returns:
Self reference.

Definition at line 484 of file PCMPointer.h.

template<typename T, class Lock>
const Pointer< T, Lock > & ParCompMark::Pointer< T, Lock >::operator= ( Pointer< T, Lock > &  pointer  )  [inline, virtual]

Assign another smart pointer.

Parameters:
[out] pointer Another smart pointer to assign.
Returns:
Self reference.

Definition at line 469 of file PCMPointer.h.

template<typename T, class Lock>
const Pointer< T, Lock > & ParCompMark::Pointer< T, Lock >::operator= ( const T *  pointer  )  [inline, virtual]

Assign a C style pointer.

Parameters:
[in] pointer C style pointer
Returns:
Self reference.

Definition at line 448 of file PCMPointer.h.

template<typename T, class Lock>
bool ParCompMark::Pointer< T, Lock >::operator== ( Pointer< T, Lock > &  pointer  )  [inline, virtual]

Equality test operator.

Parameters:
[out] pointer Another smart pointer to test.
Returns:
True if the referenced objects are identical.

Definition at line 547 of file PCMPointer.h.

template<typename T, class Lock>
bool ParCompMark::Pointer< T, Lock >::operator== ( const T *  pointer  )  [inline, virtual]

template < typename T, class Lock > inline T Pointer < T, Lock >operator*() Implementation of operator * { Assert(isNotNull(), NULL_POINTER_ERROR, "Pointer::operator()"); return *(mMeta->ptr); }

Parameters:
[in] pointer C style pointer
Returns:
True if the referenced object is identical to the parameter.

Definition at line 539 of file PCMPointer.h.

template<typename T, class Lock>
void ParCompMark::Pointer< T, Lock >::reference ( const T *  pointer  )  [inline, virtual]

Take reference from a C style pointer (does not delete referenced object when smart pointer dies).

Parameters:
[in] pointer C style pointer

Definition at line 606 of file PCMPointer.h.

Referenced by ParCompMark::HostInfo::refreshCPUs(), and ParCompMark::HostInfo::refreshGPUs().

template<typename T, class Lock>
void ParCompMark::Pointer< T, Lock >::setNull ( const bool &  force = false  )  [inline, virtual]

Set the referenced object to null without trying to deallocate the actual object.

Remarks:
The typical usage of this method the external deallocating a pointer, like fclose.

Parameters:
[in] force If false, the reference will only be set to null when one it has one reference.

Definition at line 637 of file PCMPointer.h.

Referenced by ParCompMark::FileSystemManager::closeFile().

template<typename T, class Lock>
bool ParCompMark::Pointer< T, Lock >::trylock (  )  [inline, virtual]

Try locking referenced object.

Returns:
True if the locking was successful.

Definition at line 654 of file PCMPointer.h.

template<typename T, class Lock>
void ParCompMark::Pointer< T, Lock >::unlock (  )  [inline, virtual]

Unlock the referenced object.

Definition at line 662 of file PCMPointer.h.

Referenced by ParCompMark::PluginManager::_loadPlugin(), ParCompMark::GLXRenderWindow::_setCaption(), ParCompMark::Application::_start(), ParCompMark::Application::_stop(), ParCompMark::Process::actualizeRenderWindow(), ParCompMark::FileSystemManager::closeFile(), ParCompMark::Application::commanderOperation(), ParCompMark::Node::createBuffer(), ParCompMark::Application::createLowLevelScript(), ParCompMark::Host::createNode(), ParCompMark::Node::createProcess(), ParCompMark::RendererPlugin::createRenderer(), ParCompMark::Application::createVirtualMachines(), ParCompMark::GLXRenderWindow::createWindow(), ParCompMark::GLXRenderWindow::destroyWindow(), ParCompMark::Application::executeUserCommand(), ParCompMark::GLXRenderWindow::finalize(), ParCompMark::GLXGLContext::finalize(), ParCompMark::SqVM::findOrAddScript(), ParCompMark::SqVM::findScript(), ParCompMark::PluginManager::getPlugin(), ParCompMark::ConfigOptions::getValue(), ParCompMark::Client::handleMessage(), ParCompMark::ConfigOptions::hasOption(), ParCompMark::NetServer::initialize(), ParCompMark::Host::initialize(), ParCompMark::GLXGLContext::initialize(), ParCompMark::Application::initializeDynamicScriptParameters(), ParCompMark::Process::initProcess(), ParCompMark::Process::openRenderWindow(), ParCompMark::Host::openXDisplay(), ParCompMark::Application::processScenarioScript(), ParCompMark::GLXRenderWindow::releaseCurrent(), ParCompMark::GLXGLContext::releaseCurrent(), ParCompMark::ConfigOptions::removeOption(), ParCompMark::Application::retrieveDynamicScriptParameters(), ParCompMark::Process::runningProcess(), ParCompMark::NetServer::sendBroadcastMessage(), ParCompMark::GLXRenderWindow::setCurrent(), ParCompMark::GLXGLContext::setCurrent(), ParCompMark::Application::setEnvironmentVariablesToSquirrel(), ParCompMark::ConfigOptions::setValue(), ParCompMark::Process::task(), ParCompMark::HandleClient::task(), ParCompMark::Process::threadFinalize(), ParCompMark::Process::threadInitialize(), and ParCompMark::Application::writeOutput().


Member Data Documentation

template<typename T, class Lock>
Meta* ParCompMark::Pointer< T, Lock >::mMeta [protected]

Meta field for the referenced object.

Remarks:
This is own attribute of this class.

Definition at line 119 of file PCMPointer.h.

template<typename T, class Lock>
const Pointer< T, Lock > * ParCompMark::Pointer< T, Lock >::NULLPTR [static]

Initial value:

        Pointer < T, DummyLock > ()
Null pointer constant.

Remarks:
This is own attribute of this class.

Definition at line 101 of file PCMPointer.h.


The documentation for this class was generated from the following files: