00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 template< class T > mli Cleaner<T>::refCountData;
00061
00062 template< class T > mli Cleaner<T>::refCountColumns;
00063
00064
00066 template< class T >
00067 Cleaner<T>::Cleaner(T *_data)
00068 {
00069 data = _data;
00070 columns = 0;
00071
00072
00073 mli::const_iterator tempItData = refCountData.find((long long int)data);
00074 if( tempItData == refCountData.end() )
00075 {
00076 refCountData[(long long int)data] = 1;
00077 }
00078 else
00079 {
00080 if(refCountData[(long long int)data] < 0)
00081 {
00082 cout << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
00083 Utility::Warning("Weird! data ref count is negative in memory hash. Something might be wrong.");
00084 }
00085 refCountData[(long long int)data]++;
00086 }
00087
00088 }
00089
00090
00092 template< class T >
00093 Cleaner<T>::Cleaner(Vector<T>* _columns)
00094 {
00095
00096 data = 0;
00097 columns = _columns;
00098
00099
00100 mli::const_iterator tempItRows = refCountColumns.find((long long int)columns);
00101 if( tempItRows == refCountColumns.end() )
00102 {
00103 refCountColumns[(long long int)columns] = 1;
00104 }
00105 else
00106 {
00107 if(refCountColumns[(long long int)columns] < 0)
00108 {
00109 cout << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
00110 Utility::Warning("Weird! columns ref count is negative in memory hash. Something might be wrong.");
00111 }
00112 refCountColumns[(long long int)columns]++;
00113 }
00114
00115
00116 }
00117
00118
00119 template< class T >
00120 Cleaner<T>::Cleaner(T *_data, Vector<T>* _columns)
00121 {
00122 data = _data;
00123 columns = _columns;
00124
00125
00126 mli::const_iterator tempItData = refCountData.find((long long int)data);
00127 if( tempItData == refCountData.end() )
00128 {
00129 refCountData[(long long int)data] = 1;
00130 }
00131 else
00132 {
00133 if(refCountData[(long long int)data] < 0)
00134 {
00135 cout << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
00136 Utility::Warning("Weird! data ref count is negative in memory hash. Something might be wrong.");
00137 }
00138 refCountData[(long long int)data]++;
00139 }
00140
00141
00142
00143 mli::const_iterator tempItRows = refCountColumns.find((long long int)columns);
00144 if( tempItRows == refCountColumns.end() )
00145 {
00146 refCountColumns[(long long int)columns] = 1;
00147 }
00148 else
00149 {
00150 if(refCountColumns[(long long int)columns] < 0)
00151 {
00152 cout << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
00153 Utility::Warning("Weird! columns ref count is negative in memory hash. Something might be wrong.");
00154 }
00155 refCountColumns[(long long int)columns]++;
00156 }
00157
00158
00159
00160 }
00161
00162
00163
00165 template< class T >
00166 Cleaner<T>::~Cleaner()
00167 {
00168
00169 if(data != 0){
00170
00171 mli::const_iterator tempItData = refCountData.find((long long int)data);
00172 if( tempItData == refCountData.end() )
00173 {
00174
00175 cout << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
00176 Utility::Warning("Weird! data does not exist in memory hash. Something might be wrong.");
00177 }
00178 else if(refCountData[(long long int)data] == 1)
00179 {
00180 refCountData.erase((long long int)data);
00181 delete [] data;
00182 }
00183 else if(refCountData[(long long int)data] <= 0)
00184 {
00185 cout << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
00186 Utility::Warning("Weird! data ref count is negative in memory hash. Something might be wrong.");
00187 }
00188 else
00189 {
00190 refCountData[(long long int)data]--;
00191
00192 }
00193 }
00194
00195 if(columns != 0){
00196
00197 mli::const_iterator tempItRows = refCountColumns.find((long long int)columns);
00198 if( tempItRows == refCountColumns.end() )
00199 {
00200
00201 cout << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
00202 Utility::Warning("Weird! columns does not exist in memory hash. Something might be wrong.");
00203 }
00204 else if(refCountColumns[(long long int)columns] == 1)
00205 {
00206 refCountColumns.erase((long long int)columns);
00207 delete [] columns;
00208 }
00209 else if(refCountColumns[(long long int)columns] <= 0)
00210 {
00211 cout << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
00212 Utility::Warning("Weird! columns ref count is negative in memory hash. Something might be wrong.");
00213 }
00214 else
00215 {
00216 refCountColumns[(long long int)columns]--;
00217 }
00218
00219 }
00220
00221
00222 }
00223
00224
00225
00226
00227
00229 template< class T >
00230 void Cleaner<T>::Display(void)
00231 {
00232 cout << endl;
00233 cout << "======MEMORY DISPLAY======" << endl;
00234 cout << "Memory references for (data):" << endl;
00235 for( mli::const_iterator it1 = refCountData.begin();
00236 it1 != refCountData.end(); it1++ )
00237 {
00238 cout << it1->first << '\t' << it1->second << endl;
00239
00240 }
00241
00242 cout << endl;
00243 cout << "Memory references for (columns):" << endl;
00244 for( mli::const_iterator it2 = refCountColumns.begin();
00245 it2 != refCountColumns.end(); it2++ )
00246 {
00247 cout << it2->first << '\t' << it2->second << endl;
00248 }
00249 cout << "===========END============" << endl;
00250 cout << endl;
00251 }
00252
00253
00254 template< class T >
00255 void Cleaner<T>::Display(char * s)
00256 {
00257 cout << endl;
00258 cout << "======MEMORY DISPLAY (" << s << ") ======" << endl;
00259 cout << "Memory references for (data):" << endl;
00260 for( mli::const_iterator it1 = refCountData.begin();
00261 it1 != refCountData.end(); it1++ )
00262 {
00263 cout << it1->first << '\t' << it1->second << endl;
00264
00265 }
00266
00267 cout << endl;
00268 cout << "Memory references for (columns):" << endl;
00269 for( mli::const_iterator it2 = refCountColumns.begin();
00270 it2 != refCountColumns.end(); it2++ )
00271 {
00272 cout << it2->first << '\t' << it2->second << endl;
00273 }
00274 cout << "===========END============" << endl;
00275 cout << endl;
00276 }
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
CIMPL 0.1 Code Reference.
Copyright © 2004, Baris Sumengen. All rights reserved.