FileDatastore.h

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.14 $
00022 // $Date: 2006/01/03 20:49:21 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/database/FileDatastore.h,v $
00024                                                                         
00025                                                                         
00026 #ifndef FileDatastore_h
00027 #define FileDatastore_h
00028 
00029 // Written: fmk 
00030 // Created: 10/98
00031 //
00032 // Description: This file contains the class definition for FileDatastore.
00033 // FileDatastore is a concrete subclas of FE_Datastore. A FileDatastore 
00034 // object is used in the program to store/restore the geometry and state 
00035 // information in a domain at a particular instance in the analysis. The
00036 // information is stored in text files.
00037 //
00038 // What: "@(#) FileDatastore.h, revA"
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     // methods for sending and receiving the data
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     // the commitState method
00118     int commitState(int commitTag);        
00119     
00120   protected:
00121 
00122   private:
00123     // Private methods
00124     int resizeInt(int newSize);
00125     int resizeDouble(int newSize);
00126     void resetFilePointers(void);
00127     int openFile(char *fileName, FileDatastoreOutputFile *, int dataSize);
00128 
00129     // private attributes
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 

Generated on Mon Oct 23 15:05:00 2006 for OpenSees by doxygen 1.5.0