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.

Member Typedef Documentation

◆ pointer_type

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

pointer type for convenience.

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

◆ IceSharedMemoryProvider() [2/2]

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

◆ ~IceSharedMemoryProvider()

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

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

◆ getData() [1/2]

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

◆ getData() [2/2]

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

return data via ice.

◆ 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

◆ 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

◆ getScopedReadLock()

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

◆ getScopedWriteLock()

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

Retrieve scoped lock for writing to the memory.

Returns
the scoped lock

◆ getSize()

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

return memory size via ice.

◆ lock()

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

lock memory for writing

◆ setMetaInfo()

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

◆ 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

◆ 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.

◆ unlock()

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

unlock memory after writing


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