]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/MEDMEM_GenDriver.cxx
Salome HOME
Join modifications from branch CEAFor_V3_2_0
[modules/med.git] / src / MEDMEM / MEDMEM_GenDriver.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/
19 //
20 #include "MEDMEM_GenDriver.hxx"
21 #include "MEDMEM_STRING.hxx"
22 #include "MEDMEM_Exception.hxx"
23
24 using namespace std;
25 using namespace MEDMEM;
26 using namespace MED_EN;
27
28 GENDRIVER::GENDRIVER(): _id(MED_INVALID),
29                         _fileName(""),
30                         _accessMode( (med_mode_acces) MED_INVALID ),
31                         _status(MED_INVALID),
32                         _driverType(NO_DRIVER) {}
33
34 GENDRIVER::GENDRIVER(const string & fileName,
35                      med_mode_acces accessMode=(med_mode_acces) MED_INVALID): _id(MED_INVALID),
36                                                                               _fileName(fileName),
37                                                                               _accessMode(accessMode),
38                                                                               _status(MED_CLOSED),
39                                                                               _driverType(NO_DRIVER) {}
40
41 GENDRIVER::GENDRIVER(const GENDRIVER & genDriver):
42   //_id(MED_INVALID), 
43   _id(genDriver._id),
44   _fileName(genDriver._fileName),
45   _accessMode(genDriver._accessMode),
46   _status(genDriver._status),
47   _driverType(genDriver._driverType) 
48 {}
49
50 GENDRIVER::~GENDRIVER() {}
51
52
53 GENDRIVER & MEDMEM::GENDRIVER::operator=(const GENDRIVER &  genDriver) 
54 {
55   const char * LOC = " GENDRIVER & GENDRIVER::operator=(const GENDRIVER &  genDriver)  : ";
56   
57   BEGIN_OF(LOC);
58   _fileName    = genDriver._fileName;
59   _accessMode  = genDriver._accessMode;
60   _status      = genDriver._status;
61   _id          = genDriver._id;
62   return *this;
63 }
64
65 void GENDRIVER::writeFrom      ( void ) {};
66 void GENDRIVER::readFileStruct ( void ) {};
67
68 void GENDRIVER::setMeshName    (const string & ) {};
69 void GENDRIVER::setFieldName   (const string & ) {};
70
71 void GENDRIVER::openAppend ( void ) {};
72 void GENDRIVER::writeAppend ( void ) const {};
73
74 void GENDRIVER::setId ( int id ) {
75   const char * LOC = "void GENDRIVER::setId ( int id ) : ";
76
77   BEGIN_OF(LOC);
78
79   if ( id >= 0 ) _id=id; else _id = MED_INVALID ;
80
81   END_OF(LOC);
82 };
83
84 int GENDRIVER::getId ( void) const {
85   const char * LOC = "int GENDRIVER::getId ( void) const ";
86
87   BEGIN_OF(LOC);
88
89   return _id ;
90 };
91
92 string GENDRIVER::getFileName() const {
93
94   const char * LOC = "string GENDRIVER::getFileName() const : ";
95   BEGIN_OF(LOC);
96   
97   return _fileName;
98 }
99     
100
101 void GENDRIVER::setFileName(const string & fileName)  {
102
103   const char * LOC = "void GENDRIVER::setFileName(const string & fileName) : ";
104   BEGIN_OF(LOC);
105
106   if ( _status == MED_OPENED )
107     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<" File |" << _fileName 
108                                  << "| is still openned, close it before openning : | " << fileName << "|"));
109   else
110     _fileName = fileName; 
111
112   END_OF(LOC);
113 }
114        
115
116
117 med_mode_acces GENDRIVER::getAccessMode() const {
118
119   const char * LOC = "med_mode_acces GENDRIVER::getAccessMode() const : ";
120
121   BEGIN_OF(LOC);
122
123   return _accessMode;
124 }
125
126 ostream & MEDMEM::operator<<(ostream &os,const GENDRIVER & drv)
127 {
128   switch (drv._accessMode)
129     {
130     case MED_RDONLY : 
131       os<<"C'est un IO de READ"<<endl;
132       break;
133     case MED_RDWR :
134       os<<"C'est un IO d'READ/WRITE"<<endl;
135       break;
136     case MED_REMP :
137       os <<"C'est un IO de remplacement"<<endl;
138       break;
139     }
140   switch (drv._status)
141     {
142     case MED_OPENED :
143       os<<"L'IO_Mesh_MED est open"<<endl;
144       break;
145     case MED_CLOSED :
146       os<<"L'IO_Mesh_MED est fermé"<<endl;
147       break;
148     case MED_INVALID :
149       os<<"L'IO_Mesh_MED est non-valide"<<endl;
150       break;
151     }
152   return os;
153 }
154
155 // Test if this driver has been created from  MED driver
156 bool MEDMEM::GENDRIVER::operator ==(const GENDRIVER &genDriver) const {
157   
158   const char * LOC = "bool GENDRIVER::operator ==(const GENDRIVER &genDriver) const : ";
159
160   MESSAGE(LOC);
161
162   return ( _id == genDriver._id )  &&
163     ( _driverType == genDriver._driverType ) &&
164     (_accessMode == genDriver._accessMode);
165   
166 };
167