SharedMemoryConsumer< MemoryObject, MemoryObjectMetaInfo > Class Template Reference

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

Classes

class  Wrapper
 

Public Types

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

Public Member Functions

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

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 53 of file SharedMemoryConsumer.h.

Member Typedef Documentation

◆ pointer_type

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

Pointer type for convenience.

Definition at line 223 of file SharedMemoryConsumer.h.

Constructor & Destructor Documentation

◆ SharedMemoryConsumer()

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 74 of file SharedMemoryConsumer.h.

◆ ~SharedMemoryConsumer()

~SharedMemoryConsumer ( )
inline

Destructs the shared memory consumer.

Definition at line 131 of file SharedMemoryConsumer.h.

Member Function Documentation

◆ getMemory()

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 176 of file SharedMemoryConsumer.h.

◆ getMetaInfo()

MemoryObjectMetaInfo::PointerType getMetaInfo ( bool  threadSafe = true) const
inline

Definition at line 153 of file SharedMemoryConsumer.h.

+ Here is the call graph for this function:

◆ getScopedReadLock()

SharedMemoryScopedReadLockPtr getScopedReadLock ( ) const
inline

Retrieve scoped lock to the shared memory for reading.

Returns
scoped lock to shared memory

Definition at line 186 of file SharedMemoryConsumer.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSize()

int getSize ( ) const
inline

Retrieve size of usable shared memory.

Returns
size in bytes

Definition at line 142 of file SharedMemoryConsumer.h.

+ Here is the call graph for this function:

◆ lock()

void lock ( )
inline

Lock shared memory for reading.

Definition at line 201 of file SharedMemoryConsumer.h.

+ Here is the caller graph for this function:

◆ unlock()

void unlock ( )
inline

Unlock shared memory after reading.

Definition at line 212 of file SharedMemoryConsumer.h.


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