38 #ifndef TEAMCENTER_BASE_UTILS_SHARED_COUNT_HXX
39 #define TEAMCENTER_BASE_UTILS_SHARED_COUNT_HXX
43 #include <base_utils/SharedPtrCountedImpl.hxx>
63 std::auto_ptr< Y > guard( p );
64 pi_ =
new Teamcenter::Internal::SharedPtrCountedBaseImpl_p< Y >( p );
69 template<
class Y >
inline SharedCount( std::auto_ptr< Y > & r )
70 :
pi_( new Teamcenter::Internal::SharedPtrCountedBaseImpl_p< Y >( r.
get() ) )
75 #if 0 // commented as custom deallocator isnt supported.
76 template<
class P,
class D >
SharedCount( P p, D d );
79 #if 0 // commented as we dont support weak_ptr. Might need some changes to code for Tc.
90 inline bool unique()
const;
127 #if 0 // commenting as we do not support custom deallocator. Code might need changes for Tc erorr handling.
131 pi_ =
new Teamcenter::Internal::SharedPtrCountedBaseImpl_pd< P, D >( p, d );
139 #if 0 // Commented as we do not support weak_ptr at the moment. might need some changes for Tc error handling.
144 ERROR_severe( ERROR_line, 0,
"bad Teamcenter::BadWeakPtr()" );
173 std::swap(
pi_, other.
pi_ );
186 #if 0 // custom deallocator isnt supported
187 inline void * SharedCount::get_deleter( std::type_info
const & ti )
const
199 return std::less< SharedPtrCountedBase* >()( a.
pi_, b.
pi_ );
203 #if 0 // WeakCount is used for weak_ptr. As weak_ptr isnt supported yet, commenting the code.
211 friend class SharedCount;
215 WeakCount(): pi_( 0 )
219 WeakCount( SharedCount
const & r ): pi_( r.pi_ )
221 if( pi_ != NULL ) pi_->weak_add_ref();
224 WeakCount( WeakCount
const & r ): pi_( r.pi_ )
226 if( pi_ != NULL ) pi_->weak_add_ref();
231 if( pi_ != NULL ) pi_->weak_release();
240 WeakCount & operator= ( SharedCount
const & r )
244 if( pi_ != NULL ) pi_->weak_release();
250 WeakCount & operator= ( WeakCount
const & r )
256 if( pi_ != NULL ) pi_->weak_release();
263 void swap( WeakCount & r )
270 long use_count() const
272 return pi_ != NULL ? pi_->
use_count(): 0;
275 friend inline bool operator==( WeakCount
const & a, WeakCount
const & b )
277 return a.pi_ == b.pi_;
280 friend inline bool operator<( WeakCount
const & a, WeakCount
const & b )
282 return std::less< Teamcenter::Internal::SharedPtrCountedBase * >()( a.pi_, b.pi_ );