00001 // -*- c++ -*- 00002 //***************************************************************************** 00014 //***************************************************************************** 00015 00016 #ifndef polybori_CWeakPtrFacade_h_ 00017 #define polybori_CWeakPtrFacade_h_ 00018 00019 // include basic definitions 00020 #include <polybori/pbori_defs.h> 00021 #include <boost/shared_ptr.hpp> 00022 00023 00024 BEGIN_NAMESPACE_PBORI 00025 00027 template <class ValueType> 00028 class CWeakPtr; 00029 00035 template <class ValueType> 00036 class CWeakPtrFacade { 00038 typedef CWeakPtrFacade self; 00039 00040 public: 00041 typedef ValueType value_type; 00042 typedef value_type* data_type; 00043 typedef boost::shared_ptr<data_type> ptr_type; 00044 00045 friend class CWeakPtr<value_type>; 00046 00048 CWeakPtrFacade(): 00049 m_data(new data_type(static_cast<data_type>(this))) {} 00050 00052 CWeakPtrFacade(const self& rhs): 00053 m_data(new data_type(static_cast<data_type>(this))) {} 00054 00056 ~CWeakPtrFacade() { (*m_data) = NULL; } 00057 00058 protected: 00059 ptr_type m_data; 00060 }; 00061 00062 END_NAMESPACE_PBORI 00063 00064 #endif /* polybori_CWeakPtrFacade_h_ */