VR-Forces 4.3 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Attributes | Friends
DtDebugDrawerSharedMemoryManager Class Reference

Creates shared memory for debug drawer. More...

Classes

struct  Header
class  ReadLock
class  ScopedFrame

Public Types

typedef
DtDebugDrawerNameManager::MemoryType 
MemoryType
typedef DtDebugMemoryBlockHeader DtMemoryHeader

Public Member Functions

 DtDebugDrawerSharedMemoryManager (unsigned long memorySize=30 *MB)
virtual ~DtDebugDrawerSharedMemoryManager ()
 Default destructor.
virtual bool init (MemoryType memoryType, bool clearMemory=false)
 Initializes shared memory for access by another copy of this class in another program.
virtual bool init (std::string tag, bool clearMemory=false, MemoryType memoryType=DtDebugDrawerNameManager::DtDebugDrawerSharedMemoryVRFType)
Header header () const
void setHeader (const Header &)
long getName () const
bool enabled () const
void setEnabled (bool val)
virtual bool push (DtDebugDrawerGeometryMemory *shape)
 Pushes an instance of DtDebugDrawerGeometryMemory onto shared memory.

Static Public Attributes

static const unsigned long KB = static_cast<unsigned long>(1) << 10
static const unsigned long MB = static_cast<unsigned long>(1) << 20
static const unsigned long GB = static_cast<unsigned long>(1) << 30

Protected Attributes

unsigned long myRequestedMaxSize
unsigned long myCurrentSize
 Current used size of shared memory (in bytes).
charmyCurrentMemPtr
 Pointer to the current writable location in shared memory.
charmyMemoryPtr
 Pointer to the start of shared memory.
DtMemoryHeadermyHeader
 Pointer to the header in shared memory.
LocalSharedMemoryPoolManager * myManager
 Shared memory wrapper class objects.
DtSharedMemoryPoolClient * myClient
DtDebugDrawerNameManagermyNameManager
 Connection to the name memory block where names are stored for the GUI.
bool myIsReader
long myMemoryName
MemoryType myMemoryType
boost::scoped_array< charmyBuffer
size_t myBufferSize

Friends

class ScopedLock
class ScopedFrame
virtual unsigned long frameCount () const
 Frame count allows the drawer of shapes to indicate that a complete frame has been completed and is ready for drawing.
virtual unsigned long numEntries () const
 Must call this function before calling getNext().
virtual unsigned long currentSize () const
 Current used size of shared memory (in bytes).
virtual const chargetNext (const char *previousPtr, DtDebugDrawerGeometryMemory **shape)
 Expects that pointToMemoryBlock() has been called.
virtual std::vector
< DtDebugDrawerNameManager::Slot
getMemoryBlockNames ()
 Return the names of all the memory blocks of the configured memory type.
virtual bool pointToMemoryBlock (long name)
 Switches this instance of shared memory to point to a different block of memory.
void readLock () const
 Frame count allows the drawer of shapes to indicate that a complete frame has been completed and is ready for drawing.
void readUnlock () const
 Frame count allows the drawer of shapes to indicate that a complete frame has been completed and is ready for drawing.
void startNewFrame (bool erase=true)
 Notifies the shared memory block that it will be writing new data.
void advanceFrameCount (bool outputErrors=true)
 Frame count allows the drawer of shapes to indicate that a complete frame has been completed and is ready for drawing.

Detailed Description

Creates shared memory for debug drawer.

Member Typedef Documentation

typedef DtDebugMemoryBlockHeader DtDebugDrawerSharedMemoryManager::DtMemoryHeader

Constructor & Destructor Documentation

DtDebugDrawerSharedMemoryManager::DtDebugDrawerSharedMemoryManager ( unsigned long  memorySize = 30 *MB)
Parameters
memorySizeUse default. Agreed upon size of the memory block you wish to allocate (in bytes). The value defaults to 3*10485670 bytes (30MB).
virtual DtDebugDrawerSharedMemoryManager::~DtDebugDrawerSharedMemoryManager ( )
virtual

Default destructor.

Shared memory will be destroyed when the last instance of this class is destroyed of a given name from init().

Member Function Documentation

virtual bool DtDebugDrawerSharedMemoryManager::init ( MemoryType  memoryType,
bool  clearMemory = false 
)
virtual

Initializes shared memory for access by another copy of this class in another program.

The name and size must match in all instances for access to the same shared memory space. Default parameters are generally enough. This function, if arg is true, will ask the name manager for a name and set it's name property to that. This will be how this block of memory is referenced.

Parameters
clearMemoryTrue if you are the writer to memory, false otherwise.
virtual bool DtDebugDrawerSharedMemoryManager::init ( std::string  tag,
bool  clearMemory = false,
MemoryType  memoryType = DtDebugDrawerNameManager::DtDebugDrawerSharedMemoryVRFType 
)
virtual
Header DtDebugDrawerSharedMemoryManager::header ( ) const
void DtDebugDrawerSharedMemoryManager::setHeader ( const Header )
long DtDebugDrawerSharedMemoryManager::getName ( ) const
bool DtDebugDrawerSharedMemoryManager::enabled ( ) const
void DtDebugDrawerSharedMemoryManager::setEnabled ( bool  val)
virtual bool DtDebugDrawerSharedMemoryManager::push ( DtDebugDrawerGeometryMemory shape)
virtual

Pushes an instance of DtDebugDrawerGeometryMemory onto shared memory.

If memory is full, it will simply not push any more data on. If init() has not been invoked, it will not push any data to shared memory.If the shape pointer is null it will not push anything. If the shape pointer is not a valid shape defined in DtDebugDrawerGeometry it will not push the data to memory. If an instance of this class has not pushed any data via this function, this function should not be called by this instance. Only one instance should be calling this function.

