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
00041
00042
00043 #include <FE_Datastore.h>
00044 #include <fstream.h>
00045
00046 #include <FEM_ObjectBroker.h>
00047
00048
00049 #define maxIDsize 512
00050 #define maxVectSize 512
00051 #define maxMatSize 512
00052
00076 struct IDdata{
00078 int dbTag;
00079
00081 int commitTag;
00083 int data[maxIDsize];
00084 };
00085
00087 struct VectData{
00089 int dbTag;
00091 int commitTag;
00093 double data[maxVectSize];
00094 };
00095
00097 struct MatrixData{
00099 int dbTag;
00101 int commitTag;
00103 double data[maxMatSize];
00104 };
00105
00107 struct FileEnds{
00109 int ids[maxIDsize];
00111 int vects[maxVectSize];
00113 int mats[maxMatSize];
00114 };
00115
00117 struct CurrentFilePos{
00119 int ids[maxIDsize];
00121 int vects[maxVectSize];
00123 int mats[maxMatSize];
00124 };
00125
00127 struct CurrentFileCommitTag{
00129 int ids[maxIDsize];
00131 int vects[maxVectSize];
00133 int mats[maxMatSize];
00134 };
00135
00137 struct MaxFileDbTag{
00139 int ids[maxIDsize];
00141 int vects[maxVectSize];
00143 int mats[maxMatSize];
00144 };
00145
00146
00148 class FileDatastore: public FE_Datastore
00149 {
00150 public:
00152 FileDatastore(char *dataBase,
00153 Domain &theDomain,
00154 FEM_ObjectBroker &theBroker);
00155
00157 ~FileDatastore();
00158
00160 int getDbTag(void);
00161
00163 char *addToProgram(void);
00165 int setUpShadow(void);
00167 int setUpActor(void);
00169 int setNextAddress(const ChannelAddress &otherChannelAddress);
00171 ChannelAddress *getLastSendersAddress(void);
00172
00174 int commitState(int commitTag);
00175
00177 int sendObj(int commitTag,
00178 MovableObject &theObject,
00179 ChannelAddress *theAddress =0);
00181 int recvObj(int commitTag,
00182 MovableObject &theObject,
00183 FEM_ObjectBroker &theBroker,
00184 ChannelAddress *theAddress =0);
00185
00187 int sendMsg(int dbTag, int commitTag,
00188 const Message &,
00189 ChannelAddress *theAddress =0);
00191 int recvMsg(int dbTag, int commitTag,
00192 Message &,
00193 ChannelAddress *theAddress =0);
00194
00196 int sendMatrix(int dbTag, int commitTag,
00197 const Matrix &theMatrix,
00198 ChannelAddress *theAddress =0);
00200 int recvMatrix(int dbTag, int commitTag,
00201 Matrix &theMatrix,
00202 ChannelAddress *theAddress =0);
00203
00205 int sendVector(int dbTag, int commitTag,
00206 const Vector &theVector, ChannelAddress *theAddress =0);
00208 int recvVector(int dbTag, int commitTag,
00209 Vector &theVector,
00210 ChannelAddress *theAddress =0);
00211
00213 int sendID(int dbTag, int commitTag,
00214 const ID &theID,
00215 ChannelAddress *theAddress =0);
00217 int recvID(int dbTag, int commitTag,
00218 ID &theID,
00219 ChannelAddress *theAddress =0);
00220
00221 protected:
00222
00223 private:
00224
00226 fstream *openFile(char *fileName);
00227
00229 int dbTag;
00231 char dataBase[50];
00233 fstream **ids, **vects, **mats;
00235 int lastDomainChangeStamp;
00236
00238 struct MatrixData matBuffer;
00240 struct VectData vectBuffer;
00242 struct IDdata idBuffer;
00244 struct FileEnds fileEnds;
00245
00247 struct CurrentFilePos filePos;
00249 struct CurrentFileCommitTag fileCommitTags;
00251 struct MaxFileDbTag fileDbTags;
00252 };
00253
00254
00255
00256
00257 #endif
00258