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
23 #include "MEDMEM_GenDriver.hxx"
24 #include "MEDMEM_STRING.hxx"
25 #include "MEDMEM_Exception.hxx"
28 using namespace MEDMEM;
29 using namespace MED_EN;
31 GENDRIVER::GENDRIVER(driverTypes driverType):
34 _accessMode( (med_mode_acces) MED_INVALID ),
36 _driverType(driverType) {}
38 GENDRIVER::GENDRIVER(const string & fileName,
39 med_mode_acces accessMode/*=(med_mode_acces) MED_INVALID*/,
40 driverTypes driverType)
43 _accessMode(accessMode),
45 _driverType(driverType)
49 GENDRIVER::GENDRIVER(const GENDRIVER & genDriver):
52 _fileName(genDriver._fileName),
53 _accessMode(genDriver._accessMode),
54 _status(genDriver._status),
55 _driverType(genDriver._driverType)
58 GENDRIVER::~GENDRIVER() {}
61 GENDRIVER & MEDMEM::GENDRIVER::operator=(const GENDRIVER & genDriver)
63 const char* LOC = " GENDRIVER & GENDRIVER::operator=(const GENDRIVER & genDriver) : ";
65 _fileName = genDriver._fileName;
66 _accessMode = genDriver._accessMode;
67 _status = genDriver._status;
69 _driverType = genDriver._driverType;
73 void GENDRIVER::writeFrom ( void ) const {}
74 void GENDRIVER::readFileStruct ( void ) {}
76 void GENDRIVER::setMeshName (const string & ) {}
77 string GENDRIVER::getMeshName() const { return ""; }
78 void GENDRIVER::setFieldName (const string & ) {}
79 string GENDRIVER::getFieldName() const { return ""; }
81 void GENDRIVER::openAppend ( void ) {}
82 void GENDRIVER::writeAppend ( void ) const {}
84 void GENDRIVER::setId ( int id )
86 const char* LOC = "void GENDRIVER::setId ( int id ) : ";
89 if ( id >= 0 ) _id=id; else _id = MED_INVALID ;
94 int GENDRIVER::getId ( void) const
96 const char* LOC = "int GENDRIVER::getId ( void) const ";
102 string GENDRIVER::getFileName() const {
104 const char* LOC = "string GENDRIVER::getFileName() const : ";
111 void GENDRIVER::setFileName(const string & fileName)
113 const char * LOC = "void GENDRIVER::setFileName(const string & fileName) : ";
116 if ( _status == MED_OPENED )
117 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<" File |" << _fileName
118 << "| is still openned, close it before openning : | " << fileName << "|"));
120 _fileName = fileName;
125 med_mode_acces GENDRIVER::getAccessMode() const
127 const char* LOC = "med_mode_acces GENDRIVER::getAccessMode() const : ";
133 void GENDRIVER::setAccessMode(med_mode_acces mode)
138 ostream & MEDMEM::operator<<(ostream &os,const GENDRIVER & drv)
140 switch (drv._accessMode)
143 os<<"C'est un IO de READ"<<endl;
146 os<<"C'est un IO d'READ/WRITE"<<endl;
149 os<<"C'est un IO d'WRITE"<<endl;
155 os<<"L'IO_Mesh_MED est open"<<endl;
158 os<<"L'IO_Mesh_MED est fermé"<<endl;
161 os<<"L'IO_Mesh_MED est non-valide"<<endl;
167 // Test if this driver has been created from MED driver
168 bool MEDMEM::GENDRIVER::operator ==(const GENDRIVER &genDriver) const {
171 MESSAGE_MED("bool GENDRIVER::operator ==(const GENDRIVER &genDriver) const : ");
173 return /*( _id == genDriver._id ) &&*/
174 ( _driverType == genDriver._driverType ) &&
175 (_accessMode == genDriver._accessMode);
179 // Take missing data from other driver.
180 // Is for object->read( genDriver ) if object was not passed to genDriver,
181 // then object asks driverFactory to create a driver initialized by object
182 // and fills the new driver up using merge( genDriver )
184 void GENDRIVER::merge ( const GENDRIVER &genDriver )
186 if ( _id == MED_INVALID )
188 if ( _fileName.empty() )
189 _fileName = genDriver._fileName;
190 if ( _accessMode == MED_INVALID )
191 _accessMode = genDriver._accessMode;
193 if ( getMeshName().empty() )
194 setMeshName( genDriver.getMeshName() );
195 if ( getFieldName().empty() )
196 setFieldName( genDriver.getFieldName() );