// Filename: pointerToArrayBase.I // Created by: drose (30Oct06) // //////////////////////////////////////////////////////////////////// // // PANDA 3D SOFTWARE // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved // // All use of this software is subject to the terms of the Panda 3d // Software license. You should have received a copy of this license // along with this source code; you will also find a current copy of // the license at http://etc.cmu.edu/panda3d/docs/license/ . // // To contact the maintainers of this program write to // panda3d-general@lists.sourceforge.net . // //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// // Function: ReferenceCountedVector::Constructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE ReferenceCountedVector:: ReferenceCountedVector() { } //////////////////////////////////////////////////////////////////// // Function: ReferenceCountedVector::Copy Constructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE ReferenceCountedVector:: ReferenceCountedVector(const ReferenceCountedVector ©) : NodeReferenceCount(copy), pvector(copy) { #ifdef DO_PSTATS set_col(copy._col); #endif // DO_PSTATS } //////////////////////////////////////////////////////////////////// // Function: ReferenceCountedVector::Destructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE ReferenceCountedVector:: ~ReferenceCountedVector() { adjust_size(size(), 0); } //////////////////////////////////////////////////////////////////// // Function: ReferenceCountedVector::get_col // Access: Public // Description: Returns the pointer to the PStatCollector object that // tracks the total allocated size of this buffer. //////////////////////////////////////////////////////////////////// template INLINE PStatCollectorForwardBase *ReferenceCountedVector:: get_col() const { #ifdef DO_PSTATS return _col; #else return NULL; #endif // DO_PSTATS } //////////////////////////////////////////////////////////////////// // Function: ReferenceCountedVector::set_col // Access: Public // Description: Changes the pointer to the PStatCollector object that // tracks the total allocated size of this buffer. //////////////////////////////////////////////////////////////////// template INLINE void ReferenceCountedVector:: set_col(PStatCollectorForwardBase *col) { #ifdef DO_PSTATS if (_col != col) { adjust_size(size(), 0); _col = col; adjust_size(0, size()); } #endif // DO_PSTATS } //////////////////////////////////////////////////////////////////// // Function: ReferenceCountedVector::size // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE TYPENAME ReferenceCountedVector::size_type ReferenceCountedVector:: size() const { return pvector::size(); } //////////////////////////////////////////////////////////////////// // Function: ReferenceCountedVector::insert // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE TYPENAME ReferenceCountedVector::iterator ReferenceCountedVector:: insert(iterator position, const Element &x) { adjust_size(0, 1); return pvector::insert(position, x); } //////////////////////////////////////////////////////////////////// // Function: ReferenceCountedVector::insert // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE void ReferenceCountedVector:: insert(iterator position, size_type n, const Element &x) { adjust_size(0, n); pvector::insert(position, n, x); } //////////////////////////////////////////////////////////////////// // Function: ReferenceCountedVector::erase // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE void ReferenceCountedVector:: erase(iterator position) { adjust_size(1, 0); pvector::erase(position); } //////////////////////////////////////////////////////////////////// // Function: ReferenceCountedVector::erase // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE void ReferenceCountedVector:: erase(iterator first, iterator last) { adjust_size(last - first, 0); pvector::erase(first, last); } //////////////////////////////////////////////////////////////////// // Function: ReferenceCountedVector::pop_back // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE void ReferenceCountedVector:: pop_back() { adjust_size(1, 0); pvector::pop_back(); } //////////////////////////////////////////////////////////////////// // Function: ReferenceCountedVector::clear // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE void ReferenceCountedVector:: clear() { adjust_size(size(), 0); pvector::clear(); } //////////////////////////////////////////////////////////////////// // Function: ReferenceCountedVector::adjust_size // Access: Private // Description: This internal function is used to update the // connected PStatCollector (if any) with the change in // size. //////////////////////////////////////////////////////////////////// template INLINE void ReferenceCountedVector:: adjust_size(size_t orig_size, size_t new_size) { #ifdef DO_PSTATS if (_col != (PStatCollectorForwardBase *)NULL) { _col->add_level((float)new_size - (float)orig_size); } #endif // DO_PSTATS } //////////////////////////////////////////////////////////////////// // Function: PointerToArrayBase::Constructor // Access: Protected // Description: //////////////////////////////////////////////////////////////////// template INLINE PointerToArrayBase:: PointerToArrayBase(ReferenceCountedVector *ptr) : PointerToBase >(ptr) { } //////////////////////////////////////////////////////////////////// // Function: PointerToArrayBase::Copy Constructor // Access: Protected // Description: //////////////////////////////////////////////////////////////////// template INLINE PointerToArrayBase:: PointerToArrayBase(const PointerToArrayBase ©) : PointerToBase >(copy) { } //////////////////////////////////////////////////////////////////// // Function: PointerToArrayBase::Destructor // Access: Published // Description: //////////////////////////////////////////////////////////////////// template INLINE PointerToArrayBase:: ~PointerToArrayBase() { }