Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

nvsg::Object Class Reference

Base class for all objects. More...

#include <Object.h>

Inheritance diagram for nvsg::Object:

Inheritance graph
[legend]
Collaboration diagram for nvsg::Object:

Collaboration graph
[legend]
List of all members.

Public Member Functions

unsigned int getObjectCode () const
 Identify an object at runtime by means of its object code.
virtual NVSG_API bool isDataShared (void) const
 Determine whether the data of this object is shared.
virtual NVSG_API DataID getDataID (void) const
 Get the DataID of the data of this object.
NVSG_API void setName (const std::string &name)
 Set the name of the object using C++ style string.
NVSG_API const std::string & getName (void) const
 Get the name of the object.
NVSG_API bool waitToRead (size_t milliseconds=0xFFFFFFFF) const
 Acquire read access in a multithreaded environment.
NVSG_API void doneReading (void) const
 Signal when finished reading the object.
NVSG_API bool waitToWrite (size_t milliseconds=0xFFFFFFFF) const
 Acquire write access in a multithreaded enviroment.
NVSG_API void doneWriting (void) const
 Signal when finished writing the object.

Protected Member Functions

NVSG_API Object (void)
 Constructor.
NVSG_API Object (const Object &rhs)
 Copy constructor.
virtual NVSG_API ~Object ()
 Protected destructor to prevent explicit creation on stack.

Protected Attributes

unsigned int m_objectCode
 object code (unique per object type)

Related Functions

(Note that these are not member functions.)

template<typename T>
T * beginEdit (const T *obj)
template<typename T>
const T * endEdit (T *&obj)

Detailed Description

Base class for all objects.

This class maintains a name and a user pointer for all objects that derive from it.


Constructor & Destructor Documentation

NVSG_API nvsg::Object::Object void   )  [protected]
 

Constructor.

NVSG_API nvsg::Object::Object const Object rhs  )  [protected]
 

Copy constructor.

virtual NVSG_API nvsg::Object::~Object  )  [protected, virtual]
 

Protected destructor to prevent explicit creation on stack.


Member Function Documentation

unsigned int nvsg::Object::getObjectCode  )  const [inline]
 

Identify an object at runtime by means of its object code.

Returns:
The object code, which is unique per object type.

virtual NVSG_API bool nvsg::Object::isDataShared void   )  const [virtual]
 

Determine whether the data of this object is shared.

Note:
Every class deriving from Object should reimplement this function in the same way!
Returns:
true if the object's data is shared, otherwise false.

Reimplemented in nvsg::AnimatedQuads, nvsg::AnimatedTransform, nvsg::AnimatedTriangles, nvsg::Animation< T >, nvsg::CgFx, nvsg::DirectedLight, nvsg::Drawable, nvsg::FaceAttribute, nvsg::GeoNode, nvsg::GeoSet, nvsg::Group, nvsg::JitterCamera, nvsg::LightSource, nvsg::Material, nvsg::Node, nvsg::PointLight, nvsg::Quads, nvsg::QuadStrips, nvsg::SimpleCamera, nvsg::SkinnedTriangles, nvsg::SpotLight, nvsg::StateAttribute, nvsg::StateSet, nvsg::StereoCamera, nvsg::Switch, nvsg::TextureAttributeItem, nvsg::TextureAttribute, nvsg::Transform, nvsg::Triangles, nvsg::TriStrips, nvsg::Animation< nvmath::Trafo >, and nvsg::Animation< VNVector >.

virtual NVSG_API DataID nvsg::Object::getDataID void   )  const [virtual]
 

Get the DataID of the data of this object.

Note:
Every class deriving from Object should reimplement this function in the same way!
Returns:
DataID of the object's data.

