Changeset 804 in Sophya for trunk/SophyaLib/TArray/fioarr.cc
- Timestamp:
- Apr 3, 2000, 7:36:01 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/TArray/fioarr.cc
r787 r804 3 3 4 4 #include "pexceptions.h" 5 #include "fiondblock.h" 5 6 #include "fioarr.h" 7 #include "tmatrix.h" 8 #include "tvector.h" 6 9 7 10 // -------------------------------------------------------- … … 13 16 FIO_TArray<T>::FIO_TArray() 14 17 { 15 dobj= new TArray<T>;16 ownobj= true;18 dobj=NULL; 19 ownobj=false; 17 20 } 18 21 … … 20 23 FIO_TArray<T>::FIO_TArray(string const & filename) 21 24 { 22 dobj= new TArray<T>;23 ownobj= true;25 dobj=NULL; 26 ownobj=false; 24 27 Read(filename); 25 28 } … … 28 31 FIO_TArray<T>::FIO_TArray(const TArray<T> & obj) 29 32 { 30 dobj = new TArray<T>(obj); 33 const TVector<T> * tv = dynamic_cast<const TVector<T> *>(&obj); 34 if (tv != NULL) dobj = new TVector<T>(*tv, true); 35 else { 36 const TMatrix<T> * tm = dynamic_cast<const TMatrix<T> *>(&obj); 37 if (tm != NULL) dobj = new TMatrix<T>(*tm, true); 38 else dobj = new TArray<T>(obj, true); 39 } 31 40 ownobj=true; 32 41 } … … 63 72 void FIO_TArray<T>::ReadSelf(PInPersist& is) 64 73 { 65 // On lit les 3 premiers uint_4 66 // 0: Numero de version, : NRows, 2 : NCol 74 // On lit les 5 premiers uint_4 75 // 0: Numero de version, 1 : Type (Array, matrix, Vector, ...) 2 != 0 , has Info 76 // 1:Type = 0 TArray , 12=(4+8) TMatrix , 48=(16+32) TVector 67 77 uint_4 itab[5]; 68 78 is.Get(itab,5); 69 if (dobj == NULL) dobj = new TArray<T>; 79 if (dobj == NULL) { 80 if (itab[1] == 12) dobj = new TMatrix<T>; 81 else if (itab[1] == 48) dobj = new TVector<T>; 82 else dobj = new TArray<T>; 83 } 70 84 // On lit les tailles, etc ... 71 85 is.Get(dobj->ndim_); … … 78 92 is.Get(dobj->marowi_); 79 93 is.Get(dobj->macoli_); 94 is.Get(dobj->veceli_); 80 95 // On lit le datablock 81 96 is >> dobj->DataBlock(); … … 88 103 { 89 104 if (dobj == NULL) return; 90 // On ecrit 4uint_4 ....105 // On ecrit 5 uint_4 .... 91 106 // 0: Numero de version, 1 : Type (Array, matrix, Vector, ...) 2 != 0 , has Info 107 // 1:Type = 0 TArray , 12=(4+8) TMatrix , 48=(16+32) TVector 108 uint_4 typa = 0; 109 TVector<T> * tv = dynamic_cast<TVector<T> *>(dobj); 110 if (tv != NULL) typa = 48; 111 else { 112 TMatrix<T> * tm = dynamic_cast<TMatrix<T> *>(dobj); 113 if (tm != NULL) typa = 12; 114 else typa = 0; 115 } 116 92 117 uint_4 itab[5]; 93 118 itab[0] = 1; // Numero de version a 1 94 itab[1] = 0;119 itab[1] = typa; // Real object type 95 120 itab[2] = (dobj->mInfo != NULL) ? 1 : 0; 96 121 itab[3] = itab[4] = 0; 97 os.Put(itab, 3);122 os.Put(itab,5); 98 123 // On ecrit les tailles, etc ... 99 124 os.Put(dobj->ndim_); … … 106 131 os.Put(dobj->marowi_); 107 132 os.Put(dobj->macoli_); 133 os.Put(dobj->veceli_); 108 134 // On ecrit le datablock 109 135 os << dobj->DataBlock(); … … 117 143 #ifdef __CXX_PRAGMA_TEMPLATES__ 118 144 // Instances des delegues FileIO (PPersist) 119 #pragma define_template FIO_TArray<uint_1>145 // #pragma define_template FIO_TArray<uint_1> 120 146 #pragma define_template FIO_TArray<uint_2> 121 #pragma define_template FIO_TArray<int_2>147 // #pragma define_template FIO_TArray<int_2> 122 148 #pragma define_template FIO_TArray<int_4> 123 149 #pragma define_template FIO_TArray<int_8> 124 #pragma define_template FIO_TArray<uint_4>125 #pragma define_template FIO_TArray<uint_8>150 // #pragma define_template FIO_TArray<uint_4> 151 // #pragma define_template FIO_TArray<uint_8> 126 152 #pragma define_template FIO_TArray<r_8> 127 153 #pragma define_template FIO_TArray<r_4> … … 132 158 #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES) 133 159 // Instances des delegues FileIO (PPersist) 134 template class FIO_TArray<uint_1>;160 // template class FIO_TArray<uint_1>; 135 161 template class FIO_TArray<uint_2>; 136 template class FIO_TArray<int_2>;137 template class FIO_TArray<int_4>;162 // template class FIO_TArray<int_2>; 163 // template class FIO_TArray<int_4>; 138 164 template class FIO_TArray<int_8>; 139 template class FIO_TArray<uint_4>;140 template class FIO_TArray<uint_8>;165 // template class FIO_TArray<uint_4>; 166 // template class FIO_TArray<uint_8>; 141 167 template class FIO_TArray<r_8>; 142 168 template class FIO_TArray<r_4>;
Note:
See TracChangeset
for help on using the changeset viewer.