#include <CPersistentMatrix.h>
Public Member Functions | |
| CPersistentMatrix (long inXSize, long inYSize) | |
| bool | open (char const *inFileName) |
| bool | create (char const *inFileName) const |
| bool | getLineVector (long inY, CPersistentLineVector &outVector) const |
| bool | getLineVector (long inY, CLineVector &outVector) const |
| bool | putLineVector (long inY, CPersistentLineVector const &outVector) |
| bool | putLineVector (long inY, CLineVector const &outVector) |
| FIXME: performance flaw. use vector swap for speed. | |
| bool | setValue (long inX, long inY, T const &inValue) |
| operator bool () const | |
Private Types | |
| typedef vector< T > | CLineVector |
| This is for the users of CPersistentMatrix. | |
| typedef CPersistentVector< T > | CPersistentLineVector |
Private Attributes | |
| long | mXSize |
| long | mYSize |
| fstream * | mContent |
Definition at line 32 of file CPersistentMatrix.h.
typedef vector<T> CPersistentMatrix< T >::CLineVector [private] |
typedef CPersistentVector<T> CPersistentMatrix< T >::CPersistentLineVector [private] |
Definition at line 35 of file CPersistentMatrix.h.
| CPersistentMatrix< T >::CPersistentMatrix | ( | long | inXSize, | |
| long | inYSize | |||
| ) | [inline] |
| bool CPersistentMatrix< T >::open | ( | char const * | inFileName | ) | [inline] |
Definition at line 93 of file CPersistentMatrix.h.
References CPersistentMatrix< T >::mContent.
00093 { 00094 mContent=new fstream(inFileName, 00095 fstream::in | fstream::out); 00096 00097 if(mContent && *mContent){ 00098 cout << "PersistentMatrix: Opened File " 00099 << inFileName 00100 << endl 00101 << flush; 00102 }else{ 00103 cout << "PersistentMatrix: FAILED TO OPEN FILE " 00104 << inFileName 00105 << endl 00106 << flush; 00107 00108 throw VENotFound(string(string("CPersistentMatrix open") 00109 +inFileName) 00110 .c_str()); 00111 00112 } 00113 return(mContent 00114 && 00115 *mContent); 00116 }
| bool CPersistentMatrix< T >::create | ( | char const * | inFileName | ) | const [inline] |
Definition at line 77 of file CPersistentMatrix.h.
References CPersistentMatrix< T >::mContent, CPersistentMatrix< T >::mXSize, CPersistentMatrix< T >::mYSize, and CPersistentVector< T >::write().
00077 { 00078 fstream* lFile=new fstream(inFileName,fstream::out+fstream::in); 00079 CPersistentVector<T> lLine(mXSize); 00080 if(lFile){ 00081 for(long i=0; 00082 (i<mYSize)&&(*lFile); 00083 i++){ 00084 lLine.write(*lFile); 00085 } 00086 } 00087 bool lResultValue= lFile && (*lFile); 00088 mContent=lFile; 00089 return lResultValue; 00090 }
| bool CPersistentMatrix< T >::getLineVector | ( | long | inY, | |
| CPersistentLineVector & | outVector | |||
| ) | const [inline] |
Definition at line 119 of file CPersistentMatrix.h.
References CPersistentMatrix< T >::mContent, CPersistentMatrix< T >::mXSize, and CPersistentVector< T >::read().
Referenced by CPersistentMatrix< T >::getLineVector().
00120 { 00121 #ifdef CPM_debug 00122 cout << "getLineVector"<<flush; 00123 #endif 00124 if(!mContent) 00125 return false; 00126 #ifdef CPM_debug 00127 cout << "(suite)"<<flush; 00128 #endif 00129 00130 mContent->seekg(inY * mXSize * sizeof(T)); 00131 bool lReturnValue = outVector.read(*mContent); 00132 lReturnValue = lReturnValue && (*mContent); 00133 assert(*mContent); 00134 assert(lReturnValue); 00135 #ifdef CPM_debug 00136 cout << "returning" 00137 << flush; 00138 #endif 00139 return lReturnValue; 00140 }
| bool CPersistentMatrix< T >::getLineVector | ( | long | inY, | |
| CLineVector & | outVector | |||
| ) | const [inline] |
Definition at line 143 of file CPersistentMatrix.h.
References CPersistentMatrix< T >::getLineVector(), CPersistentMatrix< T >::mContent, and CPersistentMatrix< T >::mXSize.
00144 { 00145 assert(mContent); 00146 #ifdef CPM_debug 00147 cout << "getLineVector"<<flush; 00148 #endif 00149 00150 CPersistentLineVector lVector(mXSize); 00151 bool lReturnValue; 00152 assert(lReturnValue=getLineVector(inY, 00153 lVector)); 00154 outVector.clear(); 00155 copy(lVector.begin(), 00156 lVector.end(), 00157 back_inserter(outVector)); 00158 return lReturnValue; 00159 }
| bool CPersistentMatrix< T >::putLineVector | ( | long | inY, | |
| CPersistentLineVector const & | outVector | |||
| ) | [inline] |
Definition at line 162 of file CPersistentMatrix.h.
References CPersistentMatrix< T >::mContent, CPersistentMatrix< T >::mXSize, and CPersistentVector< T >::write().
Referenced by CPersistentMatrix< T >::putLineVector().
00164 { 00165 if(!mContent) 00166 return false; 00167 00168 // cout << "Posish: " << inY * mXSize << "," << sizeof(T) << endl; 00169 00170 mContent->seekp(inY * mXSize * sizeof(T)); 00171 bool lReturnValue = inVector.write(*mContent); 00172 lReturnValue = lReturnValue && (*mContent); 00173 return lReturnValue; 00174 }
| bool CPersistentMatrix< T >::putLineVector | ( | long | inY, | |
| CLineVector const & | outVector | |||
| ) | [inline] |
FIXME: performance flaw. use vector swap for speed.
Definition at line 179 of file CPersistentMatrix.h.
References CPersistentMatrix< T >::mXSize, and CPersistentMatrix< T >::putLineVector().
00181 { 00182 CPersistentLineVector lVector(mXSize); 00183 typename CPersistentLineVector::iterator i=lVector.begin(); 00184 typename CLineVector::const_iterator j=inVector.begin(); 00185 while(i!=lVector.end() && j!=inVector.end()){ 00186 *i++=*j++; 00187 } 00188 return putLineVector(inY, 00189 lVector); 00190 }
| bool CPersistentMatrix< T >::setValue | ( | long | inX, | |
| long | inY, | |||
| T const & | inValue | |||
| ) | [inline] |
Definition at line 193 of file CPersistentMatrix.h.
References CPersistentMatrix< T >::mContent, and CPersistentMatrix< T >::mXSize.
00195 { 00196 if(!mContent) 00197 return false; 00198 00199 mContent->seekp((inY * mXSize + inX) * sizeof(T) ); 00200 00201 mContent->write(&inValue,sizeof(inValue)); 00202 00203 mContent->flush(); 00204 00205 return (*mContent); 00206 }
| CPersistentMatrix< T >::operator bool | ( | ) | const [inline] |
long CPersistentMatrix< T >::mXSize [private] |
Definition at line 37 of file CPersistentMatrix.h.
Referenced by CPersistentMatrix< T >::create(), CPersistentMatrix< T >::getLineVector(), CPersistentMatrix< T >::putLineVector(), and CPersistentMatrix< T >::setValue().
long CPersistentMatrix< T >::mYSize [private] |
fstream* CPersistentMatrix< T >::mContent [mutable, private] |
Definition at line 40 of file CPersistentMatrix.h.
Referenced by CPersistentMatrix< T >::create(), CPersistentMatrix< T >::getLineVector(), CPersistentMatrix< T >::open(), CPersistentMatrix< T >::operator bool(), CPersistentMatrix< T >::putLineVector(), and CPersistentMatrix< T >::setValue().
1.5.6