Salome HOME
Overload of MEDLoader.ReadField method to ease access of medcoupling for new comers
[tools/medcoupling.git] / src / MEDLoader / MEDFileUtilities.hxx
index a17a407ee975f94f1f404ebd3137a09182607dac..32ed5d47e145104e0a930b2941a3d94c13ac3719 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
 //
 // 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.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 #include "InterpKernelException.hxx"
 #include "MEDLoaderDefines.hxx"
 
+#include "MCAuto.hxx"
+#include "MEDCouplingMemArray.hxx"
+
 #include "med.h"
 
 namespace MEDFileUtilities
 {
   med_access_mode TraduceWriteMode(int medloaderwritemode);
   const char *GetReadableMEDFieldType(med_field_type ft);
-  void CheckMEDCode(int code, med_idt fid, const char *msg);
-  void CheckFileForRead(const char *fileName);
+  void CheckMEDCode(int code, med_idt fid, const std::string& msg);
+  void CheckFileForRead(const std::string& fileName);
 
   class AutoFid
   {
   public:
     AutoFid(med_idt fid);
-    operator med_idt() const;
+    operator med_idt() const { return _fid; }
     ~AutoFid();
   private:
     med_idt _fid;
   };
 }
-  
-namespace ParaMEDMEM
+
+namespace MEDCoupling
 {
   class MEDLOADER_EXPORT MEDFileWritable
   {
@@ -55,10 +58,27 @@ namespace ParaMEDMEM
     void setTooLongStrPolicy(int newVal);
     int getZipConnPolicy();
     void setZipConnPolicy(int newVal);
+    static std::string FileNameFromFID(med_idt fid);
   protected://policies on write
     mutable int _too_long_str;
     mutable int _zipconn_pol;
   };
+
+  class MEDFileWritableStandAlone : public MEDFileWritable
+  {
+  public:
+    MEDLOADER_EXPORT virtual void writeLL(med_idt fid) const = 0;
+    MEDLOADER_EXPORT virtual void write(const std::string& fileName, int mode) const;
+    MEDLOADER_EXPORT virtual void write30(const std::string& fileName, int mode) const;
+    MEDLOADER_EXPORT MCAuto<DataArrayByte> serialize() const;
+    MEDLOADER_EXPORT static std::string GenerateUniqueDftFileNameInMem();
+  public:
+    MEDLOADER_EXPORT static const char DFT_FILENAME_IN_MEM[];
+    template<class T>
+    static T *BuildFromMemoryChunk(DataArrayByte *db);
+  };
+  
+  MEDFileUtilities::AutoFid OpenMEDFileForRead(const std::string& fileName);
 }
 
 #endif