1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0033232: Data Exchange, DE_Wrapper - Implement ability to change global session

Add ability to set/get global session
This commit is contained in:
dpasukhi 2022-11-29 15:43:56 +00:00 committed by smoskvin
parent 6cc679d81c
commit c07f4ee70d
2 changed files with 27 additions and 4 deletions

View File

@ -34,6 +34,9 @@ namespace
static const TCollection_AsciiString aScope ("global");
return aScope;
}
//! Global configuration of current DE Session
static Handle(DE_Wrapper) THE_GLOBAL_CONFIGURATION;
}
//=======================================================================
@ -72,8 +75,23 @@ DE_Wrapper::DE_Wrapper(const Handle(DE_Wrapper)& theWrapper)
//=======================================================================
Handle(DE_Wrapper) DE_Wrapper::GlobalWrapper()
{
static const Handle(DE_Wrapper)& aConfiguration = new DE_Wrapper();
return aConfiguration;
if (THE_GLOBAL_CONFIGURATION.IsNull())
{
THE_GLOBAL_CONFIGURATION = new DE_Wrapper();
}
return THE_GLOBAL_CONFIGURATION;
}
//=======================================================================
// function : SetGlobalWrapper
// purpose :
//=======================================================================
void DE_Wrapper::SetGlobalWrapper(const Handle(DE_Wrapper)& theWrapper)
{
if (!theWrapper.IsNull())
{
THE_GLOBAL_CONFIGURATION = theWrapper;
}
}
//=======================================================================

View File

@ -61,10 +61,15 @@ public:
//! @param[in] theWrapper object to copy
Standard_EXPORT DE_Wrapper(const Handle(DE_Wrapper)& theWrapper);
//! Gets global configuration singleton
//! Gets global configuration singleton.
//! If wrapper is not set, create it by default as base class object.
//! @return point to global configuration
Standard_EXPORT static Handle(DE_Wrapper) GlobalWrapper();
//! Sets global configuration singleton
//! @param[in] theWrapper object to set as global configuration
Standard_EXPORT static void SetGlobalWrapper(const Handle(DE_Wrapper)& theWrapper);
public:
//! Reads a CAD file, according internal configuration
@ -227,7 +232,7 @@ public:
//! Copies values of all fields
//! @return new object with the same field values
Standard_EXPORT Handle(DE_Wrapper) Copy() const;
Standard_EXPORT virtual Handle(DE_Wrapper) Copy() const;
protected: