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 <string>
5#include <boost/interprocess/managed_shared_memory.hpp>
6
7namespace uhallibs {
8namespace ipc {
9
10template <class T>
12 public:
15
16 SharedMemObject(const std::string& aName);
18
20
22
23 private:
24 std::string mName;
25 boost::interprocess::managed_shared_memory mSharedMem;
26 T* mObj;
27};
28
29// Definition
30template <class T>
31SharedMemObject<T>::SharedMemObject(const std::string& aName)
32 : mName(aName),
33 mSharedMem(boost::interprocess::open_or_create, aName.c_str(), 1024, 0x0,
34 boost::interprocess::permissions(0666)),
35 mObj(mSharedMem.find_or_construct<T>(
36 boost::interprocess::unique_instance)()) {}
37
38template <class T>
40 // boost::interprocess::shared_memory_object::remove(mName.c_str());
41}
42
43template <class T>
45 return mObj;
46}
47
48template <class T>
50 return *mObj;
51}
52} // namespace ipc
53} // namespace uhal
54
55#endif /* _uhal_ipc_SharedMemObject_hpp_ */
SharedMemObject(const SharedMemObject< T > &)=delete
SharedMemObject(const std::string &aName)
boost::interprocess::managed_shared_memory mSharedMem
SharedMemObject< T > & operator=(const SharedMemObject< T > &)=delete
Definition file.hpp:28