Changeset 555

Show
Ignore:
Timestamp:
08/18/09 16:49:39 (15 years ago)
Author:
vbarta
Message:

more doxygen comments

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/shared_ptr.h

    r554 r555  
    2222namespace bdm { 
    2323 
    24 /*! \brief A naive implementation of roughly a subset of the std::tr1:shared_ptr spec 
     24/*! \brief A naive implementation of roughly a subset of the std::tr1::shared_ptr spec 
    2525 
    2626  Really just roughly - it ignores memory 
    2727  exceptions, for example; also note I didn't read the spec. 
    2828 
    29   The standard template would naturally be preferable, _if_ it was 
     29  The standard template would naturally be preferable, \b if it was 
    3030  included in the standard libraries of all supported compilers - but 
    3131  as of 2009, that's still a problem... 
     
    4040 
    4141public: 
    42         //! Creates an empty shared_ptr - one that doesn't point anywhere. 
     42        /*! 
     43          \brief Default constructor 
     44 
     45          Creates an empty shared_ptr - one that doesn't point anywhere. 
     46        */ 
    4347        shared_ptr() : 
    4448                        payload ( 0 ), 
     
    5761        } 
    5862 
    59         //! If other is empty, constructs an empty shared_ptr; otherwise, 
    60         //! constructs a shared_ptr that shares ownership with other. 
     63        /*! 
     64          \brief Copy constructor 
     65 
     66          If other is empty, constructs an empty shared_ptr; otherwise, 
     67          constructs a shared_ptr that shares ownership with other. 
     68        */ 
    6169        shared_ptr ( const shared_ptr<T> &other ) : 
    6270                        payload ( other.payload ), 
     
    6573        } 
    6674 
    67         //! If other is empty, constructs an empty shared_ptr; otherwise, 
    68         //! constructs a shared_ptr that shares ownership with other. 
     75        /*! 
     76          \brief Generalized copy 
     77 
     78          Allows initialization of shared pointer of a base type from 
     79          raw pointer to a derived type. 
     80 
     81          If other is empty, constructs an empty shared_ptr; otherwise, 
     82          constructs a shared_ptr that shares ownership with other. 
     83        */ 
    6984        template<typename U> 
    7085        shared_ptr ( const shared_ptr<U> &other ) : 
     
    7489        } 
    7590 
     91        /*! 
     92          Destructor. 
     93        */ 
    7694        ~shared_ptr() { 
    7795                del_ref(); 
    7896        } 
    7997 
     98        /*! 
     99          \brief Assignment operator 
     100        */ 
    80101        shared_ptr<T> &operator= ( const shared_ptr<T> &other ) { 
    81102                other.add_ref(); 
     
    88109        } 
    89110 
    90         //! Returns the stored pointer (which remains owned by this 
    91         //! instance). 
     111        /*! 
     112          Returns the stored pointer (which remains owned by this 
     113          instance). For empty instances, this method returns NULL. 
     114        */ 
    92115        T *get() { 
    93116                return payload; 
    94117        } 
    95118 
    96         //! Returns the stored pointer (which remains owned by this 
    97         //! instance). This method may only be called when the stored 
    98         //! pointer isn't NULL. 
     119        /*! 
     120          Dereferences the stored pointer (which remains owned by 
     121          this instance). This method may only be called when the 
     122          stored pointer isn't NULL. 
     123        */ 
    99124        T *operator->() { 
    100125                it_assert_debug ( payload, "dereferencing NULL" ); 
     
    110135        } 
    111136 
    112         //! Returns the stored pointer (which remains owned by this 
    113         //! instance). 
     137        /*! 
     138          Returns the stored pointer (which remains owned by this 
     139          instance). For empty instances, this method returns NULL. 
     140        */ 
    114141        const T* get() const { 
    115142                return payload; 
     
    132159        } 
    133160 
     161        //! Returns use_count() == 1 
    134162        bool unique() const { 
    135163                return refCnt && ( *refCnt == 1 ); 
    136164        } 
    137165 
     166        /*! 
     167          Returns the number of shared_ptr instances (including 
     168          this instance) that share ownership with this instance. For 
     169          empty instances, this method returns 0. 
     170        */ 
    138171        long use_count() const { 
    139172                return refCnt ? *refCnt : 0; 
    140173        } 
    141174 
     175        /*! 
     176          \brief Boolean cast 
     177 
     178          This operator returns true if and only if the instance isn't empty. 
     179        */ 
    142180        operator bool() const { 
    143181                return !!payload; 
    144182        } 
    145183 
     184        /*! 
     185          \brief Efficient swap for shared_ptr. 
     186         */ 
    146187        void swap ( shared_ptr &other ) { 
    147188                std::swap ( payload, other.payload ); 
     
    224265        } 
    225266 
     267        /*! 
     268          \brief Assignment operator 
     269        */ 
    226270        object_ptr<T> &operator= ( const object_ptr<T> &other ) { 
    227271                shared_ptr<T>::operator= ( other );