FARGOS/VISTA Object Management Environment Core  ..
FARGOS/VISTA Object Management Environment Core Table of Contents
SharedMemoryVariableManager Class Reference

Manager for collection of shared memory variables. More...

#include <shared_variable.hpp>

Public Member Functions

void attachExistingSegment (unsigned char *segment, size_t segmentLength)
 Use an existing, already initialized, memory segment for variable storage. More...
 
void attachExistingSegment (BufferRegion *bfr)
 Overloaded variant of attachExistingSegment() that uses an BufferRegion object in control of an already initialized segment. More...
 
void initializeSegment (unsigned char *segment, size_t segmentLength, const char *componentName)
 Initialize a memory segment for use as variable storage. More...
 
void initializeSegment (BufferRegion *bfr)
 Overloaded variant of initializeSegment that initializes a memory segment already under control of a BufferRegion for use as variable storage. More...
 
unsigned char * createAndAttachStandardSegment (const char *componentName, size_t *segmentLength)
 Convenience function to create a file and map it to segment for variable storage. The filename will include the component name, date, and process Id. More...
 
 SharedMemoryVariableManager (bool inDataSegment=true)
 Constructor for a shared memory variable manager. More...
 
 ~SharedMemoryVariableManager ()
 
int takeDeferredRegistrations (SharedMemoryVariableManager *otherMgr)
 
SharedMemoryVariable::SharedMemoryVariable_RecorditerateOver32BitSegment (SharedBufferAllocRecord_32 **iterator)
 
SharedMemoryVariable::SharedMemoryVariable_RecorditerateOver64BitSegment (SharedBufferAllocRecord_64 **iterator)
 
size_t offsetInSegment (const SharedMemoryVariable::SharedMemoryVariable_Record *rec) const
 
bool initialized () const OME_ALWAYS_INLINE
 
bool registerVariable (SharedMemoryVariable &var)
 Register a single variable with the segment manager. More...
 
void registerVariables (int count, SharedMemoryVariable *vars[])
 Register an array of variables with the segment manager. More...
 

Static Public Member Functions

static unsigned char * createSegment (const char *fileName, size_t *segmentLengthPtr, int initMode=MAP_FILE_INIT, const char *desiredMagicNumber=SMV_MAGIC_NUMBER)
 Open a file and map it to a memory segment for variable storage. More...
 

Protected Types

typedef std::list< SharedMemoryVariable * > smv_list_t
 

Protected Member Functions

void allocateVariable (SharedMemoryVariable *var)
 Internal routine to allocate storage within the segment for a shared memory variable. More...
 
void allocateDeferredVariables ()
 Internal routine to allocate previously registered SharedMemoryVariables within a newly allocated segment. More...
 

Protected Attributes

smv_list_tdeferredList
 
BufferRegionbfrMgr
 
unsigned char * regionBase
 
size_t regionLength
 

Detailed Description

Manager for collection of shared memory variables.

Note
One of the significant features of the SharedMemoryVariableManager is that it provides support for registering SharedMemoryVariables with it prior to the shared memory segment being created. This allows static variables to be defined and the segment to be created at runtime after a file name is computed.

Member Typedef Documentation

◆ smv_list_t

Constructor & Destructor Documentation

◆ SharedMemoryVariableManager()

SharedMemoryVariableManager::SharedMemoryVariableManager ( bool  inDataSegment = true)
explicit

Constructor for a shared memory variable manager.

Parameters
inDataSegmentshould be set to false if the object is constructed in the heap (e.g., via the new operator).

◆ ~SharedMemoryVariableManager()

SharedMemoryVariableManager::~SharedMemoryVariableManager ( )

Member Function Documentation

◆ allocateDeferredVariables()

void SharedMemoryVariableManager::allocateDeferredVariables ( )
protected

Internal routine to allocate previously registered SharedMemoryVariables within a newly allocated segment.

◆ allocateVariable()

◆ attachExistingSegment() [1/2]

void SharedMemoryVariableManager::attachExistingSegment ( BufferRegion bfr)

Overloaded variant of attachExistingSegment() that uses an BufferRegion object in control of an already initialized segment.

Parameters
bfrspecifies the BufferRegion manager owning the segment. Ownership of the BufferRegion object is transferred.

