Image Component Library (ICL)
SharedMemorySegment.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLIO/src/ICLIO/SharedMemorySegment.h **
10 ** Module : ICLIO **
11 ** Authors: Viktor Richter **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/CompatMacros.h>
34 #include <ICLUtils/Time.h>
35 #include <ICLUtils/Thread.h>
36 #include <ICLUtils/Exception.h>
37 #include <set>
38 
39 
40 namespace icl {
41  namespace io {
42 
44 
59  public:
60 
62 
68  SharedMemorySegment(std::string name="", int minsize=1);
69 
72 
74 
78  void release();
79 
81  std::string getName();
82 
84 
88  void reset(std::string name, int minsize=0);
89 
91 
94  bool isAttached();
95 
97 
111  bool lock(int minsize=0);
112 
114 
117  bool unlock();
118 
120 
128  void forceMinSize(int minsize);
129 
131 
134  int getSize();
135 
137 
141  bool isEmpty() const;
142 
144 
148  void* data();
149 
151 
155  const void* data() const;
156 
158 
162  const void* constData() const;
163 
165  struct Impl;
166  private:
168  mutable utils::Mutex m_Mutex;
169 
171  Impl* m_Impl;
172 
174  std::string m_Name;
175 
178  };
179 
184 
186  SharedMemorySegmentLocker(SharedMemorySegment &seg, int minSize=0);
187 
189  SharedMemorySegmentLocker(SharedMemorySegment* seg, int minSize=0);
190 
193  };
194 
196 
201  {
202  public:
203  friend struct SharedMemorySegment::Impl;
204 
206  static std::set<std::string> getSegmentSet();
207 
209 
213  static void freeSegment(std::string name);
214 
216  static void freeAllSegments();
217 
219 
224  static void resetBus();
225 
226  private:
228  static void addSegment(std::string name);
229 
231  static void removeSegment(std::string name);
232  };
233 
234  } // namespace io
235 } // namespace icl
undocument this line if you encounter any issues!
Definition: Any.h:37
utils::Mutex m_Mutex
instance locking
Definition: SharedMemorySegment.h:165
Implementation of a cross-process shared memory.
Definition: SharedMemorySegment.h:58
This is used to register all created SharedMemorySegments.
Definition: SharedMemorySegment.h:200
ICLQt_API ImgROI data(ImgQ &r)
creates full ROI ROI-struct
#define ICLIO_API
Definition: CompatMacros.h:176
SharedMemorySegment & segment
local reference to SharedMemorySegment
Definition: SharedMemorySegment.h:183
std::string m_Name
the current name of the SharedMemorySegment
Definition: SharedMemorySegment.h:174
int m_Minsize
local minimal size tf the Segment
Definition: SharedMemorySegment.h:177
Impl * m_Impl
pointer to the internal implementation
Definition: SharedMemorySegment.h:171
an easy way to lock a SharedMemorySegment, unlocking at destruction.
Definition: SharedMemorySegment.h:181
Mutex class of the ICL.
Definition: Mutex.h:54