Parameters
shapePointer to a DtDebugDrawerGeometryMemory to put in shared memory. Will always append to the end of previous push() call.
virtual unsigned long DtDebugDrawerSharedMemoryManager::frameCount ( ) const
virtual

Frame count allows the drawer of shapes to indicate that a complete frame has been completed and is ready for drawing.

The reader of the data can compare the frame count to the last frame that they read, and know whether anything has changed.

virtual unsigned long DtDebugDrawerSharedMemoryManager::numEntries ( ) const
virtual

Must call this function before calling getNext().

This function's return value is based on the number of times push() is called.

Returns
Returns the number of times getNext() can be called.
virtual unsigned long DtDebugDrawerSharedMemoryManager::currentSize ( ) const
virtual

Current used size of shared memory (in bytes).

Only the instance performing push() will have the current used size.

virtual const char* DtDebugDrawerSharedMemoryManager::getNext ( const char previousPtr,
DtDebugDrawerGeometryMemory **  shape 
)
virtual

Expects that pointToMemoryBlock() has been called.

Expects that numEntries() is called afterwards so as to not go beyond the shared memory space or even to empty shared memory. Expects a null pointer for the previousPtr for the first entry inserted through push(). Will delete the shape pointer reference and replace it with the next shape added in subsequent push() calls. It is up to the caller to delete the the final shape once the end of numEntries() has been reached and no further calls to this function will be made. Any number of instances of this class may retrieve the memory though this function.

Parameters
previousPtrPass in a null pointer for the first entry in shared memory. Subsequent calls expects the pointer it returned as this parameter previously.
shapePointer to a pointer to an instance of DtDebugDrawerGeometryMemory or null. The pointer returned will point to the pointer to the new DtDebugDrawerGeometryMemory retrieved from shared memory that was previously added via push().
Returns
Returns a pointer to the next block of memory after the read or 0 depending on how it fails.
virtual std::vector<DtDebugDrawerNameManager::Slot> DtDebugDrawerSharedMemoryManager::getMemoryBlockNames ( )
virtual

Return the names of all the memory blocks of the configured memory type.

virtual bool DtDebugDrawerSharedMemoryManager::pointToMemoryBlock ( long  name)
virtual

Switches this instance of shared memory to point to a different block of memory.

Each block is keyed by name (which is unique) and you can specify which block of memory you want to point to using this function. Generally, you want to get the block name from the getMemoryBlockName() function. If you happen to know the name of the memory block, then it can also be manually entered.

Returns
If the memory block was openned succesfully.
Parameters
nameThe name of the memory block you wish to point to.
void DtDebugDrawerSharedMemoryManager::readLock ( ) const
protected

Frame count allows the drawer of shapes to indicate that a complete frame has been completed and is ready for drawing.

The reader of the data can compare the frame count to the last frame that they read, and know whether anything has changed.

void DtDebugDrawerSharedMemoryManager::readUnlock ( ) const
protected

Frame count allows the drawer of shapes to indicate that a complete frame has been completed and is ready for drawing.

The reader of the data can compare the frame count to the last frame that they read, and know whether anything has changed.

void DtDebugDrawerSharedMemoryManager::startNewFrame ( bool  erase = true)
protected

Notifies the shared memory block that it will be writing new data.

numEntries() will return 0 after this function is called.

void DtDebugDrawerSharedMemoryManager::advanceFrameCount ( bool  outputErrors = true)
protected

Frame count allows the drawer of shapes to indicate that a complete frame has been completed and is ready for drawing.

The reader of the data can compare the frame count to the last frame that they read, and know whether anything has changed.

Friends And Related Function Documentation

friend class ScopedLock
friend
friend class ScopedFrame
friend

Member Data Documentation

const unsigned long DtDebugDrawerSharedMemoryManager::KB = static_cast<unsigned long>(1) << 10
static
const unsigned long DtDebugDrawerSharedMemoryManager::MB = static_cast<unsigned long>(1) << 20
static
const unsigned long DtDebugDrawerSharedMemoryManager::GB = static_cast<unsigned long>(1) << 30
static
unsigned long DtDebugDrawerSharedMemoryManager::myRequestedMaxSize
protected
unsigned long DtDebugDrawerSharedMemoryManager::myCurrentSize
protected

Current used size of shared memory (in bytes).

Only the instance performing push() will have the current used size and should not be modified in that instance.

char* DtDebugDrawerSharedMemoryManager::myCurrentMemPtr
protected

Pointer to the current writable location in shared memory.

Only the instance performing push() will have this pointer set.

char* DtDebugDrawerSharedMemoryManager::myMemoryPtr
protected

Pointer to the start of shared memory.

DtMemoryHeader* DtDebugDrawerSharedMemoryManager::myHeader
protected

Pointer to the header in shared memory.

LocalSharedMemoryPoolManager* DtDebugDrawerSharedMemoryManager::myManager
protected

Shared memory wrapper class objects.

DtSharedMemoryPoolClient* DtDebugDrawerSharedMemoryManager::myClient
protected
DtDebugDrawerNameManager* DtDebugDrawerSharedMemoryManager::myNameManager
protected

Connection to the name memory block where names are stored for the GUI.

bool DtDebugDrawerSharedMemoryManager::myIsReader
protected
long DtDebugDrawerSharedMemoryManager::myMemoryName
protected
MemoryType DtDebugDrawerSharedMemoryManager::myMemoryType
protected
boost::scoped_array<char> DtDebugDrawerSharedMemoryManager::myBuffer
protected
size_t DtDebugDrawerSharedMemoryManager::myBufferSize
protected

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

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)