//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
//
//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2.1 of the License.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
//
//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef MED_MED_DRIVER21_HXX
#define MED_MED_DRIVER21_HXX

#include "MEDMEM_MedMedDriver.hxx"
#include <string>
#include "MEDMEM_Utilities.hxx"
#include "MEDMEM_Exception.hxx"
#include "MEDMEM_GenDriver.hxx"
#include "MEDMEM_define.hxx"

/*!

  Driver Med for MED.

  Generic part : implement open and close methods.

*/

// This driver pilots within a MED class read/write accesses of fields/meshes
namespace MEDMEM {
class MESH;
class FIELD_;
class MED;

class MEDMEM_EXPORT MED_MED_DRIVER21 : public virtual MED_MED_DRIVER
{
protected:

  med_2_1::med_idt           _medIdt;         // The _medIdt used to write/read Meshes to ::_filename
   
public :
  MED_MED_DRIVER21();
  MED_MED_DRIVER21(const string & fileName,  MED * const ptrMed);
  MED_MED_DRIVER21(const string & fileName,  MED * const ptrMed,
		   MED_EN::med_mode_acces accessMode);
  MED_MED_DRIVER21(const MED_MED_DRIVER21 & driver);
  virtual ~MED_MED_DRIVER21();
  void open() throw (MEDEXCEPTION) ;
  void close();
  virtual void write          ( void ) const ;
  virtual void writeFrom      ( void ) const  ;
  virtual void read           ( void )  ;
  virtual void readFileStruct ( void ) ;
private:
  virtual GENDRIVER * copy ( void ) const  ;
};

/*!

  Driver Med for MED : Read only.

  Implement read method.

*/

  class MEDMEM_EXPORT MED_MED_RDONLY_DRIVER21 : public virtual IMED_MED_RDONLY_DRIVER, public virtual MED_MED_DRIVER21
{
public :
  MED_MED_RDONLY_DRIVER21();
  MED_MED_RDONLY_DRIVER21(const string & fileName,  MED * const ptrMed);
  MED_MED_RDONLY_DRIVER21(const MED_MED_RDONLY_DRIVER21 & driver);
  virtual ~MED_MED_RDONLY_DRIVER21();
  void write          ( void ) const throw (MEDEXCEPTION) ;
  void writeFrom      ( void ) const throw (MEDEXCEPTION) ;
  void read           ( void ) throw (MEDEXCEPTION);
  void readFileStruct ( void ) throw (MEDEXCEPTION) ;
private:
  virtual GENDRIVER * copy ( void ) const ;
};

class MEDMEM_EXPORT MED_MED_WRONLY_DRIVER21 : public virtual IMED_MED_WRONLY_DRIVER, public virtual MED_MED_DRIVER21
{

public :
  MED_MED_WRONLY_DRIVER21();
  MED_MED_WRONLY_DRIVER21(const string & fileName,  MED * const ptrMed);
  MED_MED_WRONLY_DRIVER21(const MED_MED_WRONLY_DRIVER21 & driver);
  virtual ~MED_MED_WRONLY_DRIVER21();
  void write          ( void ) const throw (MEDEXCEPTION);
  void writeFrom      ( void ) const throw (MEDEXCEPTION);
  void read           ( void ) throw (MEDEXCEPTION) ;
  void readFileStruct ( void ) throw (MEDEXCEPTION) ;
private:
  virtual GENDRIVER * copy ( void ) const ;
};

class MEDMEM_EXPORT MED_MED_RDWR_DRIVER21 : public MED_MED_RDONLY_DRIVER21,
			      public MED_MED_WRONLY_DRIVER21,
			      public IMED_MED_RDWR_DRIVER
{
public :
  MED_MED_RDWR_DRIVER21();
  MED_MED_RDWR_DRIVER21(const string & fileName,  MED * const ptrMed);
  MED_MED_RDWR_DRIVER21(const MED_MED_RDWR_DRIVER21 & driver);
  ~MED_MED_RDWR_DRIVER21();
  void write          ( void ) const throw (MEDEXCEPTION);
  void writeFrom      ( void ) const throw (MEDEXCEPTION);
  void read           ( void ) throw (MEDEXCEPTION);
  void readFileStruct ( void ) throw (MEDEXCEPTION);
private:
  virtual GENDRIVER * copy ( void ) const ;
};

}

#endif /* MED_MED_DRIVER21_HXX */
