C++ main module for gpm 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 
52 namespace WeakVector {};
53 namespace WeakVectorConst {};
54 namespace WeakPointer{};
55 namespace WeakPointerConst{};
56 
57 
61 namespace SP = SharedPointer;
62 
65 namespace SPC = SharedPointerConst;
66 
70 namespace WP = WeakPointer;
71 
75 namespace WPC = WeakPointerConst;
76 
77 
80 namespace WV = WeakVector;
83 namespace WVC = WeakVectorConst;
84 
87 namespace SV = SharedVector;
88 
89 
90 
93 namespace SVC = SharedVectorConst;
94 
95 
96 
103 {
106  void operator()(void const *) const {}
107 };
108 
109 
110 /* template namespace : no */
111 
112 #define NAME_SPACE_SPTR(X) \
113  namespace SharedPointer \
114  { \
115  typedef SPtr##X X; \
116  }; \
117  namespace WeakPointer \
118  { \
119  typedef WPtr##X X; \
120  }; \
121  namespace SharedPointerConst \
122  { \
123  typedef SPtrConst##X X;\
124  } \
125  namespace WeakPointerConst \
126  { \
127  typedef WPtrConst##X X; \
128  };
129 
130 #define NAME_SPACE_SVPTR(X) \
131  namespace SharedVector \
132  { \
133  typedef SVPtr##X X; \
134  } \
135  namespace SharedVectorConst \
136  { \
137  typedef SVPtrConst##X X; \
138  } \
139  namespace WeakVector \
140  { \
141  typedef WVPtr##X X; \
142  } \
143  namespace WeakVectorConst \
144  { \
145  typedef WVPtrConst##X X; \
146  }
147 
148 
149 
150 #define TYPEDEF_SPTR(X) \
151  typedef boost::weak_ptr<X> WPtr##X; \
152  typedef boost::shared_ptr<X> SPtr##X; \
153  typedef boost::shared_ptr<const X> SPtrConst##X; \
154  typedef boost::weak_ptr<const X> WPtrConst##X; \
155  NAME_SPACE_SPTR(X)
156 
157 
158 #define TYPEDEF_SAPTR(X) \
159  typedef boost::shared_array<X> X##SAPtr ; \
160  NAME_SPACE_SAPTR(X)
161 
162 
163 
164 #define DEFINE_SPTR(X) \
165  class X; \
166  TYPEDEF_SPTR(X)
167 
168 
169 #define DEFINE_SAPTR(X) \
170  class X; \
171  TYPEDEF_SAPTR(X)
172 
173 #define USE_THIS(X,Y)\
174  SP_OBJECT(X)
175 
176 #define SP_OBJECT(X)\
177  public:\
178  \
180  void getSharedPointer(SP::X& p){\
181  SP::CORE_Object r; \
182  CORE_Object::getSharedPointer(r); \
183  p=boost::dynamic_pointer_cast<X>(r); \
184  };\
185  \
187  void getSharedPointer(SPC::X& p) const{ \
188  SPC::CORE_Object r;\
189  CORE_Object::getSharedPointer(r); \
190  p=boost::dynamic_pointer_cast<const X>(r); \
191  }; \
192  private: \
193  \
195  inline SP::X getThis() { \
196  SP::X p;\
197  getSharedPointer(p);\
198  return p; \
199  }; \
200  \
202  inline SPC::X getThis() const { \
203  SPC::X p; \
204  getSharedPointer(p); \
205  return p; \
206  };\
207  public:
208 
209 
210 /* \brief cast the shared pointer of class U to T
211  */
212 template<class T, class U>
213 static boost::shared_ptr<T> dynamic_sp_cast(boost::shared_ptr<U> const & r) {
214  return boost::dynamic_pointer_cast<T>(r);
215 };
216 
217 
218 
219 
220 #endif /* CORE_Pointers_H */
Definition: CORE_Pointers.h:55
Definition: CORE_Pointers.h:50
void operator()(void const *) const
return the default nullDeleter
Definition: CORE_Pointers.h:106
Definition: CORE_Pointers.h:52
file CORE_Pointers.hpp CORE interface to reference-counting pointers
Definition: CORE_Pointers.h:46
Definition: CORE_Pointers.h:54
Definition: CORE_Pointers.h:49
Definition: CORE_Pointers.h:53
Definition: CORE_Pointers.h:48
Definition: CORE_Pointers.h:47
Definition: CORE_Pointers.h:102