DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
SharedMemObject.hpp
Go to the documentation of this file.
1#ifndef _uhal_ipc_SharedMemObject_hpp_
2#define _uhal_ipc_SharedMemObject_hpp_
3
4#include <boost/interprocess/managed_shared_memory.hpp>
5#include <string>
6
7namespace uhallibs {
8namespace ipc {
9
10template<class T>
12{
13public:
16
17 SharedMemObject(const std::string& aName);
19
21
23
24private:
25 std::string mName;
26 boost::interprocess::managed_shared_memory mSharedMem;
27 T* mObj;
28};
29
30// Definition
31template<class T>
32SharedMemObject<T>::SharedMemObject(const std::string& aName)
33 : mName(aName)
34 , mSharedMem(boost::interprocess::open_or_create, aName.c_str(), 1024, 0x0, boost::interprocess::permissions(0666))
35 , mObj(mSharedMem.find_or_construct<T>(boost::interprocess::unique_instance)())
36{
37}
38
39template<class T>
41{
42 // boost::interprocess::shared_memory_object::remove(mName.c_str());
43}
44
45template<class T>
46T*
51
52template<class T>
53T&
55{
56 return *mObj;
57}
58} // namespace ipc
59} // namespace uhal
60
61#endif /* _uhal_ipc_SharedMemObject_hpp_ */
SharedMemObject(const SharedMemObject< T > &)=delete
boost::interprocess::managed_shared_memory mSharedMem
SharedMemObject< T > & operator=(const SharedMemObject< T > &)=delete