3 #include "Arp/System/Core/TypeName.hxx" 4 #include "Arp/System/Core/AppDomainSingleton.hxx" 5 #include "Arp/System/Commons/Ipc/SharedMemory.hpp" 6 #include "Arp/System/Commons/Threading/Thread.hpp" 7 #include "boost/interprocess/containers/string.hpp" 8 #include "boost/interprocess/containers/vector.hpp" 9 #include "boost/interprocess/containers/list.hpp" 10 #include "boost/interprocess/containers/map.hpp" 11 #include "boost/interprocess/containers/set.hpp" 15 namespace Arp {
namespace System {
namespace Commons {
namespace Ipc
21 template<
class Derived>
25 typedef SharedMemory Base;
26 typedef Derived DerivedType;
28 typedef boost::interprocess::managed_shared_memory SharedMemory;
29 typedef SharedMemory::segment_manager SegmentManager;
30 typedef boost::interprocess::permissions SharedMemoryPermission;
34 using Ptr = boost::interprocess::offset_ptr<T>;
37 using ConstPtr = boost::interprocess::offset_ptr<const T>;
46 static void CreateInstance(
size_t memorySize);
47 static void OpenInstance(
void);
48 static void CloseInstance(
bool removeMemory =
false);
49 static void Remove(
void);
53 static void WaitInstance(
const char* waitMessage,
uint32 timeout = -1);
61 class Allocator :
public boost::interprocess::allocator<T, SegmentManager>
64 typedef boost::interprocess::allocator<T, SegmentManager> AllocatorBase;
81 typedef boost::interprocess::interprocess_mutex SharedMutex;
84 Mutex(
void) =
default;
85 ~
Mutex(
void) =
default;
113 template <
class TMutex>
119 this->pMutex->Lock();
125 this->pMutex->Unlock();
135 typedef boost::interprocess::basic_string<char, std::char_traits<char>,
Allocator<char>> String;
138 using vector = boost::interprocess::vector<T, Allocator<T>>;
141 using list = boost::interprocess::list<T, Allocator<T>>;
143 template <
class TKey,
class TValue,
class TCompare = std::less<TKey>>
144 using map = boost::interprocess::map<TKey, TValue, TCompare, Allocator<std::pair<const TKey, TValue>>>;
146 template <
class TKey,
class TCompare = std::less<TKey>>
147 using set = boost::interprocess::set<TKey, TCompare, Allocator<TKey>>;
150 template<
class T>
friend class Allocator;
155 template<
class Derived>
161 template<
class Derived>
167 template<
class Derived>
174 template<
class Derived>
181 template<
class Derived>
189 bool instanceExists =
false;
195 instanceExists =
true;
199 Log::Debug(waitMessage);
203 }
while (!instanceExists);
206 template<
class Derived>
221 template<
class Derived>
229 template<
class Derived>
static Derived & CreateInstance(Args &&... args)
Creates this singleton instance.
Definition: AppDomainSingleton.hxx:74
This (meta programming) class provides the C++ typename of the as template argument passed type...
Definition: TypeName.hxx:55
Definition: SharedData.hxx:101
Definition: SharedData.hxx:22
std::uint32_t uint32
The Arp unsigned integer type of 4 byte size.
Definition: PrimitiveTypes.hpp:35
static void Sleep(size_t milliseconds)
Suspends the execution of the calling thread.
static Derived & GetInstance(void)
Gets a reference of the singleton instance.
Definition: AppDomainSingleton.hxx:102
Definition: SharedData.hxx:61
Definition: SharedData.hxx:71
Definition: SharedData.hxx:78
SharedMemoryImpl sharedMemoryImpl
Actual implementation of the shared memory functionality.
Definition: SharedMemory.hpp:142
Definition: SharedData.hxx:114
Root namespace for the PLCnext API
This class implements the singleton pattern for singletons with process wide scope.
Definition: AppDomainSingleton.hxx:24
static void DisposeInstance(void)
Disposes this singleton instance.
Definition: AppDomainSingleton.hxx:119
System components used by the System, Device, Plc or Io domains.
String GetSafeName(void) const
Gets a safe name of the as template parameter given type.
Definition: TypeName.hxx:144
static bool IsCreated(void)
Determines if this singleton instance is created yet.
Definition: AppDomainSingleton.hxx:91
const Arp::String & GetName(void) const
Returns the name of the memory object.
Definition: SharedMemory.hpp:157