VR-Forces 4.2 Class Documentation
debugDrawerSharedMemoryManager.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2011 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
6 #pragma once
7 
8 #include "vlutil/vlShmPool.h"
15 #include "vlutil/vlString.h"
16 #include <vector>
17 #include <boost/shared_ptr.hpp>
18 
20 struct DtDebugMemoryBlockHeader;
21 
24 
26 {
27  public:
29  typedef DtDebugMemoryBlockHeader DtMemoryHeader;
30 
31  class ScopedLock
32  {
33  public:
34  explicit ScopedLock(DtDebugDrawerSharedMemoryManager& manager) : myManager(manager)
35  {
36  myManager.readLock();
37  }
38 
40  {
41  myManager.readUnlock();
42  }
43 
44  private:
46  };
47 
49  {
50  public:
51  explicit ScopedFrame(DtDebugDrawerSharedMemoryManager& manager, bool erase = true)
52  : myManager(manager)
53  {
54  myManager.startNewFrame(erase);
55  }
56 
58  {
59  myManager.advanceFrameCount();
60  }
61 
62  private:
64  };
65 
66  friend class ScopedLock;
67  friend class ScopedFrame;
68 
70  {
71  double lineWidth;
72  double alpha;
73 
74  Header();
75  };
76 
80  DtDebugDrawerSharedMemoryManager(unsigned long memorySize=3*10485670);
81 
85 
93  virtual void init(MemoryType memoryType, bool clearMemory=false);
94 
95  virtual void init(std::string tag, bool clearMemory=false,
97 
98  Header header() const;
99  void setHeader(const Header&);
100 
101  long getName() const;
102 
115  virtual bool push(DtDebugDrawerGeometryMemory* shape);
116 
121  virtual void update();
122 
127 
128  virtual unsigned long frameCount() const;
131  void startNewFrame(bool erase = true);
132  void advanceFrameCount();
134 
138  virtual unsigned long numEntries() const;
139 
142  virtual unsigned long currentSize() const;
143 
163  virtual const char* getNext(const char* previousPtr, DtDebugDrawerGeometryMemory** shape);
164 
166  virtual std::vector<DtDebugDrawerNameManager::Slot> getMemoryBlockNames();
167 
175  virtual bool pointToMemoryBlock(long name);
176 
177  protected:
178  void readLock();
179  void readUnlock();
180 
183  unsigned long myMaxSize;
184 
188  unsigned long myCurrentSize;
189 
193 
195  char* myMemoryPtr;
196 
199 
201  DtSharedMemoryPoolManager* myManager;
202  DtSharedMemoryPoolClient* myClient;
203 
206 
208 
210 
212 };
213 
215 {
216 public:
217  typedef boost::shared_ptr<DtDebugDrawerSharedMemoryManager> BufferPtr;
218  typedef std::vector<BufferPtr> BufferVector;
219 
221  {
222  public:
223  ScopedFrame(DtMultiBufferDebugDrawer& drawer, bool erase=true);
224  ~ScopedFrame();
225 
226  bool push(DtDebugDrawerGeometryMemory* shape);
227 
228  void update();
229 
230  private:
233  BufferVector::iterator myCurrentBuffer;
234  std::auto_ptr<DtDebugDrawerSharedMemoryManager::ScopedFrame> mySubFrame;
235  unsigned long myNumDrawn;
236  unsigned long myNumOverflows;
237  };
238 
239  friend class ScopedFrame;
240 
241  DtMultiBufferDebugDrawer(std::string tag,
242  unsigned long bufferSize=10485670/2, unsigned long maxBuffers=13);
243 
245  unsigned long bufferSize=10485670/2, unsigned long maxBuffers=13);
246 
248  void setHeader(const DtDebugDrawerSharedMemoryManager::Header&);
249 
250  bool push(DtDebugDrawerGeometryMemory* shape);
251 
252  void update();
253 
254 private:
255  std::string myTag;
257  unsigned long myBufferSize;
261 };
262 

Document ID: Generated on Sun Nov 24 19:49:21 EST 2013 from SVN revision 133924
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)