diff --git a/src/DataExchange/TKDE/DE/DE_ConfigurationNode.cxx b/src/DataExchange/TKDE/DE/DE_ConfigurationNode.cxx index bdd37294e0..f3b8340238 100644 --- a/src/DataExchange/TKDE/DE/DE_ConfigurationNode.cxx +++ b/src/DataExchange/TKDE/DE/DE_ConfigurationNode.cxx @@ -139,3 +139,17 @@ bool DE_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuf (void)theBuffer; return false; } + +//================================================================================================= + +void DE_ConfigurationNode::Register(const Handle(DE_Wrapper)& theWrapper) const +{ + theWrapper->Bind(this); +} + +//================================================================================================= + +void DE_ConfigurationNode::UnRegister(const Handle(DE_Wrapper)& theWrapper) const +{ + theWrapper->UnBind(this); +} diff --git a/src/DataExchange/TKDE/DE/DE_ConfigurationNode.hxx b/src/DataExchange/TKDE/DE/DE_ConfigurationNode.hxx index 68075ee15b..fa975baea1 100644 --- a/src/DataExchange/TKDE/DE/DE_ConfigurationNode.hxx +++ b/src/DataExchange/TKDE/DE/DE_ConfigurationNode.hxx @@ -18,6 +18,7 @@ class DE_ConfigurationContext; class DE_Provider; +class DE_Wrapper; class NCollection_Buffer; //! Base class to work with CAD transfer properties. @@ -154,6 +155,16 @@ public: //!< unit is unknown, default 1.0 (MM) } GlobalParameters; +public: + + //! Registers configuration node with the specified wrapper + //! @param[in] theWrapper wrapper to register with + Standard_EXPORT virtual void Register(const Handle(DE_Wrapper)& theWrapper) const; + + //! Unregisters configuration node from the specified wrapper + //! @param[in] theWrapper wrapper to unregister from + Standard_EXPORT virtual void UnRegister(const Handle(DE_Wrapper)& theWrapper) const; + private: Standard_Boolean myIsEnabled; //!< Flag to use a current provider for Read or Write process via DE_Wrapper // clang-format on diff --git a/src/DataExchange/TKDE/DE/DE_PluginHolder.hxx b/src/DataExchange/TKDE/DE/DE_PluginHolder.hxx index 57ed9f2302..c70ae9f285 100644 --- a/src/DataExchange/TKDE/DE/DE_PluginHolder.hxx +++ b/src/DataExchange/TKDE/DE/DE_PluginHolder.hxx @@ -15,6 +15,7 @@ #define _DE_PluginHolder_HeaderFile #include +#include //! Base class to work with DE_Wrapper global registration of components. //! Control life-time of current configuration node. @@ -29,17 +30,80 @@ public: { Standard_Mutex::Sentry aLock(DE_Wrapper::GlobalLoadMutex()); myInternalConfiguration = new TheConfType; - DE_Wrapper::GlobalWrapper()->Bind(myInternalConfiguration); + myInternalConfiguration->Register(DE_Wrapper::GlobalWrapper()); } ~DE_PluginHolder() { Standard_Mutex::Sentry aLock(DE_Wrapper::GlobalLoadMutex()); - DE_Wrapper::GlobalWrapper()->UnBind(myInternalConfiguration); + myInternalConfiguration->UnRegister(DE_Wrapper::GlobalWrapper()); } private: Handle(TheConfType) myInternalConfiguration; //!< Wrapped object }; +//! Helper class for variadic plugin registration. +//! Allows registration of multiple configuration node types simultaneously. +template +class DE_MultiPluginHolder +{ +public: + DE_MultiPluginHolder() + : myHolders{} + { + } + +private: + std::tuple...> myHolders; //!< Tuple of individual plugin holders +}; + +//! Macro to define plugin factory function for DE_Wrapper configuration nodes. +//! @param[in] theNodeType - first configuration node class to instantiate +//! @param[in] ... - additional configuration node classes to instantiate (optional) +//! Needs to be called after loading of the library to register configuration nodes. +//! +//! Example of usage: +//! @code +//! // Inside implementation of the configuration node source file: +//! DEPLUGIN(DESTEP_ConfigurationNode) +//! +//! // For multiple node types: +//! DEPLUGIN(DESTEP_ConfigurationNode, DEIGES_ConfigurationNode, DEVRML_ConfigurationNode) +//! @endcode +//! +//! After loading of the library TKDESTEP: +//! @code +//! OSD_SharedLibrary aSharedLibrary("libTKDESTEP.so"); +//! if (!aSharedLibrary.DlOpen(OSD_RTLD_LAZY)) +//! { +//! // Error handling +//! return; +//! } +//! +//! typedef void (*PluginFactoryFunc)(); +//! PluginFactoryFunc aFunc = (PluginFactoryFunc)aSharedLibrary.DlSymb("PLUGINFACTORY"); +//! if (aFunc == NULL) +//! { +//! // Error handling +//! return; +//! } +//! +//! aFunc(); // Call factory function to register configuration nodes +//! @endcode +//! +//! Will create instances of all specified configuration nodes and set them to DE_Wrapper global +//! configuration. +//! +//! Note: if OCCT_NO_PLUGINS is defined, macro does nothing. +#ifdef OCCT_NO_PLUGINS + #define DEPLUGIN(theNodeType, ...) +#else + #define DEPLUGIN(theNodeType, ...) \ + extern "C" Standard_EXPORT void PLUGINFACTORY() \ + { \ + static DE_MultiPluginHolder aMultiHolder; \ + } +#endif + #endif // _DE_PluginHolder_HeaderFile diff --git a/src/DataExchange/TKDE/DE/DE_ShapeFixConfigurationNode.cxx b/src/DataExchange/TKDE/DE/DE_ShapeFixConfigurationNode.cxx index 51d9cf3e46..15b0c05128 100644 --- a/src/DataExchange/TKDE/DE/DE_ShapeFixConfigurationNode.cxx +++ b/src/DataExchange/TKDE/DE/DE_ShapeFixConfigurationNode.cxx @@ -14,7 +14,6 @@ #include #include -#include #include IMPLEMENT_STANDARD_RTTIEXT(DE_ShapeFixConfigurationNode, DE_ConfigurationNode) diff --git a/src/DataExchange/TKDECascade/DEBREP/DEBREP_ConfigurationNode.cxx b/src/DataExchange/TKDECascade/DEBREP/DEBREP_ConfigurationNode.cxx index 2bc9ff7fd3..c83a29e947 100644 --- a/src/DataExchange/TKDECascade/DEBREP/DEBREP_ConfigurationNode.cxx +++ b/src/DataExchange/TKDECascade/DEBREP/DEBREP_ConfigurationNode.cxx @@ -15,7 +15,6 @@ #include #include -#include #include IMPLEMENT_STANDARD_RTTIEXT(DEBREP_ConfigurationNode, DE_ConfigurationNode) @@ -28,8 +27,6 @@ static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE() return aScope; } -// Wrapper to auto-load DE component -DE_PluginHolder THE_OCCT_BREP_COMPONENT_PLUGIN; } // namespace //================================================================================================= diff --git a/src/DataExchange/TKDECascade/DEXCAF/DEXCAF_ConfigurationNode.cxx b/src/DataExchange/TKDECascade/DEXCAF/DEXCAF_ConfigurationNode.cxx index 3ba0cd7072..37fb688a9e 100644 --- a/src/DataExchange/TKDECascade/DEXCAF/DEXCAF_ConfigurationNode.cxx +++ b/src/DataExchange/TKDECascade/DEXCAF/DEXCAF_ConfigurationNode.cxx @@ -15,7 +15,6 @@ #include #include -#include #include IMPLEMENT_STANDARD_RTTIEXT(DEXCAF_ConfigurationNode, DE_ConfigurationNode) @@ -28,8 +27,6 @@ static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE() return aScope; } -// Wrapper to auto-load DE component -DE_PluginHolder THE_OCCT_XCAF_COMPONENT_PLUGIN; } // namespace //================================================================================================= diff --git a/src/DataExchange/TKDECascade/FILES.cmake b/src/DataExchange/TKDECascade/FILES.cmake index 52a3fd0bae..49d783f4d0 100644 --- a/src/DataExchange/TKDECascade/FILES.cmake +++ b/src/DataExchange/TKDECascade/FILES.cmake @@ -4,4 +4,5 @@ set(OCCT_TKDECascade_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}") set(OCCT_TKDECascade_FILES EXTERNLIB PACKAGES + TKDECascade.cxx ) diff --git a/src/DataExchange/TKDECascade/TKDECascade.cxx b/src/DataExchange/TKDECascade/TKDECascade.cxx new file mode 100644 index 0000000000..00fb8c47f6 --- /dev/null +++ b/src/DataExchange/TKDECascade/TKDECascade.cxx @@ -0,0 +1,21 @@ +// Copyright (c) 2025 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include +#include + +//! Plugin factory function to register TKDECascade configuration nodes. +//! Call PLUGINFACTORY() to register both DEBREP_ConfigurationNode and DEXCAF_ConfigurationNode +//! with the global DE_Wrapper. +DEPLUGIN(DEBREP_ConfigurationNode, DEXCAF_ConfigurationNode) \ No newline at end of file diff --git a/src/DataExchange/TKDEGLTF/DEGLTF/DEGLTF_ConfigurationNode.cxx b/src/DataExchange/TKDEGLTF/DEGLTF/DEGLTF_ConfigurationNode.cxx index 4e7538ffd6..d0b70fad77 100644 --- a/src/DataExchange/TKDEGLTF/DEGLTF/DEGLTF_ConfigurationNode.cxx +++ b/src/DataExchange/TKDEGLTF/DEGLTF/DEGLTF_ConfigurationNode.cxx @@ -15,7 +15,6 @@ #include #include -#include IMPLEMENT_STANDARD_RTTIEXT(DEGLTF_ConfigurationNode, DE_ConfigurationNode) @@ -27,8 +26,6 @@ static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE() return aScope; } -// Wrapper to auto-load DE component -DE_PluginHolder THE_OCCT_GLTF_COMPONENT_PLUGIN; } // namespace //================================================================================================= diff --git a/src/DataExchange/TKDEGLTF/FILES.cmake b/src/DataExchange/TKDEGLTF/FILES.cmake index fa16044912..d4f61b411a 100644 --- a/src/DataExchange/TKDEGLTF/FILES.cmake +++ b/src/DataExchange/TKDEGLTF/FILES.cmake @@ -4,4 +4,5 @@ set(OCCT_TKDEGLTF_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}") set(OCCT_TKDEGLTF_FILES EXTERNLIB PACKAGES + TKDEGLTF.cxx ) diff --git a/src/DataExchange/TKDEGLTF/TKDEGLTF.cxx b/src/DataExchange/TKDEGLTF/TKDEGLTF.cxx new file mode 100644 index 0000000000..55f4d7779d --- /dev/null +++ b/src/DataExchange/TKDEGLTF/TKDEGLTF.cxx @@ -0,0 +1,19 @@ +// Copyright (c) 2025 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include + +//! Plugin factory function to register DEGLTF configuration node. +//! Call PLUGINFACTORY() to register the DEGLTF_ConfigurationNode with the global DE_Wrapper. +DEPLUGIN(DEGLTF_ConfigurationNode) \ No newline at end of file diff --git a/src/DataExchange/TKDEIGES/DEIGES/DEIGES_ConfigurationNode.cxx b/src/DataExchange/TKDEIGES/DEIGES/DEIGES_ConfigurationNode.cxx index b4cd3d62fa..82e7440f8d 100644 --- a/src/DataExchange/TKDEIGES/DEIGES/DEIGES_ConfigurationNode.cxx +++ b/src/DataExchange/TKDEIGES/DEIGES/DEIGES_ConfigurationNode.cxx @@ -15,7 +15,6 @@ #include #include -#include #include IMPLEMENT_STANDARD_RTTIEXT(DEIGES_ConfigurationNode, DE_ShapeFixConfigurationNode) @@ -28,8 +27,6 @@ static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE() return aScope; } -// Wrapper to auto-load DE component -DE_PluginHolder THE_OCCT_IGES_COMPONENT_PLUGIN; } // namespace //================================================================================================= diff --git a/src/DataExchange/TKDEIGES/FILES.cmake b/src/DataExchange/TKDEIGES/FILES.cmake index df850f869e..7eac9b5ecd 100644 --- a/src/DataExchange/TKDEIGES/FILES.cmake +++ b/src/DataExchange/TKDEIGES/FILES.cmake @@ -5,4 +5,5 @@ set(OCCT_TKDEIGES_FILES EXTERNLIB PACKAGES TKDEIGES_pch.hxx + TKDEIGES.cxx ) diff --git a/src/DataExchange/TKDEIGES/TKDEIGES.cxx b/src/DataExchange/TKDEIGES/TKDEIGES.cxx new file mode 100644 index 0000000000..13bbce0303 --- /dev/null +++ b/src/DataExchange/TKDEIGES/TKDEIGES.cxx @@ -0,0 +1,19 @@ +// Copyright (c) 2025 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include + +//! Plugin factory function to register DEIGES configuration node. +//! Call PLUGINFACTORY() to register the DEIGES_ConfigurationNode with the global DE_Wrapper. +DEPLUGIN(DEIGES_ConfigurationNode) \ No newline at end of file diff --git a/src/DataExchange/TKDEOBJ/DEOBJ/DEOBJ_ConfigurationNode.cxx b/src/DataExchange/TKDEOBJ/DEOBJ/DEOBJ_ConfigurationNode.cxx index 826b150848..8315f871f1 100644 --- a/src/DataExchange/TKDEOBJ/DEOBJ/DEOBJ_ConfigurationNode.cxx +++ b/src/DataExchange/TKDEOBJ/DEOBJ/DEOBJ_ConfigurationNode.cxx @@ -15,7 +15,6 @@ #include #include -#include IMPLEMENT_STANDARD_RTTIEXT(DEOBJ_ConfigurationNode, DE_ConfigurationNode) @@ -27,8 +26,6 @@ static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE() return aScope; } -// Wrapper to auto-load DE component -DE_PluginHolder THE_OCCT_OBJ_COMPONENT_PLUGIN; } // namespace //================================================================================================= diff --git a/src/DataExchange/TKDEOBJ/FILES.cmake b/src/DataExchange/TKDEOBJ/FILES.cmake index 22c8cbb208..7258953a72 100644 --- a/src/DataExchange/TKDEOBJ/FILES.cmake +++ b/src/DataExchange/TKDEOBJ/FILES.cmake @@ -4,4 +4,5 @@ set(OCCT_TKDEOBJ_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}") set(OCCT_TKDEOBJ_FILES EXTERNLIB PACKAGES + TKDEOBJ.cxx ) diff --git a/src/DataExchange/TKDEOBJ/TKDEOBJ.cxx b/src/DataExchange/TKDEOBJ/TKDEOBJ.cxx new file mode 100644 index 0000000000..bc65fc1778 --- /dev/null +++ b/src/DataExchange/TKDEOBJ/TKDEOBJ.cxx @@ -0,0 +1,19 @@ +// Copyright (c) 2025 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include + +//! Plugin factory function to register DEOBJ configuration node. +//! Call PLUGINFACTORY() to register the DEOBJ_ConfigurationNode with the global DE_Wrapper. +DEPLUGIN(DEOBJ_ConfigurationNode) \ No newline at end of file diff --git a/src/DataExchange/TKDEPLY/DEPLY/DEPLY_ConfigurationNode.cxx b/src/DataExchange/TKDEPLY/DEPLY/DEPLY_ConfigurationNode.cxx index fa47112c8f..0804e3748c 100644 --- a/src/DataExchange/TKDEPLY/DEPLY/DEPLY_ConfigurationNode.cxx +++ b/src/DataExchange/TKDEPLY/DEPLY/DEPLY_ConfigurationNode.cxx @@ -15,7 +15,6 @@ #include #include -#include #include IMPLEMENT_STANDARD_RTTIEXT(DEPLY_ConfigurationNode, DE_ConfigurationNode) @@ -28,8 +27,6 @@ static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE() return aScope; } -// Wrapper to auto-load DE component -DE_PluginHolder THE_OCCT_PLY_COMPONENT_PLUGIN; } // namespace //================================================================================================= diff --git a/src/DataExchange/TKDEPLY/FILES.cmake b/src/DataExchange/TKDEPLY/FILES.cmake index eb1dcc6d48..fa42bda9f7 100644 --- a/src/DataExchange/TKDEPLY/FILES.cmake +++ b/src/DataExchange/TKDEPLY/FILES.cmake @@ -4,4 +4,5 @@ set(OCCT_TKDEPLY_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}") set(OCCT_TKDEPLY_FILES EXTERNLIB PACKAGES + TKDEPLY.cxx ) diff --git a/src/DataExchange/TKDEPLY/TKDEPLY.cxx b/src/DataExchange/TKDEPLY/TKDEPLY.cxx new file mode 100644 index 0000000000..bbe527b26c --- /dev/null +++ b/src/DataExchange/TKDEPLY/TKDEPLY.cxx @@ -0,0 +1,19 @@ +// Copyright (c) 2025 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include + +//! Plugin factory function to register DEPLY configuration node. +//! Call PLUGINFACTORY() to register the DEPLY_ConfigurationNode with the global DE_Wrapper. +DEPLUGIN(DEPLY_ConfigurationNode) \ No newline at end of file diff --git a/src/DataExchange/TKDESTEP/DESTEP/DESTEP_ConfigurationNode.cxx b/src/DataExchange/TKDESTEP/DESTEP/DESTEP_ConfigurationNode.cxx index ed460f445a..388ba5c99e 100644 --- a/src/DataExchange/TKDESTEP/DESTEP/DESTEP_ConfigurationNode.cxx +++ b/src/DataExchange/TKDESTEP/DESTEP/DESTEP_ConfigurationNode.cxx @@ -15,7 +15,6 @@ #include #include -#include #include IMPLEMENT_STANDARD_RTTIEXT(DESTEP_ConfigurationNode, DE_ShapeFixConfigurationNode) @@ -28,8 +27,6 @@ static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE() return aScope; } -// Wrapper to auto-load DE component -DE_PluginHolder THE_OCCT_STEP_COMPONENT_PLUGIN; } // namespace //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/FILES.cmake b/src/DataExchange/TKDESTEP/FILES.cmake index ee212ff486..74005a3689 100644 --- a/src/DataExchange/TKDESTEP/FILES.cmake +++ b/src/DataExchange/TKDESTEP/FILES.cmake @@ -5,4 +5,5 @@ set(OCCT_TKDESTEP_FILES EXTERNLIB PACKAGES TKDESTEP_pch.hxx + TKDESTEP.cxx ) diff --git a/src/DataExchange/TKDESTEP/TKDESTEP.cxx b/src/DataExchange/TKDESTEP/TKDESTEP.cxx new file mode 100644 index 0000000000..2349d29619 --- /dev/null +++ b/src/DataExchange/TKDESTEP/TKDESTEP.cxx @@ -0,0 +1,19 @@ +// Copyright (c) 2025 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include + +//! Plugin factory function to register DESTEP configuration node. +//! Call PLUGINFACTORY() to register the DESTEP_ConfigurationNode with the global DE_Wrapper. +DEPLUGIN(DESTEP_ConfigurationNode) \ No newline at end of file diff --git a/src/DataExchange/TKDESTL/DESTL/DESTL_ConfigurationNode.cxx b/src/DataExchange/TKDESTL/DESTL/DESTL_ConfigurationNode.cxx index cdcf2c16ff..4281fba468 100644 --- a/src/DataExchange/TKDESTL/DESTL/DESTL_ConfigurationNode.cxx +++ b/src/DataExchange/TKDESTL/DESTL/DESTL_ConfigurationNode.cxx @@ -15,7 +15,6 @@ #include #include -#include #include IMPLEMENT_STANDARD_RTTIEXT(DESTL_ConfigurationNode, DE_ConfigurationNode) @@ -28,8 +27,6 @@ static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE() return aScope; } -// Wrapper to auto-load DE component -DE_PluginHolder THE_OCCT_STL_COMPONENT_PLUGIN; } // namespace //================================================================================================= diff --git a/src/DataExchange/TKDESTL/FILES.cmake b/src/DataExchange/TKDESTL/FILES.cmake index 93e35cccfd..c58b311388 100644 --- a/src/DataExchange/TKDESTL/FILES.cmake +++ b/src/DataExchange/TKDESTL/FILES.cmake @@ -4,4 +4,5 @@ set(OCCT_TKDESTL_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}") set(OCCT_TKDESTL_FILES EXTERNLIB PACKAGES + TKDESTL.cxx ) diff --git a/src/DataExchange/TKDESTL/TKDESTL.cxx b/src/DataExchange/TKDESTL/TKDESTL.cxx new file mode 100644 index 0000000000..abfb6f3e59 --- /dev/null +++ b/src/DataExchange/TKDESTL/TKDESTL.cxx @@ -0,0 +1,19 @@ +// Copyright (c) 2025 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include + +//! Plugin factory function to register DESTL configuration node. +//! Call PLUGINFACTORY() to register the DESTL_ConfigurationNode with the global DE_Wrapper. +DEPLUGIN(DESTL_ConfigurationNode) \ No newline at end of file diff --git a/src/DataExchange/TKDEVRML/DEVRML/DEVRML_ConfigurationNode.cxx b/src/DataExchange/TKDEVRML/DEVRML/DEVRML_ConfigurationNode.cxx index 66e48f77b3..80ae61d938 100644 --- a/src/DataExchange/TKDEVRML/DEVRML/DEVRML_ConfigurationNode.cxx +++ b/src/DataExchange/TKDEVRML/DEVRML/DEVRML_ConfigurationNode.cxx @@ -15,7 +15,6 @@ #include #include -#include IMPLEMENT_STANDARD_RTTIEXT(DEVRML_ConfigurationNode, DE_ConfigurationNode) @@ -27,8 +26,6 @@ static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE() return aScope; } -// Wrapper to auto-load DE component -DE_PluginHolder THE_OCCT_VRML_COMPONENT_PLUGIN; } // namespace //================================================================================================= diff --git a/src/DataExchange/TKDEVRML/FILES.cmake b/src/DataExchange/TKDEVRML/FILES.cmake index 42e6cd4c1d..6c1f98c65f 100644 --- a/src/DataExchange/TKDEVRML/FILES.cmake +++ b/src/DataExchange/TKDEVRML/FILES.cmake @@ -4,4 +4,5 @@ set(OCCT_TKDEVRML_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}") set(OCCT_TKDEVRML_FILES EXTERNLIB PACKAGES + TKDEVRML.cxx ) diff --git a/src/DataExchange/TKDEVRML/TKDEVRML.cxx b/src/DataExchange/TKDEVRML/TKDEVRML.cxx new file mode 100644 index 0000000000..0642232760 --- /dev/null +++ b/src/DataExchange/TKDEVRML/TKDEVRML.cxx @@ -0,0 +1,19 @@ +// Copyright (c) 2025 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include + +//! Plugin factory function to register DEVRML configuration node. +//! Call PLUGINFACTORY() to register the DEVRML_ConfigurationNode with the global DE_Wrapper. +DEPLUGIN(DEVRML_ConfigurationNode) \ No newline at end of file diff --git a/src/Draw/TKXSDRAWDE/XSDRAWDE/XSDRAWDE.cxx b/src/Draw/TKXSDRAWDE/XSDRAWDE/XSDRAWDE.cxx index 1d3ed8f6ba..c985ae3e92 100644 --- a/src/Draw/TKXSDRAWDE/XSDRAWDE/XSDRAWDE.cxx +++ b/src/Draw/TKXSDRAWDE/XSDRAWDE/XSDRAWDE.cxx @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include #include @@ -31,6 +33,16 @@ #include #include +namespace +{ +// Singleton to ensure DEBREP and DEXCAF plugins are registered only once +void DECascadeSingleton() +{ + static DE_MultiPluginHolder aHolder; + (void)aHolder; +} +} // namespace + //================================================================================================= static Standard_Integer DumpConfiguration(Draw_Interpretor& theDI, @@ -364,6 +376,9 @@ void XSDRAWDE::Factory(Draw_Interpretor& theDI) } aIsActivated = Standard_True; + //! Ensure DEBREP and DEXCAF plugins are registered + DECascadeSingleton(); + Standard_CString aGroup = "XDE translation commands"; theDI.Add("DumpConfiguration", "DumpConfiguration [-path ] [-recursive {on|off}] [-format fmt1 fmt2 ...] " @@ -428,10 +443,6 @@ void XSDRAWDE::Factory(Draw_Interpretor& theDI) // Load XSDRAW session for pilot activation XSDRAW::LoadDraw(theDI); - - // Workaround to force load TKDECascade lib - DEBREP_ConfigurationNode aTmpObj; - (void)aTmpObj; } // Declare entry point PLUGINFACTORY diff --git a/src/Draw/TKXSDRAWGLTF/XSDRAWGLTF/XSDRAWGLTF.cxx b/src/Draw/TKXSDRAWGLTF/XSDRAWGLTF/XSDRAWGLTF.cxx index 191d862218..e3f9334acb 100644 --- a/src/Draw/TKXSDRAWGLTF/XSDRAWGLTF/XSDRAWGLTF.cxx +++ b/src/Draw/TKXSDRAWGLTF/XSDRAWGLTF/XSDRAWGLTF.cxx @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include #include @@ -30,6 +32,16 @@ #include #include +namespace +{ +// Singleton to ensure DEGLTF plugin is registered only once +void DEGLTFSingleton() +{ + static DE_PluginHolder aHolder; + (void)aHolder; +} +} // namespace + //============================================================================= // function : parseNameFormat // purpose : Parse RWMesh_NameFormat enumeration @@ -509,6 +521,9 @@ void XSDRAWGLTF::Factory(Draw_Interpretor& theDI) } aIsActivated = Standard_True; + //! Ensure DEGLTF plugin is registered + DEGLTFSingleton(); + const char* aGroup = "XSTEP-STL/VRML"; // Step transfer file commands theDI.Add("ReadGltf", "ReadGltf Doc file [-parallel {on|off}] [-listExternalFiles] [-noCreateDoc] " diff --git a/src/Draw/TKXSDRAWIGES/XSDRAWIGES/XSDRAWIGES.cxx b/src/Draw/TKXSDRAWIGES/XSDRAWIGES/XSDRAWIGES.cxx index a9d0c2edea..0c4d5e2dfd 100644 --- a/src/Draw/TKXSDRAWIGES/XSDRAWIGES/XSDRAWIGES.cxx +++ b/src/Draw/TKXSDRAWIGES/XSDRAWIGES/XSDRAWIGES.cxx @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include #include #include @@ -1108,6 +1110,16 @@ static Standard_Integer WriteIges(Draw_Interpretor& theDI, return 0; } +namespace +{ +// Singleton to ensure DEIGES plugin is registered only once +void DEIGESSingleton() +{ + static DE_PluginHolder aHolder; + (void)aHolder; +} +} // namespace + //================================================================================================= void XSDRAWIGES::Factory(Draw_Interpretor& theDI) @@ -1121,6 +1133,9 @@ void XSDRAWIGES::Factory(Draw_Interpretor& theDI) IGESControl_Controller::Init(); + //! Ensure DEIGES plugin is registered + DEIGESSingleton(); + const char* aGroup = "DE: IGES"; theDI.Add("tplosttrim", diff --git a/src/Draw/TKXSDRAWOBJ/XSDRAWOBJ/XSDRAWOBJ.cxx b/src/Draw/TKXSDRAWOBJ/XSDRAWOBJ/XSDRAWOBJ.cxx index 9c7e7c0f25..1654bd4aa1 100644 --- a/src/Draw/TKXSDRAWOBJ/XSDRAWOBJ/XSDRAWOBJ.cxx +++ b/src/Draw/TKXSDRAWOBJ/XSDRAWOBJ/XSDRAWOBJ.cxx @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include #include #include @@ -335,6 +337,16 @@ static Standard_Integer WriteObj(Draw_Interpretor& theDI, return 0; } +namespace +{ +// Singleton to ensure DEOBJ plugin is registered only once +void DEOBJSingleton() +{ + static DE_PluginHolder aHolder; + (void)aHolder; +} +} // namespace + //================================================================================================= void XSDRAWOBJ::Factory(Draw_Interpretor& theDI) @@ -346,6 +358,9 @@ void XSDRAWOBJ::Factory(Draw_Interpretor& theDI) } aIsActivated = Standard_True; + //! Ensure DEOBJ plugin is registered + DEOBJSingleton(); + const char* aGroup = "XSTEP-STL/VRML"; // Step transfer file commands theDI.Add( "ReadObj", diff --git a/src/Draw/TKXSDRAWPLY/XSDRAWPLY/XSDRAWPLY.cxx b/src/Draw/TKXSDRAWPLY/XSDRAWPLY/XSDRAWPLY.cxx index 7bb9bd6c65..aeee1734dc 100644 --- a/src/Draw/TKXSDRAWPLY/XSDRAWPLY/XSDRAWPLY.cxx +++ b/src/Draw/TKXSDRAWPLY/XSDRAWPLY/XSDRAWPLY.cxx @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include #include #include @@ -295,6 +297,16 @@ static Standard_Integer WritePly(Draw_Interpretor& theDI, return 0; } +namespace +{ +// Singleton to ensure DEPLY plugin is registered only once +void DEPLYSingleton() +{ + static DE_PluginHolder aHolder; + (void)aHolder; +} +} // namespace + //================================================================================================= void XSDRAWPLY::Factory(Draw_Interpretor& theDI) @@ -306,6 +318,9 @@ void XSDRAWPLY::Factory(Draw_Interpretor& theDI) } aIsActivated = Standard_True; + //! Ensure DEPLY plugin is registered + DEPLYSingleton(); + const char* aGroup = "XSTEP-STL/VRML"; // Step transfer file commands // XSDRAW::LoadDraw(theCommands); theDI.Add("WritePly", diff --git a/src/Draw/TKXSDRAWSTEP/XSDRAWSTEP/XSDRAWSTEP.cxx b/src/Draw/TKXSDRAWSTEP/XSDRAWSTEP/XSDRAWSTEP.cxx index 3ed5126b29..1f250efdd0 100644 --- a/src/Draw/TKXSDRAWSTEP/XSDRAWSTEP/XSDRAWSTEP.cxx +++ b/src/Draw/TKXSDRAWSTEP/XSDRAWSTEP/XSDRAWSTEP.cxx @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include #include #include @@ -1092,6 +1094,16 @@ static Standard_Integer WriteStep(Draw_Interpretor& theDI, return 0; } +namespace +{ +// Singleton to ensure DESTEP plugin is registered only once +void DESTEPSingleton() +{ + static DE_PluginHolder aHolder; + (void)aHolder; +} +} // namespace + //================================================================================================= void XSDRAWSTEP::Factory(Draw_Interpretor& theDI) @@ -1104,6 +1116,9 @@ void XSDRAWSTEP::Factory(Draw_Interpretor& theDI) STEPCAFControl_Controller::Init(); aIsActivated = Standard_True; + //! Ensure DESTEP plugin is registered + DESTEPSingleton(); + const char* aGroup = "DE: STEP"; // Step transfer file commands theDI.Add("stepwrite", "stepwrite mode[0-4 afsmw] shape", __FILE__, stepwrite, aGroup); theDI.Add("testwritestep", diff --git a/src/Draw/TKXSDRAWSTL/XSDRAWSTL/XSDRAWSTL.cxx b/src/Draw/TKXSDRAWSTL/XSDRAWSTL/XSDRAWSTL.cxx index 4632aba138..b2065b7627 100644 --- a/src/Draw/TKXSDRAWSTL/XSDRAWSTL/XSDRAWSTL.cxx +++ b/src/Draw/TKXSDRAWSTL/XSDRAWSTL/XSDRAWSTL.cxx @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include #include #include @@ -1233,6 +1235,16 @@ static Standard_Integer meshinfo(Draw_Interpretor& theDI, return 0; } +namespace +{ +// Singleton to ensure DESTL plugin is registered only once +void DESTLSingleton() +{ + static DE_PluginHolder aHolder; + (void)aHolder; +} +} // namespace + //================================================================================================= void XSDRAWSTL::Factory(Draw_Interpretor& theDI) @@ -1244,6 +1256,9 @@ void XSDRAWSTL::Factory(Draw_Interpretor& theDI) } aIsActivated = Standard_True; + //! Ensure DESTL plugin is registered + DESTLSingleton(); + const char* aGroup = "XSTEP-STL/VRML"; // Step transfer file commands theDI.Add("writestl", diff --git a/src/Draw/TKXSDRAWVRML/XSDRAWVRML/XSDRAWVRML.cxx b/src/Draw/TKXSDRAWVRML/XSDRAWVRML/XSDRAWVRML.cxx index 815cb3fd78..f7dbe04202 100644 --- a/src/Draw/TKXSDRAWVRML/XSDRAWVRML/XSDRAWVRML.cxx +++ b/src/Draw/TKXSDRAWVRML/XSDRAWVRML/XSDRAWVRML.cxx @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include #include @@ -408,6 +410,16 @@ static Standard_Integer writevrml(Draw_Interpretor& di, Standard_Integer argc, c return 0; } +namespace +{ +// Singleton to ensure DEVRML plugin is registered only once +void DEVRMLSingleton() +{ + static DE_PluginHolder aHolder; + (void)aHolder; +} +} // namespace + //================================================================================================= void XSDRAWVRML::Factory(Draw_Interpretor& theDI) @@ -419,6 +431,9 @@ void XSDRAWVRML::Factory(Draw_Interpretor& theDI) } anInitActor = Standard_True; + //! Ensure DEVRML plugin is registered + DEVRMLSingleton(); + Standard_CString aGroup = "XDE translation commands"; theDI.Add( "ReadVrml",