This routine does not destroy the existing contents of the region.

References BufferRegion::getBufferBase(), and BufferRegion::getRegionLength().

◆ attachExistingSegment() [2/2]

void SharedMemoryVariableManager::attachExistingSegment ( unsigned char *  segment,
size_t  segmentLength 
)

Use an existing, already initialized, memory segment for variable storage.

This routine does not destroy the existing contents of the region and is typically used by an external process to access a segment.

◆ createAndAttachStandardSegment()

unsigned char * SharedMemoryVariableManager::createAndAttachStandardSegment ( const char *  componentName,
size_t *  segmentLength 
)

Convenience function to create a file and map it to segment for variable storage. The filename will include the component name, date, and process Id.

References FILENAME_WITH_EVERYTHING, makeQualifiedFileName(), MAP_FILE_INIT, safe_strcpy, and SMV_MAGIC_NUMBER.

◆ createSegment()

unsigned char * SharedMemoryVariableManager::createSegment ( const char *  fileName,
size_t *  segmentLengthPtr,
int  initMode = MAP_FILE_INIT,
const char *  desiredMagicNumber = SMV_MAGIC_NUMBER 
)
static

Open a file and map it to a memory segment for variable storage.

Parameters
fileNamespecifies the file to be opened.
segmentLengthPtrpoints to an area from which the desired segment length will be taken or will be filled in with the size of the opened file.
initModeis a mode for createMappedFile(), typically MAP_FILE_INIT.
desiredMagicNumberpoints to a sequence of character that will be used as the magic number for the segment. Typically this is SMV_MAGIC_NUMBER.

References createMappedFile(), SharedBufferRegionHeader_32::magicNumber, and MAP_FILE_RESET.

Referenced by ReadMappedCircularBuffer::ReadMappedCircularBuffer().

◆ initialized()

bool SharedMemoryVariableManager::initialized ( ) const
inline

References bfrMgr.

◆ initializeSegment() [1/2]

void SharedMemoryVariableManager::initializeSegment ( BufferRegion bfr)

Overloaded variant of initializeSegment that initializes a memory segment already under control of a BufferRegion for use as variable storage.

Parameters
bfrpoints to an already established BufferRegion whose region will be initialized for use. Ownership of the BufferRegion object is transferred.

References BufferRegion::getBufferBase(), and BufferRegion::getRegionLength().

◆ initializeSegment() [2/2]

void SharedMemoryVariableManager::initializeSegment ( unsigned char *  segment,
size_t  segmentLength,
const char *  componentName 
)

Initialize a memory segment for use as variable storage.

Parameters
segmentpoints to the base of the segment
segmentLengthspecifies the length of the segment
componentNamespecifies the name of the component initializing the segment.

References SMV_MAGIC_NUMBER.

◆ iterateOver32BitSegment()

◆ iterateOver64BitSegment()

◆ offsetInSegment()

size_t SharedMemoryVariableManager::offsetInSegment ( const SharedMemoryVariable::SharedMemoryVariable_Record rec) const
inline

◆ registerVariable()

bool SharedMemoryVariableManager::registerVariable ( SharedMemoryVariable var)

Register a single variable with the segment manager.

References SharedMemoryVariable::getName(), and SharedMemoryVariable::registered.

Referenced by SharedMemoryVariable::SharedMemoryVariable().

◆ registerVariables()

void SharedMemoryVariableManager::registerVariables ( int  count,
SharedMemoryVariable vars[] 
)

Register an array of variables with the segment manager.

◆ takeDeferredRegistrations()

int SharedMemoryVariableManager::takeDeferredRegistrations ( SharedMemoryVariableManager otherMgr)

Member Data Documentation

◆ bfrMgr

BufferRegion* SharedMemoryVariableManager::bfrMgr
protected

Referenced by initialized(), and offsetInSegment().

◆ deferredList

smv_list_t* SharedMemoryVariableManager::deferredList
protected

◆ regionBase

unsigned char* SharedMemoryVariableManager::regionBase
protected

◆ regionLength

size_t SharedMemoryVariableManager::regionLength
protected

The documentation for this class was generated from the following files:
Generated: Tue Jul 28 2020 16:03:27
Support Information