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