|
|
@@ -31,8 +31,9 @@ pvector<Element> ConstPointerToArray<Element>::_empty_array;
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
template<class Element>
|
|
|
INLINE PointerToArray<Element>::
|
|
|
-PointerToArray() :
|
|
|
- PointerToArrayBase<Element>((ReferenceCountedVector<Element> *)NULL)
|
|
|
+PointerToArray(TypeHandle type_handle) :
|
|
|
+ PointerToArrayBase<Element>((ReferenceCountedVector<Element> *)NULL),
|
|
|
+ _type_handle(type_handle)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
@@ -43,11 +44,11 @@ PointerToArray() :
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
template<class Element>
|
|
|
INLINE PointerToArray<Element>
|
|
|
-PointerToArray<Element>::empty_array(size_type n) {
|
|
|
- PointerToArray<Element> temp;
|
|
|
- temp.reassign(new ReferenceCountedVector<Element>);
|
|
|
+PointerToArray<Element>::empty_array(size_type n, TypeHandle type_handle) {
|
|
|
+ PointerToArray<Element> temp(type_handle);
|
|
|
+ temp.reassign(new ReferenceCountedVector<Element>(type_handle));
|
|
|
|
|
|
- To new_array(n);
|
|
|
+ To new_array(n, type_handle);
|
|
|
((To *)(temp._void_ptr))->swap(new_array);
|
|
|
return temp;
|
|
|
}
|
|
|
@@ -59,8 +60,10 @@ PointerToArray<Element>::empty_array(size_type n) {
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
template<class Element>
|
|
|
INLINE PointerToArray<Element>::
|
|
|
-PointerToArray(size_type n, const Element &value) :
|
|
|
- PointerToArrayBase<Element>(new ReferenceCountedVector<Element>) {
|
|
|
+PointerToArray(size_type n, const Element &value, TypeHandle type_handle) :
|
|
|
+ PointerToArrayBase<Element>(new ReferenceCountedVector<Element>(type_handle)),
|
|
|
+ _type_handle(type_handle)
|
|
|
+{
|
|
|
((To *)(this->_void_ptr))->reserve(n);
|
|
|
insert(begin(), n, value);
|
|
|
}
|
|
|
@@ -73,44 +76,11 @@ PointerToArray(size_type n, const Element &value) :
|
|
|
template<class Element>
|
|
|
INLINE PointerToArray<Element>::
|
|
|
PointerToArray(const PointerToArray<Element> ©) :
|
|
|
- PointerToArrayBase<Element>(copy)
|
|
|
+ PointerToArrayBase<Element>(copy),
|
|
|
+ _type_handle(copy._type_handle)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
-// Function: PointerToArray::get_col
|
|
|
-// Access: Published
|
|
|
-// Description: Returns the pointer to the PStatCollector object that
|
|
|
-// tracks the total allocated size of this buffer.
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
-template<class Element>
|
|
|
-INLINE PStatCollectorForwardBase *PointerToArray<Element>::
|
|
|
-get_col() const {
|
|
|
-#ifdef DO_PSTATS
|
|
|
- if ((this->_void_ptr) != NULL) {
|
|
|
- return ((To *)(this->_void_ptr))->get_col();
|
|
|
- }
|
|
|
-#endif // DO_PSTATS
|
|
|
- return NULL;
|
|
|
-}
|
|
|
-
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
-// Function: PointerToArray::set_col
|
|
|
-// Access: Published
|
|
|
-// Description: Changes the pointer to the PStatCollector object that
|
|
|
-// tracks the total allocated size of this buffer.
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
-template<class Element>
|
|
|
-INLINE void PointerToArray<Element>::
|
|
|
-set_col(PStatCollectorForwardBase *col) {
|
|
|
-#ifdef DO_PSTATS
|
|
|
- if ((this->_void_ptr) == NULL) {
|
|
|
- reassign(new ReferenceCountedVector<Element>);
|
|
|
- }
|
|
|
- ((To *)(this->_void_ptr))->set_col(col);
|
|
|
-#endif // DO_PSTATS
|
|
|
-}
|
|
|
-
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
// Function: PointerToArray::begin
|
|
|
// Access: Public
|
|
|
@@ -187,7 +157,7 @@ template<class Element>
|
|
|
INLINE TYPENAME PointerToArray<Element>::size_type PointerToArray<Element>::
|
|
|
max_size() const {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
+ ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>(_type_handle));
|
|
|
}
|
|
|
return ((To *)(this->_void_ptr))->max_size();
|
|
|
}
|
|
|
@@ -212,7 +182,7 @@ template<class Element>
|
|
|
INLINE void PointerToArray<Element>::
|
|
|
reserve(TYPENAME PointerToArray<Element>::size_type n) {
|
|
|
if ((this->_void_ptr) == NULL) {
|
|
|
- reassign(new ReferenceCountedVector<Element>);
|
|
|
+ reassign(new ReferenceCountedVector<Element>(_type_handle));
|
|
|
}
|
|
|
((To *)(this->_void_ptr))->reserve(n);
|
|
|
}
|
|
|
@@ -226,7 +196,7 @@ template<class Element>
|
|
|
INLINE void PointerToArray<Element>::
|
|
|
resize(TYPENAME PointerToArray<Element>::size_type n) {
|
|
|
if ((this->_void_ptr) == NULL) {
|
|
|
- reassign(new ReferenceCountedVector<Element>);
|
|
|
+ reassign(new ReferenceCountedVector<Element>(_type_handle));
|
|
|
}
|
|
|
((To *)(this->_void_ptr))->resize(n);
|
|
|
}
|
|
|
@@ -252,7 +222,7 @@ template<class Element>
|
|
|
INLINE TYPENAME PointerToArray<Element>::reference PointerToArray<Element>::
|
|
|
front() const {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
+ ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>(_type_handle));
|
|
|
}
|
|
|
nassertd(!((To *)(this->_void_ptr))->empty()) {
|
|
|
((To *)(this->_void_ptr))->push_back(Element());
|
|
|
@@ -269,7 +239,7 @@ template<class Element>
|
|
|
INLINE TYPENAME PointerToArray<Element>::reference PointerToArray<Element>::
|
|
|
back() const {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
+ ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>(_type_handle));
|
|
|
}
|
|
|
nassertd(!((To *)(this->_void_ptr))->empty()) {
|
|
|
((To *)(this->_void_ptr))->push_back(Element());
|
|
|
@@ -286,7 +256,7 @@ template<class Element>
|
|
|
INLINE TYPENAME PointerToArray<Element>::iterator PointerToArray<Element>::
|
|
|
insert(iterator position, const Element &x) {
|
|
|
if ((this->_void_ptr) == NULL) {
|
|
|
- reassign(new ReferenceCountedVector<Element>);
|
|
|
+ reassign(new ReferenceCountedVector<Element>(_type_handle));
|
|
|
position = end();
|
|
|
}
|
|
|
nassertr(position >= ((To *)(this->_void_ptr))->begin() &&
|
|
|
@@ -303,7 +273,7 @@ template<class Element>
|
|
|
INLINE void PointerToArray<Element>::
|
|
|
insert(iterator position, size_type n, const Element &x) {
|
|
|
if ((this->_void_ptr) == NULL) {
|
|
|
- reassign(new ReferenceCountedVector<Element>);
|
|
|
+ reassign(new ReferenceCountedVector<Element>(_type_handle));
|
|
|
position = end();
|
|
|
}
|
|
|
nassertv(position >= ((To *)(this->_void_ptr))->begin() &&
|
|
|
@@ -349,7 +319,7 @@ template<class Element>
|
|
|
INLINE TYPENAME PointerToArray<Element>::reference PointerToArray<Element>::
|
|
|
operator [](size_type n) const {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
+ ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>(_type_handle));
|
|
|
}
|
|
|
nassertd(!((To *)(this->_void_ptr))->empty()) {
|
|
|
((To *)(this->_void_ptr))->push_back(Element());
|
|
|
@@ -410,7 +380,7 @@ template<class Element>
|
|
|
INLINE void PointerToArray<Element>::
|
|
|
push_back(const Element &x) {
|
|
|
if ((this->_void_ptr) == NULL) {
|
|
|
- reassign(new ReferenceCountedVector<Element>);
|
|
|
+ reassign(new ReferenceCountedVector<Element>(_type_handle));
|
|
|
}
|
|
|
((To *)(this->_void_ptr))->push_back(x);
|
|
|
}
|
|
|
@@ -424,7 +394,7 @@ template<class Element>
|
|
|
INLINE void PointerToArray<Element>::
|
|
|
pop_back() {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
+ ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>(_type_handle));
|
|
|
}
|
|
|
nassertv(!((To *)(this->_void_ptr))->empty());
|
|
|
((To *)(this->_void_ptr))->pop_back();
|
|
|
@@ -441,7 +411,7 @@ template<class Element>
|
|
|
INLINE void PointerToArray<Element>::
|
|
|
make_empty() {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
+ ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>(_type_handle));
|
|
|
}
|
|
|
nassertv(!((To *)(this->_void_ptr))->empty());
|
|
|
((To *)(this->_void_ptr))->clear();
|
|
|
@@ -487,7 +457,7 @@ template<class Element>
|
|
|
INLINE pvector<Element> &PointerToArray<Element>::
|
|
|
v() const {
|
|
|
if ((this->_void_ptr) == NULL) {
|
|
|
- ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
+ ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>(_type_handle));
|
|
|
}
|
|
|
return *((To *)(this->_void_ptr));
|
|
|
}
|
|
|
@@ -546,7 +516,7 @@ template<class Element>
|
|
|
INLINE void PointerToArray<Element>::
|
|
|
node_ref() const {
|
|
|
if ((this->_void_ptr) == NULL) {
|
|
|
- ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
+ ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>(_type_handle));
|
|
|
}
|
|
|
((To *)(this->_void_ptr))->node_ref();
|
|
|
}
|
|
|
@@ -583,6 +553,7 @@ operator = (ReferenceCountedVector<Element> *ptr) {
|
|
|
template<class Element>
|
|
|
INLINE PointerToArray<Element> &PointerToArray<Element>::
|
|
|
operator = (const PointerToArray<Element> ©) {
|
|
|
+ _type_handle = copy._type_handle;
|
|
|
reassign(copy);
|
|
|
return *this;
|
|
|
}
|
|
|
@@ -597,18 +568,6 @@ operator = (const PointerToArray<Element> ©) {
|
|
|
template<class Element>
|
|
|
INLINE void PointerToArray<Element>::
|
|
|
clear() {
|
|
|
-#ifdef DO_PSTATS
|
|
|
- if ((this->_void_ptr) != NULL) {
|
|
|
- PT(PStatCollectorForwardBase) col = ((To *)(this->_void_ptr))->get_col();
|
|
|
- if (col != (PStatCollectorForwardBase *)NULL) {
|
|
|
- // If we have a PStat counter, preserve it.
|
|
|
- reassign(new ReferenceCountedVector<Element>);
|
|
|
- ((To *)(this->_void_ptr))->set_col(col);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-#endif // DO_PSTATS
|
|
|
-
|
|
|
reassign((ReferenceCountedVector<Element> *)NULL);
|
|
|
}
|
|
|
|
|
|
@@ -621,8 +580,9 @@ clear() {
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
template<class Element>
|
|
|
INLINE ConstPointerToArray<Element>::
|
|
|
-ConstPointerToArray() :
|
|
|
- PointerToArrayBase<Element>((ReferenceCountedVector<Element> *)NULL)
|
|
|
+ConstPointerToArray(TypeHandle type_handle) :
|
|
|
+ PointerToArrayBase<Element>((ReferenceCountedVector<Element> *)NULL),
|
|
|
+ _type_handle(type_handle)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
@@ -634,7 +594,8 @@ ConstPointerToArray() :
|
|
|
template<class Element>
|
|
|
INLINE ConstPointerToArray<Element>::
|
|
|
ConstPointerToArray(const PointerToArray<Element> ©) :
|
|
|
- PointerToArrayBase<Element>(copy)
|
|
|
+ PointerToArrayBase<Element>(copy),
|
|
|
+ _type_handle(copy._type_handle)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
@@ -646,27 +607,11 @@ ConstPointerToArray(const PointerToArray<Element> ©) :
|
|
|
template<class Element>
|
|
|
INLINE ConstPointerToArray<Element>::
|
|
|
ConstPointerToArray(const ConstPointerToArray<Element> ©) :
|
|
|
- PointerToArrayBase<Element>(copy)
|
|
|
+ PointerToArrayBase<Element>(copy),
|
|
|
+ _type_handle(copy._type_handle)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
-// Function: ConstPointerToArray::get_col
|
|
|
-// Access: Published
|
|
|
-// Description: Returns the pointer to the PStatCollector object that
|
|
|
-// tracks the total allocated size of this buffer.
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
-template<class Element>
|
|
|
-INLINE PStatCollectorForwardBase *ConstPointerToArray<Element>::
|
|
|
-get_col() const {
|
|
|
-#ifdef DO_PSTATS
|
|
|
- if ((this->_void_ptr) != NULL) {
|
|
|
- return ((To *)(this->_void_ptr))->get_col();
|
|
|
- }
|
|
|
-#endif // DO_PSTATS
|
|
|
- return NULL;
|
|
|
-}
|
|
|
-
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
// Function: ConstPointerToArray::begin
|
|
|
// Access: Public
|
|
|
@@ -743,7 +688,7 @@ template<class Element>
|
|
|
INLINE TYPENAME ConstPointerToArray<Element>::size_type ConstPointerToArray<Element>::
|
|
|
max_size() const {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((ConstPointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
+ ((ConstPointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>(_type_handle));
|
|
|
}
|
|
|
return ((To *)(this->_void_ptr))->max_size();
|
|
|
}
|
|
|
@@ -768,7 +713,7 @@ template<class Element>
|
|
|
INLINE TYPENAME ConstPointerToArray<Element>::size_type ConstPointerToArray<Element>::
|
|
|
capacity() const {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((ConstPointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
+ ((ConstPointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>(_type_handle));
|
|
|
}
|
|
|
return ((To *)(this->_void_ptr))->capacity();
|
|
|
}
|
|
|
@@ -782,7 +727,7 @@ template<class Element>
|
|
|
INLINE TYPENAME ConstPointerToArray<Element>::reference ConstPointerToArray<Element>::
|
|
|
front() const {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((ConstPointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
+ ((ConstPointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>(_type_handle));
|
|
|
}
|
|
|
nassertd(!((To *)(this->_void_ptr))->empty()) {
|
|
|
((To *)(this->_void_ptr))->push_back(Element());
|
|
|
@@ -799,7 +744,7 @@ template<class Element>
|
|
|
INLINE TYPENAME ConstPointerToArray<Element>::reference ConstPointerToArray<Element>::
|
|
|
back() const {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((ConstPointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
+ ((ConstPointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>(_type_handle));
|
|
|
}
|
|
|
nassertd(!((To *)(this->_void_ptr))->empty()) {
|
|
|
((To *)(this->_void_ptr))->push_back(Element());
|
|
|
@@ -817,7 +762,7 @@ template<class Element>
|
|
|
INLINE TYPENAME ConstPointerToArray<Element>::reference ConstPointerToArray<Element>::
|
|
|
operator [](size_type n) const {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((ConstPointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
+ ((ConstPointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>(_type_handle));
|
|
|
}
|
|
|
nassertd(!((To *)(this->_void_ptr))->empty()) {
|
|
|
((To *)(this->_void_ptr))->push_back(Element());
|
|
|
@@ -893,7 +838,7 @@ template<class Element>
|
|
|
INLINE const pvector<Element> &ConstPointerToArray<Element>::
|
|
|
v() const {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((ConstPointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
+ ((ConstPointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>(_type_handle));
|
|
|
}
|
|
|
return *(To *)(this->_void_ptr);
|
|
|
}
|
|
|
@@ -929,7 +874,7 @@ template<class Element>
|
|
|
INLINE void ConstPointerToArray<Element>::
|
|
|
node_ref() const {
|
|
|
if ((this->_void_ptr) == NULL) {
|
|
|
- ((ConstPointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
+ ((ConstPointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>(_type_handle));
|
|
|
}
|
|
|
((To *)(this->_void_ptr))->node_ref();
|
|
|
}
|
|
|
@@ -966,6 +911,7 @@ operator = (ReferenceCountedVector<Element> *ptr) {
|
|
|
template<class Element>
|
|
|
INLINE ConstPointerToArray<Element> &ConstPointerToArray<Element>::
|
|
|
operator = (const PointerToArray<Element> ©) {
|
|
|
+ _type_handle = copy._type_handle;
|
|
|
reassign(copy);
|
|
|
return *this;
|
|
|
}
|
|
|
@@ -978,6 +924,7 @@ operator = (const PointerToArray<Element> ©) {
|
|
|
template<class Element>
|
|
|
INLINE ConstPointerToArray<Element> &ConstPointerToArray<Element>::
|
|
|
operator = (const ConstPointerToArray<Element> ©) {
|
|
|
+ _type_handle = copy._type_handle;
|
|
|
reassign(copy);
|
|
|
return *this;
|
|
|
}
|
|
|
@@ -992,20 +939,7 @@ operator = (const ConstPointerToArray<Element> ©) {
|
|
|
template<class Element>
|
|
|
INLINE void ConstPointerToArray<Element>::
|
|
|
clear() {
|
|
|
-#ifdef DO_PSTATS
|
|
|
- if ((this->_void_ptr) != NULL) {
|
|
|
- PT(PStatCollectorForwardBase) col = ((To *)(this->_void_ptr))->get_col();
|
|
|
- if (col != (PStatCollectorForwardBase *)NULL) {
|
|
|
- // If we have a PStat counter, preserve it.
|
|
|
- reassign(new ReferenceCountedVector<Element>);
|
|
|
- ((To *)(this->_void_ptr))->set_col(col);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-#else // DO_PSTATS
|
|
|
reassign((ReferenceCountedVector<Element> *)NULL);
|
|
|
-#endif // DO_PSTATS
|
|
|
}
|
|
|
|
|
|
-#endif // CPPPARSEr
|
|
|
+#endif // CPPPARSER
|