- Timestamp:
- Jan 2, 2006, 2:38:54 PM (20 years ago)
- Location:
- trunk/SophyaLib/BaseTools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/BaseTools/ppfswapper.h
r2805 r2863 43 43 virtual int_8 WriteToSwap(const T * d, size_t sz, int_8 idx, int_8 oswp=0, bool osw=false) 44 44 { 45 if (ppfos == NULL) throw NotAvailableOperation("PPFDataSwapper<T>::WriteToSwap() - No POutPersist stream !"); 45 if (ppfos == NULL) 46 throw NotAvailableOperation("PPFDataSwapper<T>::WriteToSwap() - No POutPersist stream !"); 46 47 int_8 tag = ppfos->WritePositionTag(); 47 48 PPF_TPointer_IO<T>::Write(*ppfos, d, sz); … … 50 51 virtual void ReadFromSwap(int_8 idx, int_8 swp, T* d, size_t sz) 51 52 { 52 if (ppfis == NULL) throw NotAvailableOperation("PPFDataSwapper<T>::ReadFromSwap() - No PInPersist stream !"); 53 if (ppfis == NULL) 54 throw NotAvailableOperation("PPFDataSwapper<T>::ReadFromSwap() - No PInPersist stream !"); 53 55 bool ok = ppfis->GotoPositionTag(swp); 54 56 PPF_TPointer_IO<T>::Read(*ppfis, d, sz); 55 57 return; 58 } 59 virtual DataSwapperInterface<T>* Clone() 60 { 61 PPFDataSwapper<T> * rsw = new PPFDataSwapper<T> ; 62 (*rsw) = *this; 63 return rsw; 56 64 } 57 65 protected: -
trunk/SophyaLib/BaseTools/swsegdb.h
r2805 r2863 52 52 */ 53 53 virtual void ReadFromSwap(int_8 idx, int_8 swp, T* d, size_t sz) = 0; 54 55 /*! Duplicate the swapper object and return the new object pointer. 56 The returned pointer should be deleted when not needed any more. 57 This method is used by SwSegDataBlock<T> 58 */ 59 virtual DataSwapperInterface<T>* Clone() = 0; 54 60 }; 55 61 … … 62 68 mSRef = NULL; 63 69 SetSize(segsz, swpos.size()); 64 mSRef->swapper = &dsw;70 SetSwapper(dsw); 65 71 mSRef->swp = swpos; 66 72 for(size_t k=0; k<mSRef->fgwp.size(); k++) mSRef->fgwp[k] = true; … … 71 77 mSRef = NULL; 72 78 SetSize(segsz, nbseg); 73 mSRef->swapper = &dsw;79 SetSwapper(dsw); 74 80 } 75 81 //! copy constructor - shares the data … … 89 95 return mSRef->swp.size(); 90 96 } 91 //! Changes the data segment size and reallocates the memory segments 97 /*! \brief Changes the data segment size and reallocates the memory segments 98 \warning SetSwapper() must be called after call to SetSize() 99 */ 92 100 // segsz : Segment size ; nbseg : Number of data segments 93 101 virtual void SetSize(size_t segsz, size_t nbseg=0) … … 105 113 mSRef->fgwp.push_back(false); 106 114 } 107 } 115 mSRef->swapper = NULL; 116 } 117 118 //! Define the data swapper object. Should only be called if SetSize() is called 119 void SetSwapper(DataSwapperInterface<T> & dsw) 120 { 121 if (mSRef == NULL) return; 122 if (mSRef->swapper) delete mSRef->swapper; 123 mSRef->swapper = dsw.Clone(); 124 } 125 108 126 //! Return the segment size data structure 109 127 virtual size_t SegmentSize() const { return mSRef->segsize; } … … 165 183 mSRef->nref--; 166 184 if (mSRef->nref > 0) { mSRef = NULL; return; } 185 if (mSRef->swapper) delete mSRef->swapper; 167 186 delete[] mSRef->buff; 168 187 delete mSRef;
Note:
See TracChangeset
for help on using the changeset viewer.