Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

rdStorage.h

00001 // rdStorage.h
00002 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00003 // Copyright 2000 Realistic Dynamics, Inc.
00004 // All rights reserved.
00005 //
00006 // Please do not read, copy, distribute, or use without permission.
00007 // Contact: Frank C. Anderson, fca@RealisticDynamics.com
00008 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00009 #ifndef __rdStorage_h__
00010 #define __rdStorage_h__
00011 
00012 
00013 #include "rdTools.h"
00014 #include "rdPtrArray.h"
00015 #include "rdStateVector.h"
00016 
00017 
00018 const int rdStorage_DEFAULT_CAPACITY = 256;
00019 
00020 
00021 //=============================================================================
00022 //=============================================================================
00043 class RDTOOLS_API rdStorage : public rdPtrArray
00044 {
00045 
00046 //=============================================================================
00047 // DATA
00048 //=============================================================================
00049 public:
00051    static const double LARGE_NEGATIVE;
00053    static const double LARGE_POSITIVE;
00056    static const char *DEFAULT_HEADER_TOKEN;
00057 protected:
00059    char _headerToken[rdObject_NAME_LENGTH];
00061    char *_columnLabels;
00064    int _stepInterval;
00066    int _lastI;
00068    bool _writeSIMMHeader;
00069 
00070 //=============================================================================
00071 // METHODS
00072 //=============================================================================
00073 public:
00074    rdStorage(int aCapacity=rdStorage_DEFAULT_CAPACITY,
00075       const char *aName="UNKNOWN");
00076    rdStorage(const char* aFileName);
00077    rdStorage(const rdStorage &aStorage,bool aCopyData=true);
00078    rdStorage(const rdStorage &aStorage,int aStateIndex,int aN,
00079       const char *aDelimiter="\t");
00080    virtual ~rdStorage();
00081 
00082 private:
00083    //--------------------------------------------------------------------------
00084    // CONSTRUCTION METHODS
00085    //--------------------------------------------------------------------------
00086    void allocateCapacity();
00087    void setNull();
00088    void copyData(const rdStorage &aStorage);
00089 public:
00090 
00091    //--------------------------------------------------------------------------
00092    // GET AND SET
00093    //--------------------------------------------------------------------------
00094    void setWriteSIMMHeader(bool aTrueFalse);
00095    bool getWriteSIMMHeader() const;
00096    void setHeaderToken(const char *aToken);
00097    const char* getHeaderToken() const;
00098    void setColumnLabels(const char *aLabels=NULL);
00099    const char* getColumnLabels() const;
00100    void setStepInterval(int aStepInterval);
00101    int getStepInterval() const;
00102    // STATEVECTOR
00103    int getSmallestNumberOfStates();
00104    rdStateVector* getStateVector(int aTimeIndex) const;
00105    rdStateVector* getLastStateVector() const;
00106    // TIME
00107    double getFirstTime();
00108    double getLastTime();
00109    int getTime(int aTimeIndex,double &rTime,int aStateIndex=-1) const;
00110    int getTimeColumn(double *&rTimes,int aStateIndex=-1);
00111    // DATA
00112    int getData(int aTimeIndex,int aStateIndex,double &rValue) const;
00113    int getData(int aTimeIndex,int aStateIndex,int aN,double *rData) const;
00114    int getData(int aTimeIndex,int aN,double **rData) const;
00115    int getData(int aTimeIndex,int aN,double *rData) const;
00116    int getData(double aTime,int aN,double **rData);
00117    int getData(double aTime,int aN,double *rData);
00118    int getDataColumn(int aStateIndex,double *&rData) const;
00119 
00120    //--------------------------------------------------------------------------
00121    // RESET
00122    //--------------------------------------------------------------------------
00123    void resetStorage(double aT);
00124 
00125    //--------------------------------------------------------------------------
00126    // STORAGE
00127    //--------------------------------------------------------------------------
00128    virtual int append(void *aVec);
00129    virtual int append(rdPtrArray *aArray);
00130    virtual int append(double aT,int aN,double *aY);
00131    virtual int store(int aStep,double aT,int aN,double *aY);
00132 
00133    //--------------------------------------------------------------------------
00134    // OPERATIONS
00135    //--------------------------------------------------------------------------
00136    void shiftTime(double aValue);
00137    void scaleTime(double aValue);
00138    void add(double aValue);
00139    void add(int aN,double aY[]);
00140    void add(rdStateVector *aStateVector);
00141    void add(rdStorage *aStorage);
00142    void subtract(double aValue);
00143    void subtract(int aN,double aY[]);
00144    void subtract(rdStateVector *aStateVector);
00145    void subtract(rdStorage *aStorage);
00146    void multiply(double aValue);
00147    void multiply(int aN,double aY[]);
00148    void multiply(rdStateVector *aStateVector);
00149    void multiply(rdStorage *aStorage);
00150    void divide(double aValue);
00151    void divide(int aN,double aY[]);
00152    void divide(rdStateVector *aStateVector);
00153    void divide(rdStorage *aStorage);
00154    rdStorage* integrate(int aI1=-2,int aI2=-1);
00155    rdStorage* integrate(double aT1,double aT2);
00156    int computeArea(int aN,double *aArea);
00157    int computeArea(double aTI,double aTF,int aN,double *aArea);
00158    int computeAverage(int aN,double *aAve);
00159    int computeAverage(double aTI,double aTF,int aN,double *aAve);
00160 
00161    //--------------------------------------------------------------------------
00162    // UTILITY
00163    //--------------------------------------------------------------------------
00164    int findIndex(double aT);
00165    int findIndex(int aI,double aT);
00166 
00167    //--------------------------------------------------------------------------
00168    // IO
00169    //--------------------------------------------------------------------------
00170    void print();
00171    int print(const char *aFileName,const char *aMode="w");
00172    int print(const char *aFileName,double aDT,const char *aMode="w");
00173 private:
00174    int writeHeader(FILE *rFP,double aDT=-1);
00175    int writeSIMMHeader(FILE *rFP,double aDT=-1);
00176    int writeDescription(FILE *rFP);
00177    int writeColumnLabels(FILE *rFP);
00178    int writeDefaultColumnLabels(FILE *rFP);
00179 
00180 
00181 
00182 //=============================================================================
00183 }; // END of class rdStorage
00184 //=============================================================================
00185 //=============================================================================
00186 
00187 #endif //__rdStorage_h__

Generated on Wed Aug 20 02:17:06 2003 for Simulation Software by doxygen1.3