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