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