SharedMemoryProvider< MemoryObject, MemoryObjectMetaInfo > Class Template Reference

#include <ArmarXCore/core/services/sharedmemory/SharedMemoryProvider.h>

Classes

class  Wrapper
 

Public Types

using pointer_type = std::shared_ptr< SharedMemoryProvider< MemoryObject, MemoryObjectMetaInfo > >
 Pointer type for convenience. More...
 

Public Member Functions

int getCapacity () const
 Retrieve size of usable shared memory. More...
 
MemoryObject * getMemory () const
 Retrieve pointer to shared memory. More...
 
MemoryObjectMetaInfo * getMetaInfo () const
 
SharedMemoryScopedReadLockPtr getScopedReadLock () const
 Retrieve scoped lock to the shared memory for reading. More...
 
SharedMemoryScopedWriteLockPtr getScopedWriteLock () const
 Retrieve scoped lock to the shared memory for writing. More...
 
int getSize () const
 Retrieve size of actual used shared memory. More...
 
void lock ()
 Lock shared memory for writing. More...
 
void setMetaInfo (const typename MemoryObjectMetaInfo::PointerType &info, bool threadSafe=false)
 
 SharedMemoryProvider (const std::string &newMemoryName, typename MemoryObjectMetaInfo::PointerType info)
 Creates a shared memory provider. More...
 
void unlock ()
 Unlock shared memory after writing. More...
 
 ~SharedMemoryProvider ()
 Destructs the shared memory provider. More...
 

Detailed Description

template<class MemoryObject, class MemoryObjectMetaInfo = MetaInfoSizeBase>
class armarx::SharedMemoryProvider< MemoryObject, MemoryObjectMetaInfo >

The SharedMemoryProvider creates a shared memory segment for writing. It provides synchronized write access to the shared data. The memory content is an array of objects, where the object type is specified as template parameter. The SharedMemoryProvider needs to be constructed, before a SharedMemoryConsumer can be created.

Definition at line 88 of file SharedMemoryProvider.h.

Member Typedef Documentation

◆ pointer_type

using pointer_type = std::shared_ptr<SharedMemoryProvider<MemoryObject, MemoryObjectMetaInfo> >

Pointer type for convenience.

Definition at line 335 of file SharedMemoryProvider.h.

Constructor & Destructor Documentation

◆ SharedMemoryProvider()

SharedMemoryProvider ( const std::string &  newMemoryName,
typename MemoryObjectMetaInfo::PointerType  info 
)
inline

Creates a shared memory provider.

Parameters
memoryNamename of the memory for identification in the SharedMemoryConsumer
numberElementsnumber of elements of type MemoryObject stored in the memory
Exceptions
SharedMemoryException

Definition at line 106 of file SharedMemoryProvider.h.

◆ ~SharedMemoryProvider()

~SharedMemoryProvider ( )
inline

Destructs the shared memory provider.

Removes the shared memory object of not used by another process.

Definition at line 195 of file SharedMemoryProvider.h.

Member Function Documentation

◆ getCapacity()

int getCapacity ( ) const
inline

Retrieve size of usable shared memory.

Returns
size in bytes

Definition at line 270 of file SharedMemoryProvider.h.

◆ getMemory()

MemoryObject* getMemory ( ) const
inline

Retrieve pointer to shared memory.

Use getScopedWriteLock() or lock() / unlock() before writing to the memory.

Returns
pointer to the shared memory with type MemoryObject

Definition at line 206 of file SharedMemoryProvider.h.

◆ getMetaInfo()

MemoryObjectMetaInfo* getMetaInfo ( ) const
inline

Definition at line 211 of file SharedMemoryProvider.h.

◆ getScopedReadLock()

SharedMemoryScopedReadLockPtr getScopedReadLock ( ) const
inline

Retrieve scoped lock to the shared memory for reading.

Returns
shared scoped lock to shared memory

Definition at line 298 of file SharedMemoryProvider.h.

◆ getScopedWriteLock()

SharedMemoryScopedWriteLockPtr getScopedWriteLock ( ) const
inline

Retrieve scoped lock to the shared memory for writing.

Returns
scoped lock to shared memory

Definition at line 281 of file SharedMemoryProvider.h.

+ Here is the caller graph for this function:

◆ getSize()

int getSize ( ) const
inline

Retrieve size of actual used shared memory.

Returns
size in bytes

Definition at line 259 of file SharedMemoryProvider.h.

◆ lock()

void lock ( )
inline

Lock shared memory for writing.

Definition at line 313 of file SharedMemoryProvider.h.

+ Here is the caller graph for this function:

◆ setMetaInfo()

void setMetaInfo ( const typename MemoryObjectMetaInfo::PointerType &  info,
bool  threadSafe = false 
)
inline

Definition at line 217 of file SharedMemoryProvider.h.

◆ unlock()

void unlock ( )
inline

Unlock shared memory after writing.

Definition at line 324 of file SharedMemoryProvider.h.


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