SharedMemoryConsumer< MemoryObject, MemoryObjectMetaInfo > Class Template Reference

The SharedMemoryConsumer opens an existing shared memory segment for reading. More...

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

Classes

class  Wrapper
 

Public Types

using pointer_type
 Pointer type for convenience.
 

Public Member Functions

MemoryObject * getMemory ()
 Retrieve pointer to shared memory.
 
MemoryObjectMetaInfo::PointerType getMetaInfo (bool threadSafe=true) const
 
SharedMemoryScopedReadLockPtr getScopedReadLock () const
 Retrieve scoped lock to the shared memory for reading.
 
int getSize () const
 Retrieve size of usable shared memory.
 
void lock ()
 Lock shared memory for reading.
 
 SharedMemoryConsumer (std::string newMemoryName)
 Creates a shared memory consumer.
 
void unlock ()
 Unlock shared memory after reading.
 
 ~SharedMemoryConsumer ()
 Destructs the shared memory consumer.
 

Detailed Description

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

The SharedMemoryConsumer opens an existing shared memory segment for reading.

It provides synchronized read access to the shared data. The memory content is an array of objects, where the object type is specified as template parameter. The SharedMemoryConsumer needs to be constructed, after a SharedMemoryProvider has been created.

Member Typedef Documentation

◆ pointer_type

template<class MemoryObject, class MemoryObjectMetaInfo = MetaInfoSizeBase>
using pointer_type
Initial value:
std::shared_ptr<SharedMemoryConsumer<MemoryObject, MemoryObjectMetaInfo>>

Pointer type for convenience.

Constructor & Destructor Documentation

◆ SharedMemoryConsumer()

template<class MemoryObject, class MemoryObjectMetaInfo = MetaInfoSizeBase>
SharedMemoryConsumer ( std::string newMemoryName)
inline

Creates a shared memory consumer.

Parameters
memoryNamename of the memory as set in the SharedMemoryProvider
Exceptions
SharedMemoryConnectionFailure

◆ ~SharedMemoryConsumer()

template<class MemoryObject, class MemoryObjectMetaInfo = MetaInfoSizeBase>
~SharedMemoryConsumer ( )
inline

Destructs the shared memory consumer.

Member Function Documentation

◆ getMemory()

template<class MemoryObject, class MemoryObjectMetaInfo = MetaInfoSizeBase>
MemoryObject * getMemory ( )
inline

Retrieve pointer to shared memory.

Use getScopedReadLock() or lock() / unlock() before reading from the memory.

Returns
pointer to the shared memory with type MemoryObject

◆ getMetaInfo()

template<class MemoryObject, class MemoryObjectMetaInfo = MetaInfoSizeBase>
MemoryObjectMetaInfo::PointerType getMetaInfo ( bool threadSafe = true) const
inline

◆ getScopedReadLock()

template<class MemoryObject, class MemoryObjectMetaInfo = MetaInfoSizeBase>
SharedMemoryScopedReadLockPtr getScopedReadLock ( ) const
inline

Retrieve scoped lock to the shared memory for reading.

Returns
scoped lock to shared memory

◆ getSize()

template<class MemoryObject, class MemoryObjectMetaInfo = MetaInfoSizeBase>
int getSize ( ) const
inline

Retrieve size of usable shared memory.

Returns
size in bytes

◆ lock()

template<class MemoryObject, class MemoryObjectMetaInfo = MetaInfoSizeBase>
void lock ( )
inline

Lock shared memory for reading.

◆ unlock()

template<class MemoryObject, class MemoryObjectMetaInfo = MetaInfoSizeBase>
void unlock ( )
inline

Unlock shared memory after reading.


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