Redundant class Prs3d_Root has been marked as deprecated - Prs3d_Presentation::NewGroup() should be called directly.
+@subsection upgrade_750_cdf_session Support of multiple OCAF application instances
+
+Class *CDF_Session* has been removed.
+That class was used to store global instance of OCAF application (object of class *CDM_Application* or descendant, typically *TDataStd_Application*).
+Global directory of all opened OCAF documents has been removed as well; such directory is maintained now by each instance of the *CDM_Application* class.
+
+This allows creating programs that work with different OCAF documents concurrently in paralel threads,
+provided that each thread deals with its own instance of *TDataStd_Application* and documents managed by this instance.
+
+Note that neither *TDataStd_Application* nor *TDocStd_Document* is protected from concurrent access from several threads.
+Such protection, if necessary, shall be implemented on the application level.
+For an example, access to labels and attributes could be protected by mutex if there is a probability that different threads access the same labels / attributes:
+~~~~~
+ {
+ Standard_Mutex::Sentry aSentry (myMainLabelAccess);
+ TDF_Label aChildLab = aDocument->Main().NewChild();
+ TDataStd_Integer::Set(aChildLab, 0);
+ }
+~~~~~
+
@subsection upgrade_750_draw_hotkeys Draw Harness hotkeys
Draw Harness hotkeys **W** (Wireframe) and **S** (Shaded) have been re-mapped to **Ctrl+W** and **Ctrl+S**.
#include <TDocStd_Application.hxx>
#include <TDocStd_Document.hxx>
#include <TDocStd_XLinkTool.hxx>
-#include <CDF_Session.hxx>
// ====================================================================================
// This sample contains template for typical actions with OCAF document at application
//...Creating application
- Handle(TDocStd_Application) app;
-
- // the application is now handled by the CDF_Session variable
-
-
- //...Retrieving the application
-
-
- if (!CDF_Session::Exists()) {
- Handle(CDF_Session) S = CDF_Session::CurrentSession();
- if (!S->HasCurrentApplication())
- Standard_DomainError::Raise("DDocStd::Find no applicative session");
- app = Handle(TDocStd_Application)::DownCast(S->CurrentApplication());
- }
- else {
- // none active application
- }
+ Handle(TDocStd_Application) app = new TDocStd_Application;
//...Creating the new document (document conatins a framework)
#include <CDF_Application.hxx>
#include <CDF_Directory.hxx>
-#include <CDF_Session.hxx>
#include <CDF_FWOSDriver.hxx>
#include <CDM_CanCloseStatus.hxx>
#include <CDM_Document.hxx>
CDF_Application::CDF_Application():myRetrievableStatus(PCDM_RS_OK)
{
myDirectory = new CDF_Directory();
- myMetaDataDriver = new CDF_FWOSDriver;
+ myMetaDataDriver = new CDF_FWOSDriver (MetaDataLookUpTable());
}
//=======================================================================
SetReferenceCounter(theDocument,PCDM_RetrievalDriver::ReferenceCounter(aMetaData->FileName(), MessageDriver()));
SetDocumentVersion(theDocument,aMetaData);
- myMetaDataDriver->ReferenceIterator()->LoadReferences(theDocument,aMetaData,this,UseStorageConfiguration);
+ myMetaDataDriver->ReferenceIterator(MessageDriver())->LoadReferences(theDocument,aMetaData,this,UseStorageConfiguration);
try {
OCC_CATCH_SIGNALS
throw Standard_Failure(aMsg.str().c_str());
}
}
- myRetrievableStatus = theReader->GetStatus();
+ myRetrievableStatus = theReader->GetStatus();
+ theDocument->Open (this); // must be done before SetMetaData
theDocument->SetMetaData(aMetaData);
theDocumentToReturn=theDocument;
#include <NCollection_IndexedDataMap.hxx>
class Standard_NoSuchObject;
-class CDF_Session;
class Standard_GUID;
class CDM_Document;
class TCollection_ExtendedString;
//! returns MetaDatdDriver of this application
Standard_EXPORT Handle(CDF_MetaDataDriver) MetaDataDriver() const;
-friend class CDF_Session;
-
-
DEFINE_STANDARD_RTTIEXT(CDF_Application,CDM_Application)
Handle(CDF_MetaDataDriver) myMetaDataDriver;
#include <CDF_Directory.hxx>
#include <CDF_DirectoryIterator.hxx>
-#include <CDF_Session.hxx>
#include <CDM_Document.hxx>
#include <Standard_NoSuchObject.hxx>
//function : CDF_FWOSDriver
//purpose :
//==============================================================================
-CDF_FWOSDriver::CDF_FWOSDriver() {}
+CDF_FWOSDriver::CDF_FWOSDriver(CDM_MetaDataLookUpTable& theLookUpTable)
+: myLookUpTable (&theLookUpTable)
+{
+}
//==============================================================================
//function : Find
const TCollection_ExtendedString& /*aVersion*/)
{
TCollection_ExtendedString p = Concatenate(aFolder,aName);
- return CDM_MetaData::LookUp(aFolder,aName,p,p,UTL::IsReadOnly(p));
+ return CDM_MetaData::LookUp (*myLookUpTable, aFolder, aName, p, p, UTL::IsReadOnly(p));
}
//==============================================================================
Handle(CDM_MetaData) CDF_FWOSDriver::CreateMetaData(const Handle(CDM_Document)& aDocument,
const TCollection_ExtendedString& aFileName)
{
- return CDM_MetaData::LookUp(aDocument->RequestedFolder(),aDocument->RequestedName(),
+ return CDM_MetaData::LookUp(*myLookUpTable, aDocument->RequestedFolder(), aDocument->RequestedName(),
Concatenate(aDocument->RequestedFolder(),aDocument->RequestedName()),
aFileName,UTL::IsReadOnly(aFileName));
}
return theDefaultFolder;
}
-//==============================================================================
-//function : BuildMetaData
-//purpose :
-//==============================================================================
-Handle(CDM_MetaData) CDF_FWOSDriver::BuildMetaData(const TCollection_ExtendedString& aFileName)
-{
-
- OSD_Path p = UTL::Path(aFileName);
-
- TCollection_ExtendedString f = UTL::Trek(p);
- TCollection_ExtendedString n = UTL::Name(p);
- n +=".";
- n += UTL::Extension(p);
-
- return CDM_MetaData::LookUp(f,n,aFileName,aFileName,UTL::IsReadOnly(aFileName));
-}
-
//==============================================================================
//function : SetName
//purpose :
#include <Standard_Type.hxx>
#include <CDF_MetaDataDriver.hxx>
+#include <CDM_MetaDataLookUpTable.hxx>
+
#include <Standard_Boolean.hxx>
class TCollection_ExtendedString;
class CDM_MetaData;
public:
-
- //! initializes the MetaDatadriver with its specific name.
- Standard_EXPORT CDF_FWOSDriver();
+ //! Initializes the MetaDatadriver connected to specified look-up table.
+ //! Note that the created driver will keep reference to the table,
+ //! thus it must have life time longer than this object.
+ Standard_EXPORT CDF_FWOSDriver(CDM_MetaDataLookUpTable& theLookUpTable);
//! indicate whether a file exists corresponding to the folder and the name
Standard_EXPORT Standard_Boolean Find (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aVersion) Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(CDF_FWOSDriver,CDF_MetaDataDriver)
-protected:
-
-
-
-
private:
-
Standard_EXPORT Handle(CDM_MetaData) MetaData (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aVersion) Standard_OVERRIDE;
Standard_EXPORT Handle(CDM_MetaData) CreateMetaData (const Handle(CDM_Document)& aDocument, const TCollection_ExtendedString& aFileName) Standard_OVERRIDE;
Standard_EXPORT static TCollection_ExtendedString Concatenate (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName);
- Standard_EXPORT Handle(CDM_MetaData) BuildMetaData (const TCollection_ExtendedString& aFileName);
-
-
-
+private:
+ CDM_MetaDataLookUpTable* myLookUpTable;
};
-
-
-
-
-
-
#endif // _CDF_FWOSDriver_HeaderFile
#include <CDF_Application.hxx>
#include <CDF_MetaDataDriver.hxx>
-#include <CDF_Session.hxx>
#include <CDM_Document.hxx>
#include <CDM_MetaData.hxx>
#include <PCDM_ReferenceIterator.hxx>
#include <Standard_NotImplemented.hxx>
#include <Standard_Type.hxx>
+#include <Standard_NullObject.hxx>
#include <TCollection_ExtendedString.hxx>
#include <OSD_Thread.hxx>
//purpose :
//=======================================================================
-Handle(PCDM_ReferenceIterator) CDF_MetaDataDriver::ReferenceIterator() {
- Standard_ThreadId anID = OSD_Thread::Current();
- Handle(CDF_Application) anApp;
- CDF_Session::CurrentSession()->FindApplication(anID, anApp);
- return new PCDM_ReferenceIterator(anApp->MessageDriver());
+Handle(PCDM_ReferenceIterator) CDF_MetaDataDriver::ReferenceIterator(const Handle(Message_Messenger)& theMessageDriver)
+{
+ return new PCDM_ReferenceIterator(theMessageDriver);
}
//=======================================================================
#ifndef _CDF_MetaDataDriver_HeaderFile
#define _CDF_MetaDataDriver_HeaderFile
-#include <Standard.hxx>
#include <Standard_Type.hxx>
-#include <Standard_Transient.hxx>
-#include <Standard_Boolean.hxx>
-#include <Standard_Integer.hxx>
class Standard_NotImplemented;
class CDM_MetaData;
class TCollection_ExtendedString;
class CDM_Document;
class PCDM_ReferenceIterator;
-
+class Message_Messenger;
class CDF_MetaDataDriver;
DEFINE_STANDARD_HANDLE(CDF_MetaDataDriver, Standard_Transient)
Standard_EXPORT virtual TCollection_ExtendedString DefaultFolder() = 0;
- Standard_EXPORT virtual Handle(PCDM_ReferenceIterator) ReferenceIterator();
+ Standard_EXPORT virtual Handle(PCDM_ReferenceIterator) ReferenceIterator(const Handle(Message_Messenger)& theMessageDriver);
//! calls Find with an empty version
Standard_EXPORT Standard_Boolean Find (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName);
+++ /dev/null
-// Created on: 1997-08-08
-// Created by: Jean-Louis Frenkel
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2014 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 <CDF_Application.hxx>
-#include <CDF_Directory.hxx>
-#include <CDF_FWOSDriver.hxx>
-#include <CDF_MetaDataDriver.hxx>
-#include <CDF_MetaDataDriverFactory.hxx>
-#include <CDF_Session.hxx>
-#include <PCDM.hxx>
-#include <PCDM_Reader.hxx>
-#include <Plugin.hxx>
-#include <Standard_ErrorHandler.hxx>
-#include <Standard_Failure.hxx>
-#include <Standard_GUID.hxx>
-#include <Standard_MultiplyDefined.hxx>
-#include <Standard_NoSuchObject.hxx>
-#include <Standard_Type.hxx>
-#include <TCollection_ExtendedString.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(CDF_Session,Standard_Transient)
-
-static Handle(CDF_Session) THE_CS;
-static Standard_Mutex THE_MUTEX;
-
-//=======================================================================
-//function :
-//purpose :
-//=======================================================================
-CDF_Session::CDF_Session ()
-{
- Standard_MultiplyDefined_Raise_if(!THE_CS.IsNull()," a session already exists");
-}
-
-//=======================================================================
-//function :
-//purpose :
-//=======================================================================
-Handle(CDF_Session) CDF_Session::Create()
-{
- Standard_Mutex::Sentry aLocker(THE_MUTEX);
- if (THE_CS.IsNull())
- THE_CS = new CDF_Session;
- return THE_CS;
-}
-
-//=======================================================================
-//function : Exists
-//purpose :
-//=======================================================================
-Standard_Boolean CDF_Session::Exists() {
- return !THE_CS.IsNull();
-}
-
-//=======================================================================
-//function : CurrentSession
-//purpose :
-//=======================================================================
-Handle(CDF_Session) CDF_Session::CurrentSession() {
- Standard_NoSuchObject_Raise_if(THE_CS.IsNull(), "no session has been created");
- return THE_CS;
-}
-
-//=======================================================================
-//function : AddApplication
-//purpose : adds the application to the session with unique name
-//=======================================================================
-Standard_Boolean CDF_Session::AddApplication(const Handle(CDF_Application)& theApp,
- const Standard_ThreadId theID)
-{
- return AddApplication(theApp.get(), theID);
-}
-
-//=======================================================================
-//function : AddApplication
-//purpose : adds the application to the session with unique name
-//=======================================================================
-Standard_Boolean CDF_Session::AddApplication(const CDF_Application* theApp,
- const Standard_ThreadId theID)
-{
- Standard_Boolean aRetValue(Standard_False);
- if (theApp)
- {
- Standard_Mutex::Sentry aLocker(THE_MUTEX);
- if (!myAppDirectory.IsBound(theID))
- {
- Handle(CDF_Application) anApp(theApp);
- aRetValue = myAppDirectory.Bind(theID, anApp);
- }
- }
- return aRetValue;
-}
-
-//=======================================================================
-//function : FindApplication
-//purpose :
-//=======================================================================
-Standard_Boolean CDF_Session::FindApplication(const Standard_ThreadId theID, Handle(CDF_Application)& theApp) const
-{
- Standard_Mutex::Sentry aLocker(THE_MUTEX);
- if (myAppDirectory.IsBound(theID))
- {
- theApp = Handle(CDF_Application)::DownCast (myAppDirectory.Find(theID));
- return ! theApp.IsNull();
- }
- return Standard_False;
-}
-//=======================================================================
-//function : RemoveApplication
-//purpose : removes the application with name=<theName> from the session
-//=======================================================================
-Standard_Boolean CDF_Session::RemoveApplication(const Standard_ThreadId theID)
-{
- Standard_Boolean aRetValue(Standard_False);
- Standard_Mutex::Sentry aLocker(THE_MUTEX);
- if (myAppDirectory.IsBound(theID))
- {
- aRetValue = myAppDirectory.UnBind(theID);
- }
- return aRetValue;
-}
+++ /dev/null
-// Created on: 1997-08-07
-// Created by: Jean-Louis Frenkel
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2014 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.
-
-#ifndef _CDF_Session_HeaderFile
-#define _CDF_Session_HeaderFile
-
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <Standard_Boolean.hxx>
-#include <Standard_Transient.hxx>
-#include <Standard_Mutex.hxx>
-#include <CDM_ApplicationDirectory.hxx>
-class CDF_Directory;
-class CDF_Application;
-class CDF_MetaDataDriver;
-class Standard_NoSuchObject;
-class Standard_MultiplyDefined;
-
-class CDF_Session;
-DEFINE_STANDARD_HANDLE(CDF_Session, Standard_Transient)
-
-
-class CDF_Session : public Standard_Transient
-{
-
-public:
-
-
- //! returns true if a session has been created.
- Standard_EXPORT static Standard_Boolean Exists();
-
- //! Creates a session if it does not exists yet
- Standard_EXPORT static Handle(CDF_Session) Create();
-
- //! returns the only one instance of Session
- //! that has been created.
- Standard_EXPORT static Handle(CDF_Session) CurrentSession();
-
- //! returns true if theApp is added to the session
- Standard_EXPORT Standard_Boolean AddApplication(const Handle(CDF_Application)& theApp, const Standard_ThreadId theID);
-
- //! returns true if theApp is added to the session
- Standard_EXPORT Standard_Boolean AddApplication(const CDF_Application* theApp, const Standard_ThreadId theID);
-
- //! returns true if theApp is removed from the session
- Standard_EXPORT Standard_Boolean RemoveApplication(const Standard_ThreadId theID);
-
- //! returns true if theApp is removed from the session
- Standard_EXPORT Standard_Boolean FindApplication(const Standard_ThreadId, Handle(CDF_Application)& theApp) const;
-
-
-friend class CDF_Application;
-
-
- DEFINE_STANDARD_RTTIEXT(CDF_Session,Standard_Transient)
-
-protected:
-
- //! Use "Create" session for creation of an instance
- CDF_Session();
-
-
-
-
-private:
-
-
- CDM_ApplicationDirectory myAppDirectory;
- Handle(CDF_MetaDataDriver) myMetaDataDriver;
-};
-
-
-
-
-
-
-
-#endif // _CDF_Session_HeaderFile
#include <CDF_Application.hxx>
#include <CDF_MetaDataDriver.hxx>
-#include <CDF_Session.hxx>
#include <CDF_Store.hxx>
#include <CDF_StoreList.hxx>
#include <CDF_StoreSetNameStatus.hxx>
#include <CDF_Application.hxx>
#include <CDF_MetaDataDriver.hxx>
#include <CDF_MetaDataDriverError.hxx>
-#include <CDF_Session.hxx>
#include <CDF_StoreList.hxx>
#include <CDM_Document.hxx>
#include <CDM_MetaData.hxx>
CDF_MetaDataDriverError.hxx
CDF_MetaDataDriverFactory.cxx
CDF_MetaDataDriverFactory.hxx
-CDF_Session.cxx
-CDF_Session.hxx
CDF_Store.cxx
CDF_Store.hxx
CDF_StoreList.cxx
//function : MetaDataLookUpTable
//purpose : returns the MetaData LookUpTable
//=======================================================================
-CDM_MetaDataLookUpTable* CDM_Application::MetaDataLookUpTable()
+CDM_MetaDataLookUpTable& CDM_Application::MetaDataLookUpTable()
{
- return &myMetaDataLookUpTable;
+ return myMetaDataLookUpTable;
}
//=======================================================================
Standard_EXPORT virtual TCollection_AsciiString Version() const;
//! Returns MetaData LookUpTable
- Standard_EXPORT virtual CDM_MetaDataLookUpTable* MetaDataLookUpTable();
+ Standard_EXPORT virtual CDM_MetaDataLookUpTable& MetaDataLookUpTable();
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
+++ /dev/null
-// Created on: 1997-05-06
-// Created by: Jean-Louis Frenkel, Remi Lequette
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2014 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.
-
-#ifndef CDM_ApplicationDirectory_HeaderFile
-#define CDM_ApplicationDirectory_HeaderFile
-
-#include <CDM_Application.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
-#include <NCollection_DataMap.hxx>
-#include <Standard_ThreadId.hxx>
-#include <NCollection_DefaultHasher.hxx>
-
-typedef NCollection_DefaultHasher<Standard_ThreadId> CDM_MapThreadIDHasher;
-typedef NCollection_DataMap<Standard_ThreadId,Handle(CDM_Application),CDM_MapThreadIDHasher> CDM_ApplicationDirectory;
-typedef NCollection_DataMap<Standard_ThreadId,Handle(CDM_Application),CDM_MapThreadIDHasher>::Iterator CDM_DataMapIteratorOfApplicationDirectory;
-
-#endif
aMetaData->SetDocument(this);
-// Update the document refencing this MetaData:
- CDM_DataMapIteratorOfMetaDataLookUpTable it(*CDM_MetaData::LookUpTable());
+ // Update the document refencing this MetaData:
+ CDM_DataMapIteratorOfMetaDataLookUpTable it(Application()->MetaDataLookUpTable());
for(;it.More();it.Next()) {
const Handle(CDM_MetaData)& theMetaData=it.Value();
if(theMetaData != aMetaData && theMetaData->IsRetrieved()) {
#include <CDM_MetaData.hxx>
#include <CDM_MetaDataLookUpTable.hxx>
#include <CDM_Reference.hxx>
-#include <CDF_Session.hxx>
#include <Standard_Dump.hxx>
#include <CDF_Application.hxx>
-#include <Standard_NoSuchObject.hxx>
+#include <Standard_NullObject.hxx>
#include <Standard_Type.hxx>
#include <TCollection_ExtendedString.hxx>
#include <OSD_Thread.hxx>
void CDM_MetaData::UnsetDocument() {
myIsRetrieved = Standard_False;
}
-Handle(CDM_MetaData) CDM_MetaData::LookUp(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aPath,const TCollection_ExtendedString& aFileName,const Standard_Boolean ReadOnly) {
+Handle(CDM_MetaData) CDM_MetaData::LookUp(CDM_MetaDataLookUpTable& theLookUpTable,
+ const TCollection_ExtendedString& aFolder,
+ const TCollection_ExtendedString& aName,
+ const TCollection_ExtendedString& aPath,
+ const TCollection_ExtendedString& aFileName,
+ const Standard_Boolean ReadOnly)
+{
Handle(CDM_MetaData) theMetaData;
TCollection_ExtendedString aConventionalPath=aPath;
aConventionalPath.ChangeAll('\\','/');
- CDM_MetaDataLookUpTable* aLookUpTable = LookUpTable();
- if (!aLookUpTable) return theMetaData;
- if(!aLookUpTable->IsBound(aConventionalPath)) {
+ if(!theLookUpTable.IsBound(aConventionalPath))
+ {
theMetaData = new CDM_MetaData(aFolder,aName,aPath,aFileName,ReadOnly);
- aLookUpTable->Bind(aConventionalPath, theMetaData);
+ theLookUpTable.Bind(aConventionalPath, theMetaData);
}
else
- theMetaData = aLookUpTable->Find(aConventionalPath);
+ {
+ theMetaData = theLookUpTable.Find(aConventionalPath);
+ }
return theMetaData;
}
-Handle(CDM_MetaData) CDM_MetaData::LookUp(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aPath, const TCollection_ExtendedString& aVersion, const TCollection_ExtendedString& aFileName,const Standard_Boolean ReadOnly) {
+Handle(CDM_MetaData) CDM_MetaData::LookUp(CDM_MetaDataLookUpTable& theLookUpTable,
+ const TCollection_ExtendedString& aFolder,
+ const TCollection_ExtendedString& aName,
+ const TCollection_ExtendedString& aPath,
+ const TCollection_ExtendedString& aVersion,
+ const TCollection_ExtendedString& aFileName,
+ const Standard_Boolean ReadOnly)
+{
Handle(CDM_MetaData) theMetaData;
TCollection_ExtendedString aConventionalPath=aPath;
aConventionalPath.ChangeAll('\\','/');
- CDM_MetaDataLookUpTable* aLookUpTable = LookUpTable();
- if (!aLookUpTable) return theMetaData;
- if(!aLookUpTable->IsBound(aConventionalPath)) {
+ if(!theLookUpTable.IsBound(aConventionalPath))
+ {
theMetaData = new CDM_MetaData(aFolder,aName,aPath,aVersion,aFileName,ReadOnly);
- aLookUpTable->Bind(aConventionalPath,theMetaData);
+ theLookUpTable.Bind(aConventionalPath,theMetaData);
}
else
- theMetaData = aLookUpTable->Find(aConventionalPath);
+ {
+ theMetaData = theLookUpTable.Find(aConventionalPath);
+ }
return theMetaData;
}
return Print(anOStream);
}
-CDM_MetaDataLookUpTable* CDM_MetaData::LookUpTable() {
- Handle(CDF_Session) aSession = CDF_Session::Create();
- Handle(CDF_Application) anApp;
- CDM_MetaDataLookUpTable* pLookUpTable(NULL);
- if (aSession->FindApplication(OSD_Thread::Current(), anApp))
- return anApp->MetaDataLookUpTable();
- return pLookUpTable;
-}
Standard_Integer CDM_MetaData::DocumentVersion(const Handle(CDM_Application)& anApplication) {
if(myDocumentVersion==0) myDocumentVersion=anApplication->DocumentVersion(this);
return myDocumentVersion;
public:
-
- Standard_EXPORT static Handle(CDM_MetaData) LookUp (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aPath, const TCollection_ExtendedString& aFileName, const Standard_Boolean ReadOnly);
-
- Standard_EXPORT static Handle(CDM_MetaData) LookUp (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aPath, const TCollection_ExtendedString& aVersion, const TCollection_ExtendedString& aFileName, const Standard_Boolean ReadOnly);
-
+ Standard_EXPORT static Handle(CDM_MetaData) LookUp (CDM_MetaDataLookUpTable& theLookUpTable,
+ const TCollection_ExtendedString& aFolder,
+ const TCollection_ExtendedString& aName,
+ const TCollection_ExtendedString& aPath,
+ const TCollection_ExtendedString& aFileName,
+ const Standard_Boolean ReadOnly);
+
+ Standard_EXPORT static Handle(CDM_MetaData) LookUp (CDM_MetaDataLookUpTable& theLookUpTable,
+ const TCollection_ExtendedString& aFolder,
+ const TCollection_ExtendedString& aName,
+ const TCollection_ExtendedString& aPath,
+ const TCollection_ExtendedString& aVersion,
+ const TCollection_ExtendedString& aFileName,
+ const Standard_Boolean ReadOnly);
+
Standard_EXPORT Standard_Boolean IsRetrieved() const;
Standard_EXPORT Handle(CDM_Document) Document() const;
DEFINE_STANDARD_RTTIEXT(CDM_MetaData,Standard_Transient)
-protected:
+private:
+ CDM_MetaData (const TCollection_ExtendedString& aFolder,
+ const TCollection_ExtendedString& aName,
+ const TCollection_ExtendedString& aPath,
+ const TCollection_ExtendedString& aFileName,
+ const Standard_Boolean ReadOnly);
+ CDM_MetaData (const TCollection_ExtendedString& aFolder,
+ const TCollection_ExtendedString& aName,
+ const TCollection_ExtendedString& aPath,
+ const TCollection_ExtendedString& aVersion,
+ const TCollection_ExtendedString& aFileName,
+ const Standard_Boolean ReadOnly);
+ void SetDocument (const Handle(CDM_Document)& aDocument);
-private:
+ Standard_Integer DocumentVersion (const Handle(CDM_Application)& anApplication);
-
- Standard_EXPORT CDM_MetaData(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aPath, const TCollection_ExtendedString& aFileName, const Standard_Boolean ReadOnly);
-
- Standard_EXPORT CDM_MetaData(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aPath, const TCollection_ExtendedString& aVersion, const TCollection_ExtendedString& aFileName, const Standard_Boolean ReadOnly);
-
- Standard_EXPORT void SetDocument (const Handle(CDM_Document)& aDocument);
-
- Standard_EXPORT static CDM_MetaDataLookUpTable* LookUpTable();
-
- Standard_EXPORT Standard_Integer DocumentVersion (const Handle(CDM_Application)& anApplication);
+private:
Standard_Boolean myIsRetrieved;
CDM_DocumentPointer myDocument;
CDM_MetaData.hxx
CDM_MetaDataLookUpTable.hxx
CDM_NamesDirectory.hxx
-CDM_ApplicationDirectory.hxx
CDM_Reference.cxx
CDM_Reference.hxx
CDM_ReferenceIterator.cxx
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-
-#include <CDF_Session.hxx>
#include <DBRep.hxx>
#include <DDocStd.hxx>
#include <DDocStd_DrawDocument.hxx>
const Handle(CDM_MetaData)& aMetaData,
const Handle(CDM_Application)& anApplication,
const Standard_Boolean UseStorageConfiguration) {
- for (Init(aMetaData);More();Next()) {
- aDocument->CreateReference(MetaData(UseStorageConfiguration),ReferenceIdentifier(),
- anApplication,DocumentVersion(),UseStorageConfiguration);
+ for (Init(aMetaData);More();Next())
+ {
+ aDocument->CreateReference(MetaData(anApplication->MetaDataLookUpTable(),UseStorageConfiguration),
+ ReferenceIdentifier(),anApplication,DocumentVersion(),UseStorageConfiguration);
}
}
//purpose :
//=======================================================================
-Handle(CDM_MetaData) PCDM_ReferenceIterator::MetaData(const Standard_Boolean ) const {
+Handle(CDM_MetaData) PCDM_ReferenceIterator::MetaData(CDM_MetaDataLookUpTable& theLookUpTable,
+ const Standard_Boolean ) const
+{
TCollection_ExtendedString theFolder,theName;
TCollection_ExtendedString theFile=myReferences(myIterator).FileName();
theName = UTL::Name(p); theName+= UTL::Extension(p);
#endif // _WIN32
- return CDM_MetaData::LookUp(theFolder,theName,theFile,theFile,UTL::IsReadOnly(theFile));
+ return CDM_MetaData::LookUp(theLookUpTable, theFolder, theName, theFile, theFile, UTL::IsReadOnly(theFile));
}
+
//=======================================================================
//function : ReferenceIdentifier
//purpose :
#include <Standard_Type.hxx>
#include <PCDM_SequenceOfReference.hxx>
-#include <Standard_Integer.hxx>
-#include <Standard_Transient.hxx>
-#include <Standard_Boolean.hxx>
+#include <CDM_MetaDataLookUpTable.hxx>
+
class Message_Messenger;
class CDM_Document;
class CDM_MetaData;
class CDM_Application;
-
class PCDM_ReferenceIterator;
DEFINE_STANDARD_HANDLE(PCDM_ReferenceIterator, Standard_Transient)
Standard_EXPORT virtual void Next();
- Standard_EXPORT virtual Handle(CDM_MetaData) MetaData (const Standard_Boolean UseStorageConfiguration) const;
+ Standard_EXPORT virtual Handle(CDM_MetaData) MetaData (CDM_MetaDataLookUpTable& theLookUpTable,
+ const Standard_Boolean UseStorageConfiguration) const;
Standard_EXPORT virtual Standard_Integer ReferenceIdentifier() const;
//! returns the version of the document in the reference
Standard_EXPORT virtual Standard_Integer DocumentVersion() const;
+private:
PCDM_SequenceOfReference myReferences;
Standard_Integer myIterator;
Handle(Message_Messenger) myMessageDriver;
-
-
};
}
}
args->finished = true;
- anApp->RemoveFromSession();
}
catch (...)
{
}
+#include <BinXCAFDrivers.hxx>
+#include <Message.hxx>
+namespace
+{
+ class QABugs_XdeLoader : public OSD_Thread
+ {
+ public:
+ QABugs_XdeLoader (const Handle(TDocStd_Application)& theXdeApp,
+ const Handle(TDocStd_Document)& theXdeDoc,
+ const TCollection_AsciiString& theFilePath)
+ : OSD_Thread (performThread),
+ myXdeApp (theXdeApp), myXdeDoc (theXdeDoc), myFilePath (theFilePath) {}
+
+ private:
+ void perform()
+ {
+ Handle(TDocStd_Document) aNewDoc;
+ const PCDM_ReaderStatus aReaderStatus = myXdeApp->Open (myFilePath, aNewDoc);
+ if (aReaderStatus != PCDM_RS_OK)
+ {
+ Message::SendFail ("Error occurred while reading the file");
+ return;
+ }
+ myXdeDoc = aNewDoc;
+ Message::SendInfo() << "Info: document has been opened";
+ }
+
+ static Standard_Address performThread (Standard_Address theData)
+ {
+ QABugs_XdeLoader* aLoader = (QABugs_XdeLoader* )theData;
+ OSD::SetThreadLocalSignal (OSD_SignalMode_Set, false);
+ try
+ {
+ OCC_CATCH_SIGNALS
+ aLoader->perform();
+ }
+ catch (Standard_Failure const& theExcep)
+ {
+ Message::SendFail() << "Error: unexpected exception " << theExcep;
+ return 0;
+ }
+ return 0;
+ }
+ private:
+ Handle(TDocStd_Application) myXdeApp;
+ Handle(TDocStd_Document) myXdeDoc;
+ TCollection_AsciiString myFilePath;
+ };
+}
+
+//=======================================================================
+//function : OCC31785
+//purpose : Try reading XBF file in background thread
+//=======================================================================
+static Standard_Integer OCC31785 (Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ if (theNbArgs != 2)
+ {
+ theDI << "Syntax error: wrong number of arguments\n";
+ return 1;
+ }
+
+ TCollection_AsciiString aFileName (theArgVec[1]);
+
+ Handle(TDocStd_Application) anXdeApp = new TDocStd_Application();
+ BinXCAFDrivers::DefineFormat (anXdeApp);
+
+ Handle(TDocStd_Document) anXdeDoc;
+ anXdeApp->NewDocument (TCollection_ExtendedString ("BinXCAF"), anXdeDoc);
+ QABugs_XdeLoader aLoader (anXdeApp, anXdeDoc, aFileName);
+ aLoader.Run (&aLoader);
+ aLoader.Wait();
+ return 0;
+}
+
void QABugs::Commands_20(Draw_Interpretor& theCommands) {
const char *group = "QABugs";
theCommands.Add("OCC31320", "OCC31320 DocName ObjName : tests remove of the children GetFather method if father is removed", __FILE__, OCC31320, group);
+ theCommands.Add("OCC31785",
+ "OCC31785 file.xbf : test reading XBF file in another thread",
+ __FILE__, OCC31785, group);
+
return;
}
#include <CDF_Directory.hxx>
#include <CDF_DirectoryIterator.hxx>
-#include <CDF_Session.hxx>
#include <CDF_Store.hxx>
#include <PCDM_RetrievalDriver.hxx>
#include <PCDM_StorageDriver.hxx>
TDocStd_Application::TDocStd_Application()
: myIsDriverLoaded (Standard_True)
{
- AddToSession();
if(myMetaDataDriver.IsNull())
myIsDriverLoaded = Standard_False;
}
-
//=======================================================================
//function : IsDriverLoaded
//purpose :
Standard_Integer TDocStd_Application::NbDocuments() const
{
- if (!CDF_Session::Exists())
- throw Standard_DomainError("TDocStd_Application::NbDocuments");
- return this->myDirectory->Length();
+ return myDirectory->Length();
}
//=======================================================================
void TDocStd_Application::GetDocument(const Standard_Integer index,Handle(TDocStd_Document)& aDoc) const
{
- if (!CDF_Session::Exists())
- throw Standard_DomainError("TDocStd_Application::NbDocuments");
CDF_DirectoryIterator it (myDirectory);
Standard_Integer current = 0;
for (;it.MoreDocument();it.NextDocument()) {
// nothing to do on this level
}
-//
-void TDocStd_Application::AddToSession()
-{
- Handle(CDF_Session) S = CDF_Session::Create();
- S->AddApplication(this, OSD_Thread::Current());
-}
-
-Standard_Boolean TDocStd_Application::RemoveFromSession()
-{
- Handle(CDF_Session) aSession = CDF_Session::Create();
- return aSession->RemoveApplication(OSD_Thread::Current());
-}
-
//=======================================================================
//function : DumpJson
//purpose :
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
- //! Remove this application from the current session
- Standard_EXPORT Standard_Boolean RemoveFromSession();
-
DEFINE_STANDARD_RTTIEXT(TDocStd_Application, CDF_Application)
protected:
Handle(Resource_Manager) myResources;
Standard_Boolean myIsDriverLoaded;
-
-private:
-
- //! Add this application to the current session (register in internal container)
- void AddToSession();
};
#endif // _TDocStd_Application_HeaderFile
TKXSBase
TKMesh
TKXCAF
+TKBinXCAF
TKSTEP
TKSTEPBase
TKXDESTEP
#include <Message_Msg.hxx>
#include <Message_MsgFile.hxx>
#include <Resource_Manager.hxx>
-#include <CDF_Session.hxx>
-#include <OSD_Thread.hxx>
#include <stdio.h>
#include "TObj_TObj_msg.pxx"
//=======================================================================
Handle(TObj_Application) TObj_Application::GetInstance()
{
- Handle(CDF_Session) aSession = CDF_Session::Create();
- Handle(CDF_Application) anApp;
- if (aSession->FindApplication(OSD_Thread::Current(), anApp))
- {
- Handle(TObj_Application) aTObjApp = Handle(TObj_Application)::DownCast(anApp);
- if (!aTObjApp.IsNull())
- return aTObjApp;
- // If in session application of another type is already registered, use this global
- // application, alone, outside of the session (as a workaround for DRAW scripting where
- // many kinds of applications can be required).
- static Handle(TObj_Application) THE_TOBJ_APP(new TObj_Application);
- return THE_TOBJ_APP;
- }
- // It will register this application in the session.
- return new TObj_Application;
+ static Handle(TObj_Application) THE_TOBJ_APP(new TObj_Application);
+ return THE_TOBJ_APP;
}
//=======================================================================
theName = UTL::Name(p); theName+= UTL::Extension(p);
#endif // _WIN32
- Handle(CDM_MetaData) aMetaData = CDM_MetaData::LookUp(theFolder,theName,aPath,aPath,UTL::IsReadOnly(aFileName));
+ Handle(CDM_MetaData) aMetaData =
+ CDM_MetaData::LookUp(theApplication->MetaDataLookUpTable(), theFolder, theName, aPath, aPath, UTL::IsReadOnly(aFileName));
////////////
theNewDocument->CreateReference(aMetaData,aRefId,
theApplication,aDocumentVersion,Standard_False);
--- /dev/null
+puts "==========="
+puts "0031785: \[REGRESSION\] Application Framework - application crashes on reading XBF document in background thread"
+puts "==========="
+
+pload XDE QAcommands
+XNewDoc D
+XSave D ${imagedir}/bug31785.xbf
+Close D
+
+OCC31785 ${imagedir}/bug31785.xbf
#include <inspector/DFBrowser_Communicator.hxx>
-#include <CDF_Session.hxx>
#include <inspector/DFBrowser_Module.hxx>
#include <inspector/DFBrowser_Window.hxx>
#include <AIS_InteractiveObject.hxx>
#include <AIS_ListOfInteractive.hxx>
-#include <CDF_Session.hxx>
-
#include <inspector/DFBrowserPane_AttributePaneAPI.hxx>
#include <inspector/DFBrowser_AttributePaneStack.hxx>
}
return;
}
- else
- {
- if (anApplication.IsNull() && CDF_Session::Exists()) {
- Standard_ThreadId anID = OSD_Thread::Current();
- Handle(CDF_Application) anApp;
- CDF_Session::CurrentSession()->FindApplication(anID, anApp);
- anApplication = Handle(TDocStd_Application)::DownCast (anApp);
- }
- }
myModule = new DFBrowser_Module();
myModule->CreateViewModel (myMainWindow);
anOCAFViewModel->Reset();
//! close previous documents to open new document
- Handle(TDocStd_Application) anApplication;
- if (CDF_Session::Exists())
+ Handle(TDocStd_Application) anApplication = myModule->GetTDocStdApplication();
+ if (!anApplication.IsNull())
{
- Handle(CDF_Session) aSession = CDF_Session::CurrentSession();
- if (!aSession.IsNull())
+ for (int aDocId = 1, aNbDocuments = anApplication->NbDocuments(); aDocId <= aNbDocuments; aDocId++)
{
- Standard_ThreadId anID = OSD_Thread::Current();
- Handle(CDF_Application) anApp;
- CDF_Session::CurrentSession()->FindApplication(anID, anApp);
- anApplication = Handle(TDocStd_Application)::DownCast (anApp);
- if (!anApplication.IsNull())
- {
- for (int aDocId = 1, aNbDocuments = anApplication->NbDocuments(); aDocId <= aNbDocuments; aDocId++)
- {
- Handle(TDocStd_Document) aDocument;
- anApplication->GetDocument (aDocId, aDocument);
- if (!aDocument.IsNull())
- anApplication->Close (aDocument);
- }
- }
+ Handle(TDocStd_Document) aDocument;
+ anApplication->GetDocument (aDocId, aDocument);
+ if (!aDocument.IsNull())
+ anApplication->Close (aDocument);
}
}
+
//! open new document
bool isSTEPFileName = false;
anApplication = DFBrowser_OpenApplication::OpenApplication (theFileName, isSTEPFileName);