CARMA C++
carma::util::IPQfileBuffer Class Reference

Shared memory storage mechanism. More...

#include <carma/util/IPQfileBuffer.h>

Inheritance diagram for carma::util::IPQfileBuffer:
carma::util::IPQbufferBase carma::util::IPQbasicTypeFileBuffer carma::util::IPQfileReader< E > carma::util::IPQfileWriter< E >

Protected Member Functions

 IPQfileBuffer (void *localElement, int elementSize, const ::std::string &filename, bool isCreator=false, int nElements=0, unsigned int testOffset=0)
 Constructor for persistent queue. More...
 
- Protected Member Functions inherited from carma::util::IPQbufferBase
::std::string getTrimmedFilename ()
 Get the trimmed filename. More...
 
void init ()
 This does all the real constructor work. More...
 
 IPQbufferBase (void *localElement, int elementSize, const ::std::string &filename, bool isCreator=false, int nElements=0, unsigned int testOffset=0)
 Constructor for a read/write queue. More...
 
void trimShmemFilename ()
 Shared memory filenames must contain only one '/' and it must be the first character; this routine fixes up the filename. More...
 
void write ()
 Put an element into the queue. More...
 
- Protected Member Functions inherited from carma::util::IPQinterface
virtual void write ()=0
 Useful only for debugging. More...
 

Additional Inherited Members

- Public Member Functions inherited from carma::util::IPQbufferBase
int getElementSize () const
 Returns the size of each element in the queue in bytes. More...
 
::std::string getFileName () const
 Get the filename. More...
 
unsigned int getGetOffset () const
 Useful only for debugging. More...
 
unsigned int getLostElementCount () const
 Get the number of elements lost on the last read. More...
 
unsigned int getMaxOffset () const
 Useful only for debugging. More...
 
int getNumAvailable () const
 Gets the number of unread elements available in the queue. More...
 
unsigned int getPutOffset () const
 Used internally, but made public for debugging. More...
 
int getQueueSize () const
 Returns the allocated size of the queue. More...
 
bool isDataAvailable () const
 Checks to see if there are any unread elements (would a read not block?). More...
 
bool isEmpty () const
 Checks to see if the queue is empty. More...
 
unsigned int read ()
 Read the oldest unread element from the queue. More...
 
bool readNewest ()
 Get the newest element from the queue (with locking). More...
 
bool readNewestConditionalCopy ()
 Reads and copies the newest element from the queue into the localElement buffer, but only if has not been previously read. More...
 
void setNoneAvailable ()
 Sets the number of available (unread) elements to zero (catches up) More...
 
virtual ~IPQbufferBase ()
 Destructor Making this d'tor virtual causes the d'tors of inheriting classes to be called first when the d'tor is called on this base class (polymorphic), followed by the base class d'tor. More...
 
- Public Member Functions inherited from carma::util::IPQinterface
virtual int getElementSize () const =0
 Returns the size of each element in the queue in bytes. More...
 
virtual ::std::string getFileName () const =0
 Get the filename. More...
 
virtual unsigned int getGetOffset () const =0
 Useful only for debugging. More...
 
virtual unsigned int getLostElementCount () const =0
 Get the number of elements lost on the last read. More...
 
virtual unsigned int getMaxOffset () const =0
 Useful only for debugging. More...
 
virtual int getNumAvailable () const =0
 Gets the number of unread elements available in the queue. More...
 
virtual unsigned int getPutOffset () const =0
 
virtual int getQueueSize () const =0
 Returns the allocated size of the queue. More...
 
virtual bool isDataAvailable () const =0
 Checks to see if there are any unread elements (would a read not block?). More...
 
virtual bool isEmpty () const =0
 Checks to see if the queue is empty. More...
 
virtual unsigned int read ()=0
 Read the oldest unread element from the queue. More...
 
virtual bool readNewest ()=0
 Get the newest element from the queue (with locking). More...
 
virtual bool readNewestConditionalCopy ()=0
 Reads and copies the newest element from the queue into the localElement buffer, but only if has not been previously read. More...
 
virtual void setNoneAvailable ()=0
 Sets the number of available (unread) elements to zero (catches up) More...
 
virtual ~IPQinterface ()=0
 Destructor Making this d'tor virtual causes the d'tors of inheriting classes to be called first when the d'tor is called on this base class (polymorphic), followed by the base class d'tor. More...
 
- Protected Attributes inherited from carma::util::IPQbufferBase
bool debug_
 
int fileDescriptor_
 
const int openMask_
 
const int protectionMask_
 

Detailed Description

Shared memory storage mechanism.

for an IPQ buffer.

This class is a base class for reader and writer classes. See for e.g.

See Also
IPQfileReader, IPQfileWriter

Definition at line 29 of file IPQfileBuffer.h.

Constructor & Destructor Documentation

carma::util::IPQfileBuffer::IPQfileBuffer ( void *  localElement,
int  elementSize,
const ::std::string &  filename,
bool  isCreator = false,
int  nElements = 0,
unsigned int  testOffset = 0 
)
protected

Constructor for persistent queue.

Parameters
localElementaddress of the data buffer for reads/writes
elementSizeof an individual queue element in bytes
filenameMemory mapped filename. File must be on a native file system and not on an NFS mounted filesystem, or extremely poor performance will result.
isCreatorIf true, create a new file if one doesn't exist, and make its size match nElementsuse.
nElementsNumber of elements to allocate (queue length); ignored if not a creator.
Exceptions
std::exception

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