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 #ifndef FileDatastore_h
00027 #define FileDatastore_h
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #include <FE_Datastore.h>
00041
00042 #include <fstream>
00043 #include <map>
00044 using std::fstream;
00045 using std::map;
00046
00047
00048 #define STREAM_POSITION_TYPE int
00049
00050 class FEM_ObjectBroker;
00051
00052 typedef struct fileDatastoreOutputFile {
00053 fstream *theFile;
00054 STREAM_POSITION_TYPE fileEnd;
00055 int maxDbTag;
00056 } FileDatastoreOutputFile;
00057
00058 typedef map<int, FileDatastoreOutputFile *> MAP_FILES;
00059 typedef MAP_FILES::value_type MAP_FILES_TYPE;
00060 typedef MAP_FILES::iterator MAP_FILES_ITERATOR;
00061
00062 typedef struct intData{
00063 int *dbTag;
00064 int *data;
00065 } IntData;
00066
00067
00068 typedef struct doubleData{
00069 int *dbTag;
00070 double *data;
00071 } DoubleData;
00072
00073
00074 class FileDatastore: public FE_Datastore
00075 {
00076 public:
00077 FileDatastore(const char *dataBase,
00078 Domain &theDomain,
00079 FEM_ObjectBroker &theBroker);
00080
00081 ~FileDatastore();
00082
00083
00084 int sendMsg(int dbTag, int commitTag,
00085 const Message &,
00086 ChannelAddress *theAddress =0);
00087 int recvMsg(int dbTag, int commitTag,
00088 Message &,
00089 ChannelAddress *theAddress =0);
00090
00091 int sendMatrix(int dbTag, int commitTag,
00092 const Matrix &theMatrix,
00093 ChannelAddress *theAddress =0);
00094 int recvMatrix(int dbTag, int commitTag,
00095 Matrix &theMatrix,
00096 ChannelAddress *theAddress =0);
00097
00098 int sendVector(int dbTag, int commitTag,
00099 const Vector &theVector,
00100 ChannelAddress *theAddress =0);
00101 int recvVector(int dbTag, int commitTag,
00102 Vector &theVector,
00103 ChannelAddress *theAddress =0);
00104
00105 int sendID(int dbTag, int commitTag,
00106 const ID &theID,
00107 ChannelAddress *theAddress =0);
00108 int recvID(int dbTag, int commitTag,
00109 ID &theID,
00110 ChannelAddress *theAddress =0);
00111
00112 int createTable(const char *tableName, int numColumns, char *columns[]);
00113 int insertData(const char *tableName, char *columns[],
00114 int commitTag, const Vector &data);
00115 int getData(const char *tableName, char *columns[], int commitTag, Vector &data);
00116
00117
00118 int commitState(int commitTag);
00119
00120 protected:
00121
00122 private:
00123
00124 int resizeInt(int newSize);
00125 int resizeDouble(int newSize);
00126 void resetFilePointers(void);
00127 int openFile(char *fileName, FileDatastoreOutputFile *, int dataSize);
00128
00129
00130 char *dataBase;
00131 MAP_FILES theIDFiles;
00132 MAP_FILES theVectFiles;
00133 MAP_FILES theMatFiles;
00134 MAP_FILES_ITERATOR theIDFilesIter;
00135 MAP_FILES_ITERATOR theVectFilesIter;
00136 MAP_FILES_ITERATOR theMatFilesIter;
00137
00138 int lastDomainChangeStamp;
00139 int currentCommitTag;
00140 char *data;
00141 int sizeData;
00142
00143 IntData theIntData;
00144 DoubleData theDoubleData;
00145
00146 int currentMaxInt;
00147 int currentMaxDouble;
00148 };
00149
00150
00151
00152
00153 #endif
00154