-// Copyright (C) 2007-2014 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
#include "MEDFileParameter.hxx"
#include "MEDFileUtilities.hxx"
+#include "MEDFileSafeCaller.txx"
#include "MEDLoaderBase.hxx"
#include "InterpKernelAutoPtr.hxx"
#include <set>
-using namespace ParaMEDMEM;
+using namespace MEDCoupling;
MEDFileParameter1TS::MEDFileParameter1TS(int iteration, int order, double time):_iteration(iteration),_order(order),_time(time)
{
return true;
}
-MEDFileParameter1TS *MEDFileParameterDouble1TSWTI::deepCpy() const
+MEDFileParameter1TS *MEDFileParameterDouble1TSWTI::deepCopy() const
{
return new MEDFileParameterDouble1TSWTI(*this);
}
return sizeof(MEDFileParameterDouble1TSWTI);
}
-std::vector<const BigMemoryObject *> MEDFileParameterDouble1TSWTI::getDirectChildren() const
+std::vector<const BigMemoryObject *> MEDFileParameterDouble1TSWTI::getDirectChildrenWithNull() const
{
return std::vector<const BigMemoryObject *>();
}
{
int locDt,locIt;
double tim;
- MEDparameterComputationStepInfo(fid,name.c_str(),i+1,&locDt,&locIt,&tim);
+ MEDFILESAFECALLERRD0(MEDparameterComputationStepInfo,(fid,name.c_str(),i+1,&locDt,&locIt,&tim));
if(dt==locDt && it==locIt)
{
_iteration=locDt; _order=locIt; _time=tim;
- MEDparameterValueRd(fid,name.c_str(),_iteration,_order,reinterpret_cast<unsigned char *const>(&_arr));
+ MEDFILESAFECALLERRD0(MEDparameterValueRd,(fid,name.c_str(),_iteration,_order,reinterpret_cast<unsigned char *const>(&_arr)));
return ;
}
else
void MEDFileParameterDouble1TSWTI::readValue(med_idt fid, const std::string& name)
{
- MEDparameterValueRd(fid,name.c_str(),_iteration,_order,reinterpret_cast<unsigned char *const>(&_arr));
+ MEDFILESAFECALLERRD0(MEDparameterValueRd,(fid,name.c_str(),_iteration,_order,reinterpret_cast<unsigned char *const>(&_arr)));
}
void MEDFileParameterDouble1TSWTI::finishLoading(med_idt fid, const std::string& name, int timeStepId)
{
int locDt,locIt;
double dt;
- MEDparameterComputationStepInfo(fid,name.c_str(),timeStepId+1,&locDt,&locIt,&dt);
+ MEDFILESAFECALLERRD0(MEDparameterComputationStepInfo,(fid,name.c_str(),timeStepId+1,&locDt,&locIt,&dt));
_iteration=locDt; _order=locIt; _time=dt;
- MEDparameterValueRd(fid,name.c_str(),_iteration,_order,reinterpret_cast<unsigned char *const>(&_arr));
+ MEDFILESAFECALLERRD0(MEDparameterValueRd,(fid,name.c_str(),_iteration,_order,reinterpret_cast<unsigned char *const>(&_arr)));
}
void MEDFileParameterDouble1TSWTI::writeLL(med_idt fid, const std::string& name, const MEDFileWritable& mw) const
{
char nameW[MED_NAME_SIZE+1];
MEDLoaderBase::safeStrCpy(name.c_str(),MED_NAME_SIZE,nameW,mw.getTooLongStrPolicy());
- MEDparameterValueWr(fid,nameW,_iteration,_order,_time,reinterpret_cast<const unsigned char *>(&_arr));
+ MEDFILESAFECALLERWR0(MEDparameterValueWr,(fid,nameW,_iteration,_order,_time,reinterpret_cast<const unsigned char *>(&_arr)));
}
std::size_t MEDFileParameterTinyInfo::getHeapMemSizeOfStrings() const
MEDLoaderBase::safeStrCpy(_name.c_str(),MED_NAME_SIZE,nameW,getTooLongStrPolicy());
MEDLoaderBase::safeStrCpy(_desc_name.c_str(),MED_COMMENT_SIZE,descW,getTooLongStrPolicy());
MEDLoaderBase::safeStrCpy(_dt_unit.c_str(),MED_SNAME_SIZE,dtunitW,getTooLongStrPolicy());
- MEDparameterCr(fid,nameW,typ,descW,dtunitW);
+ MEDFILESAFECALLERWR0(MEDparameterCr,(fid,nameW,typ,descW,dtunitW));
}
void MEDFileParameterTinyInfo::mainRepr(int bkOffset, std::ostream& oss) const
for(int i=0;i<nbPar;i++)
{
int nbOfSteps;
- MEDparameterInfo(fid,i+1,pName,¶mType,descName,unitName,&nbOfSteps);
+ MEDFILESAFECALLERRD0(MEDparameterInfo,(fid,i+1,pName,¶mType,descName,unitName,&nbOfSteps));
std::string paramNameCpp=MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE);
if(paramNameCpp==paramName && paramType==MED_FLOAT64)
{
for(int i=0;i<nbPar;i++)
{
int nbOfSteps;
- MEDparameterInfo(fid,i+1,pName,¶mType,descName,unitName,&nbOfSteps);
+ MEDFILESAFECALLERRD0(MEDparameterInfo,(fid,i+1,pName,¶mType,descName,unitName,&nbOfSteps));
std::string paramNameCpp=MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE);
if(paramNameCpp==paramName && paramType==MED_FLOAT64)
{
INTERP_KERNEL::AutoPtr<char> unitName=MEDLoaderBase::buildEmptyString(MED_SNAME_SIZE);
med_parameter_type paramType;
int nbOfSteps;
- MEDparameterInfo(fid,1,pName,¶mType,descName,unitName,&nbOfSteps);
+ MEDFILESAFECALLERRD0(MEDparameterInfo,(fid,1,pName,¶mType,descName,unitName,&nbOfSteps));
std::string paramNameCpp=MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE);
if(paramType==MED_FLOAT64)
{
return true;
}
-MEDFileParameter1TS *MEDFileParameterDouble1TS::deepCpy() const
+MEDFileParameter1TS *MEDFileParameterDouble1TS::deepCopy() const
{
return new MEDFileParameterDouble1TS(*this);
}
return getHeapMemSizeOfStrings()+sizeof(MEDFileParameterDouble1TS);
}
-std::vector<const BigMemoryObject *> MEDFileParameterDouble1TS::getDirectChildren() const
+std::vector<const BigMemoryObject *> MEDFileParameterDouble1TS::getDirectChildrenWithNull() const
{
return std::vector<const BigMemoryObject *>();
}
{
const MEDFileParameter1TS *elt=_param_per_ts[i];
if(elt)
- _param_per_ts[i]=elt->deepCpy();
+ _param_per_ts[i]=elt->deepCopy();
}
}
INTERP_KERNEL::AutoPtr<char> unitName=MEDLoaderBase::buildEmptyString(MED_SNAME_SIZE);
med_parameter_type paramType;
int nbOfSteps;
- MEDparameterInfo(fid,1,pName,¶mType,descName,unitName,&nbOfSteps);
+ MEDFILESAFECALLERRD0(MEDparameterInfo,(fid,1,pName,¶mType,descName,unitName,&nbOfSteps));
std::string paramNameCpp=MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE);
_dt_unit=MEDLoaderBase::buildStringFromFortran(unitName,MED_SNAME_SIZE);
_name=paramNameCpp;
for(int i=0;i<nbPar;i++)
{
int nbOfSteps;
- MEDparameterInfo(fid,i+1,pName,¶mType,descName,unitName,&nbOfSteps);
+ MEDFILESAFECALLERRD0(MEDparameterInfo,(fid,i+1,pName,¶mType,descName,unitName,&nbOfSteps));
std::string paramNameCpp=MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE);
if(paramNameCpp==paramName)
{
{
int dt,it;
double tim;
- MEDparameterComputationStepInfo(fid,_name.c_str(),i+1,&dt,&it,&tim);
+ MEDFILESAFECALLERRD0(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());
break;*/
default:
throw INTERP_KERNEL::Exception("MEDFileParameterMultiTS::finishLoading : supporting only FLOAT64 !");
- }
+ }
}
}
std::size_t MEDFileParameterMultiTS::getHeapMemorySizeWithoutChildren() const
{
std::size_t ret(sizeof(MEDFileParameterMultiTS));
- ret+=sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS>)*_param_per_ts.capacity();
+ ret+=sizeof(MCAuto<MEDFileParameter1TS>)*_param_per_ts.capacity();
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);
- }
+ for(std::vector< MCAuto<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++)
+ ret.push_back((const MEDFileParameter1TS *)*it);
return ret;
}
-MEDFileParameterMultiTS *MEDFileParameterMultiTS::deepCpy() const
+MEDFileParameterMultiTS *MEDFileParameterMultiTS::deepCopy() const
{
return new MEDFileParameterMultiTS(*this,true);
}
void MEDFileParameterMultiTS::writeLL(med_idt fid, const MEDFileWritable& mw) const
{
std::set<med_parameter_type> diffType;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++)
+ for(std::vector< MCAuto<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++)
{
const MEDFileParameter1TS *elt(*it);
if(dynamic_cast<const MEDFileParameterDouble1TSWTI *>(elt))
return;
med_parameter_type typ=*diffType.begin();
MEDFileParameterTinyInfo::writeLLHeader(fid,typ);
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++)
+ for(std::vector< MCAuto<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++)
{
const MEDFileParameter1TS *elt(*it);
if(elt)
void MEDFileParameterMultiTS::simpleRepr2(int bkOffset, std::ostream& oss) const
{
MEDFileParameterTinyInfo::mainRepr(bkOffset,oss);
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++)
+ for(std::vector< MCAuto<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++)
{
const MEDFileParameter1TS *elt(*it);
if(elt)
void MEDFileParameterMultiTS::appendValue(int dt, int it, double time, double val)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileParameterDouble1TSWTI> elt=MEDFileParameterDouble1TSWTI::New(dt,it,time);
+ MCAuto<MEDFileParameterDouble1TSWTI> elt=MEDFileParameterDouble1TSWTI::New(dt,it,time);
elt->setValue(val);
- MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS> elt2((MEDFileParameterDouble1TSWTI*)elt); elt2->incrRef();
+ MCAuto<MEDFileParameter1TS> elt2((MEDFileParameterDouble1TSWTI*)elt); elt2->incrRef();
_param_per_ts.push_back(elt2);
}
{
int ret=0;
std::ostringstream oss; oss << "MEDFileParameterMultiTS::getPosOfTimeStep : no such iteration=" << iteration << " order=" << order << " ! Possibilities are :";
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++,ret++)
+ for(std::vector< MCAuto<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++,ret++)
{
const MEDFileParameter1TS *elt(*it);
if(elt)
{
int ret=0;
std::ostringstream oss; oss << "MEDFileParameterMultiTS::getPosGivenTime : no such time=" << time << " ! Possibilities are :";
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++,ret++)
+ for(std::vector< MCAuto<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++,ret++)
{
const MEDFileParameter1TS *elt(*it);
if(elt)
std::ostringstream oss; oss << "MEDFileParameterMultiTS::eraseTimeStepIds : At pos #" << std::distance(startIds,w) << " value is " << *w << " should be in [0," << len << ") !"; throw INTERP_KERNEL::Exception(oss.str().c_str());
}
std::size_t newNb=std::count(b.begin(),b.end(),true);
- std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS> > paramPerTs(newNb);
+ std::vector< MCAuto<MEDFileParameter1TS> > paramPerTs(newNb);
std::size_t j=0;
for(std::size_t i=0;i<_param_per_ts.size();i++)
if(b[i])
_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;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++)
+ for(std::vector< MCAuto<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++)
{
const MEDFileParameter1TS *elt(*it);
if(elt)
{
std::vector< std::pair<int,int> > ret0;
ret1.clear();
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++)
+ for(std::vector< MCAuto<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++)
{
const MEDFileParameter1TS *elt(*it);
if(elt)
for(int i=0;i<nbPar;i++)
{
int nbOfSteps;
- MEDparameterInfo(fid,i+1,pName,¶mType,descName,unitName,&nbOfSteps);
+ MEDFILESAFECALLERRD0(MEDparameterInfo,(fid,i+1,pName,¶mType,descName,unitName,&nbOfSteps));
std::string paramNameCpp=MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE);
_params[i]=MEDFileParameterMultiTS::New(fileName,paramNameCpp);
}
std::size_t MEDFileParameters::getHeapMemorySizeWithoutChildren() const
{
std::size_t ret(sizeof(MEDFileParameters));
- ret+=sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileParameterMultiTS>)*_params.capacity();
+ ret+=sizeof(MCAuto<MEDFileParameterMultiTS>)*_params.capacity();
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);
- }
+ for(std::vector< MCAuto<MEDFileParameterMultiTS> >::const_iterator it=_params.begin();it!=_params.end();it++)
+ ret.push_back((const MEDFileParameterMultiTS *)*it);
return ret;
}
-MEDFileParameters *MEDFileParameters::deepCpy() const
+MEDFileParameters *MEDFileParameters::deepCopy() const
{
return new MEDFileParameters(*this,true);
}
{
const MEDFileParameterMultiTS *elt=_params[i];
if(elt)
- _params[i]=elt->deepCpy();
+ _params[i]=elt->deepCopy();
}
}
void MEDFileParameters::writeLL(med_idt fid) const
{
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameterMultiTS> >::const_iterator it=_params.begin();it!=_params.end();it++)
+ for(std::vector< MCAuto<MEDFileParameterMultiTS> >::const_iterator it=_params.begin();it!=_params.end();it++)
{
const MEDFileParameterMultiTS *elt(*it);
if(elt)
{
std::vector<std::string> ret(_params.size());
int i=0;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameterMultiTS> >::const_iterator it=_params.begin();it!=_params.end();it++,i++)
+ for(std::vector< MCAuto<MEDFileParameterMultiTS> >::const_iterator it=_params.begin();it!=_params.end();it++,i++)
{
const MEDFileParameterMultiTS *p=(*it);
if(p)
void MEDFileParameters::simpleReprWithoutHeader(std::ostream& oss) const
{
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameterMultiTS> >::const_iterator it=_params.begin();it!=_params.end();it++)
+ for(std::vector< MCAuto<MEDFileParameterMultiTS> >::const_iterator it=_params.begin();it!=_params.end();it++)
{
const MEDFileParameterMultiTS *elt(*it);
if(elt)
{
if(param)
param->incrRef();
- MEDCouplingAutoRefCountObjectPtr<MEDFileParameterMultiTS> elt(param);
+ MCAuto<MEDFileParameterMultiTS> elt(param);
_params.push_back(elt);
}
_params.resize(i+1);
if(param)
param->incrRef();
- MEDCouplingAutoRefCountObjectPtr<MEDFileParameterMultiTS> elt(param);
+ MCAuto<MEDFileParameterMultiTS> elt(param);
_params[i]=elt;
}
std::ostringstream oss; oss << "MEDFileParameters::destroyParamAtPos : should be in [0," << _params.size() << ") !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- _params[i]=MEDCouplingAutoRefCountObjectPtr<MEDFileParameterMultiTS>(0);
+ _params[i]=MCAuto<MEDFileParameterMultiTS>(0);
}
int MEDFileParameters::getPosFromParamName(const std::string& paramName) const
{
std::ostringstream oss; oss << "MEDFileParameters::getPosFromParamName : no such name=" << paramName << " ! Possibilities are :";
int ret=0;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameterMultiTS> >::const_iterator it=_params.begin();it!=_params.end();it++,ret++)
+ for(std::vector< MCAuto<MEDFileParameterMultiTS> >::const_iterator it=_params.begin();it!=_params.end();it++,ret++)
{
const MEDFileParameterMultiTS *elt(*it);
if(elt)