#ifndef MG_UTIL_ENABLE_MASTER_PTR_H #define MG_UTIL_ENABLE_MASTER_PTR_H #include #include namespace mgd { template class enable_master_ptr { typedef std::vector< boost::shared_ptr > dependent_objects_t; mutable boost::shared_ptr _dependent_objects; protected: enable_master_ptr() { } ~enable_master_ptr() { } public: template boost::weak_ptr<__T> make_dependent_ptr( std::auto_ptr<__T> owned_object ) const { boost::shared_ptr<__T> object( owned_object ); return make_dependent_ptr( object ); } template boost::weak_ptr<__T> make_dependent_ptr( boost::shared_ptr<__T> owned_object ) const { if (!_dependent_objects) _dependent_objects = boost::shared_ptr( new dependent_objects_t ); _dependent_objects->push_back( owned_object ); return owned_object; } }; }; #endif