This commit is contained in:
Anthony Geay 2021-04-28 13:21:09 +02:00
parent 550cf0575e
commit eea4ff2d43
8 changed files with 329 additions and 177 deletions

View File

@ -347,14 +347,14 @@ namespace
Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
{
PerformMedcoupling();
MED::PWrapper myMed = CrWrapperW(myFile, myVersion);
return this->PerformInternal<MED::PWrapper>(myMed);
MED::PWrapper<MED::TFile> myMed = CrWrapperW(myFile, myVersion);
return this->PerformInternal<MED::PWrapper<MED::TFile>>(myMed);
}
Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::PerformMedcoupling()
{
MED::MCPWrapper myMed(new MED::MCTWrapper);
return this->PerformInternal<MED::MCPWrapper>(myMed);
/*MED::MCPWrapper myMed(new MED::MCTWrapper);
return this->PerformInternal<MED::MCPWrapper>(myMed);*/
}
//================================================================================

View File

@ -35,8 +35,9 @@ static int MYVALUEDEBUG = 0;
namespace MED
{
//---------------------------------------------------------------
template<class TFILECLS>
TEntity2TGeom2ElemInfo
GetEntity2TGeom2ElemInfo(const PWrapper& theWrapper,
GetEntity2TGeom2ElemInfo(const PWrapper<TFILECLS>& theWrapper,
const PMeshInfo& theMeshInfo,
const MED::TEntityInfo& theEntityInfo)
{
@ -66,8 +67,9 @@ namespace MED
}
//---------------------------------------------------------------
template<class TFILECLS>
TFamilyInfoSet
GetFamilyInfoSet(const PWrapper& theWrapper,
GetFamilyInfoSet(const PWrapper<TFILECLS>& theWrapper,
const PMeshInfo& theMeshInfo)
{
MSG(MYDEBUG,"GetFamilies(...)");
@ -120,8 +122,9 @@ namespace MED
}
//---------------------------------------------------------------
template<class TFILECLS>
TFieldInfo2TimeStampInfoSet
GetFieldInfo2TimeStampInfoSet(const PWrapper& theWrapper,
GetFieldInfo2TimeStampInfoSet(const PWrapper<TFILECLS>& theWrapper,
const PMeshInfo& theMeshInfo,
const MED::TEntityInfo& theEntityInfo)
{
@ -177,8 +180,9 @@ namespace MED
}
//---------------------------------------------------------------
template<class TFILECLS>
TEntity2FamilySet
GetEntity2FamilySet(const PWrapper& /*theWrapper*/,
GetEntity2FamilySet(const PWrapper<TFILECLS>& /*theWrapper*/,
const TEntity2TGeom2ElemInfo& theEntity2TGeom2ElemInfo,
const TFamilyInfoSet& theFamilyInfoSet)
{
@ -243,8 +247,9 @@ namespace MED
}
//---------------------------------------------------------------
template<class TFILECLS>
TKey2Gauss
GetKey2Gauss(const PWrapper& theWrapper,
GetKey2Gauss(const PWrapper<TFILECLS>& theWrapper,
TErr* theErr,
EModeSwitch theMode)
{
@ -272,8 +277,9 @@ namespace MED
}
//---------------------------------------------------------------
template<class TFILECLS>
PProfileInfo
GetProfileInfo(const PWrapper& theWrapper,
GetProfileInfo(const PWrapper<TFILECLS>& theWrapper,
const std::string& theProfileName,
TErr* theErr,
EModeProfil theMode)
@ -290,8 +296,9 @@ namespace MED
}
//---------------------------------------------------------------
template<class TFILECLS>
TMKey2Profile
GetMKey2Profile(const PWrapper& theWrapper,
GetMKey2Profile(const PWrapper<TFILECLS>& theWrapper,
TErr* theErr,
EModeProfil theMode)
{

View File

@ -51,44 +51,50 @@ namespace MED
//---------------------------------------------------------------
//! Get set of TElemInfo by its geometrical type and corresponding MED ENTITY
template<class TFILECLS>
MEDWRAPPER_EXPORT
TEntity2TGeom2ElemInfo
GetEntity2TGeom2ElemInfo(const PWrapper& theWrapper,
GetEntity2TGeom2ElemInfo(const PWrapper<TFILECLS>& theWrapper,
const PMeshInfo& theMeshInfo,
const MED::TEntityInfo& theEntityInfo);
//---------------------------------------------------------------
//! Read set of MED FAMILIES for defined MED file
template<class TFILECLS>
MEDWRAPPER_EXPORT
TFamilyInfoSet
GetFamilyInfoSet(const PWrapper& theWrapper,
GetFamilyInfoSet(const PWrapper<TFILECLS>& theWrapper,
const PMeshInfo& theMeshInfo);
//---------------------------------------------------------------
//! Compare two MED FAMILIES
template<class TFILECLS>
MEDWRAPPER_EXPORT
bool
operator<(const TFamilyTSize& theLeft, const TFamilyTSize& theRight);
//---------------------------------------------------------------
//! Split set of MED FAMILIES by corresponding MED ENTITY
template<class TFILECLS>
MEDWRAPPER_EXPORT
TEntity2FamilySet
GetEntity2FamilySet(const PWrapper& theWrapper,
GetEntity2FamilySet(const PWrapper<TFILECLS>& theWrapper,
const TEntity2TGeom2ElemInfo& theEntity2TGeom2ElemInfo,
const TFamilyInfoSet& theFamilyInfoSet);
//---------------------------------------------------------------
//! Split the input set of MED FAMILIES by corresponding MED GROUPS
template<class TFILECLS>
MEDWRAPPER_EXPORT
TGroupInfo
GetGroupInfo(const TFamilyInfoSet& theFamilyInfoSet);
//---------------------------------------------------------------
//! Read set of MED TIMESTAMPS groupped by corresponding MED FIELDS
template<class TFILECLS>
MEDWRAPPER_EXPORT
TFieldInfo2TimeStampInfoSet
GetFieldInfo2TimeStampInfoSet(const PWrapper& theWrapper,
GetFieldInfo2TimeStampInfoSet(const PWrapper<TFILECLS>& theWrapper,
const PMeshInfo& theMeshInfo,
const MED::TEntityInfo& theEntityInfo);
@ -100,26 +106,29 @@ namespace MED
//---------------------------------------------------------------
//! Read set of MED GAUSS
template<class TFILECLS>
MEDWRAPPER_EXPORT
TKey2Gauss
GetKey2Gauss(const PWrapper& theWrapper,
GetKey2Gauss(const PWrapper<TFILECLS>& theWrapper,
TErr* theErr = NULL,
EModeSwitch theMode = eFULL_INTERLACE);
//---------------------------------------------------------------
//! Get MED PROFILE by its name
template<class TFILECLS>
MEDWRAPPER_EXPORT
PProfileInfo
GetProfileInfo(const PWrapper& theWrapper,
GetProfileInfo(const PWrapper<TFILECLS>& theWrapper,
const std::string& theProfileName,
TErr* theErr = NULL,
EModeProfil theMode = eCOMPACT);
//---------------------------------------------------------------
//! Read set of MED PROFILES
template<class TFILECLS>
MEDWRAPPER_EXPORT
TMKey2Profile
GetMKey2Profile(const PWrapper& theWrapper,
GetMKey2Profile(const PWrapper<TFILECLS>& theWrapper,
TErr* theErr = NULL,
EModeProfil theMode = eCOMPACT);

View File

@ -134,8 +134,10 @@ namespace MED
struct TTimeStampValueBase;
typedef SharedPtr<TTimeStampValueBase> PTimeStampValueBase;
template<class TFILECLS>
struct TWrapper;
typedef SharedPtr<TWrapper> PWrapper;
template<class TFILECLS>
using PWrapper = class SharedPtr<TWrapper<TFILECLS> >;
MEDWRAPPER_EXPORT
TInt

View File

@ -178,15 +178,15 @@ namespace MED
return version;
}
PWrapper CrWrapperR(const std::string& fileName)
PWrapper<MED::TFile> CrWrapperR(const std::string& fileName)
{
if (!CheckCompatibility(fileName)) {
EXCEPTION(std::runtime_error, "Cannot open file '"<<fileName<<"'.");
}
return new MED::TWrapper(fileName, false);
return new MED::TWrapper<MED::TFile>(fileName, false);
}
PWrapper CrWrapperW(const std::string& fileName, int theVersion)
PWrapper<MED::TFile> CrWrapperW(const std::string& fileName, int theVersion)
{
bool isCreated = false;
if (!CheckCompatibility(fileName, true))
@ -204,6 +204,6 @@ namespace MED
wantedMajor = theVersion/10;
wantedMinor = theVersion%10;
}
return new MED::TWrapper(fileName, true, wantedMajor, wantedMinor);
return new MED::TWrapper<MED::TFile>(fileName, true, wantedMajor, wantedMinor);
}
}

View File

@ -44,10 +44,10 @@ namespace MED
std::vector<int> GetMEDVersionsAppendCompatible();
MEDWRAPPER_EXPORT
PWrapper CrWrapperR( const std::string& );
PWrapper<TFile> CrWrapperR( const std::string& );
MEDWRAPPER_EXPORT
PWrapper CrWrapperW( const std::string&, int theVersion=-1 );
PWrapper<TFile> CrWrapperW( const std::string&, int theVersion=-1 );
}
#endif // MED_Factory_HeaderFile

File diff suppressed because it is too large Load Diff

View File

@ -39,6 +39,7 @@ namespace MED
//----------------------------------------------------------------------------
//! Class that wraps the MED API
template<class TFILECLS>
class MEDWRAPPER_EXPORT TWrapper
{
friend class TLockProxy;
@ -938,55 +939,57 @@ namespace MED
TErr* theErr = NULL);
protected:
PFile myFile;
TFILECLS myFile;
TInt myMajor;
TInt myMinor;
};
//----------------------------------------------------------------------------
typedef SharedPtr<TWrapper> PWrapper;
template<class TFILECLS>
using PWrapper = class SharedPtr<TWrapper<TFILECLS> >;
//----------------------------------------------------------------------------
//! This class provides thread-safety for MEDWrapper interaction
template<class TFILECLS>
class MEDWRAPPER_EXPORT TLockProxy
{
TLockProxy& operator=(const TLockProxy& );
TWrapper* myWrapper;
typedef TWrapper<TFILECLS>* myWrapper;
public:
TLockProxy(TWrapper* theWrapper);
TLockProxy(TWrapper<TFILECLS>* theWrapper);
~TLockProxy();
TWrapper* operator->() const;
TWrapper<TFILECLS>* operator->() const;
};
//----------------------------------------------------------------------------
//! Specialization of SharedPtr for TWrapper
template<>
class MEDWRAPPER_EXPORT SharedPtr<TWrapper>: public std::shared_ptr<TWrapper>
template<class TFILECLS>
class MEDWRAPPER_EXPORT SharedPtr<TWrapper<TFILECLS>>: public std::shared_ptr<TWrapper<TFILECLS>>
{
public:
SharedPtr() {}
SharedPtr(TWrapper* p):
std::shared_ptr<TWrapper>(p)
SharedPtr(TWrapper<TFILECLS>* p):
std::shared_ptr<TWrapper<TFILECLS>>(p)
{}
template<class Y>
explicit SharedPtr(Y* p):
std::shared_ptr<TWrapper>(p)
std::shared_ptr<TWrapper<TFILECLS>>(p)
{}
template<class Y>
SharedPtr(const SharedPtr<Y>& r):
std::shared_ptr<TWrapper>(boost::dynamic_pointer_cast<TWrapper,Y>(r))
std::shared_ptr<TWrapper<TFILECLS>>(boost::dynamic_pointer_cast<TWrapper<TFILECLS>,Y>(r))
{}
template<class Y>
SharedPtr&
operator=(const SharedPtr<Y>& r)
{
SharedPtr<TWrapper>(r).swap(*this);
SharedPtr<TWrapper<TFILECLS>>(r).swap(*this);
return *this;
}
@ -1004,24 +1007,24 @@ namespace MED
return operator=<Y>(SharedPtr<Y>(r));
}
TLockProxy
TLockProxy<TFILECLS>
operator->() const // never throws
{
return TLockProxy(this->get());
return TLockProxy<TFILECLS>(this->get());
}
protected:
operator const TWrapper&() const;
operator const TWrapper<TFILECLS>&() const;
operator TWrapper&();
operator TWrapper<TFILECLS>&();
TWrapper&
TWrapper<TFILECLS>&
operator*() const;
TWrapper*
TWrapper<TFILECLS>*
get() const // never throws
{
return std::shared_ptr<TWrapper>::get();
return std::shared_ptr<TWrapper<TFILECLS>>::get();
}
};
}