3 #include "Arp/System/Core/TypeName.hxx"     4 #include "Arp/System/Core/AppDomainSingleton.hxx"     5 #include "Arp/System/Commons/Logging.h"     6 #include "Arp/System/Commons/Threading/Thread.hpp"     7 #include "boost/interprocess/managed_shared_memory.hpp"    13 namespace Arp { 
namespace System { 
namespace Commons { 
namespace Ipc
    21     typedef boost::interprocess::managed_shared_memory  SharedMemoryImpl;
    22     typedef SharedMemoryImpl::segment_manager           SegmentManager;
    23     typedef boost::interprocess::permissions            SharedMemoryPermission;
    27     using Ptr = boost::interprocess::offset_ptr<T>;
    88     template<
class T, 
typename ...TArgs>
    97     template<
class T, 
typename ...TArgs>
   105     template<
class T, 
typename ...TArgs>
   112     void    Destroy(
const char* name);
   183 template<
class T, 
typename ...TArgs>
   187     Ptr<T> result = Get<T>(name);
   191         return Construct<T>(name, args...);
   196 template<
class T, 
typename ...TArgs>
   202 template<
class T, 
typename ...TArgs>
   208     return new (pResult) T(args...);
   214     Ptr<T> pValue = this->Get<T>(name);
   215     if(pValue != 
nullptr)
   226     (void)boost::interprocess::shared_memory_object::remove(this->
GetName());
 void Destroy(const char *name)
Deallocates the object in the shared memory, also calling the objects destructor.
Definition: SharedMemory.hpp:212
 
void ZeroFreeMemory(void)
Writes zero in all bytes not yet allocated.
Definition: SharedMemory.hpp:234
 
API to manage and manipulate memory shared between different processes
Definition: SharedMemory.hpp:17
 
size_t GetFreeMemory(void) const
Obtain the number of free bytes in the shared memory.
Definition: SharedMemory.hpp:229
 
byte * Allocate(size_t size)
Tries to allocate size amount of bytes in the memory.
Definition: SharedMemory.hpp:167
 
Ptr< T > Construct(const char *name, TArgs... args)
Creates a named object in the shared memory.
Definition: SharedMemory.hpp:197
 
size_t GetSize(void) const
Returns the capacity of the shared memory in bytes.
Definition: SharedMemory.hpp:162
 
Ptr< T > ConstructUnnamed(TArgs... args)
Creates an unnamed object in the shared memory.
Definition: SharedMemory.hpp:203
 
SharedMemoryImpl sharedMemoryImpl
Actual implementation of the shared memory functionality.
Definition: SharedMemory.hpp:142
 
boost::interprocess::offset_ptr< T > Ptr
Returned pointer types are shared memory based offset pointer.
Definition: SharedMemory.hpp:27
 
void Deallocate(byte *pMemory)
Marks the memory pointed to by pMemory available for new allocation requests.
Definition: SharedMemory.hpp:172
 
Root namespace for the PLCnext API
 
Ptr< T > GetOrConstruct(const char *name, TArgs... args)
Tries to find object identified by name, creates a new one if the object does not exists yet...
Definition: SharedMemory.hpp:184
 
Arp::String memoryName
Name of memory identifying the shared memory inside the operating system.
Definition: SharedMemory.hpp:139
 
SharedMemory(const char *name)
Opens an existing shared memory.
Definition: SharedMemory.hpp:151
 
System components used by the System, Device, Plc or Io domains.
 
~SharedMemory(void)=default
Deallocates the memory for this management object but not the memory shared between processes...
 
void Remove(void)
Removes the shared memory from the system.
Definition: SharedMemory.hpp:224
 
bool CheckSanity(void)
Performs a sanity check over the shared memory.
Definition: SharedMemory.hpp:244
 
Ptr< T > Get(const char *name)
Tries to find a previously allocated named object.
Definition: SharedMemory.hpp:178
 
bool AllMemoryDeallocated(void)
Checks if all memory has been deallocated.
Definition: SharedMemory.hpp:239
 
const Arp::String & GetName(void) const
Returns the name of the memory object.
Definition: SharedMemory.hpp:157
 
unsigned char byte
The Arp character type.
Definition: PrimitiveTypes.hpp:23