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.

Definition at line 55 of file SharedMemoryConsumer.h.

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.

Definition at line 244 of file SharedMemoryConsumer.h.

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

Definition at line 77 of file SharedMemoryConsumer.h.

◆ ~SharedMemoryConsumer()

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

Destructs the shared memory consumer.

Definition at line 146 of file SharedMemoryConsumer.h.

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

Definition at line 194 of file SharedMemoryConsumer.h.

◆ getMetaInfo()

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

Definition at line 171 of file SharedMemoryConsumer.h.

◆ 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

Definition at line 205 of file SharedMemoryConsumer.h.

+ Here is the caller graph for this function:

◆ getSize()

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

Retrieve size of usable shared memory.

Returns
size in bytes

Definition at line 158 of file SharedMemoryConsumer.h.

◆ lock()

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

Lock shared memory for reading.

Definition at line 221 of file SharedMemoryConsumer.h.

+ Here is the caller graph for this function:

◆ unlock()

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

Unlock shared memory after reading.

Definition at line 233 of file SharedMemoryConsumer.h.


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