Salome HOME
Copyrights update
[modules/med.git] / src / MEDMEM / MEDMEM_GenDriver.hxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/
19 //
20 #ifndef GENDRIVER_HXX
21 #define GENDRIVER_HXX
22
23 #include <string>
24
25 #include "MEDMEM_define.hxx"
26 #include "MEDMEM_Utilities.hxx"
27
28 /* Generic Read/Write Driver Class for Meshes & Fields */
29
30 using namespace std;
31
32 /*!
33
34   Virtual class GENDRIVER use by all driver.
35
36 */
37 namespace MEDMEM {
38
39 /* Modify the following line to add a new driver type (step 1) */
40 typedef enum { MED_DRIVER = 0, GIBI_DRIVER = 1, PORFLOW_DRIVER = 2, VTK_DRIVER = 254, ASCII_DRIVER = 3, NO_DRIVER = 255 } driverTypes;
41 class GENDRIVER {
42
43 protected :
44
45   int            _id;         // MED_INVALID : if the driver hasn't been created by a MedMedDriver
46                               // the MedMedDriver index of the driver vector in the MED object where it has been created
47   /*File related part*/
48   string         _fileName;   // The name of the file currently in use.
49   MED_EN::med_mode_acces _accessMode; // The file access mode set by the adequate construtor.
50   int            _status;     // The file status {MED_INVALID, MED_OPENED, MED_CLOSED } 
51   driverTypes    _driverType; //  A FAIRE LE POSITIONNER DS TOUTES LES SS CLASSES !!
52
53
54 public:
55   /*!
56     Constructor.
57   */
58   GENDRIVER();
59   /*!
60     Constructor.
61   */
62   GENDRIVER(const string & fileName,MED_EN::med_mode_acces accessMode);
63   /*!
64     Copy constructor.
65   */
66   GENDRIVER(const GENDRIVER & genDriver);
67
68   /*!
69     Destructor.
70   */
71   virtual ~GENDRIVER();
72
73   /*!
74     Operator = : duplicate the given genDriver.
75   */
76   GENDRIVER & operator=(const GENDRIVER & genDriver);
77
78   /*!
79     Operator << : put GENDRIVER object information to the given stream
80   */
81   friend ostream & operator<<(ostream &os,const GENDRIVER &genDriver);
82
83   bool operator ==(const GENDRIVER &genDriver) const;
84   /*!
85     Open file.
86   */
87   virtual void open ( void ) = 0;
88   /*!
89     Open file with the append option. This method is used especially
90     on ASCII drivers (e.g. VTK_DRIVER).
91   */
92   virtual void openAppend ( void );
93   /*!
94     Close file.
95   */
96   virtual void close( void ) = 0;
97   /*!
98     Write object in opened file.
99   */
100   virtual void write( void ) const = 0;
101   /*!
102     Write object in opened file. This method is used especially
103     on ASCII drivers (e.g. VTK_DRIVER).
104   */
105   virtual void writeAppend( void ) const;
106   /*!
107     Read object in opened file.
108   */
109   virtual void read ( void ) = 0;
110   
111   // needed to duplicate arrays 
112   virtual GENDRIVER * copy ( void ) const = 0 ;
113
114   // MED  related part
115   virtual void writeFrom      ( void );
116   virtual void readFileStruct ( void );
117   // MESH related Part
118   virtual void setMeshName    ( const string & meshName);
119   // FIELD related Part
120   virtual void setFieldName   ( const string & fieldName);
121
122   void   setId       ( int id = MED_INVALID );
123   int    getId       ( void ) const ;
124   string getFileName () const;
125   void   setFileName ( const string & fileName);
126   MED_EN::med_mode_acces getAccessMode() const;
127 };
128 };
129
130
131 #endif /* GENDRIVER_HXX */