mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0029195: OCAF - ensure thread safety for different documents.
OCAF persistence architecture modification to satisfy multi-threading criteria.
This commit is contained in:
@@ -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;
|
||||
}
|
@@ -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
|
@@ -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;
|
||||
}
|
||||
|
@@ -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:
|
||||
|
||||
|
||||
|
@@ -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();
|
||||
|
@@ -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()) {}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@@ -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());
|
||||
}
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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;
|
||||
{
|
||||
|
@@ -1,5 +1,3 @@
|
||||
CDF.cxx
|
||||
CDF.hxx
|
||||
CDF_Application.cxx
|
||||
CDF_Application.hxx
|
||||
CDF_Directory.cxx
|
||||
|
Reference in New Issue
Block a user