1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
29 #include "MEDMEM_define.hxx"
30 #include "MEDMEM_Utilities.hxx"
32 /* Generic Read/Write Driver Class for Meshes & Fields */
38 Virtual class GENDRIVER use by all driver.
43 /* Modify the following line to add a new driver type (step 1) */
44 typedef enum { MED_DRIVER = 0, GIBI_DRIVER = 1, PORFLOW_DRIVER = 2,
45 ENSIGHT_DRIVER = 250, VTK_DRIVER = 254, ASCII_DRIVER = 3,
46 NO_DRIVER = 255 } driverTypes;
49 MEDMEM_EXPORT ostream & operator<<(ostream &os,const GENDRIVER &genDriver);
51 class MEDMEM_EXPORT GENDRIVER {
55 int _id; // MED_INVALID : if the driver hasn't been created by a MedMedDriver
56 // the MedMedDriver index of the driver vector in the MED object where it has been created
58 string _fileName; // The name of the file currently in use.
59 MED_EN::med_mode_acces _accessMode; // The file access mode set by the adequate construtor.
60 int _status; // The file status {MED_INVALID, MED_OPENED, MED_CLOSED }
61 driverTypes _driverType; // A FAIRE LE POSITIONNER DS TOUTES LES SS CLASSES !!
68 GENDRIVER(driverTypes driverType);
72 GENDRIVER(const string & fileName, MED_EN::med_mode_acces accessMode,
73 driverTypes driverType);
77 GENDRIVER(const GENDRIVER & genDriver);
85 Operator = : duplicate the given genDriver.
87 GENDRIVER & operator=(const GENDRIVER & genDriver);
90 Operator << : put GENDRIVER object information to the given stream
92 friend ostream & operator<<(ostream &os,const GENDRIVER &genDriver);
94 bool operator ==(const GENDRIVER &genDriver) const;
98 virtual void open ( void ) = 0;
100 Open file with the append option. This method is used especially
101 on ASCII drivers (e.g. VTK_DRIVER).
103 virtual void openAppend ( void );
107 virtual void close( void ) = 0;
109 Write object in opened file.
111 virtual void write( void ) const = 0;
113 Write object in opened file. This method is used especially
114 on ASCII drivers (e.g. VTK_DRIVER).
116 virtual void writeAppend( void ) const;
118 Read object in opened file.
120 virtual void read ( void ) = 0;
122 // needed to duplicate arrays
123 virtual GENDRIVER * copy ( void ) const = 0 ;
125 // Take missing data from other driver.
126 // Is for object->read( genDriver ) if object was not passed to genDriver
127 // (i.e. genDriver has been created through constructor without parameters),
128 // then object asks driverFactory to create a driver initialized by object
129 // and fills the new driver up using merge( genDriver ).
130 // Needed for drivers possessing own data
131 virtual void merge ( const GENDRIVER &genDriver );
134 virtual void writeFrom ( void ) const;
135 virtual void readFileStruct ( void );
137 virtual void setMeshName ( const string & meshName);
138 virtual string getMeshName() const;
139 // FIELD related Part
140 virtual void setFieldName ( const string & fieldName);
141 virtual string getFieldName() const;
143 void setId ( int id = MED_INVALID );
144 int getId ( void ) const ;
145 string getFileName () const;
146 virtual void setFileName ( const string & fileName);
147 virtual MED_EN::med_mode_acces getAccessMode() const;
148 driverTypes getDriverType() const { return _driverType; }
153 #endif /* GENDRIVER_HXX */