From: Anthony Geay Date: Wed, 28 Apr 2021 11:21:09 +0000 (+0200) Subject: throw it X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fagy%2Fsmesh_to_mc_00;p=modules%2Fsmesh.git throw it --- diff --git a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx index a49dc01c5..306bfce4e 100644 --- a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx @@ -347,14 +347,14 @@ namespace Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() { PerformMedcoupling(); - MED::PWrapper myMed = CrWrapperW(myFile, myVersion); - return this->PerformInternal(myMed); + MED::PWrapper myMed = CrWrapperW(myFile, myVersion); + return this->PerformInternal>(myMed); } Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::PerformMedcoupling() { - MED::MCPWrapper myMed(new MED::MCTWrapper); - return this->PerformInternal(myMed); + /*MED::MCPWrapper myMed(new MED::MCTWrapper); + return this->PerformInternal(myMed);*/ } //================================================================================ diff --git a/src/MEDWrapper/MED_Algorithm.cxx b/src/MEDWrapper/MED_Algorithm.cxx index 5343f0b54..8a8e9dd16 100644 --- a/src/MEDWrapper/MED_Algorithm.cxx +++ b/src/MEDWrapper/MED_Algorithm.cxx @@ -35,8 +35,9 @@ static int MYVALUEDEBUG = 0; namespace MED { //--------------------------------------------------------------- + template TEntity2TGeom2ElemInfo - GetEntity2TGeom2ElemInfo(const PWrapper& theWrapper, + GetEntity2TGeom2ElemInfo(const PWrapper& theWrapper, const PMeshInfo& theMeshInfo, const MED::TEntityInfo& theEntityInfo) { @@ -66,8 +67,9 @@ namespace MED } //--------------------------------------------------------------- + template TFamilyInfoSet - GetFamilyInfoSet(const PWrapper& theWrapper, + GetFamilyInfoSet(const PWrapper& theWrapper, const PMeshInfo& theMeshInfo) { MSG(MYDEBUG,"GetFamilies(...)"); @@ -120,8 +122,9 @@ namespace MED } //--------------------------------------------------------------- + template TFieldInfo2TimeStampInfoSet - GetFieldInfo2TimeStampInfoSet(const PWrapper& theWrapper, + GetFieldInfo2TimeStampInfoSet(const PWrapper& theWrapper, const PMeshInfo& theMeshInfo, const MED::TEntityInfo& theEntityInfo) { @@ -177,8 +180,9 @@ namespace MED } //--------------------------------------------------------------- + template TEntity2FamilySet - GetEntity2FamilySet(const PWrapper& /*theWrapper*/, + GetEntity2FamilySet(const PWrapper& /*theWrapper*/, const TEntity2TGeom2ElemInfo& theEntity2TGeom2ElemInfo, const TFamilyInfoSet& theFamilyInfoSet) { @@ -243,8 +247,9 @@ namespace MED } //--------------------------------------------------------------- + template TKey2Gauss - GetKey2Gauss(const PWrapper& theWrapper, + GetKey2Gauss(const PWrapper& theWrapper, TErr* theErr, EModeSwitch theMode) { @@ -272,8 +277,9 @@ namespace MED } //--------------------------------------------------------------- + template PProfileInfo - GetProfileInfo(const PWrapper& theWrapper, + GetProfileInfo(const PWrapper& theWrapper, const std::string& theProfileName, TErr* theErr, EModeProfil theMode) @@ -290,8 +296,9 @@ namespace MED } //--------------------------------------------------------------- + template TMKey2Profile - GetMKey2Profile(const PWrapper& theWrapper, + GetMKey2Profile(const PWrapper& theWrapper, TErr* theErr, EModeProfil theMode) { diff --git a/src/MEDWrapper/MED_Algorithm.hxx b/src/MEDWrapper/MED_Algorithm.hxx index 7227cdccd..40653958a 100644 --- a/src/MEDWrapper/MED_Algorithm.hxx +++ b/src/MEDWrapper/MED_Algorithm.hxx @@ -51,44 +51,50 @@ namespace MED //--------------------------------------------------------------- //! Get set of TElemInfo by its geometrical type and corresponding MED ENTITY + template MEDWRAPPER_EXPORT TEntity2TGeom2ElemInfo - GetEntity2TGeom2ElemInfo(const PWrapper& theWrapper, + GetEntity2TGeom2ElemInfo(const PWrapper& theWrapper, const PMeshInfo& theMeshInfo, const MED::TEntityInfo& theEntityInfo); //--------------------------------------------------------------- //! Read set of MED FAMILIES for defined MED file + template MEDWRAPPER_EXPORT TFamilyInfoSet - GetFamilyInfoSet(const PWrapper& theWrapper, + GetFamilyInfoSet(const PWrapper& theWrapper, const PMeshInfo& theMeshInfo); //--------------------------------------------------------------- //! Compare two MED FAMILIES + template MEDWRAPPER_EXPORT bool operator<(const TFamilyTSize& theLeft, const TFamilyTSize& theRight); //--------------------------------------------------------------- //! Split set of MED FAMILIES by corresponding MED ENTITY + template MEDWRAPPER_EXPORT TEntity2FamilySet - GetEntity2FamilySet(const PWrapper& theWrapper, + GetEntity2FamilySet(const PWrapper& theWrapper, const TEntity2TGeom2ElemInfo& theEntity2TGeom2ElemInfo, const TFamilyInfoSet& theFamilyInfoSet); //--------------------------------------------------------------- //! Split the input set of MED FAMILIES by corresponding MED GROUPS + template MEDWRAPPER_EXPORT TGroupInfo GetGroupInfo(const TFamilyInfoSet& theFamilyInfoSet); //--------------------------------------------------------------- //! Read set of MED TIMESTAMPS groupped by corresponding MED FIELDS + template MEDWRAPPER_EXPORT TFieldInfo2TimeStampInfoSet - GetFieldInfo2TimeStampInfoSet(const PWrapper& theWrapper, + GetFieldInfo2TimeStampInfoSet(const PWrapper& theWrapper, const PMeshInfo& theMeshInfo, const MED::TEntityInfo& theEntityInfo); @@ -100,26 +106,29 @@ namespace MED //--------------------------------------------------------------- //! Read set of MED GAUSS + template MEDWRAPPER_EXPORT TKey2Gauss - GetKey2Gauss(const PWrapper& theWrapper, + GetKey2Gauss(const PWrapper& theWrapper, TErr* theErr = NULL, EModeSwitch theMode = eFULL_INTERLACE); //--------------------------------------------------------------- //! Get MED PROFILE by its name + template MEDWRAPPER_EXPORT PProfileInfo - GetProfileInfo(const PWrapper& theWrapper, + GetProfileInfo(const PWrapper& theWrapper, const std::string& theProfileName, TErr* theErr = NULL, EModeProfil theMode = eCOMPACT); //--------------------------------------------------------------- //! Read set of MED PROFILES + template MEDWRAPPER_EXPORT TMKey2Profile - GetMKey2Profile(const PWrapper& theWrapper, + GetMKey2Profile(const PWrapper& theWrapper, TErr* theErr = NULL, EModeProfil theMode = eCOMPACT); diff --git a/src/MEDWrapper/MED_Common.hxx b/src/MEDWrapper/MED_Common.hxx index e5c33803e..e3a9d7793 100644 --- a/src/MEDWrapper/MED_Common.hxx +++ b/src/MEDWrapper/MED_Common.hxx @@ -134,8 +134,10 @@ namespace MED struct TTimeStampValueBase; typedef SharedPtr PTimeStampValueBase; + template struct TWrapper; - typedef SharedPtr PWrapper; + template + using PWrapper = class SharedPtr >; MEDWRAPPER_EXPORT TInt diff --git a/src/MEDWrapper/MED_Factory.cxx b/src/MEDWrapper/MED_Factory.cxx index e8c145f8c..f3bf08dd3 100644 --- a/src/MEDWrapper/MED_Factory.cxx +++ b/src/MEDWrapper/MED_Factory.cxx @@ -178,15 +178,15 @@ namespace MED return version; } - PWrapper CrWrapperR(const std::string& fileName) + PWrapper CrWrapperR(const std::string& fileName) { if (!CheckCompatibility(fileName)) { EXCEPTION(std::runtime_error, "Cannot open file '"<(fileName, false); } - PWrapper CrWrapperW(const std::string& fileName, int theVersion) + PWrapper 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(fileName, true, wantedMajor, wantedMinor); } } diff --git a/src/MEDWrapper/MED_Factory.hxx b/src/MEDWrapper/MED_Factory.hxx index 6a8c73454..347ce0393 100644 --- a/src/MEDWrapper/MED_Factory.hxx +++ b/src/MEDWrapper/MED_Factory.hxx @@ -44,10 +44,10 @@ namespace MED std::vector GetMEDVersionsAppendCompatible(); MEDWRAPPER_EXPORT - PWrapper CrWrapperR( const std::string& ); + PWrapper CrWrapperR( const std::string& ); MEDWRAPPER_EXPORT - PWrapper CrWrapperW( const std::string&, int theVersion=-1 ); + PWrapper CrWrapperW( const std::string&, int theVersion=-1 ); } #endif // MED_Factory_HeaderFile diff --git a/src/MEDWrapper/MED_Wrapper.cxx b/src/MEDWrapper/MED_Wrapper.cxx index f4a7fc458..98c911e75 100644 --- a/src/MEDWrapper/MED_Wrapper.cxx +++ b/src/MEDWrapper/MED_Wrapper.cxx @@ -45,31 +45,34 @@ static int MYVALUEDEBUG = 0; namespace MED { //--------------------------------------------------------------- - TLockProxy - ::TLockProxy(TWrapper* theWrapper): + template + TLockProxy + ::TLockProxy(TWrapper* theWrapper): myWrapper(theWrapper) { #if BOOST_VERSION >= 103500 myWrapper->myMutex.lock(); #else - boost::detail::thread::lock_ops::lock(myWrapper->myMutex); + boost::detail::thread::lock_ops::TMutex>::lock(myWrapper->myMutex); #endif INITMSG(MYDEBUG, "TLockProxy() - this -"<; +template class MEDWRAPPER_EXPORT MED::TLockProxy; diff --git a/src/MEDWrapper/MED_Wrapper.hxx b/src/MEDWrapper/MED_Wrapper.hxx index 7b28dcbd6..2a5ee2d7c 100644 --- a/src/MEDWrapper/MED_Wrapper.hxx +++ b/src/MEDWrapper/MED_Wrapper.hxx @@ -39,6 +39,7 @@ namespace MED //---------------------------------------------------------------------------- //! Class that wraps the MED API + template 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 PWrapper; + template + using PWrapper = class SharedPtr >; //---------------------------------------------------------------------------- //! This class provides thread-safety for MEDWrapper interaction + template class MEDWRAPPER_EXPORT TLockProxy { TLockProxy& operator=(const TLockProxy& ); - TWrapper* myWrapper; + typedef TWrapper* myWrapper; public: - TLockProxy(TWrapper* theWrapper); + TLockProxy(TWrapper* theWrapper); ~TLockProxy(); - TWrapper* operator->() const; + TWrapper* operator->() const; }; //---------------------------------------------------------------------------- //! Specialization of SharedPtr for TWrapper - template<> - class MEDWRAPPER_EXPORT SharedPtr: public std::shared_ptr + template + class MEDWRAPPER_EXPORT SharedPtr>: public std::shared_ptr> { public: SharedPtr() {} - SharedPtr(TWrapper* p): - std::shared_ptr(p) + SharedPtr(TWrapper* p): + std::shared_ptr>(p) {} template explicit SharedPtr(Y* p): - std::shared_ptr(p) + std::shared_ptr>(p) {} template SharedPtr(const SharedPtr& r): - std::shared_ptr(boost::dynamic_pointer_cast(r)) + std::shared_ptr>(boost::dynamic_pointer_cast,Y>(r)) {} template SharedPtr& operator=(const SharedPtr& r) { - SharedPtr(r).swap(*this); + SharedPtr>(r).swap(*this); return *this; } @@ -1004,24 +1007,24 @@ namespace MED return operator=(SharedPtr(r)); } - TLockProxy + TLockProxy operator->() const // never throws { - return TLockProxy(this->get()); + return TLockProxy(this->get()); } protected: - operator const TWrapper&() const; + operator const TWrapper&() const; - operator TWrapper&(); + operator TWrapper&(); - TWrapper& + TWrapper& operator*() const; - TWrapper* + TWrapper* get() const // never throws { - return std::shared_ptr::get(); + return std::shared_ptr>::get(); } }; }