mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0025812: Replace dynamic loading mechanism of OCAF persistence with dynamic-link one
Fields to store cached instances of reader and writer drivers for each format are added in CDF_Application. Method DefineFormat() is added in TDocStd_Application, allowing defining format completely by single call, including drivers to be used for persistence. All OCAF driver packages provide static method DefineFormat() that defines standard OCAF persistence format supported by corresponding package; these methods are called in DRAW to enable all persistence by default. DRAW commands (except TObj-specific ones) now use single instance of OCAF Application, returned by DDocStd::GetApplication(). Other instances are eliminated, as well as method DDocStd::Find(const Handle(TDocStd_Application)&). Method MessageDriver() and relevant field are moved to TDocStd_Application from its descendants. Method CDF_Application::ReaderFromFormat() is made virtual to allow its redefinition in descendants. Creation of storage driver is moved from PCDM::StorageDriver() to new virtual method CDF_Application::WriterFromFormat(). The code loading driver as plugin is retained in both these methods for compatibility. Test command OCC24925 is converted to use virtual methods instead of defining plugin resource. Migration table for old OCAF types is hard-coded in Storage_Schema::CheckTypeMigration(). Removed obsolete and unused items: - FWOSPlugin library (driver is created directly) - Methods in classes CDM_Document dealing with unused parameters of format - DRAW command OCC23010 for testing non-reproducible issue #23010 - Methods PCDM::StorageDriver(), PCDM::FindStorageDriver() - Method Formats() from CDF_Application and descendants - Methods LoadExtensions and SchemaName from PCDM_StorageDriver - Method Plugin::AdditionalPluginMap() - Method BinLDrivers_DocumentStorageDriver::SchemaName() - Method CDF_Application::DefaultExtension(), Reader(), FindReader(), FindReaderFromFormat() - Method CDF_Store::Check()
This commit is contained in:
@@ -25,7 +25,6 @@
|
||||
#include <CDM_Document.hxx>
|
||||
#include <CDM_MetaData.hxx>
|
||||
#include <PCDM_Reader.hxx>
|
||||
#include <PCDM_ReaderStatus.hxx>
|
||||
#include <PCDM_ReadWriter.hxx>
|
||||
#include <PCDM_RetrievalDriver.hxx>
|
||||
#include <PCDM_StorageDriver.hxx>
|
||||
@@ -34,8 +33,6 @@
|
||||
#include <Standard_GUID.hxx>
|
||||
#include <Standard_NoSuchObject.hxx>
|
||||
#include <Standard_ProgramError.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
#include <UTL.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(CDF_Application,CDM_Application)
|
||||
@@ -188,7 +185,17 @@ PCDM_ReaderStatus CDF_Application::CanRetrieve(const TCollection_ExtendedString&
|
||||
else
|
||||
return PCDM_RS_UnrecognizedFileFormat;
|
||||
}
|
||||
if(!FindReaderFromFormat(theFormat)) return PCDM_RS_NoDriver;
|
||||
|
||||
// check actual availability of the driver
|
||||
try {
|
||||
Handle(PCDM_Reader) aReader = ReaderFromFormat(theFormat);
|
||||
if (aReader.IsNull())
|
||||
return PCDM_RS_NoDriver;
|
||||
}
|
||||
catch (Standard_Failure)
|
||||
{
|
||||
// no need to report error, this was just check for availability
|
||||
}
|
||||
}
|
||||
}
|
||||
return PCDM_RS_OK;
|
||||
@@ -226,27 +233,6 @@ Standard_Boolean CDF_Application::SetDefaultFolder(const Standard_ExtString aFol
|
||||
return found;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DefaultExtension
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_ExtString CDF_Application::DefaultExtension() {
|
||||
static TCollection_ExtendedString theDefaultExtension;
|
||||
theDefaultExtension="*";
|
||||
TColStd_SequenceOfExtendedString theFormats;
|
||||
Formats(theFormats);
|
||||
|
||||
for (Standard_Integer i=1; i<= theFormats.Length(); i++) {
|
||||
TCollection_ExtendedString theResource(theFormats(i));
|
||||
theResource+=".FileExtension";
|
||||
if(UTL::Find(Resources(),theResource)) {
|
||||
theDefaultExtension=UTL::Value(Resources(),theResource);
|
||||
return theDefaultExtension.ToExtString();
|
||||
}
|
||||
}
|
||||
return theDefaultExtension.ToExtString();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Retrieve
|
||||
//purpose :
|
||||
@@ -285,11 +271,17 @@ Handle(CDM_Document) CDF_Application::Retrieve(const Handle(CDM_MetaData)& aMeta
|
||||
if(AlreadyRetrieved) myRetrievableStatus = PCDM_RS_AlreadyRetrieved;
|
||||
Standard_Boolean Modified=AlreadyRetrieved && aMetaData->Document()->IsModified();
|
||||
if(Modified) myRetrievableStatus = PCDM_RS_AlreadyRetrievedAndModified;
|
||||
if(!AlreadyRetrieved || Modified) {
|
||||
|
||||
Handle(PCDM_Reader) theReader=Reader(aMetaData->FileName());
|
||||
|
||||
|
||||
if(!AlreadyRetrieved || Modified)
|
||||
{
|
||||
TCollection_ExtendedString aFormat;
|
||||
if (!Format(aMetaData->FileName(), aFormat))
|
||||
{
|
||||
Standard_SStream aMsg;
|
||||
aMsg << "Could not determine format for the file " << aMetaData->FileName() << (char)0;
|
||||
Standard_NoSuchObject::Raise(aMsg);
|
||||
}
|
||||
Handle(PCDM_Reader) theReader = ReaderFromFormat (aFormat);
|
||||
|
||||
Handle(CDM_Document) theDocument;
|
||||
|
||||
if(Modified) {
|
||||
@@ -357,32 +349,6 @@ CDF_TypeOfActivation CDF_Application::TypeOfActivation(const Handle(CDM_MetaData
|
||||
return CDF_TOA_New;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : FindReader
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean CDF_Application::FindReader(const TCollection_ExtendedString& aFileName) {
|
||||
Standard_GUID voidGUID;
|
||||
TCollection_ExtendedString voidResourceName;
|
||||
return FindReader(aFileName,voidGUID,voidResourceName);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Reader
|
||||
//purpose : code dp
|
||||
//=======================================================================
|
||||
Handle(PCDM_Reader) CDF_Application::Reader (const TCollection_ExtendedString& aFileName) {
|
||||
TCollection_ExtendedString theFormat;
|
||||
if (!Format(aFileName,theFormat)) {
|
||||
Standard_SStream aMsg;
|
||||
aMsg << "Could not found the format" <<(char)0;
|
||||
Standard_NoSuchObject::Raise(aMsg);
|
||||
|
||||
}
|
||||
return ReaderFromFormat (theFormat);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose :
|
||||
@@ -444,71 +410,116 @@ Handle(CDM_Document) CDF_Application::Read (Standard_IStream& theIStream)
|
||||
return aDoc;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FindReaderFromFormat
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean CDF_Application::FindReaderFromFormat(const TCollection_ExtendedString& aFormat) {
|
||||
Standard_GUID voidGUID;
|
||||
TCollection_ExtendedString voidResourceName;
|
||||
return FindReaderFromFormat(aFormat,voidGUID,voidResourceName);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ReaderFromFormat
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(PCDM_Reader) CDF_Application::ReaderFromFormat(const TCollection_ExtendedString& aFormat) {
|
||||
TCollection_ExtendedString UnfoundResourceName;
|
||||
Standard_GUID thePluginId;
|
||||
if(!FindReaderFromFormat(aFormat,thePluginId,UnfoundResourceName)) {
|
||||
Handle(PCDM_Reader) CDF_Application::ReaderFromFormat(const TCollection_ExtendedString& theFormat)
|
||||
{
|
||||
// check map of readers
|
||||
Handle(PCDM_RetrievalDriver) aReader;
|
||||
if (myReaders.Find (theFormat, aReader))
|
||||
return aReader;
|
||||
|
||||
// support of legacy method of loading reader as plugin
|
||||
TCollection_ExtendedString aResourceName = theFormat;
|
||||
aResourceName += ".RetrievalPlugin";
|
||||
if (!UTL::Find(Resources(), aResourceName))
|
||||
{
|
||||
myReaders.Bind(theFormat, aReader);
|
||||
Standard_SStream aMsg;
|
||||
aMsg << "Could not found the item:" << UnfoundResourceName <<(char)0;
|
||||
aMsg << "Could not found the item:" << aResourceName <<(char)0;
|
||||
myRetrievableStatus = PCDM_RS_WrongResource;
|
||||
Standard_NoSuchObject::Raise(aMsg);
|
||||
}
|
||||
Handle(PCDM_Reader) R;
|
||||
}
|
||||
|
||||
// Get GUID as a string.
|
||||
TCollection_ExtendedString strPluginId = UTL::Value(Resources(), aResourceName);
|
||||
|
||||
// If the GUID (as a string) contains blanks, remove them.
|
||||
if (strPluginId.Search(' ') != -1)
|
||||
strPluginId.RemoveAll(' ');
|
||||
|
||||
// Convert to GUID.
|
||||
Standard_GUID aPluginId = UTL::GUID(strPluginId);
|
||||
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
R = Handle(PCDM_Reader)::DownCast(Plugin::Load(thePluginId));
|
||||
aReader = Handle(PCDM_RetrievalDriver)::DownCast(Plugin::Load(aPluginId));
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
catch (Standard_Failure)
|
||||
{
|
||||
myReaders.Bind(theFormat, aReader);
|
||||
myRetrievableStatus = PCDM_RS_WrongResource;
|
||||
Standard_SStream aMsg;
|
||||
aMsg << Standard_Failure::Caught() << endl;
|
||||
Standard_Failure::Raise(aMsg);
|
||||
Standard_Failure::Caught()->Reraise();
|
||||
}
|
||||
Handle(PCDM_RetrievalDriver) RD = Handle(PCDM_RetrievalDriver)::DownCast(R);
|
||||
if (!RD.IsNull()) {
|
||||
RD->SetFormat(aFormat);
|
||||
return RD;
|
||||
} else
|
||||
if (!aReader.IsNull()) {
|
||||
aReader->SetFormat(theFormat);
|
||||
}
|
||||
else
|
||||
{
|
||||
myRetrievableStatus = PCDM_RS_WrongResource;
|
||||
return R;
|
||||
}
|
||||
|
||||
// record in map
|
||||
myReaders.Bind (theFormat, aReader);
|
||||
return aReader;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FindReader
|
||||
//function : WriterFromFormat
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean CDF_Application::FindReader(const TCollection_ExtendedString& aFileName, Standard_GUID& thePluginId, TCollection_ExtendedString& ResourceName) {
|
||||
|
||||
TCollection_ExtendedString theFormat=PCDM_ReadWriter::FileFormat(aFileName);
|
||||
Handle(PCDM_StorageDriver) CDF_Application::WriterFromFormat(const TCollection_ExtendedString& theFormat)
|
||||
{
|
||||
// check map of writers
|
||||
Handle(PCDM_StorageDriver) aDriver;
|
||||
if (myWriters.Find (theFormat, aDriver))
|
||||
return aDriver;
|
||||
|
||||
// It is good if the format is in the file. Otherwise base on the extension.
|
||||
|
||||
if(theFormat.Length()==0) {
|
||||
ResourceName=UTL::Extension(aFileName);
|
||||
ResourceName+=".FileFormat";
|
||||
|
||||
if(UTL::Find(Resources(),ResourceName)) {
|
||||
theFormat=UTL::Value(Resources(),ResourceName);
|
||||
}
|
||||
else
|
||||
return Standard_False;
|
||||
// support of legacy method of loading reader as plugin
|
||||
TCollection_ExtendedString aResourceName = theFormat;
|
||||
aResourceName += ".StoragePlugin";
|
||||
if(!UTL::Find(Resources(), aResourceName))
|
||||
{
|
||||
myWriters.Bind (theFormat, aDriver);
|
||||
Standard_SStream aMsg;
|
||||
aMsg << "Could not found the resource definition:" << aResourceName <<(char)0;
|
||||
Standard_NoSuchObject::Raise(aMsg);
|
||||
}
|
||||
return FindReaderFromFormat(theFormat,thePluginId,ResourceName);
|
||||
|
||||
// Get GUID as a string.
|
||||
TCollection_ExtendedString strPluginId = UTL::Value(Resources(), aResourceName);
|
||||
|
||||
// If the GUID (as a string) contains blanks, remove them.
|
||||
if (strPluginId.Search(' ') != -1)
|
||||
strPluginId.RemoveAll(' ');
|
||||
|
||||
// Convert to GUID.
|
||||
Standard_GUID aPluginId = UTL::GUID(strPluginId);
|
||||
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
aDriver = Handle(PCDM_StorageDriver)::DownCast(Plugin::Load(aPluginId));
|
||||
}
|
||||
catch (Standard_Failure)
|
||||
{
|
||||
myWriters.Bind (theFormat, aDriver);
|
||||
myRetrievableStatus = PCDM_RS_WrongResource;
|
||||
Standard_Failure::Caught()->Reraise();
|
||||
}
|
||||
if (aDriver.IsNull())
|
||||
{
|
||||
myRetrievableStatus = PCDM_RS_WrongResource;
|
||||
}
|
||||
else
|
||||
{
|
||||
aDriver->SetFormat(theFormat);
|
||||
}
|
||||
|
||||
// record in map
|
||||
myWriters.Bind(theFormat, aDriver);
|
||||
return aDriver;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -534,30 +545,6 @@ Standard_Boolean CDF_Application::Format(const TCollection_ExtendedString& aFile
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FindReaderFromFormat
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean CDF_Application::FindReaderFromFormat(const TCollection_ExtendedString& aFormat, Standard_GUID& thePluginId, TCollection_ExtendedString& ResourceName) {
|
||||
|
||||
ResourceName=aFormat;
|
||||
ResourceName+=".RetrievalPlugin";
|
||||
|
||||
if(UTL::Find(Resources(),ResourceName)) {
|
||||
// Get GUID as a string.
|
||||
TCollection_ExtendedString strPluginId = UTL::Value(Resources(),ResourceName);
|
||||
|
||||
// If the GUID (as a string) contains blanks, remove them.
|
||||
if (strPluginId.Search(' ') != -1)
|
||||
strPluginId.RemoveAll(' ');
|
||||
|
||||
// Convert to GUID.
|
||||
thePluginId=UTL::GUID(strPluginId);
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CanRetrieve
|
||||
//purpose :
|
||||
|
@@ -17,19 +17,14 @@
|
||||
#ifndef _CDF_Application_HeaderFile
|
||||
#define _CDF_Application_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
#include <PCDM_ReaderStatus.hxx>
|
||||
#include <CDM_Application.hxx>
|
||||
#include <CDM_CanCloseStatus.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <TColStd_SequenceOfExtendedString.hxx>
|
||||
#include <CDF_TypeOfActivation.hxx>
|
||||
#include <Standard_ExtString.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_IStream.hxx>
|
||||
#include <NCollection_DataMap.hxx>
|
||||
|
||||
class Standard_NoSuchObject;
|
||||
class CDF_Session;
|
||||
@@ -38,7 +33,8 @@ class CDM_Document;
|
||||
class TCollection_ExtendedString;
|
||||
class PCDM_Reader;
|
||||
class CDM_MetaData;
|
||||
|
||||
class PCDM_RetrievalDriver;
|
||||
class PCDM_StorageDriver;
|
||||
|
||||
class CDF_Application;
|
||||
DEFINE_STANDARD_HANDLE(CDF_Application, CDM_Application)
|
||||
@@ -113,22 +109,40 @@ public:
|
||||
|
||||
Standard_EXPORT PCDM_ReaderStatus CanRetrieve (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aVersion);
|
||||
|
||||
Standard_EXPORT virtual void Formats (TColStd_SequenceOfExtendedString& Formats) = 0;
|
||||
|
||||
//! Checks status after Retrieve
|
||||
PCDM_ReaderStatus GetRetrieveStatus() const;
|
||||
PCDM_ReaderStatus GetRetrieveStatus() const { return myRetrievableStatus; }
|
||||
|
||||
Standard_EXPORT Standard_Boolean FindReader (const TCollection_ExtendedString& aFileName);
|
||||
|
||||
Standard_EXPORT Handle(PCDM_Reader) Reader (const TCollection_ExtendedString& aFileName);
|
||||
|
||||
//! Reads aDoc from standard SEEKABLE stream theIStream,
|
||||
//! the stream should support SEEK fuctionality
|
||||
Standard_EXPORT Handle(CDM_Document) Read (Standard_IStream& theIStream);
|
||||
|
||||
Standard_EXPORT Standard_Boolean FindReaderFromFormat (const TCollection_ExtendedString& aFormat);
|
||||
//! Returns instance of read driver for specified format.
|
||||
//!
|
||||
//! Default implementation uses plugin mechanism to load reader dynamically.
|
||||
//! For this to work, application resources should define GUID of
|
||||
//! the plugin as value of [Format].RetrievalPlugin, and "Plugin"
|
||||
//! resource should define name of plugin library to be loaded as
|
||||
//! value of [GUID].Location. Plugin library should provide
|
||||
//! method PLUGINFACTORY returning instance of the reader for the
|
||||
//! same GUID (see Plugin_Macro.hxx).
|
||||
//!
|
||||
//! In case if reader is not available, will raise Standard_NoSuchObject
|
||||
//! or other exception if raised by plugin loader.
|
||||
Standard_EXPORT virtual Handle(PCDM_Reader) ReaderFromFormat (const TCollection_ExtendedString& aFormat);
|
||||
|
||||
Standard_EXPORT Handle(PCDM_Reader) ReaderFromFormat (const TCollection_ExtendedString& aFormat);
|
||||
//! Returns instance of storage driver for specified format.
|
||||
//!
|
||||
//! Default implementation uses plugin mechanism to load driver dynamically.
|
||||
//! For this to work, application resources should define GUID of
|
||||
//! the plugin as value of [Format].StoragePlugin, and "Plugin"
|
||||
//! resource should define name of plugin library to be loaded as
|
||||
//! value of [GUID].Location. Plugin library should provide
|
||||
//! method PLUGINFACTORY returning instance of the reader for the
|
||||
//! same GUID (see Plugin_Macro.hxx).
|
||||
//!
|
||||
//! In case if driver is not available, will raise Standard_NoSuchObject
|
||||
//! or other exception if raised by plugin loader.
|
||||
Standard_EXPORT virtual Handle(PCDM_StorageDriver) WriterFromFormat (const TCollection_ExtendedString& aFormat);
|
||||
|
||||
//! try to retrieve a Format directly in the file or in
|
||||
//! application resource by using extension. returns
|
||||
@@ -139,9 +153,6 @@ public:
|
||||
|
||||
Standard_EXPORT Standard_Boolean SetDefaultFolder (const Standard_ExtString aFolder);
|
||||
|
||||
Standard_EXPORT Standard_ExtString DefaultExtension();
|
||||
|
||||
|
||||
friend class CDF_Session;
|
||||
|
||||
|
||||
@@ -153,7 +164,8 @@ protected:
|
||||
Standard_EXPORT CDF_Application();
|
||||
|
||||
PCDM_ReaderStatus myRetrievableStatus;
|
||||
|
||||
NCollection_DataMap<TCollection_ExtendedString, Handle(PCDM_RetrievalDriver)> myReaders;
|
||||
NCollection_DataMap<TCollection_ExtendedString, Handle(PCDM_StorageDriver)> myWriters;
|
||||
|
||||
private:
|
||||
|
||||
@@ -179,24 +191,12 @@ private:
|
||||
|
||||
Standard_EXPORT Standard_Integer DocumentVersion (const Handle(CDM_MetaData)& theMetaData) Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT Standard_Boolean FindReader (const TCollection_ExtendedString& aFileName, Standard_GUID& PluginIn, TCollection_ExtendedString& ResourceName);
|
||||
|
||||
Standard_EXPORT Standard_Boolean FindReaderFromFormat (const TCollection_ExtendedString& aFormat, Standard_GUID& PluginIn, TCollection_ExtendedString& ResourceName);
|
||||
|
||||
Standard_EXPORT CDF_TypeOfActivation TypeOfActivation (const Handle(CDM_MetaData)& aMetaData);
|
||||
|
||||
Standard_EXPORT PCDM_ReaderStatus CanRetrieve (const Handle(CDM_MetaData)& aMetaData);
|
||||
|
||||
private:
|
||||
TCollection_ExtendedString myDefaultFolder;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <CDF_Application.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _CDF_Application_HeaderFile
|
||||
|
@@ -1,18 +0,0 @@
|
||||
// Created on: 2003-06-26
|
||||
// Created by: Sergey ZARITCHNY <szy@opencascade.com>
|
||||
// Copyright (c) 2003-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.
|
||||
|
||||
inline PCDM_ReaderStatus CDF_Application::GetRetrieveStatus() const {
|
||||
return myRetrievableStatus;
|
||||
}
|
@@ -123,17 +123,9 @@ Handle(CDF_MetaDataDriver) CDF_Session::MetaDataDriver() const {
|
||||
//=======================================================================
|
||||
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;
|
||||
try {
|
||||
aFactory = Handle(CDF_MetaDataDriverFactory)::DownCast (
|
||||
Plugin::Load (Standard_GUID ("a148e300-5740-11d1-a904-080036aaa103"),
|
||||
Standard_False /*theVerbose*/));
|
||||
} catch (const Standard_Failure&) {
|
||||
}
|
||||
if (!aFactory.IsNull()) {
|
||||
myMetaDataDriver = aFactory->Build();
|
||||
} else {
|
||||
myMetaDataDriver = new CDF_FWOSDriver;
|
||||
}
|
||||
myMetaDataDriver = new CDF_FWOSDriver;
|
||||
}
|
||||
}
|
||||
|
@@ -65,34 +65,6 @@ void CDF_Store::Init() {
|
||||
myCurrentDocument = myMainDocument;
|
||||
}
|
||||
|
||||
CDF_TryStoreStatus CDF_Store::Check() {
|
||||
if(!PCDM::FindStorageDriver(myMainDocument)) return CDF_TS_NoDriver;
|
||||
|
||||
|
||||
// Checking the subcomponent.
|
||||
Handle(CDM_Document) theCurrentDocument;
|
||||
myList->Init();
|
||||
for ( myList->Init(); myList->More(); myList->Next()) {
|
||||
theCurrentDocument = myList->Value();
|
||||
|
||||
if(theCurrentDocument != myMainDocument) {
|
||||
if( theCurrentDocument->IsModified()) {
|
||||
|
||||
myLastName = theCurrentDocument->Presentation();
|
||||
|
||||
if(!PCDM::FindStorageDriver(theCurrentDocument)) return CDF_TS_NoDriver;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return CDF_TS_OK;
|
||||
}
|
||||
|
||||
|
||||
Standard_ExtString CDF_Store::LastName() const {
|
||||
return myLastName.ToExtString();
|
||||
}
|
||||
|
||||
Standard_ExtString CDF_Store::Folder() const {
|
||||
static TCollection_ExtendedString retv;
|
||||
if(myCurrentDocument->HasRequestedFolder())
|
||||
|
@@ -44,28 +44,6 @@ public:
|
||||
//! creates a store list from the document of the current selection.
|
||||
Standard_EXPORT CDF_Store(const Handle(CDM_Document)& aDocument);
|
||||
|
||||
//! Checks will make the following control. Check must be used before
|
||||
//! using Create method. Check will not be done twice by Create.
|
||||
//!
|
||||
//! 1) controls whether there is one document in the current selection.
|
||||
//! 2) controls whether there is a storage driver for the document.
|
||||
//! 3) controls whether the applicationdatatype associated with the driver
|
||||
//! exists as metadata in the metadata manager (Design Manager for example).
|
||||
//! 4) controls whether there is a storage driver for each subcomponents
|
||||
//! of the document if there are. If the control fails for a subcomponent,
|
||||
//! the control stops and name and type of this subcomponent can be get
|
||||
//! with LastName method
|
||||
//! 5) controls whether the applicationdatatype associated with the driver of
|
||||
//! each subcomponent exists as metadata in the metadata manager
|
||||
//! (Design Manager for example). If the control fails for a subcomponent,
|
||||
//! the control stops and name and type of this subcomponent can be get
|
||||
//! with LastName method
|
||||
Standard_EXPORT CDF_TryStoreStatus Check();
|
||||
|
||||
//! in the case of a subcomponent for which no storage driver exists,
|
||||
//! returns the name of the subcomponent if there is one.
|
||||
Standard_EXPORT Standard_ExtString LastName() const;
|
||||
|
||||
//! returns the folder in which the current document will be stored.
|
||||
Standard_EXPORT Standard_ExtString Folder() const;
|
||||
|
||||
@@ -181,7 +159,6 @@ private:
|
||||
Handle(CDM_Document) myCurrentDocument;
|
||||
Standard_Boolean myHasSubComponents;
|
||||
Standard_Boolean myIsMainDocument;
|
||||
TCollection_ExtendedString myLastName;
|
||||
TCollection_ExtendedString myPath;
|
||||
TCollection_ExtendedString myText;
|
||||
PCDM_StoreStatus myStatus;
|
||||
|
@@ -91,7 +91,15 @@ PCDM_StoreStatus CDF_StoreList::Store (Handle(CDM_MetaData)& aMetaData, TCollect
|
||||
Handle(CDM_Document) theDocument = myStack.First();
|
||||
if( theDocument == myMainDocument || theDocument->IsModified()) {
|
||||
|
||||
if(!PCDM::FindStorageDriver(theDocument)){
|
||||
Handle(CDF_Application) anApp = Handle(CDF_Application)::DownCast (theDocument->Application());
|
||||
if (anApp.IsNull())
|
||||
{
|
||||
Standard_Failure::Raise("Document has no application, cannot save!");
|
||||
}
|
||||
Handle(PCDM_StorageDriver) aDocumentStorageDriver =
|
||||
anApp->WriterFromFormat(theDocument->StorageFormat());
|
||||
if (aDocumentStorageDriver.IsNull())
|
||||
{
|
||||
Standard_SStream aMsg;
|
||||
aMsg <<"No storage driver does exist for this format: " << theDocument->StorageFormat() << (char)0;
|
||||
Standard_Failure::Raise(aMsg);
|
||||
@@ -105,8 +113,6 @@ PCDM_StoreStatus CDF_StoreList::Store (Handle(CDM_MetaData)& aMetaData, TCollect
|
||||
TCollection_ExtendedString theName=theMetaDataDriver->BuildFileName(theDocument);
|
||||
|
||||
CDF_Timer theTimer;
|
||||
Handle(PCDM_StorageDriver) aDocumentStorageDriver = PCDM::StorageDriver(theDocument);
|
||||
|
||||
aDocumentStorageDriver->Write(theDocument,theName);
|
||||
status = aDocumentStorageDriver->GetStoreStatus();
|
||||
|
||||
|
@@ -2,7 +2,6 @@ CDF.cxx
|
||||
CDF.hxx
|
||||
CDF_Application.cxx
|
||||
CDF_Application.hxx
|
||||
CDF_Application.lxx
|
||||
CDF_Directory.cxx
|
||||
CDF_Directory.hxx
|
||||
CDF_DirectoryIterator.cxx
|
||||
|
Reference in New Issue
Block a user