30 #include <ArmarXCore/interface/core/SharedMemory.h>
33 #include <Ice/ObjectAdapter.h>
34 #include <Ice/Initialize.h>
49 template <
class MemoryObject,
class MemoryObjectMetaInfo = MetaInfoSizeBase>
52 virtual public SharedMemoryProviderInterface
67 memoryName =
object->getName() +
"Memory" + nameSuffix;
69 this->
object = object;
71 typename MemoryObjectMetaInfo::PointerType info =
new MemoryObjectMetaInfo();
76 info->capacity = capacity;
80 info->capacity = size;
84 initSharedMemory(
object, info);
90 memoryName =
object->getName() +
"Memory" + nameSuffix;
92 this->
object = object;
96 initSharedMemory(
object, info);
114 if (object->
getState() < eManagedIceObjectStarting)
130 memoryAdapter->remove(
id);
131 object->getIceManager()->getIceGridSession()->getAdmin()->removeObject(
id);
132 memoryAdapter->destroy();
133 memoryAdapter = NULL;
146 return sharedMemoryProvider->getMemory();
158 auto prov = sharedMemoryProvider;
161 return sharedMemoryProvider->getScopedWriteLock();
171 auto prov = sharedMemoryProvider;
174 return sharedMemoryProvider->getScopedReadLock();
187 sharedMemoryProvider->lock();
195 sharedMemoryProvider->unlock();
201 Blob
getData(MetaInfoSizeBasePtr& info,
const Ice::Current&
c = Ice::emptyCurrent)
override
205 info =
new MemoryObjectMetaInfo(*sharedMemoryProvider->getMetaInfo());
209 memcpy(buffer.data(),
getBuffer(), info->size);
219 if (sharedMemoryProvider->getMetaInfo()->size)
221 memcpy(buffer.data(),
getBuffer(), sharedMemoryProvider->getMetaInfo()->size);
228 void setMetaInfo(
const typename MemoryObjectMetaInfo::PointerType& info,
bool threadSafe =
true)
235 sharedMemoryProvider->setMetaInfo(info);
237 buffer.resize(info->size);
243 typename MemoryObjectMetaInfo::PointerType
getMetaInfo(
bool threadSafe =
true)
const
250 return new MemoryObjectMetaInfo(*sharedMemoryProvider->getMetaInfo());
264 int getSize(
const Ice::Current&
c = Ice::emptyCurrent)
override
266 return sharedMemoryProvider->getSize();
282 Ice::ObjectPrx thisProxy =
object->getIceManager()->getIceGridSession()->registerObjectWithNewAdapter(
this, memoryName, memoryAdapter);
284 buffer.resize(sharedMemoryProvider->getSize());
288 void initSharedMemory(
ManagedIceObject*
object,
typename MemoryObjectMetaInfo::PointerType info)
294 std::string memoryName;
300 ManagedIceObject* object;