1 // Copyright (C) 2007-2012 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
30 #include "MEDMEM_define.hxx"
31 #include "MEDMEM_Utilities.hxx"
33 /* Generic Read/Write Driver Class for Meshes & Fields */
39 Virtual class GENDRIVER use by all driver.
44 /* Modify the following line to add a new driver type (step 1) */
45 typedef enum { MED_DRIVER = 0, GIBI_DRIVER = 1, PORFLOW_DRIVER = 2,
46 ENSIGHT_DRIVER = 250, VTK_DRIVER = 254, ASCII_DRIVER = 3,
47 NO_DRIVER = 255 } driverTypes;
50 MEDMEM_EXPORT ostream & operator<<(ostream &os,const GENDRIVER &genDriver);
52 class MEDMEM_EXPORT GENDRIVER {
56 int _id; // position in a vector of drivers in GMESH or FIELD_
59 string _fileName; // The name of the file currently in use.
60 MED_EN::med_mode_acces _accessMode; // The file access mode set by the adequate construtor.
61 int _status; // The file status {MED_INVALID, MED_OPENED, MED_CLOSED }
62 driverTypes _driverType;
69 GENDRIVER(driverTypes driverType);
73 GENDRIVER(const string & fileName, MED_EN::med_mode_acces accessMode,
74 driverTypes driverType);
78 GENDRIVER(const GENDRIVER & genDriver);
86 Operator = : duplicate the given genDriver.
88 GENDRIVER & operator=(const GENDRIVER & genDriver);
91 Operator << : put GENDRIVER object information to the given stream
93 friend ostream & operator<<(ostream &os,const GENDRIVER &genDriver);
95 bool operator ==(const GENDRIVER &genDriver) const;
99 virtual void open ( void ) = 0;
101 Open file with the append option. This method is used especially
102 on ASCII drivers (e.g. VTK_DRIVER).
104 virtual void openAppend ( void );
108 virtual void close( void ) = 0;
110 Write object in opened file.
112 virtual void write( void ) const = 0;
114 Write object in opened file. This method is used especially
115 on ASCII drivers (e.g. VTK_DRIVER).
117 virtual void writeAppend( void ) const;
119 Read object in opened file.
121 virtual void read ( void ) = 0;
123 // needed to duplicate arrays
124 virtual GENDRIVER * copy ( void ) const = 0 ;
126 // Take missing data from other driver.
127 // Intended for object->read( genDriver ) if object was not passed to genDriver
128 // (i.e. genDriver has been created through constructor without parameters),
129 // then object asks driverFactory to create a driver initialized by object
130 // and fills the new driver up using merge( genDriver ).
131 // Needed for drivers possessing specific data
132 virtual void merge ( const GENDRIVER &genDriver );
135 virtual void writeFrom ( void ) const;
136 virtual void readFileStruct ( void );
138 virtual void setMeshName ( const string & meshName);
139 virtual string getMeshName() const;
140 // FIELD related Part
141 virtual void setFieldName ( const string & fieldName);
142 virtual string getFieldName() const;
144 void setId ( int id = MED_EN::MED_INVALID );
145 int getId ( void ) const ;
146 string getFileName () const;
147 virtual void setFileName ( const string & fileName);
148 virtual MED_EN::med_mode_acces getAccessMode() const;
149 virtual void setAccessMode(MED_EN::med_mode_acces mode);
150 driverTypes getDriverType() const { return _driverType; }
155 #endif /* GENDRIVER_HXX */