Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[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/ or email : webmaster.salome@opencascade.com
19 //
20 #ifndef GENDRIVER_HXX
21 #define GENDRIVER_HXX
22
23 #include <MEDMEM.hxx>
24
25 #include <string>
26
27 #include "MEDMEM_define.hxx"
28 #include "MEDMEM_Utilities.hxx"
29
30 /* Generic Read/Write Driver Class for Meshes & Fields */
31
32 using namespace std;
33
34 /*!
35
36   Virtual class GENDRIVER use by all driver.
37
38 */
39 namespace MEDMEM {
40
41 /* Modify the following line to add a new driver type (step 1) */
42 typedef enum { MED_DRIVER = 0, GIBI_DRIVER = 1, PORFLOW_DRIVER = 2, ENSIGHT_DRIVER = 250, VTK_DRIVER = 254, ASCII_DRIVER = 3, NO_DRIVER = 255 } driverTypes;
43   class GENDRIVER;
44   ostream & operator<<(ostream &os,const GENDRIVER &genDriver);
45
46 class MEDMEM_EXPORT GENDRIVER {
47
48 protected :
49
50   int            _id;         // MED_INVALID : if the driver hasn't been created by a MedMedDriver
51                               // the MedMedDriver index of the driver vector in the MED object where it has been created
52   /*File related part*/
53   string         _fileName;   // The name of the file currently in use.
54   MED_EN::med_mode_acces _accessMode; // The file access mode set by the adequate construtor.
55   int            _status;     // The file status {MED_INVALID, MED_OPENED, MED_CLOSED } 
56   driverTypes    _driverType; //  A FAIRE LE POSITIONNER DS TOUTES LES SS CLASSES !!
57
58
59 public:
60   /*!
61     Constructor.
62   */
63   GENDRIVER();
64   /*!
65     Constructor.
66   */
67   GENDRIVER(const string & fileName,MED_EN::med_mode_acces accessMode);
68   /*!
69     Copy constructor.
70   */
71   GENDRIVER(const GENDRIVER & genDriver);
72
73   /*!
74     Destructor.
75   */
76   virtual ~GENDRIVER();
77
78   /*!
79     Operator = : duplicate the given genDriver.
80   */
81   GENDRIVER & operator=(const GENDRIVER & genDriver);
82
83   /*!
84     Operator << : put GENDRIVER object information to the given stream
85   */
86   friend MEDMEM_EXPORT ostream & operator<<(ostream &os,const GENDRIVER &genDriver);
87
88   bool operator ==(const GENDRIVER &genDriver) const;
89   /*!
90     Open file.
91   */
92   virtual void open ( void ) = 0;
93   /*!
94     Open file with the append option. This method is used especially
95     on ASCII drivers (e.g. VTK_DRIVER).
96   */
97   virtual void openAppend ( void );
98   /*!
99     Close file.
100   */
101   virtual void close( void ) = 0;
102   /*!
103     Write object in opened file.
104   */
105   virtual void write( void ) const = 0;
106   /*!
107     Write object in opened file. This method is used especially
108     on ASCII drivers (e.g. VTK_DRIVER).
109   */
110   virtual void writeAppend( void ) const;
111   /*!
112     Read object in opened file.
113   */
114   virtual void read ( void ) = 0;
115   
116   // needed to duplicate arrays 
117   virtual GENDRIVER * copy ( void ) const = 0 ;
118
119   // MED  related part
120   virtual void writeFrom      ( void );
121   virtual void readFileStruct ( void );
122   // MESH related Part
123   virtual void setMeshName    ( const string & meshName);
124   virtual string getMeshName() const { return string(""); }
125   // FIELD related Part
126   virtual void setFieldName   ( const string & fieldName);
127
128   void   setId       ( int id = MED_INVALID );
129   int    getId       ( void ) const ;
130   string getFileName () const;
131   void   setFileName ( const string & fileName);
132   virtual MED_EN::med_mode_acces getAccessMode() const;
133 };
134 };
135
136
137 #endif /* GENDRIVER_HXX */