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

0029195: OCAF - ensure thread safety for different documents.

OCAF persistence architecture modification to satisfy multi-threading criteria.
This commit is contained in:
mpv 2020-08-26 10:15:22 +03:00 committed by abv
parent c3e0e1de43
commit d9d03f10c3
39 changed files with 570 additions and 606 deletions

View File

@ -91,7 +91,7 @@ void BinLDrivers_DocumentRetrievalDriver::Read
TCollection_ExtendedString aFormat = PCDM_ReadWriter::FileFormat (aFileStream, dData);
Read(aFileStream, dData, theNewDocument, theApplication, theProgress);
if (theProgress->UserBreak())
if (!theProgress.IsNull() && theProgress->UserBreak())
{
myReaderStatus = PCDM_RS_UserBreak;
return;

View File

@ -1,39 +0,0 @@
// Created on: 1998-03-11
// Created by: Jean-Louis Frenkel
// Copyright (c) 1998-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.hxx>
#include <Standard_Failure.hxx>
static void CDF_InitApplication () {
static Standard_Boolean FirstApplication = Standard_True;
if(FirstApplication) {
FirstApplication = Standard_False;
}
}
void CDF::GetLicense(const Standard_Integer ){
CDF_InitApplication();
}
Standard_Boolean CDF::IsAvailable(const Standard_Integer ) {
CDF_InitApplication();
return Standard_True;
}

View File

@ -1,45 +0,0 @@
// 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_HeaderFile
#define _CDF_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
class CDF_Directory;
class CDF_DirectoryIterator;
class CDF_Session;
class CDF_Application;
class CDF_StoreList;
class CDF_Store;
class CDF_MetaDataDriver;
class CDF_FWOSDriver;
class CDF_MetaDataDriverFactory;
class CDF
{
public:
Standard_EXPORT static void GetLicense (const Standard_Integer anApplicationIdentifier);
Standard_EXPORT static Standard_Boolean IsAvailable (const Standard_Integer anApplicationIdentifier);
};
#endif // _CDF_HeaderFile

View File

@ -18,8 +18,8 @@
#include <CDF_Application.hxx>
#include <CDF_Directory.hxx>
#include <CDF_MetaDataDriver.hxx>
#include <CDF_Session.hxx>
#include <CDF_FWOSDriver.hxx>
#include <CDM_CanCloseStatus.hxx>
#include <CDM_Document.hxx>
#include <CDM_MetaData.hxx>
@ -36,15 +36,15 @@
#include <Message_ProgressSentry.hxx>
IMPLEMENT_STANDARD_RTTIEXT(CDF_Application,CDM_Application)
#define theMetaDataDriver CDF_Session::CurrentSession()->MetaDataDriver()
//=======================================================================
//function :
//purpose :
//=======================================================================
CDF_Application::CDF_Application():myRetrievableStatus(PCDM_RS_OK) {}
CDF_Application::CDF_Application():myRetrievableStatus(PCDM_RS_OK)
{
myDirectory = new CDF_Directory();
myMetaDataDriver = new CDF_FWOSDriver;
}
//=======================================================================
//function : Load
@ -59,7 +59,7 @@ Handle(CDF_Application) CDF_Application::Load(const Standard_GUID& aGUID) {
//purpose :
//=======================================================================
void CDF_Application::Open(const Handle(CDM_Document)& aDocument) {
CDF_Session::CurrentSession()->Directory()->Add(aDocument);
myDirectory->Add(aDocument);
aDocument->Open(this);
Activate(aDocument,CDF_TOA_New);
}
@ -77,7 +77,7 @@ CDM_CanCloseStatus CDF_Application::CanClose(const Handle(CDM_Document)& aDocume
//purpose :
//=======================================================================
void CDF_Application::Close(const Handle(CDM_Document)& aDocument) {
CDF_Session::CurrentSession()->Directory()->Remove(aDocument);
myDirectory->Remove(aDocument);
aDocument->Close();
}
@ -107,15 +107,15 @@ Handle(CDM_Document) CDF_Application::Retrieve (const TCollection_ExtendedStrin
Handle(CDM_MetaData) theMetaData;
if(aVersion.Length() == 0)
theMetaData=theMetaDataDriver->MetaData(aFolder,aName);
theMetaData=myMetaDataDriver->MetaData(aFolder,aName);
else
theMetaData=theMetaDataDriver->MetaData(aFolder,aName,aVersion);
theMetaData=myMetaDataDriver->MetaData(aFolder,aName,aVersion);
CDF_TypeOfActivation theTypeOfActivation=TypeOfActivation(theMetaData);
Handle(CDM_Document) theDocument = Retrieve(theMetaData, UseStorageConfiguration,
Standard_False, theProgress);
CDF_Session::CurrentSession()->Directory()->Add(theDocument);
myDirectory->Add(theDocument);
Activate(theDocument,theTypeOfActivation);
theDocument->Open(this);
@ -137,12 +137,12 @@ PCDM_ReaderStatus CDF_Application::CanRetrieve(const TCollection_ExtendedString&
//=======================================================================
PCDM_ReaderStatus CDF_Application::CanRetrieve(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aVersion) {
if (!theMetaDataDriver->Find(aFolder,aName,aVersion))
if (!myMetaDataDriver->Find(aFolder,aName,aVersion))
return PCDM_RS_UnknownDocument;
else if (!theMetaDataDriver->HasReadPermission(aFolder,aName,aVersion))
else if (!myMetaDataDriver->HasReadPermission(aFolder,aName,aVersion))
return PCDM_RS_PermissionDenied;
else {
Handle(CDM_MetaData) theMetaData = theMetaDataDriver->MetaData(aFolder,aName,aVersion);
Handle(CDM_MetaData) theMetaData = myMetaDataDriver->MetaData(aFolder,aName,aVersion);
if(theMetaData->IsRetrieved()) {
return theMetaData->Document()->IsModified()
@ -190,7 +190,7 @@ void CDF_Application::Activate(const Handle(CDM_Document)& ,const CDF_TypeOfActi
//=======================================================================
Standard_ExtString CDF_Application::DefaultFolder(){
if(myDefaultFolder.Length() == 0) {
myDefaultFolder=CDF_Session::CurrentSession()->MetaDataDriver()->DefaultFolder();
myDefaultFolder=myMetaDataDriver->DefaultFolder();
}
return myDefaultFolder.ToExtString();
}
@ -200,7 +200,7 @@ Standard_ExtString CDF_Application::DefaultFolder(){
//purpose :
//=======================================================================
Standard_Boolean CDF_Application::SetDefaultFolder(const Standard_ExtString aFolder) {
Standard_Boolean found = CDF_Session::CurrentSession()->MetaDataDriver()->FindFolder(aFolder);
Standard_Boolean found = myMetaDataDriver->FindFolder(aFolder);
if(found) myDefaultFolder=aFolder;
return found;
}
@ -271,7 +271,7 @@ Handle(CDM_Document) CDF_Application::Retrieve (const Handle(CDM_MetaData)& aMet
SetReferenceCounter(theDocument,PCDM_RetrievalDriver::ReferenceCounter(aMetaData->FileName(), MessageDriver()));
SetDocumentVersion(theDocument,aMetaData);
theMetaDataDriver->ReferenceIterator()->LoadReferences(theDocument,aMetaData,this,UseStorageConfiguration);
myMetaDataDriver->ReferenceIterator()->LoadReferences(theDocument,aMetaData,this,UseStorageConfiguration);
try {
OCC_CATCH_SIGNALS
@ -530,3 +530,12 @@ PCDM_ReaderStatus CDF_Application::CanRetrieve(const Handle(CDM_MetaData)& aMeta
else
return CanRetrieve(aMetaData->Folder(),aMetaData->Name());
}
//=======================================================================
//function : MetaDataDriver
//purpose :
//=======================================================================
Handle(CDF_MetaDataDriver) CDF_Application::MetaDataDriver() const {
Standard_NoSuchObject_Raise_if(myMetaDataDriver.IsNull(), "no metadatadriver has been provided; this application is not able to store or retrieve files.");
return myMetaDataDriver;
}

View File

@ -19,10 +19,11 @@
#include <TCollection_ExtendedString.hxx>
#include <PCDM_ReaderStatus.hxx>
#include <CDF_TypeOfActivation.hxx>
#include <CDF_MetaDataDriver.hxx>
#include <CDM_Application.hxx>
#include <CDM_CanCloseStatus.hxx>
#include <TColStd_SequenceOfExtendedString.hxx>
#include <CDF_TypeOfActivation.hxx>
#include <Standard_IStream.hxx>
#include <NCollection_IndexedDataMap.hxx>
@ -35,7 +36,7 @@ class PCDM_Reader;
class CDM_MetaData;
class PCDM_RetrievalDriver;
class PCDM_StorageDriver;
class CDF_Directory;
class CDF_Application;
DEFINE_STANDARD_HANDLE(CDF_Application, CDM_Application)
@ -167,12 +168,17 @@ public:
Standard_EXPORT Standard_ExtString DefaultFolder();
Standard_EXPORT Standard_Boolean SetDefaultFolder (const Standard_ExtString aFolder);
//! 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;
Handle(CDF_Directory) myDirectory;
private:

View File

@ -31,31 +31,22 @@ void CDF_Directory::Add(const Handle(CDM_Document)& aDocument) {
}
void CDF_Directory::Remove(const Handle(CDM_Document)& aDocument) {
CDM_ListIteratorOfListOfDocument it(myDocuments);
Standard_Boolean found = Standard_False;
for (; it.More() && !found;) {
found = aDocument == it.Value();
if(found)
for (CDM_ListIteratorOfListOfDocument it(myDocuments); it.More(); it.Next()) {
if (aDocument == it.Value()) {
myDocuments.Remove(it);
else
it.Next();
break;
}
}
}
Standard_Boolean CDF_Directory::Contains(const Handle(CDM_Document)& aDocument) const {
CDM_ListIteratorOfListOfDocument it(myDocuments);
Standard_Boolean found = Standard_False;
for (; it.More() && !found; it.Next()) {
found = aDocument == it.Value();
for (CDM_ListIteratorOfListOfDocument it(myDocuments); it.More(); it.Next()) {
if (aDocument == it.Value())
return Standard_True;
}
return found;
return Standard_False;
}
Standard_Integer CDF_Directory::Length() const {
return myDocuments.Extent();
}
@ -69,6 +60,7 @@ const CDM_ListOfDocument& CDF_Directory::List() const {
Standard_Boolean CDF_Directory::IsEmpty() const {
return myDocuments.IsEmpty();
}
Handle(CDM_Document) CDF_Directory::Last() {
Standard_NoSuchObject_Raise_if(IsEmpty(),"CDF_Directory::Last: the directory does not contain any document");
return myDocuments.Last();

View File

@ -21,9 +21,6 @@
#include <CDM_Document.hxx>
#include <Standard_NoSuchObject.hxx>
CDF_DirectoryIterator::CDF_DirectoryIterator():myIterator(CDF_Session::CurrentSession()->Directory()->List()) {}
CDF_DirectoryIterator::CDF_DirectoryIterator(const Handle(CDF_Directory)& aDirectory):myIterator(aDirectory->List()) {}

View File

@ -24,6 +24,7 @@
#include <Standard_NotImplemented.hxx>
#include <Standard_Type.hxx>
#include <TCollection_ExtendedString.hxx>
#include <OSD_Thread.hxx>
IMPLEMENT_STANDARD_RTTIEXT(CDF_MetaDataDriver,Standard_Transient)
@ -68,7 +69,8 @@ void CDF_MetaDataDriver::CreateDependsOn(const Handle(CDM_MetaData)& ,
//purpose :
//=======================================================================
void CDF_MetaDataDriver::CreateReference(const Handle(CDM_MetaData)& ,const Handle(CDM_MetaData)& , const Standard_Integer , const Standard_Integer ) {}
void CDF_MetaDataDriver::CreateReference(const Handle(CDM_MetaData)& ,
const Handle(CDM_MetaData)& , const Standard_Integer , const Standard_Integer ) {}
//=======================================================================
//function : ReferenceIterator
@ -76,7 +78,10 @@ void CDF_MetaDataDriver::CreateReference(const Handle(CDM_MetaData)& ,const Hand
//=======================================================================
Handle(PCDM_ReferenceIterator) CDF_MetaDataDriver::ReferenceIterator() {
return new PCDM_ReferenceIterator(CDF_Session::CurrentSession()->CurrentApplication()->MessageDriver());
Standard_ThreadId anID = OSD_Thread::Current();
Handle(CDF_Application) anApp;
CDF_Session::CurrentSession()->FindApplication(anID, anApp);
return new PCDM_ReferenceIterator(anApp->MessageDriver());
}
//=======================================================================
@ -84,7 +89,9 @@ Handle(PCDM_ReferenceIterator) CDF_MetaDataDriver::ReferenceIterator() {
//purpose :
//=======================================================================
Standard_Boolean CDF_MetaDataDriver::Find(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName) {
Standard_Boolean CDF_MetaDataDriver::Find(const TCollection_ExtendedString& aFolder,
const TCollection_ExtendedString& aName)
{
TCollection_ExtendedString aVersion;
return Find(aFolder,aName,aVersion);
}

View File

@ -34,17 +34,28 @@
IMPLEMENT_STANDARD_RTTIEXT(CDF_Session,Standard_Transient)
static Handle(CDF_Session) CS;
static Handle(CDF_Session) THE_CS;
static Standard_Mutex THE_MUTEX;
//=======================================================================
//function :
//purpose :
//=======================================================================
CDF_Session::CDF_Session () : myHasCurrentApplication(Standard_False)
CDF_Session::CDF_Session ()
{
Standard_MultiplyDefined_Raise_if(!CS.IsNull()," a session already exists");
myDirectory = new CDF_Directory();
CS = this;
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;
}
//=======================================================================
@ -52,16 +63,7 @@ CDF_Session::CDF_Session () : myHasCurrentApplication(Standard_False)
//purpose :
//=======================================================================
Standard_Boolean CDF_Session::Exists() {
return !CS.IsNull();
}
//=======================================================================
//function : Directory
//purpose :
//=======================================================================
Handle(CDF_Directory) CDF_Session::Directory() const {
return CS->myDirectory;
return !THE_CS.IsNull();
}
//=======================================================================
@ -69,63 +71,65 @@ Handle(CDF_Directory) CDF_Session::Directory() const {
//purpose :
//=======================================================================
Handle(CDF_Session) CDF_Session::CurrentSession() {
Standard_NoSuchObject_Raise_if(CS.IsNull(), "no session has been created");
return CS;
Standard_NoSuchObject_Raise_if(THE_CS.IsNull(), "no session has been created");
return THE_CS;
}
//=======================================================================
//function : HasCurrentApplication
//purpose :
//function : AddApplication
//purpose : adds the application to the session with unique name
//=======================================================================
Standard_Boolean CDF_Session::HasCurrentApplication() const {
return myHasCurrentApplication;
Standard_Boolean CDF_Session::AddApplication(const Handle(CDF_Application)& theApp,
const Standard_ThreadId theID)
{
return AddApplication(theApp.get(), theID);
}
//=======================================================================
//function : CurrentApplication
//purpose :
//function : AddApplication
//purpose : adds the application to the session with unique name
//=======================================================================
Handle(CDF_Application) CDF_Session::CurrentApplication() const {
Standard_NoSuchObject_Raise_if(!myHasCurrentApplication,"there is no current application in the session");
return myCurrentApplication;
}
//=======================================================================
//function : SetCurrentApplication
//purpose :
//=======================================================================
void CDF_Session::SetCurrentApplication(const Handle(CDF_Application)& anApplication) {
myCurrentApplication = anApplication;
myHasCurrentApplication = Standard_True;
}
//=======================================================================
//function : UnsetCurrentApplication
//purpose :
//=======================================================================
void CDF_Session::UnsetCurrentApplication() {
myHasCurrentApplication = Standard_False;
myCurrentApplication.Nullify();
}
//=======================================================================
//function : MetaDataDriver
//purpose :
//=======================================================================
Handle(CDF_MetaDataDriver) CDF_Session::MetaDataDriver() const {
Standard_NoSuchObject_Raise_if(myMetaDataDriver.IsNull(),"no metadatadriver has been provided; this session is not able to store or retrieve files.");
return myMetaDataDriver;
}
//=======================================================================
//function : LoadDriver
//purpose :
//=======================================================================
void CDF_Session::LoadDriver() {
if (myMetaDataDriver.IsNull()) {
// for compatibility with old code, initialize useless driver directly
// instead of loading it as plugin
Handle(CDF_MetaDataDriverFactory) aFactory;
myMetaDataDriver = new CDF_FWOSDriver;
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;
}

View File

@ -22,13 +22,14 @@
#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)
@ -39,29 +40,27 @@ class CDF_Session : public Standard_Transient
public:
Standard_EXPORT CDF_Session();
//! 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 the directory of the session;
Standard_EXPORT Handle(CDF_Directory) Directory() const;
Standard_EXPORT Standard_Boolean HasCurrentApplication() const;
Standard_EXPORT Handle(CDF_Application) CurrentApplication() const;
Standard_EXPORT void SetCurrentApplication (const Handle(CDF_Application)& anApplication);
Standard_EXPORT void UnsetCurrentApplication();
Standard_EXPORT Handle(CDF_MetaDataDriver) MetaDataDriver() const;
Standard_EXPORT void LoadDriver();
//! 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;
@ -71,18 +70,17 @@ friend class CDF_Application;
protected:
//! Use "Create" session for creation of an instance
CDF_Session();
private:
Handle(CDF_Directory) myDirectory;
Handle(CDF_Application) myCurrentApplication;
Standard_Boolean myHasCurrentApplication;
CDM_ApplicationDirectory myAppDirectory;
Handle(CDF_MetaDataDriver) myMetaDataDriver;
};

View File

@ -25,14 +25,10 @@
#include <PCDM_StorageDriver.hxx>
#include <PCDM_StoreStatus.hxx>
#include <Standard_ProgramError.hxx>
#include <TCollection_ExtendedString.hxx>
#define theMetaDataDriver CDF_Session::CurrentSession()->MetaDataDriver()
static TCollection_ExtendedString blank("");
#define theMetaDataDriver Handle(CDF_Application)::DownCast((myCurrentDocument->Application()))->MetaDataDriver()
static const Handle(TCollection_HExtendedString) blank = new TCollection_HExtendedString("");
CDF_Store::CDF_Store()
: myHasSubComponents(Standard_False),
@ -67,19 +63,14 @@ void CDF_Store::Init() {
myCurrentDocument = myMainDocument;
}
Standard_ExtString CDF_Store::Folder() const {
static TCollection_ExtendedString retv;
Handle(TCollection_HExtendedString) CDF_Store::Folder() const {
if(myCurrentDocument->HasRequestedFolder())
retv = myCurrentDocument->RequestedFolder();
else
retv= blank;
return retv.ToExtString();
return new TCollection_HExtendedString(myCurrentDocument->RequestedFolder());
return blank;
}
Standard_ExtString CDF_Store::Name() const {
static TCollection_ExtendedString retv;
retv = myCurrentDocument->RequestedName();
return retv.ToExtString();
Handle(TCollection_HExtendedString) CDF_Store::Name() const {
return new TCollection_HExtendedString(myCurrentDocument->RequestedName());
}
@ -156,21 +147,15 @@ void CDF_Store::Realize (const Handle(Message_ProgressIndicator)& theProgress)
Standard_ExtString CDF_Store::Path() const {
return myPath.ToExtString();
}
Standard_ExtString CDF_Store::MetaDataPath() const {
static TCollection_ExtendedString retv;
retv="";
if(myCurrentDocument->IsStored()) retv=myCurrentDocument->MetaData()->Path();
return retv.ToExtString();
Handle(TCollection_HExtendedString) CDF_Store::MetaDataPath() const {
if(myCurrentDocument->IsStored())
return new TCollection_HExtendedString(myCurrentDocument->MetaData()->Path());
return blank;
}
Standard_ExtString CDF_Store::Description() const {
static TCollection_ExtendedString retv;
Handle(TCollection_HExtendedString) CDF_Store::Description() const {
if(myMainDocument->FindDescription())
retv = myMainDocument->Description();
else
retv= blank;
return retv.ToExtString();
return new TCollection_HExtendedString(myMainDocument->Description());
return blank;
}
Standard_Boolean CDF_Store::IsStored() const {
@ -192,13 +177,10 @@ Standard_Boolean CDF_Store::HasAPreviousVersion() const {
return myCurrentDocument->HasRequestedPreviousVersion();
}
Standard_ExtString CDF_Store::PreviousVersion() const {
static TCollection_ExtendedString retv;
Handle(TCollection_HExtendedString) CDF_Store::PreviousVersion() const {
if(myCurrentDocument->HasRequestedPreviousVersion())
retv= myCurrentDocument->RequestedPreviousVersion();
else
retv=blank;
return retv.ToExtString();
return new TCollection_HExtendedString(myCurrentDocument->RequestedPreviousVersion());
return blank;
}
Standard_Boolean CDF_Store::SetPreviousVersion (const Standard_ExtString aPreviousVersion) {
@ -218,36 +200,7 @@ Standard_Boolean CDF_Store::SetPreviousVersion (const Standard_ExtString aPrevio
return Standard_True;
}
void CDF_Store::InitComponent() {
myList->Init();
}
Standard_Boolean CDF_Store::MoreComponent() const {
return myList->More();
}
void CDF_Store::NextComponent() {
myList->Next();
}
void CDF_Store::SetCurrent() {
myCurrentDocument = myList->Value();
myIsMainDocument = myCurrentDocument == myMainDocument;
}
Standard_ExtString CDF_Store::Component() const {
static TCollection_ExtendedString retv;
retv=myList->Value()->Presentation();
return retv.ToExtString();
}
Standard_Boolean CDF_Store::HasSubComponents () const {
return myHasSubComponents;
}
void CDF_Store::SetCurrent(const Standard_ExtString aPresentation) {
myCurrentDocument = CDM_Document::FindFromPresentation(aPresentation);
void CDF_Store::SetCurrent(const Standard_ExtString /*aPresentation*/) {
myIsMainDocument = myCurrentDocument == myMainDocument;
}
void CDF_Store::SetMain() {
@ -259,18 +212,6 @@ Standard_Boolean CDF_Store::IsMainDocument() const {
return myIsMainDocument;
}
CDF_SubComponentStatus CDF_Store::SubComponentStatus(const Standard_ExtString aPresentation) const {
Handle(CDM_Document) d = CDM_Document::FindFromPresentation(aPresentation);
if(!d->IsStored())
return d->HasRequestedFolder()? CDF_SCS_Consistent : CDF_SCS_Unconsistent;
if(d->IsModified()) return CDF_SCS_Modified;
return CDF_SCS_Stored;
}
PCDM_StoreStatus CDF_Store::StoreStatus() const {
return myStatus;
}
@ -281,8 +222,7 @@ Standard_ExtString CDF_Store::AssociatedStatusText() const {
void CDF_Store::FindDefault() {
if (!myCurrentDocument->IsStored ()) {
myCurrentDocument->SetRequestedFolder(CDF_Session::CurrentSession()->CurrentApplication()->DefaultFolder());
// myCurrentDocument->SetRequestedName(theMetaDataDriver->SetName(myCurrentDocument,myCurrentDocument->Presentation()));
myCurrentDocument->SetRequestedFolder(Handle(CDF_Application)::DownCast((myCurrentDocument->Application()))->DefaultFolder());
myCurrentDocument->SetRequestedName(theMetaDataDriver->SetName(myCurrentDocument,myCurrentDocument->RequestedName()));
}
}
@ -290,8 +230,6 @@ void CDF_Store::SetComment(const Standard_ExtString aComment) {
myCurrentDocument->SetRequestedComment(aComment);
}
Standard_ExtString CDF_Store::Comment() const {
static TCollection_ExtendedString retv;
retv=myCurrentDocument->RequestedComment();
return retv.ToExtString();
Handle(TCollection_HExtendedString) CDF_Store::Comment() const {
return new TCollection_HExtendedString(myCurrentDocument->RequestedComment());
}

View File

@ -28,6 +28,7 @@
#include <Standard_ExtString.hxx>
#include <CDF_StoreSetNameStatus.hxx>
#include <CDF_SubComponentStatus.hxx>
#include <TCollection_HExtendedString.hxx>
#include <Message_ProgressIndicator.hxx>
@ -48,10 +49,10 @@ public:
Standard_EXPORT CDF_Store(const Handle(CDM_Document)& aDocument);
//! returns the folder in which the current document will be stored.
Standard_EXPORT Standard_ExtString Folder() const;
Standard_EXPORT Handle(TCollection_HExtendedString) Folder() const;
//! returns the name under which the current document will be stored
Standard_EXPORT Standard_ExtString Name() const;
Standard_EXPORT Handle(TCollection_HExtendedString) Name() const;
//! returns true if the current document is already stored
Standard_EXPORT Standard_Boolean IsStored() const;
@ -64,7 +65,7 @@ public:
Standard_EXPORT Standard_Boolean HasAPreviousVersion() const;
Standard_EXPORT Standard_ExtString PreviousVersion() const;
Standard_EXPORT Handle(TCollection_HExtendedString) PreviousVersion() const;
//! returns true if the currentdocument is the main one, ie the document
//! of the current selection.
@ -80,7 +81,7 @@ public:
Standard_EXPORT void SetComment (const Standard_ExtString aComment);
Standard_EXPORT Standard_ExtString Comment() const;
Standard_EXPORT Handle(TCollection_HExtendedString) Comment() const;
//! defines the name under which the document should be stored.
//! uses for example after modification of the folder.
@ -95,29 +96,10 @@ public:
//! returns the path of the previous store is the object
//! is already stored, otherwise an empty string;
Standard_EXPORT Standard_ExtString MetaDataPath() const;
Standard_EXPORT Handle(TCollection_HExtendedString) MetaDataPath() const;
//! returns the description of the format of the main object.
Standard_EXPORT Standard_ExtString Description() const;
//! Allows to Start a new Iteration from beginning
Standard_EXPORT void InitComponent();
//! Returns True if there are more entries to return
Standard_EXPORT Standard_Boolean MoreComponent() const;
//! Go to the next entry
//! (if there is not, Value will raise an exception)
Standard_EXPORT void NextComponent();
Standard_EXPORT void SetCurrent();
//! Returns item value of current entry
Standard_EXPORT Standard_ExtString Component() const;
Standard_EXPORT Standard_Boolean HasSubComponents() const;
Standard_EXPORT CDF_SubComponentStatus SubComponentStatus (const Standard_ExtString aPresentation) const;
Standard_EXPORT Handle(TCollection_HExtendedString) Description() const;
Standard_EXPORT void SetCurrent (const Standard_ExtString aPresentation);

View File

@ -78,7 +78,7 @@ PCDM_StoreStatus CDF_StoreList::Store (Handle(CDM_MetaData)& aMetaData,
TCollection_ExtendedString& aStatusAssociatedText,
const Handle(Message_ProgressIndicator)& theProgress)
{
Handle(CDF_MetaDataDriver) theMetaDataDriver = CDF_Session::CurrentSession()->MetaDataDriver();
Handle(CDF_MetaDataDriver) theMetaDataDriver = Handle(CDF_Application)::DownCast((myMainDocument->Application()))->MetaDataDriver();
PCDM_StoreStatus status = PCDM_SS_OK;
{

View File

@ -1,5 +1,3 @@
CDF.cxx
CDF.hxx
CDF_Application.cxx
CDF_Application.hxx
CDF_Directory.cxx

View File

@ -28,6 +28,14 @@
IMPLEMENT_STANDARD_RTTIEXT(CDM_Application,Standard_Transient)
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
CDM_Application::CDM_Application()
{
myMessenger = new Message_Messenger;
}
//=======================================================================
//function : SetDocumentVersion
//purpose :
@ -58,10 +66,7 @@ void CDM_Application::SetReferenceCounter
Handle(Message_Messenger) CDM_Application::MessageDriver()
{
static Handle(Message_Messenger) theMessenger;
if(theMessenger.IsNull())
theMessenger = Message::DefaultMessenger();
return theMessenger;
return myMessenger;
}
//=======================================================================
@ -79,10 +84,10 @@ void CDM_Application::Write(const Standard_ExtString aString)
//purpose :
//=======================================================================
void CDM_Application::BeginOfUpdate (const Handle(CDM_Document)& aDocument)
void CDM_Application::BeginOfUpdate (const Handle(CDM_Document)& /*aDocument*/)
{
TCollection_ExtendedString updating("Updating:");
updating+=aDocument->Presentation();
TCollection_ExtendedString updating("Updating: ");
updating += "Document";
Write(updating.ToExtString());
}
@ -92,17 +97,17 @@ void CDM_Application::BeginOfUpdate (const Handle(CDM_Document)& aDocument)
//=======================================================================
void CDM_Application::EndOfUpdate
(const Handle(CDM_Document)& aDocument,
(const Handle(CDM_Document)& /*aDocument*/,
const Standard_Boolean theStatus,
const TCollection_ExtendedString& /*ErrorString*/)
{
TCollection_ExtendedString message;
if (theStatus)
message="Updated:";
message="Updated: ";
else
message="Error during updating:";
message="Error during updating: ";
message+=aDocument->Presentation();
message+="Document";
Write(message.ToExtString());
}
@ -128,6 +133,15 @@ TCollection_AsciiString CDM_Application::Version() const
return TCollection_AsciiString();
}
//=======================================================================
//function : MetaDataLookUpTable
//purpose : returns the MetaData LookUpTable
//=======================================================================
CDM_MetaDataLookUpTable* CDM_Application::MetaDataLookUpTable()
{
return &myMetaDataLookUpTable;
}
//=======================================================================
//function : DumpJson
//purpose :

View File

@ -26,6 +26,7 @@
#include <Standard_ExtString.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <CDM_MetaDataLookUpTable.hxx>
#include <Message_ProgressIndicator.hxx>
class CDM_Reference;
@ -68,6 +69,9 @@ public:
//! Returns the application version.
Standard_EXPORT virtual TCollection_AsciiString Version() const;
//! Returns MetaData LookUpTable
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;
@ -79,13 +83,12 @@ friend class CDM_MetaData;
protected:
Standard_EXPORT CDM_Application();
Standard_EXPORT void SetDocumentVersion (const Handle(CDM_Document)& aDocument, const Handle(CDM_MetaData)& aMetaData) const;
Standard_EXPORT void SetReferenceCounter (const Handle(CDM_Document)& aDocument, const Standard_Integer aReferenceCounter);
private:
@ -97,7 +100,8 @@ private:
//! returns -1 if the metadata has no modification counter.
Standard_EXPORT virtual Standard_Integer DocumentVersion (const Handle(CDM_MetaData)& aMetaData) = 0;
Handle(Message_Messenger) myMessenger;
CDM_MetaDataLookUpTable myMetaDataLookUpTable;
};

View File

@ -14,16 +14,17 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef CDM_PresentationDirectory_HeaderFile
#define CDM_PresentationDirectory_HeaderFile
#ifndef CDM_ApplicationDirectory_HeaderFile
#define CDM_ApplicationDirectory_HeaderFile
#include <TCollection_ExtendedString.hxx>
#include <CDM_Document.hxx>
#include <TCollection_ExtendedString.hxx>
#include <CDM_Application.hxx>
#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
#include <Standard_ThreadId.hxx>
#include <NCollection_DefaultHasher.hxx>
typedef NCollection_DataMap<TCollection_ExtendedString,Handle(CDM_Document),TCollection_ExtendedString> CDM_PresentationDirectory;
typedef NCollection_DataMap<TCollection_ExtendedString,Handle(CDM_Document),TCollection_ExtendedString>::Iterator CDM_DataMapIteratorOfPresentationDirectory;
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

View File

@ -1,20 +0,0 @@
// Copyright (c) 2015 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_DataMapIteratorOfPresentationDirectory_HeaderFile
#define CDM_DataMapIteratorOfPresentationDirectory_HeaderFile
#include <CDM_PresentationDirectory.hxx>
#endif

View File

@ -23,7 +23,6 @@
#include <CDM_ListOfDocument.hxx>
#include <CDM_MetaData.hxx>
#include <CDM_NamesDirectory.hxx>
#include <CDM_PresentationDirectory.hxx>
#include <CDM_Reference.hxx>
#include <CDM_ReferenceIterator.hxx>
#include <Resource_Manager.hxx>
@ -40,11 +39,6 @@
IMPLEMENT_STANDARD_RTTIEXT(CDM_Document,Standard_Transient)
static CDM_PresentationDirectory& getPresentations() {
static CDM_PresentationDirectory thePresentations;
return thePresentations;
}
//=======================================================================
//function : CDM_Document
//purpose :
@ -52,7 +46,6 @@ static CDM_PresentationDirectory& getPresentations() {
CDM_Document::CDM_Document():
myResourcesAreLoaded (Standard_False),
myValidPresentation (Standard_False),
myVersion (1),
myActualReferenceIdentifier (0),
myStorageVersion (0),
@ -229,11 +222,6 @@ Handle(CDM_Reference) CDM_Document::Reference
return theReference;
}
static CDM_ListOfDocument& getListOfDocumentToUpdate() {
static CDM_ListOfDocument theListOfDocumentToUpdate;
return theListOfDocumentToUpdate;
}
//=======================================================================
//function : IsInSession
//purpose :
@ -286,25 +274,23 @@ TCollection_ExtendedString CDM_Document::Name
//function : UpdateFromDocuments
//purpose :
//=======================================================================
void CDM_Document::UpdateFromDocuments(const Standard_Address aModifContext) const
{
Standard_Boolean StartUpdateCycle=getListOfDocumentToUpdate().IsEmpty();
CDM_ListOfDocument aListOfDocumentsToUpdate;
Standard_Boolean StartUpdateCycle = aListOfDocumentsToUpdate.IsEmpty();
CDM_ListIteratorOfListOfReferences it(myFromReferences);
for(; it.More() ; it.Next()) {
Handle(CDM_Document) theFromDocument=it.Value()->FromDocument();
CDM_ListIteratorOfListOfDocument itUpdate;
for(; itUpdate.More(); itUpdate.Next()) {
if(itUpdate.Value() == theFromDocument) break;
if(itUpdate.Value()->ShallowReferences(theFromDocument)) {
getListOfDocumentToUpdate().InsertBefore(theFromDocument,itUpdate);
aListOfDocumentsToUpdate.InsertBefore(theFromDocument,itUpdate);
break;
}
}
if(!itUpdate.More()) getListOfDocumentToUpdate().Append(theFromDocument);
if(!itUpdate.More()) aListOfDocumentsToUpdate.Append(theFromDocument);
theFromDocument->Update(this,it.Value()->ReferenceIdentifier(),aModifContext);
}
@ -314,15 +300,15 @@ void CDM_Document::UpdateFromDocuments(const Standard_Address aModifContext) con
Handle(CDM_Application) theApplication;
TCollection_ExtendedString ErrorString;
while(!getListOfDocumentToUpdate().IsEmpty()) {
theDocumentToUpdate=getListOfDocumentToUpdate().First();
while(!aListOfDocumentsToUpdate.IsEmpty()) {
theDocumentToUpdate = aListOfDocumentsToUpdate.First();
theApplication=theDocumentToUpdate->Application();
ErrorString.Clear();
theApplication->BeginOfUpdate(theDocumentToUpdate);
theApplication->EndOfUpdate (theDocumentToUpdate,
theDocumentToUpdate->Update(ErrorString),
ErrorString);
getListOfDocumentToUpdate().RemoveFirst();
aListOfDocumentsToUpdate.RemoveFirst();
}
}
}
@ -519,104 +505,6 @@ Standard_ExtString CDM_Document::Comment() const
return myComments(1).ToExtString();
}
//=======================================================================
//function : Presentation
//purpose :
//=======================================================================
Standard_ExtString CDM_Document::Presentation()
{
if(!myValidPresentation) ComputePresentation();
return myPresentation.ToExtString();
}
//=======================================================================
//function : UnvalidPresentation
//purpose :
//=======================================================================
void CDM_Document::UnvalidPresentation()
{
if(myValidPresentation) {
getPresentations().UnBind(myPresentation);
myValidPresentation=Standard_False;
}
}
//=======================================================================
//function : ComputePresentation
//purpose :
//=======================================================================
void CDM_Document::ComputePresentation()
{
TCollection_ExtendedString presentation("");
static Standard_Integer theUnnamedDocuments(0);
static CDM_NamesDirectory theNames;
if(!myMetaData.IsNull()) {
presentation += myMetaData->Name();
if(!theNames.IsBound(presentation)) theNames.Bind(presentation,0);
Standard_Integer range = theNames(presentation);
range += 1;
theNames(presentation) = range;
if(range != 1) {
presentation += "<";
presentation += range;
presentation += ">";
}
}
else {
presentation = "Document_";
presentation += ++theUnnamedDocuments;
}
if(getPresentations().IsBound(presentation)) {
TCollection_ExtendedString Test = presentation;
Test += "!";
Standard_Integer Count=0;
while (getPresentations().IsBound(Test)) {
Count++;
Test = presentation; Test+= "!"; Test+= Count;
}
presentation = Test;
}
myPresentation = TCollection_ExtendedString(presentation);
myValidPresentation = Standard_True;
getPresentations().Bind(presentation,this);
}
//=======================================================================
//function : FindFromPresentation
//purpose :
//=======================================================================
Handle(CDM_Document) CDM_Document::FindFromPresentation
(const TCollection_ExtendedString& aPresentation)
{
TCollection_ExtendedString x(aPresentation);
if(!getPresentations().IsBound(x)) {
Standard_SStream aMsg;
aMsg <<"No document having this presentation: " << x << " does exist."
<< std::endl << (char)0;
throw Standard_NoSuchObject(aMsg.str().c_str());
}
return getPresentations()(x);
}
//=======================================================================
//function : FindPresentation
//purpose :
//=======================================================================
Standard_Boolean CDM_Document::FindPresentation
(const TCollection_ExtendedString& aPresentation)
{
return getPresentations().IsBound(aPresentation);
}
//=======================================================================
//function : IsStored
//purpose :
@ -649,7 +537,7 @@ void CDM_Document::SetMetaData(const Handle(CDM_MetaData)& aMetaData)
aMetaData->SetDocument(this);
// Update the document refencing this MetaData:
CDM_DataMapIteratorOfMetaDataLookUpTable it(CDM_MetaData::LookUpTable());
CDM_DataMapIteratorOfMetaDataLookUpTable it(*CDM_MetaData::LookUpTable());
for(;it.More();it.Next()) {
const Handle(CDM_MetaData)& theMetaData=it.Value();
if(theMetaData != aMetaData && theMetaData->IsRetrieved()) {
@ -660,11 +548,8 @@ void CDM_Document::SetMetaData(const Handle(CDM_MetaData)& aMetaData)
}
}
if(!myMetaData.IsNull()) {
if(myMetaData->Name() != aMetaData->Name()) UnvalidPresentation();
myMetaData->UnsetDocument();
}
else
UnvalidPresentation();
}
myStorageVersion = Modifications();
@ -684,7 +569,6 @@ void CDM_Document::UnsetIsStored()
{
if(!myMetaData.IsNull()) {
myMetaData->UnsetDocument();
// myMetaData.Nullify();
}
}
@ -791,7 +675,7 @@ TCollection_ExtendedString CDM_Document::RequestedName()
if(!myMetaData.IsNull())
myRequestedName=myMetaData->Name();
else
myRequestedName=Presentation();
myRequestedName="Document_";
}
myRequestedNameIsDefined=Standard_True;
return myRequestedName;
@ -912,7 +796,6 @@ void CDM_Document::Close()
RemoveAllReferences();
UnsetIsStored();
myApplication.Nullify();
UnvalidPresentation();
}
@ -1299,8 +1182,6 @@ void CDM_Document::DumpJson (Standard_OStream& theOStream, Standard_Integer theD
const TCollection_ExtendedString& aComment = aCommentIt.Value();
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, aComment)
}
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myPresentation)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myValidPresentation)
for (CDM_ListOfReferences::Iterator aFromReferenceIt (myFromReferences); aFromReferenceIt.More(); aFromReferenceIt.Next())
{

View File

@ -25,6 +25,7 @@
#include <TColStd_SequenceOfExtendedString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <Standard_OStream.hxx>
#include <CDM_ListOfDocument.hxx>
class CDM_MetaData;
class CDM_Application;
@ -216,21 +217,6 @@ public:
//! the comment is an empty string.
Standard_EXPORT Standard_ExtString Comment() const;
//! Returns an alphanumeric string identifying this document
//! in a unique manner in the current process. The presentation
//! may change when the document is stored.
//! Tries to get the 'FileFormat`.Presentation resource
//! This item is used to give a default presentation
//! to the document.
Standard_EXPORT Standard_ExtString Presentation();
//! returns the document having the given alphanumeric presentation.
Standard_EXPORT static Handle(CDM_Document) FindFromPresentation (const TCollection_ExtendedString& aPresentation);
//! indicates whether a document having the given presentation
//! does exist.
Standard_EXPORT static Standard_Boolean FindPresentation (const TCollection_ExtendedString& aPresentation);
Standard_EXPORT Standard_Boolean IsStored() const;
//! returns the value of the modification counter at the
@ -374,10 +360,6 @@ private:
//! the manager returned by this method will be
//! used to search for the following resource items.
Standard_EXPORT Handle(Resource_Manager) StorageResource();
Standard_EXPORT void ComputePresentation();
Standard_EXPORT void UnvalidPresentation();
Standard_EXPORT void AddToReference (const Handle(CDM_Reference)& aReference);
@ -385,9 +367,8 @@ private:
Standard_EXPORT void RemoveFromReference (const Standard_Integer aReferenceIdentifier);
TColStd_SequenceOfExtendedString myComments;
TCollection_ExtendedString myPresentation;
Standard_Boolean myValidPresentation;
CDM_ListOfReferences myFromReferences;
CDM_ListOfReferences myToReferences;
Standard_Integer myVersion;
@ -407,7 +388,6 @@ private:
Standard_Boolean myDescriptionWasFound;
Handle(CDM_Application) myApplication;
Standard_Integer myStorageFormatVersion;
};

View File

@ -20,17 +20,16 @@
#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_Type.hxx>
#include <TCollection_ExtendedString.hxx>
#include <OSD_Thread.hxx>
IMPLEMENT_STANDARD_RTTIEXT(CDM_MetaData,Standard_Transient)
static CDM_MetaDataLookUpTable& getLookUpTable(){
static CDM_MetaDataLookUpTable theLookUpTable;
return theLookUpTable;
}
CDM_MetaData::CDM_MetaData(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aPath,const TCollection_ExtendedString& aFileName,const Standard_Boolean ReadOnly):
myIsRetrieved(Standard_False),
myDocument(NULL),
@ -75,12 +74,14 @@ Handle(CDM_MetaData) CDM_MetaData::LookUp(const TCollection_ExtendedString& aFol
Handle(CDM_MetaData) theMetaData;
TCollection_ExtendedString aConventionalPath=aPath;
aConventionalPath.ChangeAll('\\','/');
if(!getLookUpTable().IsBound(aConventionalPath)) {
CDM_MetaDataLookUpTable* aLookUpTable = LookUpTable();
if (!aLookUpTable) return theMetaData;
if(!aLookUpTable->IsBound(aConventionalPath)) {
theMetaData = new CDM_MetaData(aFolder,aName,aPath,aFileName,ReadOnly);
getLookUpTable().Bind(aConventionalPath,theMetaData);
aLookUpTable->Bind(aConventionalPath, theMetaData);
}
else
theMetaData = getLookUpTable()(aConventionalPath);
theMetaData = aLookUpTable->Find(aConventionalPath);
return theMetaData;
}
@ -88,12 +89,14 @@ Handle(CDM_MetaData) CDM_MetaData::LookUp(const TCollection_ExtendedString& aFol
Handle(CDM_MetaData) theMetaData;
TCollection_ExtendedString aConventionalPath=aPath;
aConventionalPath.ChangeAll('\\','/');
if(!getLookUpTable().IsBound(aConventionalPath)) {
CDM_MetaDataLookUpTable* aLookUpTable = LookUpTable();
if (!aLookUpTable) return theMetaData;
if(!aLookUpTable->IsBound(aConventionalPath)) {
theMetaData = new CDM_MetaData(aFolder,aName,aPath,aVersion,aFileName,ReadOnly);
getLookUpTable().Bind(aConventionalPath,theMetaData);
aLookUpTable->Bind(aConventionalPath,theMetaData);
}
else
theMetaData = getLookUpTable()(aConventionalPath);
theMetaData = aLookUpTable->Find(aConventionalPath);
return theMetaData;
}
@ -130,8 +133,14 @@ Standard_OStream& CDM_MetaData::Print(Standard_OStream& anOStream) const {
Standard_OStream& CDM_MetaData::operator << (Standard_OStream& anOStream) {
return Print(anOStream);
}
const CDM_MetaDataLookUpTable& CDM_MetaData::LookUpTable() {
return getLookUpTable();
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);

View File

@ -115,7 +115,7 @@ private:
Standard_EXPORT void SetDocument (const Handle(CDM_Document)& aDocument);
Standard_EXPORT static const CDM_MetaDataLookUpTable& LookUpTable();
Standard_EXPORT static CDM_MetaDataLookUpTable* LookUpTable();
Standard_EXPORT Standard_Integer DocumentVersion (const Handle(CDM_Application)& anApplication);

View File

@ -19,7 +19,7 @@
#include <TCollection_ExtendedString.hxx>
#include <NCollection_DataMap.hxx>
class CDM_MetaData;
typedef NCollection_DataMap<TCollection_ExtendedString,Handle(CDM_MetaData),TCollection_ExtendedString> CDM_MetaDataLookUpTable;
typedef NCollection_DataMap<TCollection_ExtendedString,Handle(CDM_MetaData),TCollection_ExtendedString>::Iterator CDM_DataMapIteratorOfMetaDataLookUpTable;

View File

@ -2,7 +2,6 @@ CDM_Application.cxx
CDM_Application.hxx
CDM_CanCloseStatus.hxx
CDM_DataMapIteratorOfMetaDataLookUpTable.hxx
CDM_DataMapIteratorOfPresentationDirectory.hxx
CDM_Document.cxx
CDM_Document.hxx
CDM_DocumentHasher.hxx
@ -17,7 +16,7 @@ CDM_MetaData.cxx
CDM_MetaData.hxx
CDM_MetaDataLookUpTable.hxx
CDM_NamesDirectory.hxx
CDM_PresentationDirectory.hxx
CDM_ApplicationDirectory.hxx
CDM_Reference.cxx
CDM_Reference.hxx
CDM_ReferenceIterator.cxx

View File

@ -74,8 +74,7 @@ void PCDM_ReadWriter::Open (const Handle(Storage_BaseDriver)& aDriver,
Handle(PCDM_ReadWriter) PCDM_ReadWriter::Reader
(const TCollection_ExtendedString&)
{
static Handle(PCDM_ReadWriter_1) theReader=new PCDM_ReadWriter_1;
return theReader;
return (new PCDM_ReadWriter_1);
}
//=======================================================================
@ -85,8 +84,7 @@ Handle(PCDM_ReadWriter) PCDM_ReadWriter::Reader
Handle(PCDM_ReadWriter) PCDM_ReadWriter::Writer ()
{
static Handle(PCDM_ReadWriter_1) theWriter=new PCDM_ReadWriter_1;
return theWriter;
return (new PCDM_ReadWriter_1);
}
//=======================================================================
@ -120,9 +118,7 @@ TCollection_ExtendedString PCDM_ReadWriter::FileFormat
if (PCDM::FileDriverType (theFileName, theFileDriver) == PCDM_TOFD_Unknown)
return ::TryXmlDriverType (theFileName);
static Standard_Boolean theFileIsOpen;
theFileIsOpen=Standard_False;
Standard_Boolean theFileIsOpen(Standard_False);
try {
OCC_CATCH_SIGNALS

View File

@ -226,18 +226,14 @@ void PCDM_ReadWriter_1::WriteVersion(const Handle(Storage_Data)& aData, const Ha
Standard_Integer PCDM_ReadWriter_1::ReadReferenceCounter(const TCollection_ExtendedString& aFileName, const Handle(Message_Messenger)& theMsgDriver) const {
static Standard_Integer theReferencesCounter ;
theReferencesCounter=0;
static Standard_Integer i ;
Standard_Integer theReferencesCounter(0) ;
Standard_Integer i ;
Handle(Storage_BaseDriver) theFileDriver;
TCollection_AsciiString aFileNameU(aFileName);
if(PCDM::FileDriverType(aFileNameU, theFileDriver) == PCDM_TOFD_Unknown)
return theReferencesCounter;
static Standard_Boolean theFileIsOpen ;
theFileIsOpen=Standard_False;
Standard_Boolean theFileIsOpen(Standard_False);
try {
OCC_CATCH_SIGNALS
PCDM_ReadWriter::Open(theFileDriver,aFileName,Storage_VSRead);
@ -342,7 +338,7 @@ void PCDM_ReadWriter_1::ReadUserInfo(const TCollection_ExtendedString& aFileName
TColStd_SequenceOfExtendedString& theUserInfo,
const Handle(Message_Messenger)&)
{
static Standard_Integer i ;
Standard_Integer i ;
Handle(Storage_BaseDriver) theFileDriver;
TCollection_AsciiString aFileNameU(aFileName);
if(PCDM::FileDriverType(aFileNameU, theFileDriver) == PCDM_TOFD_Unknown)
@ -377,16 +373,13 @@ void PCDM_ReadWriter_1::ReadUserInfo(const TCollection_ExtendedString& aFileName
Standard_Integer PCDM_ReadWriter_1::ReadDocumentVersion(const TCollection_ExtendedString& aFileName, const Handle(Message_Messenger)& theMsgDriver) const {
static Standard_Integer theVersion ;
theVersion=-1;
Standard_Integer theVersion(-1);
Handle(Storage_BaseDriver) theFileDriver;
TCollection_AsciiString aFileNameU(aFileName);
if(PCDM::FileDriverType(aFileNameU, theFileDriver) == PCDM_TOFD_Unknown)
return theVersion;
static Standard_Boolean theFileIsOpen ;
theFileIsOpen =Standard_False;
Standard_Boolean theFileIsOpen(Standard_False);
try {
OCC_CATCH_SIGNALS
@ -397,7 +390,7 @@ Standard_Integer PCDM_ReadWriter_1::ReadDocumentVersion(const TCollection_Extend
hd.Read (theFileDriver);
const TColStd_SequenceOfAsciiString &refUserInfo = hd.UserInfo();
static Standard_Integer i ;
Standard_Integer i ;
for ( i =1; i<= refUserInfo.Length() ; i++) {
if(refUserInfo(i).Search(MODIFICATION_COUNTER) != -1) {
try { OCC_CATCH_SIGNALS theVersion=refUserInfo(i).Token(" ",2).IntegerValue();}

View File

@ -50,8 +50,7 @@ void PCDM_StorageDriver::Write (const Handle(CDM_Document)& aDocument,
Handle(Storage_Data) theData = new Storage_Data;
static Standard_Boolean Failure;
Failure=Standard_False;
Standard_Boolean Failure(Standard_False);
Standard_SStream aMsg; aMsg << "error during Make:";
PCDM_SequenceOfDocument thePersistentDocuments;
{

View File

@ -29,7 +29,6 @@
#include <TDocStd_Application.hxx>
#include <TDocStd_Document.hxx>
#include <DDocStd.hxx>
#include <CDF.hxx>
#include <Resource_Manager.hxx>
#include <TopoDS_Wire.hxx>

View File

@ -2976,6 +2976,217 @@ static Standard_Integer OCC30391(Draw_Interpretor& theDI,
return 0;
}
#include <Standard_Mutex.hxx>
#include <NCollection_Sequence.hxx>
#include <BinLDrivers.hxx>
#include <BinDrivers.hxx>
#include <XmlLDrivers.hxx>
#include <XmlDrivers.hxx>
#include <StdLDrivers.hxx>
#include <StdDrivers.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDocStd_PathParser.hxx>
#include <OSD.hxx>
#include <OSD_Thread.hxx>
#include <OSD_Environment.hxx>
typedef NCollection_Sequence <TCollection_AsciiString> SequenceOfDocNames;
typedef struct
{
Standard_ThreadId ID;
int iThread;
TCollection_AsciiString inFile[3];
TCollection_AsciiString outFile[2];
bool finished;
int* res;
} Args;
static void printMsg(const char* msg)
{
printf("%s\n", msg);
}
static Standard_Integer nbREP(50);
void* threadFunction(void* theArgs)
{
Args* args = (Args*)theArgs;
try
{
if(args->inFile[0].IsEmpty())
{
*(args->res) = -1;
return args->res;
}
Handle(TDocStd_Application) anApp = new TDocStd_Application();
OCC_CATCH_SIGNALS;
BinLDrivers::DefineFormat(anApp);
BinDrivers::DefineFormat(anApp);
XmlLDrivers::DefineFormat(anApp);
XmlDrivers::DefineFormat(anApp);
StdLDrivers::DefineFormat(anApp);
StdDrivers::DefineFormat(anApp);
for (int aFileIndex = 0; aFileIndex < 3; aFileIndex++)
{
TCollection_AsciiString aDocName = args->inFile[aFileIndex];
Handle(TDocStd_Document) aDoc;
for (int i = 1; i <= nbREP; i++) {
PCDM_ReaderStatus aStatus = anApp->Open(aDocName, aDoc);
if (aStatus != PCDM_RS_OK) {
args->finished = true;
*(args->res) = -1;
return args->res;
}
else {
TDF_Label aLabel = aDoc->Main();
TDF_ChildIterator anIt(aLabel, Standard_True);
for (; anIt.More(); anIt.Next()) {
const TDF_Label& aLab = anIt.Value();
Handle(TDataStd_AsciiString) anAtt;
aLab.FindAttribute(TDataStd_AsciiString::GetID(), anAtt);
if (!anAtt.IsNull()) {
TCollection_AsciiString aStr = anAtt->Get();
if (aStr.IsEqual(aDocName)) {
*(args->res) = (int)aLab.Tag();
break;
}
}
}
if (aFileIndex != 2) {
TCollection_AsciiString anOutDocName = args->outFile[aFileIndex];
anApp->SaveAs(aDoc, anOutDocName);
}
anApp->Close(aDoc);
}
}
}
args->finished = true;
anApp->RemoveFromSession();
}
catch (...)
{
args->finished = true;
*(args->res) = -1;
return args->res;
}
args->finished = true;
return args->res;
}
int getNumCores()
{
#ifdef WIN32
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
return sysinfo.dwNumberOfProcessors;
#elif MACOS
int nm[2];
size_t len = 4;
uint32_t count;
nm[0] = CTL_HW; nm[1] = HW_AVAILCPU;
sysctl(nm, 2, &count, &len, NULL, 0);
if (count < 1) {
nm[1] = HW_NCPU;
sysctl(nm, 2, &count, &len, NULL, 0);
if (count < 1) { count = 1; }
}
return count;
#else
return sysconf(_SC_NPROCESSORS_ONLN);
#endif
}
//=======================================================================
//function : OCC29195
//purpose :
//=======================================================================
static Standard_Integer OCC29195(Draw_Interpretor&, Standard_Integer theArgC, const char** theArgV)
{
if (theArgC < 2)
{
std::cout << "\nOCC29195 [nbRep] doc1.cbf doc1.xml doc1.std outDoc1.cbf outDoc1.xml doc2.cbf doc2.xml doc2.std outDoc2.cbf outDoc2.xml ...], where:";
std::cout << "\nnbRep - number repetitions of a thread function (by default - 50)";
std::cout << "\ndocN - names (5 in each group) of OCAF documents names (3 input files, 2 output)\n" << std::endl;
return 1;
}
int iThread(0), nbThreads(0), off(0);
if (TCollection_AsciiString(theArgV[1]).IsIntegerValue())
{
nbREP = TCollection_AsciiString(theArgV[1]).IntegerValue();
off = 1;
}
if (theArgC - off - 1 < 5 || (theArgC - off - 1) % 5 != 0 )
{
printMsg("TEST is FAILED: number of arguments is invalid\n");
return 0;
}
Standard_Integer aNbFiles = (theArgC - off - 1) / 5;
nbThreads = getNumCores();
if (aNbFiles < nbThreads)
{
nbThreads = aNbFiles;
}
// Allocate data
Args* args = new Args[nbThreads];
OSD_Thread* threads = new OSD_Thread[nbThreads];
while (iThread < nbThreads)
{
if (iThread < aNbFiles)
{
args[iThread].inFile[0] = theArgV[iThread * 5 + off + 1];
args[iThread].inFile[1] = theArgV[iThread * 5 + off + 2];
args[iThread].inFile[2] = theArgV[iThread * 5 + off + 3];
args[iThread].outFile[0] = theArgV[iThread * 5 + off + 4];
args[iThread].outFile[1] = theArgV[iThread * 5 + off + 5];
}
args[iThread].iThread = iThread;
args[iThread].ID = threads[iThread].GetId();
args[iThread].finished = false;
args[iThread].res = new int;
threads[iThread].SetFunction(&threadFunction);
iThread++;
}
for (iThread = 0; iThread < nbThreads; iThread++)
{
args[iThread].finished = false;
threads[iThread].Run((void*)&(args[iThread]));
}
// Sleep while the threads are run.
bool finished = false;
while (!finished)
{
OSD::MilliSecSleep(100);
finished = true;
for (iThread = 0; iThread < nbThreads && finished; iThread++)
{
finished = args[iThread].finished;
}
}
OSD_Environment anEnv("Result29195");
for (iThread = 0; iThread < nbThreads; iThread++)
{
if (*(args[iThread].res) == -1)
{
printMsg("OCC29195 is FAILED\n");
anEnv.SetValue("FAILED_ERR");
break;
}
}
if (iThread == nbThreads)
{
printMsg("OCC29195 is finished OK\n");
anEnv.SetValue("OK");
}
anEnv.Build();
return 0;
}
//=======================================================================
//function : QAStartsWith string startstring
//=======================================================================
@ -3620,6 +3831,7 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) {
theCommands.Add("OCC29807", "OCC29807 surface1 surface2 u1 v1 u2 v2", __FILE__, OCC29807, group);
theCommands.Add("OCC29311", "OCC29311 shape counter nbiter: check performance of OBB calculation", __FILE__, OCC29311, group);
theCommands.Add("OCC30391", "OCC30391 result face LenBeforeUfirst LenAfterUlast LenBeforeVfirst LenAfterVlast", __FILE__, OCC30391, group);
theCommands.Add("OCC29195", "OCC29195 [nbRep] doc1 [doc2 [doc3 [doc4]]]", __FILE__, OCC29195, group);
theCommands.Add("OCC30435", "OCC30435 result curve inverse nbit", __FILE__, OCC30435, group);
theCommands.Add("OCC30990", "OCC30990 surface", __FILE__, OCC30990, group);

View File

@ -22,7 +22,6 @@
#include <TDocStd.hxx>
#include <CDF.hxx>
#include <OSD_Environment.hxx>
#include <TDocStd_XLink.hxx>

View File

@ -34,6 +34,7 @@
#include <TDocStd_Document.hxx>
#include <TDocStd_Owner.hxx>
#include <TDocStd_PathParser.hxx>
#include <OSD_Thread.hxx>
#include<Message_ProgressSentry.hxx>
@ -47,20 +48,9 @@ IMPLEMENT_STANDARD_RTTIEXT(TDocStd_Application,CDF_Application)
TDocStd_Application::TDocStd_Application()
: myIsDriverLoaded (Standard_True)
{
myMessageDriver = CDM_Application::MessageDriver();
Handle(CDF_Session) S;
if (!CDF_Session::Exists()) S = new CDF_Session();
else S = CDF_Session::CurrentSession();
S->SetCurrentApplication(this);
try
{
OCC_CATCH_SIGNALS
S->LoadDriver();
}
catch (Plugin_Failure const&)
{
AddToSession();
if(myMetaDataDriver.IsNull())
myIsDriverLoaded = Standard_False;
}
}
@ -73,15 +63,6 @@ Standard_Boolean TDocStd_Application::IsDriverLoaded() const
return myIsDriverLoaded;
}
//=======================================================================
//function : MessageDriver
//purpose :
//=======================================================================
Handle(Message_Messenger) TDocStd_Application::MessageDriver()
{
return myMessageDriver;
}
//=======================================================================
//function : Resources
//purpose :
@ -179,8 +160,7 @@ Standard_Integer TDocStd_Application::NbDocuments() const
{
if (!CDF_Session::Exists())
throw Standard_DomainError("TDocStd_Application::NbDocuments");
Handle(CDF_Session) S = CDF_Session::CurrentSession();
return S->Directory()->Length();
return this->myDirectory->Length();
}
//=======================================================================
@ -192,8 +172,7 @@ void TDocStd_Application::GetDocument(const Standard_Integer index,Handle(TDocSt
{
if (!CDF_Session::Exists())
throw Standard_DomainError("TDocStd_Application::NbDocuments");
Handle(CDF_Session) S = CDF_Session::CurrentSession();
CDF_DirectoryIterator it (S->Directory());
CDF_DirectoryIterator it (myDirectory);
Standard_Integer current = 0;
for (;it.MoreDocument();it.NextDocument()) {
current++;
@ -624,6 +603,19 @@ void TDocStd_Application::OnCommitTransaction (const Handle(TDocStd_Document)&)
// 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 :

View File

@ -79,9 +79,6 @@ public:
//! Check if meta data driver was successfully loaded
//! by the application constructor
Standard_EXPORT Standard_Boolean IsDriverLoaded() const;
//! Redefines message driver, by default outputs to std::cout.
Standard_EXPORT virtual Handle(Message_Messenger) MessageDriver() Standard_OVERRIDE;
//! Returns resource manager defining supported persistent formats.
//!
@ -286,12 +283,20 @@ public:
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
DEFINE_STANDARD_RTTIEXT(TDocStd_Application,CDF_Application)
//! Remove this application from the current session
Standard_EXPORT Standard_Boolean RemoveFromSession();
DEFINE_STANDARD_RTTIEXT(TDocStd_Application, CDF_Application)
protected:
Handle(Message_Messenger) myMessageDriver;
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

View File

@ -34,6 +34,11 @@ TKXSDRAW
TKSTL
TKXml
TKTObj
TKXmlL
TKBin
TKBinL
TKStd
TKStdL
CSF_gdi32
CSF_advapi32
CSF_user32

View File

@ -25,7 +25,8 @@
#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"
@ -36,11 +37,13 @@ IMPLEMENT_STANDARD_RTTIEXT(TObj_Application,TDocStd_Application)
//function : GetInstance
//purpose :
//=======================================================================
Handle(TObj_Application) TObj_Application::GetInstance()
{
static Handle(TObj_Application) anInstance = new TObj_Application;
return anInstance;
Handle(CDF_Session) aSession = CDF_Session::Create();
Handle(CDF_Application) anApp;
if (aSession->FindApplication(OSD_Thread::Current(), anApp))
return Handle(TObj_Application)::DownCast(anApp);
return new TObj_Application;
}
//=======================================================================

View File

@ -510,12 +510,11 @@ void TObjDRAW::Init(Draw_Interpretor& di)
void TObjDRAW::Factory(Draw_Interpretor& theDI)
{
// Initialize TObj OCAF formats
Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
Handle(TDocStd_Application) anApp = TObj_Application::GetInstance();//DDocStd::GetApplication();
BinTObjDrivers::DefineFormat(anApp);
XmlTObjDrivers::DefineFormat(anApp);
// define formats for TObj specific application
anApp = TObj_Application::GetInstance();
BinTObjDrivers::DefineFormat(anApp);
XmlTObjDrivers::DefineFormat(anApp);

View File

@ -26,6 +26,7 @@
#include <Standard_Boolean.hxx>
#include <XmlObjMgt_Element.hxx>
#include <Standard_Integer.hxx>
class XmlMDF_ADriverTable;
class TCollection_ExtendedString;
class CDM_Document;
@ -81,8 +82,7 @@ protected:
const Handle(Message_ProgressIndicator)& theProgress = NULL);
Handle(XmlMDF_ADriverTable) myDrivers;
XmlObjMgt_SRelocationTable myRelocTable;
XmlObjMgt_SRelocationTable myRelocTable;
private:

39
tests/bugs/caf/bug29195_1 Normal file
View File

@ -0,0 +1,39 @@
pload QAcommands
##set imagedir [pwd]
set aFile1 [locate_data_file bug29195_1.cbf]
set aFile2 [locate_data_file bug29195_2.cbf]
set aFile3 [locate_data_file bug29195_3.cbf]
set aFile4 [locate_data_file bug29195_4.cbf]
set aFile5 [locate_data_file bug29195_1.xml]
set aFile6 [locate_data_file bug29195_2.xml]
set aFile7 [locate_data_file bug29195_3.xml]
set aFile8 [locate_data_file bug29195_4.xml]
set aFile9 [locate_data_file bug29195_1.std]
set aFile10 [locate_data_file bug29195_2.std]
set aFile11 [locate_data_file bug29195_3.std]
set aFile12 [locate_data_file bug29195_4.std]
set aNew1 ${imagedir}/new_bug29195_1.cbf
set aNew2 ${imagedir}/new_bug29195_2.cbf
set aNew3 ${imagedir}/new_bug29195_3.cbf
set aNew4 ${imagedir}/new_bug29195_4.cbf
set aNew5 ${imagedir}/new_bug29195_1.xml
set aNew6 ${imagedir}/new_bug29195_2.xml
set aNew7 ${imagedir}/new_bug29195_3.xml
set aNew8 ${imagedir}/new_bug29195_4.xml
OCC29195 50 $aFile1 $aFile5 $aFile9 ${aNew1} ${aNew5} $aFile2 $aFile6 $aFile10 ${aNew2} ${aNew6} $aFile3 $aFile7 $aFile11 ${aNew3} ${aNew7} $aFile4 $aFile8 $aFile12 ${aNew4} ${aNew8}
set RES [dgetenv Result29195]
if { [file exists ${aNew1}] } {file delete ${aNew1}}
if { [file exists ${aNew2}] } {file delete ${aNew2}}
if { [file exists ${aNew3}] } {file delete ${aNew3}}
if { [file exists ${aNew4}] } {file delete ${aNew4}}
if { [file exists ${aNew5}] } {file delete ${aNew5}}
if { [file exists ${aNew6}] } {file delete ${aNew6}}
if { [file exists ${aNew7}] } {file delete ${aNew7}}
if { [file exists ${aNew8}] } {file delete ${aNew8}}
puts "OCC29195 is $RES"

View File

@ -53,7 +53,7 @@
#include <OSD_Directory.hxx>
#include <OSD_Environment.hxx>
#include <OSD_Protection.hxx>
#include <OSD_Thread.hxx>
#include <inspector/View_Displayer.hxx>
#include <inspector/View_ToolBar.hxx>
#include <inspector/View_Viewer.hxx>
@ -64,6 +64,7 @@
#include <inspector/ViewControl_Tools.hxx>
#include <Standard_WarningsDisable.hxx>
#include <Standard_ThreadId.hxx>
#include <QAction>
#include <QApplication>
#include <QComboBox>
@ -440,8 +441,12 @@ void DFBrowser_Window::Init (const NCollection_List<Handle(Standard_Transient)>&
}
else
{
if (anApplication.IsNull() && CDF_Session::Exists())
anApplication = Handle(TDocStd_Application)::DownCast (CDF_Session::CurrentSession()->CurrentApplication());
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();
@ -504,7 +509,10 @@ void DFBrowser_Window::OpenFile (const TCollection_AsciiString& theFileName)
Handle(CDF_Session) aSession = CDF_Session::CurrentSession();
if (!aSession.IsNull())
{
anApplication = Handle(TDocStd_Application)::DownCast (CDF_Session::CurrentSession()->CurrentApplication());
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++)

View File

@ -77,7 +77,7 @@ void DFBrowserPane_TDocStdOwner::GetValues (const Handle(TDF_Attribute)& theAttr
// CDM_Document methods
theValues << "Comments" << convertToString (aComments)
<< "Presentation" << DFBrowserPane_Tools::ToString (aDocument->Presentation())
// << "Presentation" << DFBrowserPane_Tools::ToString (aDocument->Presentation())
<< "IsStored" << DFBrowserPane_Tools::BoolToStr (aDocument->IsStored())
<< "StorageVersion" << QString::number (aDocument->StorageVersion())
<< "Folder" << (aDocument->IsStored() ? DFBrowserPane_Tools::ToString (aDocument->Folder()) : "")