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
22 #include "MEDMEM_GenDriver.hxx"
23 #include "MEDMEM_STRING.hxx"
24 #include "MEDMEM_Exception.hxx"
27 using namespace MEDMEM;
28 using namespace MED_EN;
30 GENDRIVER::GENDRIVER(driverTypes driverType):
33 _accessMode( (med_mode_acces) MED_INVALID ),
35 _driverType(driverType) {}
37 GENDRIVER::GENDRIVER(const string & fileName,
38 med_mode_acces accessMode/*=(med_mode_acces) MED_INVALID*/,
39 driverTypes driverType)
42 _accessMode(accessMode),
44 _driverType(driverType)
48 GENDRIVER::GENDRIVER(const GENDRIVER & genDriver):
51 _fileName(genDriver._fileName),
52 _accessMode(genDriver._accessMode),
53 _status(genDriver._status),
54 _driverType(genDriver._driverType)
57 GENDRIVER::~GENDRIVER() {}
60 GENDRIVER & MEDMEM::GENDRIVER::operator=(const GENDRIVER & genDriver)
62 const char* LOC = " GENDRIVER & GENDRIVER::operator=(const GENDRIVER & genDriver) : ";
64 _fileName = genDriver._fileName;
65 _accessMode = genDriver._accessMode;
66 _status = genDriver._status;
68 _driverType = genDriver._driverType;
72 void GENDRIVER::writeFrom ( void ) const {}
73 void GENDRIVER::readFileStruct ( void ) {}
75 void GENDRIVER::setMeshName (const string & ) {}
76 string GENDRIVER::getMeshName() const { return ""; }
77 void GENDRIVER::setFieldName (const string & ) {}
78 string GENDRIVER::getFieldName() const { return ""; }
80 void GENDRIVER::openAppend ( void ) {}
81 void GENDRIVER::writeAppend ( void ) const {}
83 void GENDRIVER::setId ( int id )
85 const char* LOC = "void GENDRIVER::setId ( int id ) : ";
88 if ( id >= 0 ) _id=id; else _id = MED_INVALID ;
93 int GENDRIVER::getId ( void) const
95 const char* LOC = "int GENDRIVER::getId ( void) const ";
101 string GENDRIVER::getFileName() const {
103 const char* LOC = "string GENDRIVER::getFileName() const : ";
110 void GENDRIVER::setFileName(const string & fileName)
112 const char * LOC = "void GENDRIVER::setFileName(const string & fileName) : ";
115 if ( _status == MED_OPENED )
116 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<" File |" << _fileName
117 << "| is still openned, close it before openning : | " << fileName << "|"));
119 _fileName = fileName;
126 med_mode_acces GENDRIVER::getAccessMode() const
128 const char* LOC = "med_mode_acces GENDRIVER::getAccessMode() const : ";
134 ostream & MEDMEM::operator<<(ostream &os,const GENDRIVER & drv)
136 switch (drv._accessMode)
139 os<<"C'est un IO de READ"<<endl;
142 os<<"C'est un IO d'READ/WRITE"<<endl;
145 //os <<"C'est un IO de remplacement"<<endl;
151 os<<"L'IO_Mesh_MED est open"<<endl;
154 os<<"L'IO_Mesh_MED est fermé"<<endl;
157 os<<"L'IO_Mesh_MED est non-valide"<<endl;
163 // Test if this driver has been created from MED driver
164 bool MEDMEM::GENDRIVER::operator ==(const GENDRIVER &genDriver) const {
167 MESSAGE_MED("bool GENDRIVER::operator ==(const GENDRIVER &genDriver) const : ");
169 return /*( _id == genDriver._id ) &&*/
170 ( _driverType == genDriver._driverType ) &&
171 (_accessMode == genDriver._accessMode);
175 // Take missing data from other driver.
176 // Is for object->read( genDriver ) if object was not passed to genDriver,
177 // then object asks driverFactory to create a driver initialized by object
178 // and fills the new driver up using merge( genDriver )
180 void GENDRIVER::merge ( const GENDRIVER &genDriver )
182 if ( _id == MED_INVALID )
184 if ( _fileName.empty() )
185 _fileName = genDriver._fileName;
186 if ( _accessMode == MED_INVALID )
187 _accessMode = genDriver._accessMode;
189 if ( getMeshName().empty() )
190 setMeshName( genDriver.getMeshName() );
191 if ( getFieldName().empty() )
192 setFieldName( genDriver.getFieldName() );