PolyBoRi
CWeakPtrFacade.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //*****************************************************************************
14 //*****************************************************************************
15 
16 #ifndef polybori_CWeakPtrFacade_h_
17 #define polybori_CWeakPtrFacade_h_
18 
19 // include basic definitions
20 #include <polybori/pbori_defs.h>
21 #include <boost/shared_ptr.hpp>
22 
23 
25 
27 template <class ValueType>
28 class CWeakPtr;
29 
35 template <class ValueType>
38  typedef CWeakPtrFacade self;
39 
40 public:
41  typedef ValueType value_type;
42  typedef value_type* data_type;
43  typedef boost::shared_ptr<data_type> ptr_type;
44 
45  friend class CWeakPtr<value_type>;
46 
49  m_data(new data_type(static_cast<data_type>(this))) {}
50 
52  CWeakPtrFacade(const self& rhs):
53  m_data(new data_type(static_cast<data_type>(this))) {}
54 
56  ~CWeakPtrFacade() { (*m_data) = NULL; }
57 
58 protected:
59  ptr_type m_data;
60 };
61 
63 
64 #endif /* polybori_CWeakPtrFacade_h_ */
#define END_NAMESPACE_PBORI
Finish project's namespace.
Definition: pbori_defs.h:77
#define BEGIN_NAMESPACE_PBORI
Start project's namespace.
Definition: pbori_defs.h:74
~CWeakPtrFacade()
Destructor (invalidates pointer to here)
Definition: CWeakPtrFacade.h:56
ptr_type m_data
Definition: CWeakPtrFacade.h:59
CWeakPtrFacade(const self &rhs)
Copy constructor (constructs new facade)
Definition: CWeakPtrFacade.h:52
ValueType value_type
Definition: CWeakPtrFacade.h:41
This class defines CWeakPtrFacade.
Definition: CWeakPtrFacade.h:36
Forward declaration of friend.
Definition: CWeakPtr.h:31
boost::shared_ptr< data_type > ptr_type
Definition: CWeakPtrFacade.h:43
CWeakPtrFacade()
Default constructor (only data is the pointer to here)
Definition: CWeakPtrFacade.h:48
value_type * data_type
Definition: CWeakPtrFacade.h:42