-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2019 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
{
public:
PflFinder(const std::string& pfl):_pfl(pfl) { }
- bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
+ bool operator() (const MCAuto<DataArrayInt>& loc) { return loc->getName()==_pfl; }
private:
- const std::string& _pfl;
+ const std::string _pfl;
};
}
/// @endcond
return std::distance(_locs.begin(),it);
}
-/*!
- * The returned value is never null.
- */
-const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
+int MEDFileFieldGlobs::getProfileId(const std::string& pfl) const
{
- std::string pflNameCpp(pflName);
- std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
+ std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pfl));
if(it==_pfls.end())
{
- std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
+ std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfileId : no such profile name : \"" << pfl << "\" Possible localizations are : ";
for(it=_pfls.begin();it!=_pfls.end();it++)
oss << "\"" << (*it)->getName() << "\", ";
throw INTERP_KERNEL::Exception(oss.str());
}
- return *it;
+ return std::distance(_pfls.begin(),it);
+}
+
+/*!
+ * The returned value is never null.
+ */
+const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
+{
+ return getProfileFromId(getProfileId(pflName));
}
const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
return contentNotNull()->getLocalizationId(loc);
}
+/*!
+ * Returns an id of a profile by its name.
+ * \param [in] loc - the profile name of interest.
+ * \return int - the id of the profile.
+ * \throw If there is no a profile named \a loc.
+ */
+int MEDFileFieldGlobsReal::getProfileId(const std::string& pfl) const
+{
+ return contentNotNull()->getProfileId(pfl);
+}
+
/*!
* Returns the name of the MED file.
* \return const std::string& - the MED file name.