Salome HOME
Merge branch 'master' of https://codev-tuleap.cea.fr/plugins/git/salome/medcoupling
[tools/medcoupling.git] / src / MEDLoader / MEDFileParameter.hxx
index cb4c6fad1e8347be21cdcc5aefa7277e5ff15894..10e1f82cd25bb718dfc21aff586a157ac1926288 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2020  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
 #define __MEDFILEPARAMETER_HXX__
 
 #include "MEDLoaderDefines.hxx"
-#include "MEDFileUtilities.hxx"
+#include "MEDFileUtilities.txx"
 #include "MEDCouplingMemArray.hxx"
-#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+#include "MCAuto.hxx"
 
-namespace ParaMEDMEM
+namespace MEDCoupling
 {
-  class MEDLOADER_EXPORT MEDFileParameter1TS : public RefCountObject
+  class MEDFileParameter1TS : public RefCountObject
   {
   public:
-    virtual MEDFileParameter1TS *deepCpy() const throw(INTERP_KERNEL::Exception) = 0;
-    virtual bool isEqual(const MEDFileParameter1TS *other, double eps, std::string& what) const;
-    virtual void simpleRepr2(int bkOffset, std::ostream& oss) const = 0;
-    virtual void readValue(med_idt fid, const std::string& name) throw(INTERP_KERNEL::Exception) = 0;
-    virtual void writeLL(med_idt fid, const std::string& name, const MEDFileWritable& mw) const throw(INTERP_KERNEL::Exception) = 0;
+    MEDLOADER_EXPORT virtual MEDFileParameter1TS *deepCopy() const = 0;
+    MEDLOADER_EXPORT virtual bool isEqual(const MEDFileParameter1TS *other, double eps, std::string& what) const;
+    MEDLOADER_EXPORT virtual void simpleRepr2(int bkOffset, std::ostream& oss) const = 0;
+    MEDLOADER_EXPORT virtual void readValue(med_idt fid, const std::string& name) = 0;
+    MEDLOADER_EXPORT virtual void writeAdvanced(med_idt fid, const std::string& name, const MEDFileWritable& mw) const = 0;
   public:
-    void setIteration(int it) { _iteration=it; }
-    int getIteration() const { return _iteration; }
-    void setOrder(int order) { _order=order; }
-    int getOrder() const { return _order; }
-    void setTimeValue(double time) { _time=time; }
-    void setTime(int dt, int it, double time) { _time=time; _iteration=dt; _order=it; }
-    double getTime(int& dt, int& it) { dt=_iteration; it=_order; return _time; }
-    double getTimeValue() const { return _time; }
+    MEDLOADER_EXPORT void setIteration(int it) { _iteration=it; }
+    MEDLOADER_EXPORT int getIteration() const { return _iteration; }
+    MEDLOADER_EXPORT void setOrder(int order) { _order=order; }
+    MEDLOADER_EXPORT int getOrder() const { return _order; }
+    MEDLOADER_EXPORT void setTimeValue(double time) { _time=time; }
+    MEDLOADER_EXPORT void setTime(int dt, int it, double time) { _time=time; _iteration=dt; _order=it; }
+    MEDLOADER_EXPORT double getTime(int& dt, int& it) { dt=_iteration; it=_order; return _time; }
+    MEDLOADER_EXPORT double getTimeValue() const { return _time; }
   protected:
     MEDFileParameter1TS(int iteration, int order, double time);
     MEDFileParameter1TS();
@@ -53,40 +53,42 @@ namespace ParaMEDMEM
     int _order;
     double _time;    
   };
-  
-  class MEDLOADER_EXPORT MEDFileParameterDouble1TSWTI : public MEDFileParameter1TS
+
+  class MEDFileParameterDouble1TSWTI : public MEDFileParameter1TS
   {
   public:
-    static MEDFileParameterDouble1TSWTI *New(int iteration, int order, double time);
-    MEDFileParameter1TS *deepCpy() const throw(INTERP_KERNEL::Exception);
-    void setValue(double val) throw(INTERP_KERNEL::Exception) { _arr=val; }
-    double getValue() const throw(INTERP_KERNEL::Exception) { return _arr; }
-    bool isEqual(const MEDFileParameter1TS *other, double eps, std::string& what) const;
-    std::size_t getHeapMemorySize() const;
-    void readValue(med_idt fid, const std::string& name) throw(INTERP_KERNEL::Exception);
-    std::string simpleRepr() const;
+    MEDLOADER_EXPORT static MEDFileParameterDouble1TSWTI *New(int iteration, int order, double time);
+    MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileParameterDouble1TSWTI"); }
+    MEDLOADER_EXPORT MEDFileParameter1TS *deepCopy() const;
+    MEDLOADER_EXPORT void setValue(double val) { _arr=val; }
+    MEDLOADER_EXPORT double getValue() const { return _arr; }
+    MEDLOADER_EXPORT bool isEqual(const MEDFileParameter1TS *other, double eps, std::string& what) const;
+    MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
+    MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
+    MEDLOADER_EXPORT void readValue(med_idt fid, const std::string& name);
+    MEDLOADER_EXPORT std::string simpleRepr() const;
   protected:
     MEDFileParameterDouble1TSWTI();
     MEDFileParameterDouble1TSWTI(int iteration, int order, double time);
     void simpleRepr2(int bkOffset, std::ostream& oss) const;
-    void finishLoading(med_idt fid, const std::string& name, int dt, int it, int nbOfSteps) throw(INTERP_KERNEL::Exception);
-    void finishLoading(med_idt fid, const std::string& name, int timeStepId) throw(INTERP_KERNEL::Exception);
-    void writeLL(med_idt fid, const std::string& name, const MEDFileWritable& mw) const throw(INTERP_KERNEL::Exception);
+    void finishLoading(med_idt fid, const std::string& name, int dt, int it, int nbOfSteps);
+    void finishLoading(med_idt fid, const std::string& name, int timeStepId);
+    void writeAdvanced(med_idt fid, const std::string& name, const MEDFileWritable& mw) const;
   protected:
     double _arr;
   };
 
-  class MEDLOADER_EXPORT MEDFileParameterTinyInfo : public MEDFileWritable
+  class MEDFileParameterTinyInfo : public MEDFileWritable
   {
   public:
-    void setDescription(const char *name) { _desc_name=name; }
-    std::string getDescription() const { return _desc_name; }
-    void setTimeUnit(const char *unit) { _dt_unit=unit; }
-    std::string getTimeUnit() const { return _dt_unit; }
-    std::size_t getHeapMemSizeOfStrings() const;
-    bool isEqualStrings(const MEDFileParameterTinyInfo& other, std::string& what) const;
+    MEDLOADER_EXPORT void setDescription(const std::string& name) { _desc_name=name; }
+    MEDLOADER_EXPORT std::string getDescription() const { return _desc_name; }
+    MEDLOADER_EXPORT void setTimeUnit(const std::string& unit) { _dt_unit=unit; }
+    MEDLOADER_EXPORT std::string getTimeUnit() const { return _dt_unit; }
+    MEDLOADER_EXPORT std::size_t getHeapMemSizeOfStrings() const;
+    MEDLOADER_EXPORT bool isEqualStrings(const MEDFileParameterTinyInfo& other, std::string& what) const;
   protected:
-    void writeLLHeader(med_idt fid, med_parameter_type typ) const throw(INTERP_KERNEL::Exception);
+    void writeLLHeader(med_idt fid, med_parameter_type typ) const;
     void mainRepr(int bkOffset, std::ostream& oss) const;
   protected:
     std::string _dt_unit;
@@ -94,88 +96,98 @@ namespace ParaMEDMEM
     std::string _desc_name;
   };
 
-  class MEDLOADER_EXPORT MEDFileParameterDouble1TS : public MEDFileParameterDouble1TSWTI, public MEDFileParameterTinyInfo
+  class MEDFileParameterDouble1TS : public MEDFileParameterDouble1TSWTI, public MEDFileParameterTinyInfo
   {
   public:
-    static MEDFileParameterDouble1TS *New();
-    static MEDFileParameterDouble1TS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
-    static MEDFileParameterDouble1TS *New(const char *fileName, const char *paramName) throw(INTERP_KERNEL::Exception);
-    static MEDFileParameterDouble1TS *New(const char *fileName, const char *paramName, int dt, int it) throw(INTERP_KERNEL::Exception);
-    virtual MEDFileParameter1TS *deepCpy() const throw(INTERP_KERNEL::Exception);
-    virtual bool isEqual(const MEDFileParameter1TS *other, double eps, std::string& what) const;
-    virtual std::string simpleRepr() const;
-    std::size_t getHeapMemorySize() const;
-    void setName(const char *name) throw(INTERP_KERNEL::Exception) { _name=name; }
-    std::string getName() const throw(INTERP_KERNEL::Exception) { return _name; }
-    void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+    MEDLOADER_EXPORT static MEDFileParameterDouble1TS *New();
+    MEDLOADER_EXPORT static MEDFileParameterDouble1TS *New(const std::string& fileName);
+    MEDLOADER_EXPORT static MEDFileParameterDouble1TS *New(const std::string& fileName, const std::string& paramName);
+    MEDLOADER_EXPORT static MEDFileParameterDouble1TS *New(const std::string& fileName, const std::string& paramName, int dt, int it);
+    MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileParameterDouble1TS"); }
+    MEDLOADER_EXPORT virtual MEDFileParameter1TS *deepCopy() const;
+    MEDLOADER_EXPORT virtual bool isEqual(const MEDFileParameter1TS *other, double eps, std::string& what) const;
+    MEDLOADER_EXPORT virtual std::string simpleRepr() const;
+    MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
+    MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
+    MEDLOADER_EXPORT void setName(const std::string& name) { _name=name; }
+    MEDLOADER_EXPORT std::string getName() const { return _name; }
+    MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const;
   private:
     MEDFileParameterDouble1TS();
-    MEDFileParameterDouble1TS(const char *fileName) throw(INTERP_KERNEL::Exception);
-    MEDFileParameterDouble1TS(const char *fileName, const char *paramName) throw(INTERP_KERNEL::Exception);
-    MEDFileParameterDouble1TS(const char *fileName, const char *paramName, int dt, int it) throw(INTERP_KERNEL::Exception);
+    MEDFileParameterDouble1TS(const std::string& fileName);
+    MEDFileParameterDouble1TS(const std::string& fileName, const std::string& paramName);
+    MEDFileParameterDouble1TS(const std::string& fileName, const std::string& paramName, int dt, int it);
   };
 
-  class MEDLOADER_EXPORT MEDFileParameterMultiTS : public RefCountObject, public MEDFileParameterTinyInfo
+  class MEDFileParameterMultiTS : public RefCountObject, public MEDFileParameterTinyInfo
   {
   public:
-    static MEDFileParameterMultiTS *New();
-    static MEDFileParameterMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
-    static MEDFileParameterMultiTS *New(const char *fileName, const char *paramName) throw(INTERP_KERNEL::Exception);
-    std::string getName() const { return _name; }
-    void setName(const char *name) { _name=name; }
-    std::size_t getHeapMemorySize() const;
-    MEDFileParameterMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception);
-    bool isEqual(const MEDFileParameterMultiTS *other, double eps, std::string& what) const;
-    void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
-    void writeLL(med_idt fid, const MEDFileWritable& mw) const throw(INTERP_KERNEL::Exception);
-    std::string simpleRepr() const;
-    void appendValue(int dt, int it, double time, double val) throw(INTERP_KERNEL::Exception);
-    double getDoubleValue(int iteration, int order) const throw(INTERP_KERNEL::Exception);
-    int getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
-    int getPosGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
-    MEDFileParameter1TS *getTimeStepAtPos(int posId) const throw(INTERP_KERNEL::Exception);
-    void eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception);
-    std::vector< std::pair<int,int> > getIterations() const throw(INTERP_KERNEL::Exception);
-    std::vector< std::pair<int,int> > getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception);
-    void simpleRepr2(int bkOffset, std::ostream& oss) const;
+    MEDLOADER_EXPORT static MEDFileParameterMultiTS *New();
+    MEDLOADER_EXPORT static MEDFileParameterMultiTS *New(const std::string& fileName);
+    MEDLOADER_EXPORT static MEDFileParameterMultiTS *New(med_idt fid);
+    MEDLOADER_EXPORT static MEDFileParameterMultiTS *New(const std::string& fileName, const std::string& paramName);
+    MEDLOADER_EXPORT static MEDFileParameterMultiTS *New(med_idt fid, const std::string& paramName);
+    MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileParameterMultiTS"); }
+    MEDLOADER_EXPORT std::string getName() const { return _name; }
+    MEDLOADER_EXPORT void setName(const std::string& name) { _name=name; }
+    MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
+    MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
+    MEDLOADER_EXPORT MEDFileParameterMultiTS *deepCopy() const;
+    MEDLOADER_EXPORT bool isEqual(const MEDFileParameterMultiTS *other, double eps, std::string& what) const;
+    MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const;
+    MEDLOADER_EXPORT void writeAdvanced(med_idt fid, const MEDFileWritable& mw) const;
+    MEDLOADER_EXPORT std::string simpleRepr() const;
+    MEDLOADER_EXPORT void appendValue(int dt, int it, double time, double val);
+    MEDLOADER_EXPORT double getDoubleValue(int iteration, int order) const;
+    MEDLOADER_EXPORT int getPosOfTimeStep(int iteration, int order) const;
+    MEDLOADER_EXPORT int getPosGivenTime(double time, double eps=1e-8) const;
+    MEDLOADER_EXPORT MEDFileParameter1TS *getTimeStepAtPos(int posId) const;
+    MEDLOADER_EXPORT void eraseTimeStepIds(const int *startIds, const int *endIds);
+    MEDLOADER_EXPORT int getNumberOfTS() const;
+    MEDLOADER_EXPORT std::vector< std::pair<int,int> > getIterations() const;
+    MEDLOADER_EXPORT std::vector< std::pair<int,int> > getTimeSteps(std::vector<double>& ret1) const;
+    MEDLOADER_EXPORT void simpleRepr2(int bkOffset, std::ostream& oss) const;
   protected:
     MEDFileParameterMultiTS();
     MEDFileParameterMultiTS(const MEDFileParameterMultiTS& other, bool deepCopy);
