Salome HOME
Little refactoring of progeny mechanism to avoid if.
[modules/med.git] / src / MEDLoader / MEDFileParameter.cxx
index 38559d7ae5b2b8e5b77e314bbecf527f19330d3b..e50d32600846f862de7ea89cd14ae161e67e6022 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2014  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
@@ -72,7 +72,7 @@ std::size_t MEDFileParameterDouble1TSWTI::getHeapMemorySizeWithoutChildren() con
   return sizeof(MEDFileParameterDouble1TSWTI);
 }
 
-std::vector<const BigMemoryObject *> MEDFileParameterDouble1TSWTI::getDirectChildren() const
+std::vector<const BigMemoryObject *> MEDFileParameterDouble1TSWTI::getDirectChildrenWithNull() const
 {
   return std::vector<const BigMemoryObject *>();
 }
@@ -350,7 +350,7 @@ std::size_t MEDFileParameterDouble1TS::getHeapMemorySizeWithoutChildren() const
   return getHeapMemSizeOfStrings()+sizeof(MEDFileParameterDouble1TS);
 }
 
-std::vector<const BigMemoryObject *> MEDFileParameterDouble1TS::getDirectChildren() const
+std::vector<const BigMemoryObject *> MEDFileParameterDouble1TS::getDirectChildrenWithNull() const
 {
   return std::vector<const BigMemoryObject *>();
 }
@@ -465,7 +465,7 @@ void MEDFileParameterMultiTS::finishLoading(med_idt fid, med_parameter_type typ,
       double tim;
       MEDparameterComputationStepInfo(fid,_name.c_str(),i+1,&dt,&it,&tim);
       switch(typ)
-        {
+      {
         case MED_FLOAT64:
           _param_per_ts[i]=MEDFileParameterDouble1TSWTI::New(dt,it,tim);
           _param_per_ts[i]->readValue(fid,_name.c_str());
@@ -475,7 +475,7 @@ void MEDFileParameterMultiTS::finishLoading(med_idt fid, med_parameter_type typ,
          break;*/
         default:
           throw INTERP_KERNEL::Exception("MEDFileParameterMultiTS::finishLoading : supporting only FLOAT64 !");
-        }
+      }
     }
 }
 
@@ -486,15 +486,11 @@ std::size_t MEDFileParameterMultiTS::getHeapMemorySizeWithoutChildren() const
   return ret;
 }
 
-std::vector<const BigMemoryObject *> MEDFileParameterMultiTS::getDirectChildren() const
+std::vector<const BigMemoryObject *> MEDFileParameterMultiTS::getDirectChildrenWithNull() const
 {
   std::vector<const BigMemoryObject *> ret;
   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++)
-    {
-      const MEDFileParameter1TS *elt(*it);
-      if(elt)
-        ret.push_back(elt);
-    }
+    ret.push_back((const MEDFileParameter1TS *)*it);
   return ret;
 }
 
@@ -606,7 +602,7 @@ int MEDFileParameterMultiTS::getPosOfTimeStep(int iteration, int order) const
       const MEDFileParameter1TS *elt(*it);
       if(elt)
         {
-          if(elt->getIteration()==iteration && elt->getOrder())
+          if(elt->getIteration()==iteration && elt->getOrder()==order)
             return ret;
           else
             oss << "(" << elt->getIteration() << "," << elt->getOrder() << "), ";
@@ -666,6 +662,11 @@ void MEDFileParameterMultiTS::eraseTimeStepIds(const int *startIds, const int *e
   _param_per_ts=paramPerTs;
 }
 
+int MEDFileParameterMultiTS::getNumberOfTS() const
+{
+  return (int) getIterations().size();
+}
+
 std::vector< std::pair<int,int> > MEDFileParameterMultiTS::getIterations() const
 {
   std::vector< std::pair<int,int> > ret;
@@ -737,15 +738,11 @@ std::size_t MEDFileParameters::getHeapMemorySizeWithoutChildren() const
   return ret;
 }
 
-std::vector<const BigMemoryObject *> MEDFileParameters::getDirectChildren() const
+std::vector<const BigMemoryObject *> MEDFileParameters::getDirectChildrenWithNull() const
 {
   std::vector<const BigMemoryObject *> ret;
   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameterMultiTS> >::const_iterator it=_params.begin();it!=_params.end();it++)
-    {
-      const MEDFileParameterMultiTS *elt(*it);
-      if(elt)
-        ret.push_back(elt);
-    }
+    ret.push_back((const MEDFileParameterMultiTS *)*it);
   return ret;
 }