Salome HOME
bos #24400 [CEA] Option in SALOME for not storing in med files the indices (number...
[modules/smesh.git] / src / MEDWrapper / MED_TFile.hxx
index 10dc553964136398d51fcbdbf95fc5b95d878614..09634f89167e5ee04e62c74b5b4b6e1a3f10a74b 100644 (file)
@@ -20,6 +20,7 @@
 #pragma once
 
 #include "MED_Wrapper.hxx"
+#include "MED_WrapperDef.hxx"
 
 namespace MED
 {
@@ -32,7 +33,7 @@ namespace MED
     virtual const TIdt& Id() const = 0;
   };
 
-  class MEDIDTHoder : public TFileInternal
+  class MEDWRAPPER_EXPORT MEDIDTHoder : public TFileInternal
   {
   protected:
     MEDIDTHoder(bool *isClosedStatus = nullptr):_isClosedStatus(isClosedStatus) { }
@@ -57,7 +58,7 @@ namespace MED
     bool *_isClosedStatus = nullptr;
   };
 
-  class TFileDecorator : public TFileInternal
+  class MEDWRAPPER_EXPORT TFileDecorator : public TFileInternal
   {
   public:
     TFileDecorator(TFileInternal *effective):_effective(effective) { }
@@ -69,18 +70,21 @@ namespace MED
     TFileInternal *_effective = nullptr;
   };
 
-  class TMemFile : public MEDIDTHoder
+  class MEDWRAPPER_EXPORT TMemFile : public MEDIDTHoder
   {
   public:
-    TMemFile(bool* isClosedStatus = nullptr):MEDIDTHoder(isClosedStatus) { }
+    TMemFile(void **data, std::size_t *sz, bool* isClosedStatus):MEDIDTHoder(isClosedStatus),_data(data),_sz(sz) { memfile.app_image_ptr=*data; memfile.app_image_size=*sz; }
+    ~TMemFile() { UnRefFid(); if(myIsClosed) { *_data = memfile.app_image_ptr; *_sz = memfile.app_image_size; } }
     void Open(EModeAcces theMode, TErr* theErr = nullptr) override;
     void *getData() const { return memfile.app_image_ptr; }
     std::size_t getSize() const { return memfile.app_image_size; }
   private:
+    void **_data = nullptr;
+    std::size_t * _sz = nullptr;
     med_memfile memfile = MED_MEMFILE_INIT;
   };
 
-  class TFile : public MEDIDTHoder
+  class MEDWRAPPER_EXPORT TFile : public MEDIDTHoder
   {
   public:
     TFile(const std::string& theFileName, TInt theMajor=-1, TInt theMinor=-1);