IceSharedMemoryProvider< MemoryObject, MemoryObjectMetaInfo > Class Template Reference

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

+ Inheritance diagram for IceSharedMemoryProvider< MemoryObject, MemoryObjectMetaInfo >:

Public Types

using pointer_type = IceUtil::Handle< IceSharedMemoryProvider< MemoryObject, MemoryObjectMetaInfo > >
 pointer type for convenience. More...
 

Public Member Functions

MemoryObject * getBuffer ()
 Retrieve pointer to buffer. More...
 
Blob getData ()
 
Blob getData (MetaInfoSizeBasePtr &info, const Ice::Current &c=Ice::emptyCurrent) override
 return data via ice. More...
 
MemoryObjectMetaInfo::PointerType getMetaInfo (bool threadSafe=true) const
 getMetaInfo returns a copy of the memory object information More...
 
MetaInfoSizeBasePtr getMetaInfo (const Ice::Current &c) const override
 getMetaInfo returns a copy of the memory object information More...
 
SharedMemoryScopedReadLockPtr getScopedReadLock () const
 
SharedMemoryScopedWriteLockPtr getScopedWriteLock () const
 Retrieve scoped lock for writing to the memory. More...
 
int getSize (const Ice::Current &c=Ice::emptyCurrent) override
 return memory size via ice. More...
 
 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. More...
 
 IceSharedMemoryProvider (ManagedIceObject *object, typename MemoryObjectMetaInfo::PointerType info, std::string nameSuffix="")
 
void lock ()
 lock memory for writing More...
 
void setMetaInfo (const typename MemoryObjectMetaInfo::PointerType &info, bool threadSafe=true)
 
void start ()
 Starts the memory provider. More...
 
void stop ()
 Removes this object from Ice. More...
 
void unlock ()
 unlock memory after writing More...
 

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

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 50 of file IceSharedMemoryProvider.h.

Member Typedef Documentation

◆ pointer_type

using pointer_type = IceUtil::Handle<IceSharedMemoryProvider<MemoryObject, MemoryObjectMetaInfo> >

pointer type for convenience.

Definition at line 273 of file IceSharedMemoryProvider.h.

Constructor & Destructor Documentation

◆ IceSharedMemoryProvider() [1/2]

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 64 of file IceSharedMemoryProvider.h.

◆ IceSharedMemoryProvider() [2/2]

IceSharedMemoryProvider ( ManagedIceObject object,
typename MemoryObjectMetaInfo::PointerType  info,
std::string  nameSuffix = "" 
)
inline

Definition at line 88 of file IceSharedMemoryProvider.h.

◆ ~IceSharedMemoryProvider()

~IceSharedMemoryProvider ( )
inlineoverrideprotected

Definition at line 99 of file IceSharedMemoryProvider.h.

Member Function Documentation

◆ getBuffer()

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 144 of file IceSharedMemoryProvider.h.

+ Here is the caller graph for this function:

◆ getData() [1/2]

Blob getData ( )
inline

Definition at line 215 of file IceSharedMemoryProvider.h.

◆ getData() [2/2]

Blob getData ( MetaInfoSizeBasePtr &  info,
const Ice::Current &  c = Ice::emptyCurrent 
)
inlineoverride

return data via ice.

Definition at line 201 of file IceSharedMemoryProvider.h.

+ Here is the caller graph for this function:

◆ getMetaInfo() [1/2]

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

getMetaInfo returns a copy of the memory object information

Definition at line 243 of file IceSharedMemoryProvider.h.

+ Here is the caller graph for this function:

◆ getMetaInfo() [2/2]

MetaInfoSizeBasePtr getMetaInfo ( const Ice::Current &  c) const
inlineoverride

getMetaInfo returns a copy of the memory object information

Definition at line 256 of file IceSharedMemoryProvider.h.

◆ getScopedReadLock()

SharedMemoryScopedReadLockPtr getScopedReadLock ( ) const
inline

Definition at line 169 of file IceSharedMemoryProvider.h.

+ Here is the caller graph for this function:

◆ getScopedWriteLock()

SharedMemoryScopedWriteLockPtr getScopedWriteLock ( ) const
inline

Retrieve scoped lock for writing to the memory.

Returns
the scoped lock

Definition at line 156 of file IceSharedMemoryProvider.h.

+ Here is the caller graph for this function:

◆ getSize()

int getSize ( const Ice::Current &  c = Ice::emptyCurrent)
inlineoverride

return memory size via ice.

Definition at line 264 of file IceSharedMemoryProvider.h.

◆ lock()

void lock ( )
inline

lock memory for writing

Definition at line 185 of file IceSharedMemoryProvider.h.

+ Here is the caller graph for this function:

◆ setMetaInfo()

void setMetaInfo ( const typename MemoryObjectMetaInfo::PointerType &  info,
bool  threadSafe = true 
)
inline

Definition at line 228 of file IceSharedMemoryProvider.h.

+ Here is the caller graph for this function:

◆ start()

void start ( )
inline

Starts the memory provider.

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

Exceptions
SharedMemoryException

Definition at line 112 of file IceSharedMemoryProvider.h.

+ Here is the caller graph for this function:

◆ stop()

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 124 of file IceSharedMemoryProvider.h.

+ Here is the caller graph for this function:

◆ unlock()

void unlock ( )
inline

unlock memory after writing

Definition at line 193 of file IceSharedMemoryProvider.h.


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