Back to index

salome-med  6.5.0
MEDMEM_GenDriver.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #ifndef GENDRIVER_HXX
00024 #define GENDRIVER_HXX
00025 
00026 #include <MEDMEM.hxx>
00027 
00028 #include <string>
00029 
00030 #include "MEDMEM_define.hxx"
00031 #include "MEDMEM_Utilities.hxx"
00032 
00033 /* Generic Read/Write Driver Class for Meshes & Fields */
00034 
00035 using namespace std;
00036 
00042 namespace MEDMEM {
00043 
00044   /* Modify the following line to add a new driver type (step 1) */
00045   typedef enum { MED_DRIVER = 0, GIBI_DRIVER = 1, PORFLOW_DRIVER = 2,
00046                  ENSIGHT_DRIVER = 250, VTK_DRIVER = 254, ASCII_DRIVER = 3,
00047                  NO_DRIVER = 255 } driverTypes;
00048 
00049   class GENDRIVER;
00050   MEDMEM_EXPORT ostream & operator<<(ostream &os,const GENDRIVER &genDriver);
00051 
00052   class MEDMEM_EXPORT GENDRIVER {
00053 
00054 protected :
00055 
00056     int            _id; // position in a vector of drivers in GMESH or FIELD_
00057 
00058   /*File related part*/
00059   string         _fileName;   // The name of the file currently in use.
00060   MED_EN::med_mode_acces _accessMode; // The file access mode set by the adequate construtor.
00061   int            _status;     // The file status {MED_INVALID, MED_OPENED, MED_CLOSED } 
00062   driverTypes    _driverType;
00063 
00064 
00065 public:
00069   GENDRIVER(driverTypes driverType);
00073   GENDRIVER(const string & fileName, MED_EN::med_mode_acces accessMode,
00074             driverTypes driverType);
00078   GENDRIVER(const GENDRIVER & genDriver);
00079 
00083   virtual ~GENDRIVER();
00084 
00088   GENDRIVER & operator=(const GENDRIVER & genDriver);
00089 
00093   friend ostream & operator<<(ostream &os,const GENDRIVER &genDriver);
00094 
00095   bool operator ==(const GENDRIVER &genDriver) const;
00099   virtual void open ( void ) = 0;
00104   virtual void openAppend ( void );
00108   virtual void close( void ) = 0;
00112   virtual void write( void ) const = 0;
00117   virtual void writeAppend( void ) const;
00121   virtual void read ( void ) = 0;
00122   
00123   // needed to duplicate arrays 
00124   virtual GENDRIVER * copy ( void ) const = 0 ;
00125 
00126   // Take missing data from other driver.
00127   // Intended for object->read( genDriver ) if object was not passed to genDriver
00128   // (i.e. genDriver has been created through constructor without parameters),
00129   // then object asks driverFactory to create a driver initialized by object
00130   // and fills the new driver up using merge( genDriver ).
00131   // Needed for drivers possessing specific data
00132   virtual void merge ( const GENDRIVER &genDriver );
00133 
00134   // MED  related part
00135   virtual void writeFrom      ( void ) const;
00136   virtual void readFileStruct ( void );
00137   // MESH related Part
00138   virtual void setMeshName    ( const string & meshName);
00139   virtual string getMeshName() const;
00140   // FIELD related Part
00141   virtual void setFieldName   ( const string & fieldName);
00142   virtual string getFieldName() const;
00143 
00144   void   setId       ( int id = MED_EN::MED_INVALID );
00145   int    getId       ( void ) const ;
00146   string getFileName () const;
00147   virtual void setFileName ( const string & fileName);
00148   virtual MED_EN::med_mode_acces getAccessMode() const;
00149   virtual void setAccessMode(MED_EN::med_mode_acces mode);
00150   driverTypes getDriverType() const { return _driverType; }
00151 };
00152 }
00153 
00154 
00155 #endif /* GENDRIVER_HXX */