-    MEDFileParameterMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception);
-    MEDFileParameterMultiTS(const char *fileName, const char *paramName) throw(INTERP_KERNEL::Exception);
-    void finishLoading(med_idt fid, med_parameter_type typ, int nbOfSteps) throw(INTERP_KERNEL::Exception);
+    MEDFileParameterMultiTS(med_idt fid);
+    MEDFileParameterMultiTS(med_idt fid, const std::string& paramName);
+    void finishLoading(med_idt fid, med_parameter_type typ, int nbOfSteps);
   protected:
-    std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS> > _param_per_ts;
+    std::vector< MCAuto<MEDFileParameter1TS> > _param_per_ts;
   };
 
-  class MEDLOADER_EXPORT MEDFileParameters : public RefCountObject, public MEDFileWritable
+  class MEDFileParameters : public RefCountObject, public MEDFileWritableStandAlone
   {
   public:
-    static MEDFileParameters *New();
-    static MEDFileParameters *New(const char *fileName) throw(INTERP_KERNEL::Exception);
-    std::size_t getHeapMemorySize() const;
-    MEDFileParameters *deepCpy() const throw(INTERP_KERNEL::Exception);
-    bool isEqual(const MEDFileParameters *other, double eps, std::string& what) const;
-    void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
-    void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
-    std::vector<std::string> getParamsNames() const throw(INTERP_KERNEL::Exception);
-    std::string simpleRepr() const;
-    void simpleReprWithoutHeader(std::ostream& oss) const;
-    void resize(int newSize) throw(INTERP_KERNEL::Exception);
-    void pushParam(MEDFileParameterMultiTS *param) throw(INTERP_KERNEL::Exception);
-    void setParamAtPos(int i, MEDFileParameterMultiTS *param) throw(INTERP_KERNEL::Exception);
-    MEDFileParameterMultiTS *getParamAtPos(int i) const throw(INTERP_KERNEL::Exception);
-    MEDFileParameterMultiTS *getParamWithName(const char *paramName) const throw(INTERP_KERNEL::Exception);
-    void destroyParamAtPos(int i) throw(INTERP_KERNEL::Exception);
-    int getPosFromParamName(const char *paramName) const throw(INTERP_KERNEL::Exception);
-    int getNumberOfParams() const throw(INTERP_KERNEL::Exception);
+    MEDLOADER_EXPORT static MEDFileParameters *New();
+    MEDLOADER_EXPORT static MEDFileParameters *New(med_idt fid);
+    MEDLOADER_EXPORT static MEDFileParameters *New(DataArrayByte *db) { return BuildFromMemoryChunk<MEDFileParameters>(db); }
+    MEDLOADER_EXPORT static MEDFileParameters *New(const std::string& fileName);
+    MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileParameters"); }
+    MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
+    MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
+    MEDLOADER_EXPORT MEDFileParameters *deepCopy() const;
+    MEDLOADER_EXPORT bool isEqual(const MEDFileParameters *other, double eps, std::string& what) const;
+    MEDLOADER_EXPORT void writeLL(med_idt fid) const;
+    MEDLOADER_EXPORT std::vector<std::string> getParamsNames() const;
+    MEDLOADER_EXPORT std::string simpleRepr() const;
+    MEDLOADER_EXPORT void simpleReprWithoutHeader(std::ostream& oss) const;
+    MEDLOADER_EXPORT void resize(int newSize);
+    MEDLOADER_EXPORT void pushParam(MEDFileParameterMultiTS *param);
+    MEDLOADER_EXPORT void setParamAtPos(int i, MEDFileParameterMultiTS *param);
+    MEDLOADER_EXPORT MEDFileParameterMultiTS *getParamAtPos(int i) const;
+    MEDLOADER_EXPORT MEDFileParameterMultiTS *getParamWithName(const std::string& paramName) const;
+    MEDLOADER_EXPORT void destroyParamAtPos(int i);
+    MEDLOADER_EXPORT int getPosFromParamName(const std::string& paramName) const;
+    MEDLOADER_EXPORT int getNumberOfParams() const;
   protected:
     void simpleRepr2(int bkOffset, std::ostream& oss) const;
-    MEDFileParameters(const char *fileName) throw(INTERP_KERNEL::Exception);
+    MEDFileParameters(med_idt fid);
     MEDFileParameters(const MEDFileParameters& other, bool deepCopy);
     MEDFileParameters();
   protected:
-    std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameterMultiTS> > _params;
+    std::vector< MCAuto<MEDFileParameterMultiTS> > _params;
   };
 }