Changeset 1042 for branches/Carsten_PtrWork2/Source/System/FieldContainer/Fields/OSGMChildFCPointerField.inl
- Timestamp:
- 01/25/08 14:32:12 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/Carsten_PtrWork2/Source/System/FieldContainer/Fields/OSGMChildFCPointerField.inl
r1041 r1042 111 111 } 112 112 113 /*! Clears the field, adjusting the reference count of pointed to objects, but 114 NOT their parent links. 115 */ 116 template <class ObjectT, Int32 NamespaceI, class AllocatorT> 117 inline void 118 MChildFCPointerField<ObjectT, NamespaceI, AllocatorT>::clearNoUnlink(void) 119 { 120 StorageIter vI = this->editRawStorage().begin(); 121 StorageIter vE = this->editRawStorage().end (); 122 123 for(; vI != vE; ++vI) 124 { 125 decRefCount(*vI); 126 } 127 128 this->editRawStorage().clear(); 129 } 130 131 /*! Resizes the field, adjusting the reference count of pointed to objects, but 132 NOT their parent links. 133 */ 134 template <class ObjectT, Int32 NamespaceI, class AllocatorT> 135 inline void 136 MChildFCPointerField<ObjectT, NamespaceI, AllocatorT>::resizeNoUnlink( 137 size_t newSize) 138 { 139 UInt32 oldSize = this->size(); 140 141 if(newSize < oldSize) 142 { 143 StorageIter vI = this->editRawStorage().begin() + newSize; 144 StorageIter vE = this->editRawStorage().end (); 145 146 for(; vI != vE; ++vI) 147 { 148 decRefCount(*vI); 149 } 150 } 151 152 this->editRawStorage().resize(newSize); 153 } 154 113 155 /*-------------------------------------------------------------------------*/ 114 156 /* MChildFCPointerField<class ObjectT, */ … … 553 595 AllocatorT >::copyFromBin(BinaryDataHandler &pMem) 554 596 { 555 UInt32 n; 556 557 pMem.getValue(n); 558 clear(); 559 560 #ifdef __hpux 561 StoredType tmpVal; 562 resize(n, tmpVal); 563 #else 564 resize(n); 565 #endif 566 567 if(n != 0) 568 { 569 MFieldTraits::copyFromBin(pMem, &(this->editRawStorage()[0]), n); 597 UInt32 newSize; 598 599 pMem.getValue(newSize); 600 601 if(newSize > 0) 602 { 603 this->resizeNoUnlink(newSize); 604 605 MFieldTraits::copyFromBin(pMem, &(this->editRawStorage()[0]), newSize); 570 606 571 607 StorageIter vI = this->editRawStorage().begin(); … … 575 611 { 576 612 incRefCount(*vI); 577 linkParent (*vI);578 613 } 614 } 615 else 616 { 617 this->clearNoUnlink(); 579 618 } 580 619 } … … 999 1038 UInt32 newSize = source. size(); 1000 1039 1040 // be careful to operate on raw storage, otherwise parent/child linking is 1041 // done, which is not necessary, since by assumption we sync to a correctly 1042 // linked aspect. 1043 1001 1044 if(newSize > 0) 1002 1045 { 1003 if(newSize < oldSize) 1004 { 1005 StorageIter oI = this->editRawStorage().begin() + newSize; 1006 StorageIter oE = this->editRawStorage().end (); 1007 1008 for(; oI != oE; ++oI) 1009 { 1010 decRefCount(*oI); 1011 } 1012 } 1013 1014 this->editRawStorage().resize(newSize); 1046 this->resizeNoUnlink(newSize); 1015 1047 1016 1048 StorageConstIter sI = source.getRawStorage ().begin(); … … 1034 1066 else 1035 1067 { 1036 clear();1068 this->clearNoUnlink(); 1037 1069 } 1038 1070 }
