C++ main module for emicrom Package  1.0
CORE_Pointers.h
Go to the documentation of this file.
1 #ifndef CORE_Pointers_H
2 #define CORE_Pointers_H
3 
39 #include <boost/shared_array.hpp>
40 #include <boost/shared_ptr.hpp>
41 #include <boost/weak_ptr.hpp>
42 #include <boost/enable_shared_from_this.hpp>
43 
44 
45 
46 namespace SharedPointer {};
47 namespace SharedPointerConst {};
48 namespace SharedVector {};
49 namespace SharedVectorConst {};
51 namespace SharedArray {};
52 namespace SharedArrayConst {};
53 
54 namespace WeakArray {};
55 namespace WeakArrayConst {};
56 namespace WeakVector {};
57 namespace WeakVectorConst {};
58 namespace WeakPointer{};
59 namespace WeakPointerConst{};
60 
61 
62 
66 namespace SP = SharedPointer;
67 
70 namespace SPC = SharedPointerConst;
71 
75 namespace WP = WeakPointer;
76 
80 namespace WPC = WeakPointerConst;
81 
82 
85 namespace WV = WeakVector;
88 namespace WVC = WeakVectorConst;
89 
92 namespace SV = SharedVector;
93 
94 
95 
98 namespace SVC = SharedVectorConst;
99 
100 
101 namespace SA = SharedArray;
102 namespace SAC = SharedArrayConst;
103 
104 namespace WA = WeakArray;
105 namespace WAC = WeakArrayConst;
106 
113 {
116  void operator()(void const *) const {}
117 };
118 
119 
120 /* template namespace : no */
121 
122 #define NAME_SPACE_SPTR(X) \
123  namespace SharedPointer \
124  { \
125  typedef SPtr##X X; \
126  } \
127  namespace WeakPointer \
128  { \
129  typedef WPtr##X X; \
130  } \
131  namespace SharedPointerConst \
132  { \
133  typedef SPtrConst##X X;\
134  } \
135  namespace WeakPointerConst \
136  { \
137  typedef WPtrConst##X X; \
138  };
139 
140 #define NAME_SPACE_SVPTR(X) \
141  namespace SharedVector \
142  { \
143  typedef SVPtr##X X; \
144  } \
145  namespace SharedVectorConst \
146  { \
147  typedef SVPtrConst##X X; \
148  } \
149  namespace SharedArray \
150  { \
151  typedef SAPtr##X X; \
152  } \
153  namespace SharedArrayConst \
154  { \
155  typedef SAPtrConst##X X; \
156  } \
157  namespace WeakVector \
158  { \
159  typedef WVPtr##X X; \
160  } \
161  namespace WeakVectorConst \
162  { \
163  typedef WVPtrConst##X X; \
164  } \
165  namespace WeakArray \
166  { \
167  typedef WAPtr##X X; \
168  } \
169  namespace WeakArrayConst \
170  { \
171  typedef WAPtrConst##X X; \
172  };
173 
174 
175 
176 
177 #define TYPEDEF_SPTR(X) \
178  typedef boost::weak_ptr<X> WPtr##X; \
179  typedef boost::shared_ptr<X> SPtr##X; \
180  typedef boost::shared_ptr<const X> SPtrConst##X; \
181  typedef boost::weak_ptr<const X> WPtrConst##X; \
182  NAME_SPACE_SPTR(X)
183 
184 
185 #define TYPEDEF_SAPTR(X) \
186  typedef boost::shared_array<X> X##SAPtr ; \
187  NAME_SPACE_SAPTR(X)
188 
189 
190 
191 #define DEFINE_SPTR(X) \
192  class X; \
193  TYPEDEF_SPTR(X)
194 
195 
196 #define DEFINE_SAPTR(X) \
197  class X; \
198  TYPEDEF_SAPTR(X)
199 
200 #define USE_THIS(X,Y)\
201  SP_OBJECT(X)
202 
203 #define SP_OBJECT(X)\
204  public:\
205  \
207  void getSharedPointer(SP::X& p){\
208  SP::CORE_Object r; \
209  CORE_Object::getSharedPointer(r); \
210  p=boost::dynamic_pointer_cast<X>(r); \
211  };\
212  \
214  void getSharedPointer(SPC::X& p) const{ \
215  SPC::CORE_Object r;\
216  CORE_Object::getSharedPointer(r); \
217  p=boost::dynamic_pointer_cast<const X>(r); \
218  }; \
219  private: \
220  \
222  inline SP::X getThis() { \
223  SP::X p;\
224  getSharedPointer(p);\
225  return p; \
226  }; \
227  \
229  inline SPC::X getThis() const { \
230  SPC::X p; \
231  getSharedPointer(p); \
232  return p; \
233  };\
234  public:
235 
236 
237 /* \brief cast the shared pointer of class U to T
238  */
239 template<class T, class U>
240 static boost::shared_ptr<T> dynamic_sp_cast(boost::shared_ptr<U> const & r) {
241  return boost::dynamic_pointer_cast<T>(r);
242 };
243 
244 
245 
246 
247 #endif /* CORE_Pointers_H */
Definition: CORE_Pointers.h:55
Definition: CORE_Pointers.h:59
Definition: CORE_Pointers.h:50
Definition: CORE_Pointers.h:56
file CORE_Pointers.hpp CORE interface to reference-counting pointers
Definition: CORE_Pointers.h:46
Definition: CORE_Pointers.h:52
Definition: CORE_Pointers.h:58
Definition: CORE_Pointers.h:49
Definition: CORE_Pointers.h:57
void operator()(void const *) const
return the default nullDeleter
Definition: CORE_Pointers.h:116
Definition: CORE_Pointers.h:54
Definition: CORE_Pointers.h:48
Definition: CORE_Pointers.h:47
Definition: CORE_Pointers.h:51
Definition: CORE_Pointers.h:112