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() Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
{ {
PerformMedcoupling(); PerformMedcoupling();
MED::PWrapper myMed = CrWrapperW(myFile, myVersion); MED::PWrapper<MED::TFile> myMed = CrWrapperW(myFile, myVersion);
return this->PerformInternal<MED::PWrapper>(myMed); return this->PerformInternal<MED::PWrapper<MED::TFile>>(myMed);
} }
Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::PerformMedcoupling() Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::PerformMedcoupling()
{ {
MED::MCPWrapper myMed(new MED::MCTWrapper); /*MED::MCPWrapper myMed(new MED::MCTWrapper);
return this->PerformInternal<MED::MCPWrapper>(myMed); return this->PerformInternal<MED::MCPWrapper>(myMed);*/
} }
//================================================================================ //================================================================================

View File

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

View File

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

View File

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

View File

@ -178,15 +178,15 @@ namespace MED
return version; return version;
} }
PWrapper CrWrapperR(const std::string& fileName) PWrapper<MED::TFile> CrWrapperR(const std::string& fileName)
{ {
if (!CheckCompatibility(fileName)) { if (!CheckCompatibility(fileName)) {
EXCEPTION(std::runtime_error, "Cannot open file '"<<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; bool isCreated = false;
if (!CheckCompatibility(fileName, true)) if (!CheckCompatibility(fileName, true))
@ -204,6 +204,6 @@ namespace MED
wantedMajor = theVersion/10; wantedMajor = theVersion/10;
wantedMinor = 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(); std::vector<int> GetMEDVersionsAppendCompatible();
MEDWRAPPER_EXPORT MEDWRAPPER_EXPORT
PWrapper CrWrapperR( const std::string& ); PWrapper<TFile> CrWrapperR( const std::string& );
MEDWRAPPER_EXPORT MEDWRAPPER_EXPORT
PWrapper CrWrapperW( const std::string&, int theVersion=-1 ); PWrapper<TFile> CrWrapperW( const std::string&, int theVersion=-1 );
} }
#endif // MED_Factory_HeaderFile #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 //! Class that wraps the MED API
template<class TFILECLS>
class MEDWRAPPER_EXPORT TWrapper class MEDWRAPPER_EXPORT TWrapper
{ {
friend class TLockProxy; friend class TLockProxy;
@ -938,55 +939,57 @@ namespace MED
TErr* theErr = NULL); TErr* theErr = NULL);
protected: protected:
PFile myFile; TFILECLS myFile;
TInt myMajor; TInt myMajor;
TInt myMinor; TInt myMinor;
}; };
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
typedef SharedPtr<TWrapper> PWrapper; template<class TFILECLS>
using PWrapper = class SharedPtr<TWrapper<TFILECLS> >;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
//! This class provides thread-safety for MEDWrapper interaction //! This class provides thread-safety for MEDWrapper interaction
template<class TFILECLS>
class MEDWRAPPER_EXPORT TLockProxy class MEDWRAPPER_EXPORT TLockProxy
{ {
TLockProxy& operator=(const TLockProxy& ); TLockProxy& operator=(const TLockProxy& );
TWrapper* myWrapper; typedef TWrapper<TFILECLS>* myWrapper;
public: public:
TLockProxy(TWrapper* theWrapper); TLockProxy(TWrapper<TFILECLS>* theWrapper);
~TLockProxy(); ~TLockProxy();
TWrapper* operator->() const; TWrapper<TFILECLS>* operator->() const;
}; };
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
//! Specialization of SharedPtr for TWrapper //! Specialization of SharedPtr for TWrapper
template<> template<class TFILECLS>
class MEDWRAPPER_EXPORT SharedPtr<TWrapper>: public std::shared_ptr<TWrapper> class MEDWRAPPER_EXPORT SharedPtr<TWrapper<TFILECLS>>: public std::shared_ptr<TWrapper<TFILECLS>>
{ {
public: public:
SharedPtr() {} SharedPtr() {}
SharedPtr(TWrapper* p): SharedPtr(TWrapper<TFILECLS>* p):
std::shared_ptr<TWrapper>(p) std::shared_ptr<TWrapper<TFILECLS>>(p)
{} {}
template<class Y> template<class Y>
explicit SharedPtr(Y* p): explicit SharedPtr(Y* p):
std::shared_ptr<TWrapper>(p) std::shared_ptr<TWrapper<TFILECLS>>(p)
{} {}
template<class Y> template<class Y>
SharedPtr(const SharedPtr<Y>& r): 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> template<class Y>
SharedPtr& SharedPtr&
operator=(const SharedPtr<Y>& r) operator=(const SharedPtr<Y>& r)
{ {
SharedPtr<TWrapper>(r).swap(*this); SharedPtr<TWrapper<TFILECLS>>(r).swap(*this);
return *this; return *this;
} }
@ -1004,24 +1007,24 @@ namespace MED
return operator=<Y>(SharedPtr<Y>(r)); return operator=<Y>(SharedPtr<Y>(r));
} }
TLockProxy TLockProxy<TFILECLS>
operator->() const // never throws operator->() const // never throws
{ {
return TLockProxy(this->get()); return TLockProxy<TFILECLS>(this->get());
} }
protected: protected:
operator const TWrapper&() const; operator const TWrapper<TFILECLS>&() const;
operator TWrapper&(); operator TWrapper<TFILECLS>&();
TWrapper& TWrapper<TFILECLS>&
operator*() const; operator*() const;
TWrapper* TWrapper<TFILECLS>*
get() const // never throws get() const // never throws
{ {
return std::shared_ptr<TWrapper>::get(); return std::shared_ptr<TWrapper<TFILECLS>>::get();
} }
}; };
} }