Salome HOME
c7a31b9776d72223400286ce3752e77646338ccd
[modules/med.git] / src / MEDMEM / MEDMEM_GenDriver.hxx
1 #ifndef GENDRIVER_HXX
2 #define GENDRIVER_HXX
3
4 #include <string>
5
6 #include "MEDMEM_define.hxx"
7 #include "utilities.h"
8
9 /* Generic Read/Write Driver Class for Meshes & Fields */
10
11 using namespace std;
12
13 /*!
14
15   Virtual class GENDRIVER use by all driver.
16
17 */
18 namespace MEDMEM {
19
20 /* Modify the following line to add a new driver type (step 1) */
21 typedef enum { MED_DRIVER = 0, GIBI_DRIVER = 1, PORFLOW_DRIVER = 2, VTK_DRIVER = 254, NO_DRIVER = 255 } driverTypes;
22 class GENDRIVER {
23
24 protected :
25
26   int            _id;         // MED_INVALID : if the driver hasn't been created by a MedMedDriver
27                               // the MedMedDriver index of the driver vector in the MED object where it has been created
28   /*File related part*/
29   string         _fileName;   // The name of the file currently in use.
30   MED_EN::med_mode_acces _accessMode; // The file access mode set by the adequate construtor.
31   int            _status;     // The file status {MED_INVALID, MED_OPENED, MED_CLOSED } 
32   driverTypes    _driverType; //  A FAIRE LE POSITIONNER DS TOUTES LES SS CLASSES !!
33
34
35 public:
36   /*!
37     Constructor.
38   */
39   GENDRIVER();
40   /*!
41     Constructor.
42   */
43   GENDRIVER(const string & fileName,MED_EN::med_mode_acces accessMode);
44   /*!
45     Copy constructor.
46   */
47   GENDRIVER(const GENDRIVER & genDriver);
48
49   /*!
50     Destructor.
51   */
52   virtual ~GENDRIVER();
53
54   /*!
55     Operator = : duplicate the given genDriver.
56   */
57   GENDRIVER & operator=(const GENDRIVER & genDriver);
58
59   /*!
60     Operator << : put GENDRIVER object information to the given stream
61   */
62   friend ostream & operator<<(ostream &os,const GENDRIVER &genDriver);
63
64   bool operator ==(const GENDRIVER &genDriver) const;
65   /*!
66     Open file.
67   */
68   virtual void open ( void ) = 0;
69   /*!
70     Open file with the append option. This method is used especially
71     on ASCII drivers (e.g. VTK_DRIVER).
72   */
73   virtual void openAppend ( void );
74   /*!
75     Close file.
76   */
77   virtual void close( void ) = 0;
78   /*!
79     Write object in opened file.
80   */
81   virtual void write( void ) const = 0;
82   /*!
83     Write object in opened file. This method is used especially
84     on ASCII drivers (e.g. VTK_DRIVER).
85   */
86   virtual void writeAppend( void ) const;
87   /*!
88     Read object in opened file.
89   */
90   virtual void read ( void ) = 0;
91   
92   // needed to duplicate arrays 
93   virtual GENDRIVER * copy ( void ) const = 0 ;
94
95   // MED  related part
96   virtual void writeFrom      ( void );
97   virtual void readFileStruct ( void );
98   // MESH related Part
99   virtual void setMeshName    ( const string & meshName);
100   // FIELD related Part
101   virtual void setFieldName   ( const string & fieldName);
102
103   void   setId       ( int id = MED_INVALID );
104   int    getId       ( void ) const ;
105   string getFileName () const;
106   void   setFileName ( const string & fileName);
107   MED_EN::med_mode_acces getAccessMode() const;
108 };
109 };
110
111
112 #endif /* GENDRIVER_HXX */