// file : Utility/ReferenceCounting/SmartPtr.hpp // author : Boris Kolpackov // copyright : Copyright (c) 2002-2003 Boris Kolpackov // license : http://kolpackov.net/license.html #ifndef UTILITY_REFERENCE_COUNTING_SMART_PTR_HPP #define UTILITY_REFERENCE_COUNTING_SMART_PTR_HPP #include "Utility/ExH/Compound.hpp" #include "Utility/ExH/Logic/DescriptiveException.hpp" #include "Utility/ReferenceCounting/Interface.hpp" namespace Utility { namespace ReferenceCounting { template class SmartPtr { public: typedef T Type; class NotInitialized_ {}; typedef ExH::Compound NotInitialized; public: // c-tor's SmartPtr () throw (); SmartPtr (Type* ptr) throw (); SmartPtr (SmartPtr const& s_ptr) throw (Interface::Exception, Interface::SystemException); template SmartPtr (SmartPtr const& s_ptr) throw (Interface::Exception, Interface::SystemException); // d-tor ~SmartPtr () throw (); // assignment & copy-assignment operators SmartPtr& operator= (Type* ptr) throw (); SmartPtr& operator= (SmartPtr const& s_ptr) throw (Interface::Exception, Interface::SystemException); template SmartPtr& operator= (SmartPtr const& s_ptr) throw (Interface::Exception, Interface::SystemException); //conversions operator Type* () const throw (); // accessors Type* operator-> () const throw (NotInitialized); Type* in () const throw (); Type* retn() throw (); private: Type* ptr_; }; // Specialization of add_ref function for SmartPtr template T* add_ref (SmartPtr const& ptr) throw (Interface::Exception, Interface::SystemException); // Dynamic type conversion function for SmartPtr's template D* smart_cast (SmartPtr const& s) throw (Interface::Exception, Interface::SystemException); // Acquisition function template SmartPtr acquire (T* ptr) throw (Interface::Exception, Interface::SystemException); } } #include "Utility/ReferenceCounting/SmartPtr.tpp" #endif // UTILITY_REFERENCE_COUNTING_SMART_PTR_HPP //$Id$