Reimplemented in nvsg::AnimatedQuads, nvsg::AnimatedTransform, nvsg::AnimatedTriangles, nvsg::Animation< T >, nvsg::CgFx, nvsg::DirectedLight, nvsg::Drawable, nvsg::FaceAttribute, nvsg::GeoNode, nvsg::GeoSet, nvsg::Group, nvsg::JitterCamera, nvsg::LightSource, nvsg::Material, nvsg::Node, nvsg::PointLight, nvsg::Quads, nvsg::QuadStrips, nvsg::SimpleCamera, nvsg::SkinnedTriangles, nvsg::SpotLight, nvsg::StateAttribute, nvsg::StateSet, nvsg::StereoCamera, nvsg::Switch, nvsg::TextureAttributeItem, nvsg::TextureAttribute, nvsg::Transform, nvsg::Triangles, nvsg::TriStrips, nvsg::Animation< nvmath::Trafo >, and nvsg::Animation< VNVector >.

void nvsg::Object::setName const std::string &  name  )  [inline]
 

Set the name of the object using C++ style string.

Parameters:
name  name of the object

const std::string & nvsg::Object::getName void   )  const [inline]
 

Get the name of the object.

Returns:
name of the object

bool nvsg::Object::waitToRead size_t  milliseconds = 0xFFFFFFFF  )  const [inline]
 

Acquire read access in a multithreaded environment.

For safety in a multithreaded environment, an object maintains a read/write locking mechanism that allows contemporaneous access by multiple readers but restricts write access to a single writer.

This function returns either when it obtains read access or when the time-out interval elapses. By default, this function waits indefinitely.
Returns:
true, if read access could be acquired, false otherwise.

void nvsg::Object::doneReading void   )  const [inline]
 

Signal when finished reading the object.

Read access to this object, acquired by a previous call to waitToRead, is ended by a call to this function.

bool nvsg::Object::waitToWrite size_t  milliseconds = 0xFFFFFFFF  )  const [inline]
 

Acquire write access in a multithreaded enviroment.

For safety in a multithreaded environment, an object maintains a read/write locking mechanism that allows contemporaneous access for multiple readers but restricts write access to a single writer.

This function returns either when it gets write access or when the time-out interval elapses. By default, this function waits indefinitely.
Returns:
true, if write access could be acquired, false otherwise.
Parameters:
milliseconds  Time-out interval, in millisceconds.

void nvsg::Object::doneWriting void   )  const [inline]
 

Signal when finished writing the object.

Write access to this object, acquired by a previous call to waitToWrite, is ended by a call to this function.


Friends And Related Function Documentation

template<typename T>
T * beginEdit const T *  obj  )  [related]
 

Initiates a safe edit operation on an NVSG Object.

The function returns when the calling thread successfully obtained write access to the object. If the object is currently locked for write or read access from a concurrent thread, the calling thread enters the wait state. It uses no processor time while waiting to obtain write access.

After getting write access to the object, the function returns a pointer to the non-const object. Throught this pointer, the const and especially the non-const interface of the object can be accessed.

When the function returns, the object is protected against any write or read access from concurrent threads. After the desired edit operation has been completed, the write lock for the object must be released through a corresponding call to endEdit . Missing the endEdit call after completing the edit operation can cause the system to become deadlocked!

Returns:
A pointer to the now writable object.
Note:
The behavior is undefined if called with an invalid pointer.
Parameters:
obj  Specifies the object for which write access is requested.

template<typename T>
const T * endEdit T *&  obj  )  [related]
 

Ends an edit operation on an NVSG Object.

The function ends an edit operation that previously has been initiated through a call to beginEdit .

The function must be called with the pointer to the non-const object, that has been returned by the matching call to beginEdit. The write lock for the object will be released and the function returns a pointer to the const object, through which only the const interface of the object could be utilized.

Immediately after the call, the passed pointer to the non-const object becomes invalid. Hence, using the pointer to the non-const object after this call leads to undefined behavior!

Returns:
A pointer to the non-const object, which is not writable anymore.
Note:
The behavior is undefined if called with an invalid pointer.
Parameters:
obj  Specifies the object for which write access should be released.


Member Data Documentation

unsigned int nvsg::Object::m_objectCode [protected]
 

object code (unique per object type)


The documentation for this class was generated from the following file:
Generated on Tue Mar 1 13:20:51 2005 for NVSGSDK by NVIDIA