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