IceSharedMemoryProvider< MemoryObject, MemoryObjectMetaInfo > Class Template Reference

The IceSharedMemoryProvider provides data via Ice or shared memory. More...

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

+ Inheritance diagram for IceSharedMemoryProvider< MemoryObject, MemoryObjectMetaInfo >:

Public Types

using pointer_type
 pointer type for convenience.
 

Public Member Functions

MemoryObject * getBuffer ()
 Retrieve pointer to buffer.
 
Blob getData ()
 
Blob getData (MetaInfoSizeBasePtr &info, const Ice::Current &c=Ice::emptyCurrent) override
 return data via ice.
 
MemoryObjectMetaInfo::PointerType getMetaInfo (bool threadSafe=true) const
 getMetaInfo returns a copy of the memory object information
 
MetaInfoSizeBasePtr getMetaInfo (const Ice::Current &c) const override
 getMetaInfo returns a copy of the memory object information
 
SharedMemoryScopedReadLockPtr getScopedReadLock () const
 
SharedMemoryScopedWriteLockPtr getScopedWriteLock () const
 Retrieve scoped lock for writing to the memory.
 
int getSize (const Ice::Current &c=Ice::emptyCurrent) override
 return memory size via ice.
 
 IceSharedMemoryProvider (ManagedIceObject *object, int size, int capacity=0, std::string nameSuffix="")
 Creates an ice shared memory provider which transparentely communicates using shared memory on local machines and using Ice on remote machines.
 
 IceSharedMemoryProvider (ManagedIceObject *object, typename MemoryObjectMetaInfo::PointerType info, std::string nameSuffix="")
 
void lock ()
 lock memory for writing
 
void setMetaInfo (const typename MemoryObjectMetaInfo::PointerType &info, bool threadSafe=true)
 
void start ()
 Starts the memory provider.
 
void stop ()
 Removes this object from Ice.
 
void unlock ()
 unlock memory after writing
 

Protected Member Functions

 ~IceSharedMemoryProvider () override
 
- Protected Member Functions inherited from HardwareIdentifierProvider
std::string getHardwareId (const Ice::Current &c=Ice::emptyCurrent) override
 Retrieve machine's hardware Id string.
 

Detailed Description

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

The IceSharedMemoryProvider provides data via Ice or shared memory.

Whether Ice or shared memory is used for data transfer is determined based on the hardware id of the machine. The provider should be constructed in the onInit method and started in the onStart method.
Use the getScopedWriteLock() or lock() / unlock() methods before writing to the memory.

Definition at line 51 of file IceSharedMemoryProvider.h.

Member Typedef Documentation

◆ pointer_type

template<class MemoryObject, class MemoryObjectMetaInfo = MetaInfoSizeBase>
using pointer_type

Constructor & Destructor Documentation

◆ IceSharedMemoryProvider() [1/2]

template<class MemoryObject, class MemoryObjectMetaInfo = MetaInfoSizeBase>
IceSharedMemoryProvider ( ManagedIceObject * object,
int size,
int capacity = 0,
std::string nameSuffix = "" )
inline

Creates an ice shared memory provider which transparentely communicates using shared memory on local machines and using Ice on remote machines.

Parameters
componentpointer to component
numberElementsnumber of elements of type MemoryObject stored in the memory
Exceptions
SharedMemoryException

Definition at line 65 of file IceSharedMemoryProvider.h.

◆ IceSharedMemoryProvider() [2/2]

template<class MemoryObject, class MemoryObjectMetaInfo = MetaInfoSizeBase>
IceSharedMemoryProvider ( ManagedIceObject * object,
typename MemoryObjectMetaInfo::PointerType info,
std::string nameSuffix = "" )
inline

Definition at line 91 of file IceSharedMemoryProvider.h.

◆ ~IceSharedMemoryProvider()

template<class MemoryObject, class MemoryObjectMetaInfo = MetaInfoSizeBase>
~IceSharedMemoryProvider ( )
inlineoverrideprotected

Definition at line 105 of file IceSharedMemoryProvider.h.

+ Here is the call graph for this function:

Member Function Documentation

◆ getBuffer()

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

Retrieve pointer to buffer.

This buffer should only be used for writing. Before writing do not forget to lock the provider using either lock() and unlock() or getScopedLock()

Returns
pointer to the shared memory segment

Definition at line 155 of file IceSharedMemoryProvider.h.

+ Here is the caller graph for this function:

◆ getData() [1/2]

template<class MemoryObject, class MemoryObjectMetaInfo = MetaInfoSizeBase>
Blob getData ( )
inline

Definition at line 230 of file IceSharedMemoryProvider.h.

+ Here is the call graph for this function:

◆ getData() [2/2]

template<class MemoryObject, class MemoryObjectMetaInfo = MetaInfoSizeBase>
Blob getData ( MetaInfoSizeBasePtr & info,
const Ice::Current & c = Ice::emptyCurrent )
inlineoverride

return data via ice.

Definition at line 215 of file IceSharedMemoryProvider.h.

+ Here is the call graph for this function:

◆ getMetaInfo() [1/2]

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

getMetaInfo returns a copy of the memory object information

Definition at line 259 of file IceSharedMemoryProvider.h.

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

◆ getMetaInfo() [2/2]

template<class MemoryObject, class MemoryObjectMetaInfo = MetaInfoSizeBase>
MetaInfoSizeBasePtr getMetaInfo ( const Ice::Current & c) const
inlineoverride

getMetaInfo returns a copy of the memory object information

Definition at line 273 of file IceSharedMemoryProvider.h.

+ Here is the call graph for this function:

◆ getScopedReadLock()

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

Definition at line 180 of file IceSharedMemoryProvider.h.

+ Here is the caller graph for this function:

◆ getScopedWriteLock()

template<class MemoryObject, class MemoryObjectMetaInfo = MetaInfoSizeBase>
SharedMemoryScopedWriteLockPtr getScopedWriteLock ( ) const
inline

Retrieve scoped lock for writing to the memory.

Returns
the scoped lock

Definition at line 166 of file IceSharedMemoryProvider.h.

+ Here is the caller graph for this function:

◆ getSize()

template<class MemoryObject, class MemoryObjectMetaInfo = MetaInfoSizeBase>
int getSize ( const Ice::Current & c = Ice::emptyCurrent)
inlineoverride

return memory size via ice.

Definition at line 282 of file IceSharedMemoryProvider.h.

◆ lock()

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

lock memory for writing

Definition at line 197 of file IceSharedMemoryProvider.h.

+ Here is the caller graph for this function:

◆ setMetaInfo()

template<class MemoryObject, class MemoryObjectMetaInfo = MetaInfoSizeBase>
void setMetaInfo ( const typename MemoryObjectMetaInfo::PointerType & info,
bool threadSafe = true )
inline

Definition at line 243 of file IceSharedMemoryProvider.h.

+ Here is the call graph for this function:

◆ start()

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

Starts the memory provider.

The component needs to be connected, otherwise method will fail.

Exceptions
SharedMemoryException

Definition at line 118 of file IceSharedMemoryProvider.h.

◆ stop()

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

Removes this object from Ice.

Call this if you want to use a sharedmemory with the same name again.

Definition at line 134 of file IceSharedMemoryProvider.h.

+ Here is the caller graph for this function:

◆ unlock()

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

unlock memory after writing

Definition at line 206 of file IceSharedMemoryProvider.h.


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