1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

108
src/CDF/CDF.cdl Executable file
View File

@@ -0,0 +1,108 @@
-- File: CDF.cdl
-- Created: Thu Aug 7 16:06:58 1997
-- Author: Jean-Louis Frenkel
-- <rmi@frilox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
package CDF
uses CDM, PCDM, TCollection, TColStd, Storage, Resource, Quantity, OSD
is
class Directory;
class DirectoryIterator;
class Session;
enumeration TypeOfActivation is TOA_New,TOA_Modified,TOA_Unchanged
end TypeOfActivation from CDF;
deferred class Application;
---Category: Store in Database related classes.
--
private class StoreList;
enumeration StoreStatus is
SS_OK,
SS_DriverFailure,
SS_WriteFailure,
SS_Failure
end StoreStatus from CDF;
---Category: Retrieve from Database related classes.
--
---Category: API for Store and retrieve
--
class Store;
enumeration TryStoreStatus is TS_OK,TS_NoCurrentDocument,TS_NoDriver,TS_NoSubComponentDriver
end TryStoreStatus;
enumeration RetrievableStatus is
RS_OK,
RS_AlreadyRetrievedAndModified,
RS_AlreadyRetrieved,
RS_UnknownDocument,
RS_NoDriver,
RS_UnknownFileDriver,
RS_WrongResource,
RS_OpenError,
RS_NoVersion,
RS_NoModel,
RS_NoSchema,
RS_NoDocument,
RS_ExtensionFailure,
RS_WrongStreamMode,
RS_FormatFailure,
RS_TypeFailure,
RS_TypeNotFoundInSchema,
RS_UnrecognizedFileFormat,
RS_MakeFailure,
RS_PermissionDenied,
RS_DriverFailure
end RetrievableStatus;
enumeration SubComponentStatus is SCS_Consistent, SCS_Unconsistent,SCS_Stored,SCS_Modified
end SubComponentStatus;
enumeration StoreSetNameStatus is
SSNS_OK,
SSNS_ReplacingAnExistentDocument,
SSNS_OpenDocument
end StoreSetNameStatus;
---Category: MetaData management
--
deferred class MetaDataDriver;
---Purpose: this class list the method that must be available for
-- a specific DBMS
exception MetaDataDriverError inherits Failure from Standard;
---Purpose: this exception is used in the deferred methods.
-- Programmer implementing such methods may use this
-- exception or any exception inheriting MetaDataDriverError.
deferred class MetaDataDriverFactory;
private class Timer;
GetLicense(anApplicationIdentifier: Integer from Standard);
IsAvailable(anApplicationIdentifier: Integer from Standard)
returns Boolean from Standard;
end CDF;

50
src/CDF/CDF.cxx Executable file
View File

@@ -0,0 +1,50 @@
// File: CDF.cxx
// Created: Wed Mar 11 11:03:45 1998
// Author: Jean-Louis Frenkel
// <rmi@frilox.paris1.matra-dtv.fr>
#include <CDF.ixx>
#include <Standard_Failure.hxx>
// Unused :
#ifdef DEB
static void CDF_CheckStatus(int LicenseStatus) {
if (LicenseStatus != 0) {
switch (LicenseStatus) {
case 1: Standard_Failure::Raise("LICENSE_unauthorized"); break;
case 2: Standard_Failure::Raise("LICENSE_wrong_data"); break;
case 3: Standard_Failure::Raise("LICENSE_max_users"); break;
case 4: Standard_Failure::Raise("LICENSE_unspecified"); break;
case 5: Standard_Failure::Raise("LICENSE_pb_init"); break;
case 6: Standard_Failure::Raise("LICENSE_unspecified"); break;
case 7: Standard_Failure::Raise("LICENSE_cantopenfile"); break;
case 8: Standard_Failure::Raise("LICENSE_connexion"); break;
case 9: Standard_Failure::Raise("LICENSE_syntaxe"); break;
default: Standard_Failure::Raise("LICENSE_unspecified"); break;
}
}
}
#endif
void static 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;
}

214
src/CDF/CDF_Application.cdl Executable file
View File

@@ -0,0 +1,214 @@
-- File: CDF_Application.cdl
-- Created: Thu Aug 7 17:47:28 1997
-- Author: Jean-Louis Frenkel
-- <rmi@frilox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
deferred class Application from CDF inherits Application from CDM
uses
ExtendedString from TCollection,
ExtendedString from TCollection,
Document from CDM,
Manager from Resource,
MetaData from CDM,
RetrievableStatus from CDF,
GUID from Standard,
Reader from PCDM,
Writer from PCDM,
TypeOfActivation from CDF,
SequenceOfExtendedString from TColStd,
CanCloseStatus from CDM,
AsciiString from TCollection
raises NoSuchObject from Standard
is
Initialize;
Load(myclass; aGUID:GUID from Standard)
returns mutable Application from CDF;
---Purpose: plugs an application.
---Category: Open closing of documents
---Purpose:
-- Open is used
-- - for opening a Document that has been created in an application
-- - for opening a Document from the database
-- - for opening a Document from a file.
-- The Open methods always add the document in the session directory and
-- calls the virtual Activate method. The document is considered to be
-- opened until Close is used. To be storable, a document must be
-- opened by an application since the application resources are
-- needed to store it.
--
--
--
--
Open(me: mutable; aDocument: Document from CDM);
---Purpose: puts the document in the current session directory
-- and calls the virtual method Activate on it.
CanClose(me: mutable; aDocument: Document from CDM)
returns CanCloseStatus from CDM;
Close(me: mutable; aDocument: Document from CDM);
---Purpose: removes the document of the current session directory
-- and closes the document;
Retrieve (me: mutable; aFolder, aName: ExtendedString from TCollection; UseStorageConfiguration: Boolean from Standard = Standard_True)
returns Document from CDM;
---Purpose: This method retrieves a document from the database.
-- If the Document references other documents which have
-- been updated, the latest version of these documents will
-- be used if {UseStorageConfiguration} is Standard_True.
-- The content of {aFolder}, {aName} and {aVersion} depends on
-- the Database Manager system. If the DBMS is only based on
-- the OS, {aFolder} is a directory and {aName} is the name of a
-- file. In this case the use of the syntax with {aVersion}
-- has no sense. For example:
--
-- Handle(CDM_Document) theDocument=myApplication->Retrieve("/home/cascade","box.dsg");
-- If the DBMS is EUCLID/Design Manager, {aFolder}, {aName}
-- have the form they have in EUCLID/Design Manager. For example:
--
-- Handle(CDM_Document) theDocument=myApplication->Retrieve("|user|cascade","box");
--
-- Since the version is not specified in this syntax, the latest wil be used.
-- A link is kept with the database through an instance of CDM_MetaData
Retrieve (me: mutable; aFolder, aName, aVersion: ExtendedString from TCollection; UseStorageConfiguration: Boolean from Standard = Standard_True)
returns Document from CDM;
---Purpose: This method retrieves a document from the database.
-- If the Document references other documents which have
-- been updated, the latest version of these documents
-- will be used if {UseStorageConfiguration} is
-- Standard_True. -- If the DBMS is only based on the
-- OS, this syntax should not be used.
--
-- If the DBMS is EUCLID/Design Manager, {aFolder}, {aName}
-- and {aVersion} have the form they have in
-- EUCLID/Design Manager. For example:
--
-- Handle(CDM_Document) theDocument=myApplication->Retrieve("|user|cascade","box","2");
-- A link is kept with the database through an instance
-- of CDM_MetaData
CanRetrieve(me: mutable; aFolder, aName: ExtendedString from TCollection)
---Purpose:
returns RetrievableStatus from CDF;
CanRetrieve(me: mutable; aFolder, aName, aVersion: ExtendedString from TCollection)
---Purpose:
returns RetrievableStatus from CDF;
Formats(me: mutable; Formats: out SequenceOfExtendedString from TColStd)
is deferred;
---Category: CurrentDocument methods.
--
GetRetrieveStatus(me) returns RetrievableStatus from CDF;
---C++: inline
---Purpose: Checks status after Retrieve
---Category: Store&Retrieve virtuals methods
Activate(me: mutable; aDocument: Document from CDM; aTypeOfActivation: TypeOfActivation from CDF)
is virtual private;
---Purpose: Informs the application that aDocument has been
-- activated. A document is activated when it is created or
-- retrieved.
-- aTypeOfActivation will be:
-- - CDF_TOA_New if the document is a new one
-- (even empty or retrieved from the database for
-- the first time).
-- - CDF_TOA_Unchanged if the document was already
-- retrieved but had no changes since the previous retrieval.
-- - CDF_TOA_Modified if the document was already
-- retrieved and modified since the previous retrieval.
-- You do not need to call <Activate>, but you should redefine
-- this method to implement application specific behavior.
---Category: methods to get storage/retrieval driver.
--
--
FindReader(me: mutable; aFileName: ExtendedString from TCollection)
returns Boolean from Standard;
Reader(me: mutable; aFileName: ExtendedString from TCollection)
returns Reader from PCDM
raises NoSuchObject from Standard;
FindReaderFromFormat(me: mutable; aFormat: ExtendedString from TCollection)
returns Boolean from Standard;
ReaderFromFormat(me: mutable; aFormat: ExtendedString from TCollection)
returns Reader from PCDM
raises NoSuchObject from Standard;
---Purpose:
Format (me : mutable; aFileName : ExtendedString from TCollection;
theFormat : out ExtendedString from TCollection)
---Purpose: try to retrieve a Format directly in the file or in
-- application resource by using extension. returns
-- True if found;
returns Boolean from Standard;
---Category: Default Storage folder
--
DefaultFolder(me: mutable) returns ExtString from Standard;
SetDefaultFolder(me: mutable; aFolder: ExtString from Standard)
returns Boolean from Standard;
DefaultExtension(me: mutable) returns ExtString from Standard;
---Category: private methods
Retrieve(me: mutable; aMetaData: MetaData from CDM; UseStorageConfiguration: Boolean from Standard)
returns mutable Document from CDM
is private;
Retrieve(me: mutable; aMetaData: MetaData from CDM; UseStorageConfiguration: Boolean from Standard; IsComponent: Boolean from Standard)
returns mutable Document from CDM
is private;
DocumentVersion(me: mutable; theMetaData: MetaData from CDM)
returns Integer from Standard
is private;
FindReader(me: mutable; aFileName: ExtendedString from TCollection; PluginIn: out GUID from Standard; ResourceName: out ExtendedString from TCollection)
returns Boolean from Standard
is private;
FindReaderFromFormat(me: mutable; aFormat: ExtendedString from TCollection; PluginIn: out GUID from Standard; ResourceName: out ExtendedString from TCollection)
returns Boolean from Standard
is private;
TypeOfActivation(me: mutable; aMetaData: MetaData from CDM)
returns TypeOfActivation from CDF
is private;
CanRetrieve(me: mutable; aMetaData: MetaData from CDM)
returns RetrievableStatus from CDF
is private;
fields
myDefaultFolder: ExtendedString from TCollection;
myRetrievableStatus : RetrievableStatus from CDF is protected;
friends
class Session from CDF--,
--class CheckDocumentToStore from CDF
end Application from CDF;

548
src/CDF/CDF_Application.cxx Executable file
View File

@@ -0,0 +1,548 @@
// File: CDF_Application.cxx
// Created: Fri Aug 8 07:49:46 1997
// Author: Jean-Louis Frenkel
// <rmi@frilox.paris1.matra-dtv.fr>
// Modified by rmi, Wed Jan 14 08:17:35 1998
#include <CDF_Application.ixx>
#include <Standard_ErrorHandler.hxx>
#include <TCollection_ExtendedString.hxx>
#include <Standard_ProgramError.hxx>
#include <Standard_GUID.hxx>
#include <CDM_MetaData.hxx>
#include <CDM_CanCloseStatus.hxx>
#include <CDF_Session.hxx>
#include <CDF_Directory.hxx>
#include <CDF_MetaDataDriver.hxx>
#include <CDF_RetrievableStatus.hxx>
#include <PCDM_ReadWriter.hxx>
#include <PCDM_RetrievalDriver.hxx>
#include <PCDM_StorageDriver.hxx>
#include <PCDM_ReaderStatus.hxx>
#include <Plugin.hxx>
#include <UTL.hxx>
#include <CDF_Timer.hxx>
#define theMetaDataDriver CDF_Session::CurrentSession()->MetaDataDriver()
//=======================================================================
//function :
//purpose :
//=======================================================================
CDF_Application::CDF_Application():myRetrievableStatus(CDF_RS_OK) {}
//=======================================================================
//function : Load
//purpose :
//=======================================================================
Handle(CDF_Application) CDF_Application::Load(const Standard_GUID& aGUID) {
return Handle(CDF_Application)::DownCast(Plugin::Load(aGUID));
}
//=======================================================================
//function : Open
//purpose :
//=======================================================================
void CDF_Application::Open(const Handle(CDM_Document)& aDocument) {
CDF_Session::CurrentSession()->Directory()->Add(aDocument);
aDocument->Open(this);
Activate(aDocument,CDF_TOA_New);
}
//=======================================================================
//function : CanClose
//purpose :
//=======================================================================
CDM_CanCloseStatus CDF_Application::CanClose(const Handle(CDM_Document)& aDocument) {
return aDocument->CanClose();
}
//=======================================================================
//function : Close
//purpose :
//=======================================================================
void CDF_Application::Close(const Handle(CDM_Document)& aDocument) {
CDF_Session::CurrentSession()->Directory()->Remove(aDocument);
aDocument->Close();
}
//=======================================================================
//function : Retrieve
//purpose :
//=======================================================================
Handle(CDM_Document) CDF_Application::Retrieve(const TCollection_ExtendedString& aFolder,
const TCollection_ExtendedString& aName,
const Standard_Boolean UseStorageConfiguration) {
TCollection_ExtendedString nullVersion;
return Retrieve(aFolder,aName,nullVersion,UseStorageConfiguration);
}
//=======================================================================
//function : Retrieve
//purpose :
//=======================================================================
Handle(CDM_Document) CDF_Application::Retrieve(const TCollection_ExtendedString& aFolder,
const TCollection_ExtendedString& aName,
const TCollection_ExtendedString& aVersion,
const Standard_Boolean UseStorageConfiguration) {
#ifdef DEB
CDF_Timer theTimer;
#endif
Handle(CDM_MetaData) theMetaData;
if(aVersion.Length() == 0)
theMetaData=theMetaDataDriver->MetaData(aFolder,aName);
else
theMetaData=theMetaDataDriver->MetaData(aFolder,aName,aVersion);
#ifdef DEB
theTimer.ShowAndRestart("Getting MetaData: ");
#endif
CDF_TypeOfActivation theTypeOfActivation=TypeOfActivation(theMetaData);
Handle(CDM_Document) theDocument=Retrieve(theMetaData,UseStorageConfiguration,Standard_False);
#ifdef DEB
theTimer.ShowAndRestart("Creating Transient: ");
#endif
CDF_Session::CurrentSession()->Directory()->Add(theDocument);
Activate(theDocument,theTypeOfActivation);
#ifdef DEB
theTimer.ShowAndStop("Activate: ");
#endif
theDocument->Open(this);
return theDocument;
}
//=======================================================================
//function : CanRetrieve
//purpose :
//=======================================================================
CDF_RetrievableStatus CDF_Application::CanRetrieve(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName) {
TCollection_ExtendedString aVersion;
return CanRetrieve(aFolder,aName,aVersion);
}
//=======================================================================
//function : CanRetrieve
//purpose :
//=======================================================================
CDF_RetrievableStatus CDF_Application::CanRetrieve(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aVersion) {
#ifdef DEB
CDF_Timer theTimer;
#endif
if (!theMetaDataDriver->Find(aFolder,aName,aVersion))
return CDF_RS_UnknownDocument;
else if (!theMetaDataDriver->HasReadPermission(aFolder,aName,aVersion))
return CDF_RS_PermissionDenied;
else {
#ifdef DEB
theTimer.ShowAndRestart("theMetaDataDriver->Find: ");
#endif
Handle(CDM_MetaData) theMetaData = theMetaDataDriver->MetaData(aFolder,aName,aVersion);
#ifdef DEB
theTimer.ShowAndStop("Getting MetaData: ");
#endif
if(theMetaData->IsRetrieved()) {
return theMetaData->Document()->IsModified()
? CDF_RS_AlreadyRetrievedAndModified : CDF_RS_AlreadyRetrieved;
}
else {
TCollection_ExtendedString theFileName=theMetaData->FileName();
TCollection_ExtendedString theFormat=PCDM_ReadWriter::FileFormat(theFileName);
if(theFormat.Length()==0) {
TCollection_ExtendedString ResourceName=UTL::Extension(theFileName);
ResourceName+=".FileFormat";
if(UTL::Find(Resources(),ResourceName)) {
theFormat=UTL::Value(Resources(),ResourceName);
}
else
return CDF_RS_UnrecognizedFileFormat;
}
if(!FindReaderFromFormat(theFormat)) return CDF_RS_NoDriver;
}
}
return CDF_RS_OK;
}
//=======================================================================
//function : Activate
//purpose :
//=======================================================================
//void CDF_Application::Activate(const Handle(CDM_Document)& aDocument,const CDF_TypeOfActivation aTypeOfActivation) {
void CDF_Application::Activate(const Handle(CDM_Document)& ,const CDF_TypeOfActivation ) {
}
//=======================================================================
//function : DefaultFolder
//purpose :
//=======================================================================
Standard_ExtString CDF_Application::DefaultFolder(){
if(myDefaultFolder.Length() == 0) {
myDefaultFolder=CDF_Session::CurrentSession()->MetaDataDriver()->DefaultFolder();
}
return myDefaultFolder.ToExtString();
}
//=======================================================================
//function : SetDefaultFolder
//purpose :
//=======================================================================
Standard_Boolean CDF_Application::SetDefaultFolder(const Standard_ExtString aFolder) {
Standard_Boolean found = CDF_Session::CurrentSession()->MetaDataDriver()->FindFolder(aFolder);
if(found) myDefaultFolder=aFolder;
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 :
//=======================================================================
Handle(CDM_Document) CDF_Application::Retrieve(const Handle(CDM_MetaData)& aMetaData,const Standard_Boolean UseStorageConfiguration) {
return Retrieve(aMetaData,UseStorageConfiguration,Standard_True);
}
//=======================================================================
//function : ConvertStatus
//purpose :
//=======================================================================
static CDF_RetrievableStatus ConvertStatus(const PCDM_ReaderStatus theStatus) {
CDF_RetrievableStatus aStatus;
switch(theStatus) {
case PCDM_RS_OK:
aStatus=CDF_RS_OK;
break;
case PCDM_RS_NoDriver:
aStatus=CDF_RS_NoDriver;
break;
case PCDM_RS_UnknownFileDriver:
aStatus=CDF_RS_UnknownFileDriver;
break;
case PCDM_RS_OpenError:
aStatus=CDF_RS_OpenError;
break;
case PCDM_RS_NoVersion:
aStatus=CDF_RS_NoVersion;
break;
case PCDM_RS_NoSchema:
aStatus=CDF_RS_NoSchema;
break;
case PCDM_RS_NoDocument:
aStatus=CDF_RS_NoDocument;
break;
case PCDM_RS_ExtensionFailure:
aStatus=CDF_RS_ExtensionFailure;
break;
case PCDM_RS_WrongStreamMode:
aStatus=CDF_RS_WrongStreamMode;
break;
case PCDM_RS_FormatFailure:
aStatus=CDF_RS_FormatFailure;
break;
case PCDM_RS_TypeFailure:
aStatus=CDF_RS_TypeFailure;
break;
case PCDM_RS_TypeNotFoundInSchema:
aStatus=CDF_RS_TypeNotFoundInSchema;
break;
case PCDM_RS_UnrecognizedFileFormat:
aStatus=CDF_RS_UnrecognizedFileFormat;
break;
case PCDM_RS_MakeFailure:
aStatus=CDF_RS_MakeFailure;
break;
case PCDM_RS_PermissionDenied:
aStatus=CDF_RS_PermissionDenied;
break;
default:
aStatus=CDF_RS_DriverFailure;
}
return aStatus;
}
//=======================================================================
//function : Retrieve
//purpose :
//=======================================================================
Handle(CDM_Document) CDF_Application::Retrieve(const Handle(CDM_MetaData)& aMetaData,const Standard_Boolean UseStorageConfiguration, const Standard_Boolean IsComponent) {
Handle(CDM_Document) theDocumentToReturn;
myRetrievableStatus = CDF_RS_DriverFailure;
if(IsComponent) {
Standard_SStream aMsg;
switch (CanRetrieve(aMetaData)) {
case CDF_RS_UnknownDocument:
aMsg << "could not find the referenced document: " << aMetaData->Path() << "; not found." <<(char)0 << endl;
myRetrievableStatus = CDF_RS_UnknownDocument;
Standard_Failure::Raise(aMsg);
break;
case CDF_RS_PermissionDenied:
aMsg << "Could not find the referenced document: " << aMetaData->Path() << "; permission denied. " <<(char)0 << endl;
myRetrievableStatus = CDF_RS_PermissionDenied;
Standard_Failure::Raise(aMsg);
break;
default:
break;
}
}
Standard_Boolean AlreadyRetrieved=aMetaData->IsRetrieved();
if(AlreadyRetrieved) myRetrievableStatus = CDF_RS_AlreadyRetrieved;
Standard_Boolean Modified=AlreadyRetrieved && aMetaData->Document()->IsModified();
if(Modified) myRetrievableStatus = CDF_RS_AlreadyRetrievedAndModified;
if(!AlreadyRetrieved || Modified) {
Handle(PCDM_Reader) theReader=Reader(aMetaData->FileName());
Handle(CDM_Document) theDocument;
if(Modified) {
theDocument=aMetaData->Document();
theDocument->RemoveAllReferences();
}
else
theDocument=theReader->CreateDocument();
SetReferenceCounter(theDocument,PCDM_RetrievalDriver::ReferenceCounter(aMetaData->FileName(), MessageDriver()));
SetDocumentVersion(theDocument,aMetaData);
theMetaDataDriver->ReferenceIterator()->LoadReferences(theDocument,aMetaData,this,UseStorageConfiguration);
try {
OCC_CATCH_SIGNALS
theReader->Read(aMetaData->FileName(),theDocument,this);
}
catch (Standard_Failure) {
PCDM_ReaderStatus aStatus = theReader->GetStatus();
myRetrievableStatus = ConvertStatus(aStatus);
if(myRetrievableStatus > CDF_RS_AlreadyRetrieved){
Standard_SStream aMsg;
aMsg << Standard_Failure::Caught() << endl;
Standard_Failure::Raise(aMsg);
}
}
PCDM_ReaderStatus aStatus = theReader->GetStatus();
myRetrievableStatus = ConvertStatus(aStatus);
theDocument->SetMetaData(aMetaData);
theDocumentToReturn=theDocument;
}
else
theDocumentToReturn=aMetaData->Document();
return theDocumentToReturn;
}
//=======================================================================
//function : DocumentVersion
//purpose :
//=======================================================================
Standard_Integer CDF_Application::DocumentVersion(const Handle(CDM_MetaData)& theMetaData) {
// const Handle(CDM_MessageDriver)& aMsgDriver = MessageDriver();
return PCDM_RetrievalDriver::DocumentVersion(theMetaData->FileName(), MessageDriver());
}
//=======================================================================
//function : TypeOfActivation
//purpose :
//=======================================================================
CDF_TypeOfActivation CDF_Application::TypeOfActivation(const Handle(CDM_MetaData)& aMetaData) {
if(aMetaData->IsRetrieved()) {
Handle(CDM_Document) theDocument=aMetaData->Document();
if(theDocument->IsOpened()) {
if(theDocument->IsModified())
return CDF_TOA_Modified;
else
return CDF_TOA_Unchanged;
}
else
return CDF_TOA_New;
}
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 : 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)) {
Standard_SStream aMsg;
aMsg << "Could not found the item:" << UnfoundResourceName <<(char)0;
myRetrievableStatus = CDF_RS_WrongResource;
Standard_NoSuchObject::Raise(aMsg);
}
Handle(PCDM_Reader) R;
try {
OCC_CATCH_SIGNALS
R = Handle(PCDM_Reader)::DownCast(Plugin::Load(thePluginId));
}
catch (Standard_Failure) {
myRetrievableStatus = CDF_RS_WrongResource;
Standard_SStream aMsg;
aMsg << Standard_Failure::Caught() << endl;
Standard_Failure::Raise(aMsg);
}
Handle(PCDM_RetrievalDriver) RD = Handle(PCDM_RetrievalDriver)::DownCast(R);
if (!RD.IsNull()) {
RD->SetFormat(aFormat);
return RD;
} else
myRetrievableStatus = CDF_RS_WrongResource;
return R;
}
//=======================================================================
//function : FindReader
//purpose :
//=======================================================================
Standard_Boolean CDF_Application::FindReader(const TCollection_ExtendedString& aFileName, Standard_GUID& thePluginId, TCollection_ExtendedString& ResourceName) {
TCollection_ExtendedString theFormat=PCDM_ReadWriter::FileFormat(aFileName);
// Si le format est dans le fichier, tant mieux. Sinon on se base sur l'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;
}
return FindReaderFromFormat(theFormat,thePluginId,ResourceName);
}
//=======================================================================
//function : Format
//purpose : dp
//=======================================================================
Standard_Boolean CDF_Application::Format(const TCollection_ExtendedString& aFileName,
TCollection_ExtendedString& theFormat)
{
theFormat = PCDM_ReadWriter::FileFormat(aFileName);
// Si le format est dans le fichier, tant mieux. Sinon on se base sur l'extension.
if(theFormat.Length()==0) {
TCollection_ExtendedString ResourceName;
ResourceName=UTL::Extension(aFileName);
ResourceName+=".FileFormat";
if(UTL::Find(Resources(),ResourceName)) {
theFormat = UTL::Value(Resources(),ResourceName);
}
else return Standard_False;
}
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)) {
thePluginId=UTL::GUID(UTL::Value(Resources(),ResourceName));
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : CanRetrieve
//purpose :
//=======================================================================
CDF_RetrievableStatus CDF_Application::CanRetrieve(const Handle(CDM_MetaData)& aMetaData) {
if(aMetaData->HasVersion())
return CanRetrieve(aMetaData->Folder(),aMetaData->Name(),aMetaData->Version());
else
return CanRetrieve(aMetaData->Folder(),aMetaData->Name());
}

28
src/CDF/CDF_Application.lxx Executable file
View File

@@ -0,0 +1,28 @@
// File: CDF_Application.lxx
// Created: Thu Jun 26 15:44:40 2003
// Author: Sergey ZARITCHNY <szy@opencascade.com>
// Copyright: Open CASCADE 2003
// const static char sccsid[] = "%Z% 5.0-20-%L%, $Date: 2003-07-17 20:53:37 $%Z%";
// Lastly modified by :
// +---------------------------------------------------------------------------+
// ! szy ! Creation !26-06-2003! 5.0-20-%L%!
// +---------------------------------------------------------------------------+
inline CDF_RetrievableStatus CDF_Application::GetRetrieveStatus() const {
return myRetrievableStatus;
}
// @@SDM: begin
// Copyright Open CASCADE......................................Version 5.0-20
// Lastly modified by : szy Date : 26-06-2003
// File history synopsis (creation,modification,correction)
// +---------------------------------------------------------------------------+
// ! Developer ! Comments ! Date ! Version !
// +-----------!-----------------------------------------!----------!----------+
// ! szy ! Creation !26-06-2003! 5.0-20-%L%!
// +---------------------------------------------------------------------------+
// @@SDM: end

68
src/CDF/CDF_Directory.cdl Executable file
View File

@@ -0,0 +1,68 @@
-- File: CDF_Directory.cdl
-- Created: Thu Aug 7 16:57:46 1997
-- Author: Jean-Louis Frenkel
-- <rmi@frilox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class Directory from CDF inherits Transient from Standard
---Purpose: A directory is a collection of documents. There is only one instance
-- of a given document in a directory.
-- put.
uses Document from CDM, ListOfDocument from CDM
raises NoSuchObject
is
Create
returns mutable Directory from CDF;
---Purpose: Creates an empty directory.
Add(me:mutable; aDocument: Document from CDM);
---Purpose: adds a document into the directory.
Remove(me: mutable; aDocument: Document from CDM);
---Purpose: removes the document.
---Category: Inquire Methods
--
Contains(me; aDocument: Document from CDM)
---Purpose: Returns true if the document aDocument is in the directory
returns Boolean from Standard
is static;
Last(me:mutable) returns Document from CDM
---Purpose: returns the last document (if any) which has been added
-- in the directory.
raises NoSuchObject from Standard
---Warning: if the directory is empty.
is static;
Length(me) returns Integer from Standard
---Purpose: returns the number of documents of the directory.
is static;
IsEmpty(me) returns Boolean from Standard
---Purpose: returns true if the directory is empty.
is static;
---Category: Private methods
List(me) returns ListOfDocument from CDM
is static private;
---C++: return const &
--
fields
myDocuments: ListOfDocument from CDM;
friends
class DirectoryIterator from CDF
end Directory from CDF;

58
src/CDF/CDF_Directory.cxx Executable file
View File

@@ -0,0 +1,58 @@
// File: CDF_Directory.cxx
// Created: Thu Aug 7 17:05:01 1997
// Author: Jean-Louis Frenkel
// <rmi@frilox.paris1.matra-dtv.fr>
#include <CDF_Directory.ixx>
#include <CDM_ListIteratorOfListOfDocument.hxx>
#include <Standard_NoSuchObject.hxx>
CDF_Directory::CDF_Directory () {}
void CDF_Directory::Add(const Handle(CDM_Document)& aDocument) {
if(!Contains(aDocument)) myDocuments.Append(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)
myDocuments.Remove(it);
else
it.Next();
}
}
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();
}
return found;
}
Standard_Integer CDF_Directory::Length() const {
return myDocuments.Extent();
}
const CDM_ListOfDocument& CDF_Directory::List() const {
return myDocuments;
}
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

@@ -0,0 +1,40 @@
-- File: CDF_DirectoryIterator.cdl
-- Created: Wed Aug 13 13:53:20 1997
-- Author: Jean-Louis Frenkel
-- <rmi@frilox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class DirectoryIterator from CDF
uses
Directory from CDF,
Document from CDM,
ListIteratorOfListOfDocument from CDM
raises
NoSuchObject from Standard
is
Create
returns DirectoryIterator from CDF;
---Purpose: creates an Iterator with the directory
-- of the current CDF.
Create(aDirectory: Directory from CDF)
returns DirectoryIterator from CDF;
MoreDocument (me: in out) returns Boolean from Standard;
---Purpose : Returns True if there are more entries to return
NextDocument (me: in out);
---Purpose : Go to the next entry
-- (if there is not, Value will raise an exception)
Document (me: in out) returns Document from CDM
---Purpose : Returns item value of current entry
raises NoSuchObject from Standard;
fields
myIterator: ListIteratorOfListOfDocument from CDM;
end DirectoryIterator from CDF;

View File

@@ -0,0 +1,29 @@
// File: CDF_DirectoryIterator.cxx
// Created: Wed Aug 13 13:55:19 1997
// Author: Jean-Louis Frenkel
// <rmi@frilox.paris1.matra-dtv.fr>
#include <CDF_DirectoryIterator.ixx>
#include <CDF_Session.hxx>
CDF_DirectoryIterator::CDF_DirectoryIterator():myIterator(CDF_Session::CurrentSession()->Directory()->List()) {}
CDF_DirectoryIterator::CDF_DirectoryIterator(const Handle(CDF_Directory)& aDirectory):myIterator(aDirectory->List()) {}
Standard_Boolean CDF_DirectoryIterator::MoreDocument() {
return myIterator.More() ;
}
void CDF_DirectoryIterator::NextDocument() {
myIterator.Next();
}
Handle(CDM_Document) CDF_DirectoryIterator::Document() {
return myIterator.Value();
}

136
src/CDF/CDF_MetaDataDriver.cdl Executable file
View File

@@ -0,0 +1,136 @@
-- File: CDF_MetaDataDriver.cdl
-- Created: Mon Nov 17 16:41:35 1997
-- Author: Jean-Louis Frenkel
-- <rmi@frilox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
deferred class MetaDataDriver from CDF inherits Transient from Standard
uses
Document from CDM, MetaData from CDM,
ExtendedString from TCollection,
ReferenceIterator from PCDM
raises
NotImplemented from Standard
is
Initialize;
---Category: virtual methods
HasVersionCapability(me: mutable)
---Purpose: returns true if the MetaDataDriver can manage different
-- versions of a Data.
-- By default, returns Standard_False.
returns Boolean from Standard
is virtual;
CreateDependsOn(me: mutable; aFirstData: MetaData from CDM;
aSecondData: MetaData from CDM)
---Purpose: Creates a "Depends On" relation between two Datas.
-- By default does nothing
is virtual;
CreateReference(me: mutable; aFrom, aTo: MetaData from CDM; aReferenceIdentifier: Integer from Standard; aToDocumentVersion: Integer from Standard)
is virtual;
HasVersion(me: mutable; aFolder, aName: ExtendedString from TCollection)
returns Boolean from Standard
---Purpose: by default return Standard_True.
is virtual;
BuildFileName(me: mutable; aDocument: Document from CDM)
returns ExtendedString from TCollection
is deferred;
SetName(me: mutable; aDocument: Document from CDM; aName: ExtendedString from TCollection)
returns ExtendedString from TCollection
is virtual;
---Purpose: this methods is usefull if the name of an object --
-- depends on the metadatadriver. For example a Driver
-- -- based on the operating system can choose to add
-- the extension of file to create to the object.
---Category: Deferred methods
---Overview: inquiring can be made either using a folder, a name and eventually
-- a version
-- or a path which is the concatenation of a folder, a name and eventually
-- a version.
Find(me: mutable; aFolder, aName, aVersion: ExtendedString from TCollection)
returns Boolean from Standard
---Purpose: should indicate whether meta-data exist in the DBMS corresponding
-- to the Data.
-- aVersion may be NULL;
is deferred;
HasReadPermission(me: mutable; aFolder, aName, aVersion: ExtendedString from TCollection)
returns Boolean from Standard
is deferred;
MetaData(me: mutable; aFolder, aName, aVersion: ExtendedString from TCollection)
returns MetaData from CDM
---Purpose: should return the MetaData stored in the DBMS with the meta-data
-- corresponding to the Data. If the MetaDataDriver has version management capabilities
-- the version has to be set in the returned MetaData.
-- aVersion may be NULL
-- MetaData is called by GetMetaData
-- If the version is set to NULL, MetaData should return
-- the last version of the metadata
is deferred;
LastVersion(me: mutable; aMetaData: MetaData from CDM)
returns MetaData from CDM
is virtual;
---Purpose: by default returns aMetaDATA
-- MetaData(me: mutable; aPath: ExtendedString from TCollection)
-- returns MetaData from CDM
---Purpose: should return the MetaData stored in the DBMS with the meta-data
-- corresponding to the path. If the MetaDataDriver has version management capabilities
-- the version has to be set in the returned MetaData.
-- MetaData is called by GetMetaData
-- If the version is not included in the path , MetaData should return
-- the last version of the metadata
-- is deferred;
CreateMetaData(me: mutable; aDocument: Document from CDM;
aFileName: ExtendedString from TCollection)
---Purpose: should create meta-data corresponding to aData and maintaining a meta-link
-- between these meta-data and aFileName
-- CreateMetaData is called by CreateData
returns MetaData from CDM
---Purpose: If the metadata-driver
-- has version capabilities, version must be set in the returned Data.
is deferred;
FindFolder(me: mutable; aFolder: ExtendedString from TCollection)
returns Boolean from Standard
is deferred;
DefaultFolder(me: mutable) returns ExtendedString from TCollection
is deferred;
---Category: methods about references.
ReferenceIterator(me: mutable)
returns ReferenceIterator from PCDM
is virtual;
Find(me: mutable; aFolder, aName: ExtendedString from TCollection)
returns Boolean from Standard;
---Purpose: calls Find with an empty version
MetaData(me: mutable; aFolder, aName: ExtendedString from TCollection)
returns MetaData from CDM;
---Purpose: calls MetaData with an empty version
end MetaDataDriver from CDF;

98
src/CDF/CDF_MetaDataDriver.cxx Executable file
View File

@@ -0,0 +1,98 @@
// File: CDF_MetaDataDriver.cxx
// Created: Mon Nov 17 16:53:25 1997
// Author: Jean-Louis Frenkel
// <rmi@frilox.paris1.matra-dtv.fr>
#include <CDF_MetaDataDriver.ixx>
#include <CDF_Application.hxx>
#include <CDF_Session.hxx>
//=======================================================================
//function : CDF_MetaDataDriver
//purpose :
//=======================================================================
CDF_MetaDataDriver::CDF_MetaDataDriver() {}
//=======================================================================
//function : HasVersion
//purpose :
//=======================================================================
Standard_Boolean CDF_MetaDataDriver::HasVersion(const TCollection_ExtendedString& ,const TCollection_ExtendedString& ) {
return Standard_True;
}
//=======================================================================
//function : HasVersionCapability
//purpose :
//=======================================================================
//=======================================================================
//function : HasVersionCapability
//purpose :
//=======================================================================
Standard_Boolean CDF_MetaDataDriver::HasVersionCapability() {
return Standard_False;
}
//=======================================================================
//function : CreateDependsOn
//purpose :
//=======================================================================
void CDF_MetaDataDriver::CreateDependsOn(const Handle(CDM_MetaData)& ,
const Handle(CDM_MetaData)& ) {}
//=======================================================================
//function : CreateReference
//purpose :
//=======================================================================
void CDF_MetaDataDriver::CreateReference(const Handle(CDM_MetaData)& ,const Handle(CDM_MetaData)& , const Standard_Integer , const Standard_Integer ) {}
//=======================================================================
//function : ReferenceIterator
//purpose :
//=======================================================================
Handle(PCDM_ReferenceIterator) CDF_MetaDataDriver::ReferenceIterator() {
return new PCDM_ReferenceIterator(CDF_Session::CurrentSession()->CurrentApplication()->MessageDriver());
}
//=======================================================================
//function : Find
//purpose :
//=======================================================================
Standard_Boolean CDF_MetaDataDriver::Find(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName) {
TCollection_ExtendedString aVersion;
return Find(aFolder,aName,aVersion);
}
//=======================================================================
//function : MetaData
//purpose :
//=======================================================================
Handle(CDM_MetaData) CDF_MetaDataDriver::MetaData(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName) {
TCollection_ExtendedString aVersion;
return MetaData(aFolder,aName,aVersion);
}
//=======================================================================
//function : LastVersion
//purpose :
//=======================================================================
Handle(CDM_MetaData) CDF_MetaDataDriver::LastVersion(const Handle(CDM_MetaData)& aMetaData) {
return aMetaData;
}
//=======================================================================
//function : SetName
//purpose :
//=======================================================================
TCollection_ExtendedString CDF_MetaDataDriver::SetName(const Handle(CDM_Document)& , const TCollection_ExtendedString& aName) {
return aName;
}

View File

@@ -0,0 +1,15 @@
-- File: CDF_MetaDataDriverFactory.cdl
-- Created: Mon Nov 17 16:43:20 1997
-- Author: Jean-Louis Frenkel
-- <rmi@frilox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
deferred class MetaDataDriverFactory from CDF inherits Transient from Standard
uses MetaDataDriver from CDF, ExtendedString from TCollection
is
Build(me)
returns MetaDataDriver from CDF
is deferred;
end MetaDataDriverFactory from CDF;

View File

@@ -0,0 +1,7 @@
// File: CDF_MetaDataDriverFactory.cxx
// Created: Mon Nov 17 16:52:26 1997
// Author: Jean-Louis Frenkel
// <rmi@frilox.paris1.matra-dtv.fr>
#include <CDF_MetaDataDriverFactory.ixx>

65
src/CDF/CDF_Session.cdl Executable file
View File

@@ -0,0 +1,65 @@
-- File: CDF_Session.cdl
-- Created: Thu Aug 7 17:28:05 1997
-- Author: Jean-Louis Frenkel
-- <rmi@frilox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class Session from CDF inherits Transient from Standard
uses
Directory from CDF,
ExtendedString from TCollection,
Application from CDF,
MetaDataDriver from CDF,
Writer from PCDM
raises
NoSuchObject from Standard,MultiplyDefined from Standard
is
Create returns mutable Session from CDF
raises MultiplyDefined from Standard;
Exists(myclass)
--- Purpose: returns true if a session has been created.
returns Boolean from Standard;
CurrentSession(myclass) returns mutable Session from CDF;
---Purpose: returns the only one instance of Session
-- that has been created.
Directory(me) returns mutable Directory from CDF;
---Purpose: returns the directory of the session;
---Level: Public
---Category: current application management
HasCurrentApplication(me) returns Boolean from Standard;
CurrentApplication(me) returns mutable Application from CDF
raises NoSuchObject from Standard;
SetCurrentApplication(me: mutable; anApplication: Application from CDF);
UnsetCurrentApplication(me: mutable);
---Category: database related methods
MetaDataDriver(me) returns MetaDataDriver from CDF
raises NoSuchObject from Standard;
LoadDriver(me: mutable);
fields
myDirectory : Directory from CDF;
myCurrentApplication : Application from CDF;
myHasCurrentApplication: Boolean from Standard;
myMetaDataDriver : MetaDataDriver from CDF;
friends
class Application from CDF
end Session from CDF;

106
src/CDF/CDF_Session.cxx Executable file
View File

@@ -0,0 +1,106 @@
// File: CDF_Session.cxx
// Created: Fri Aug 8 11:04:07 1997
// Author: Jean-Louis Frenkel
// <rmi@frilox.paris1.matra-dtv.fr>
#include <CDF_Session.ixx>
#include <TCollection_ExtendedString.hxx>
#include <CDF_MetaDataDriverFactory.hxx>
#include <Plugin.hxx>
#include <Standard_GUID.hxx>
#include <PCDM.hxx>
#include <PCDM_Reader.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
static Handle(CDF_Session) CS;
//=======================================================================
//function :
//purpose :
//=======================================================================
CDF_Session::CDF_Session () : myHasCurrentApplication(Standard_False)
{
Standard_MultiplyDefined_Raise_if(!CS.IsNull()," a session already exists");
myDirectory = new CDF_Directory();
CS = this;
}
//=======================================================================
//function : Exists
//purpose :
//=======================================================================
Standard_Boolean CDF_Session::Exists() {
return !CS.IsNull();
}
//=======================================================================
//function : Directory
//purpose :
//=======================================================================
Handle(CDF_Directory) CDF_Session::Directory() const {
return CS->myDirectory;
}
//=======================================================================
//function : CurrentSession
//purpose :
//=======================================================================
Handle(CDF_Session) CDF_Session::CurrentSession() {
Standard_NoSuchObject_Raise_if(CS.IsNull(), "no session has been created");
return CS;
}
//=======================================================================
//function : HasCurrentApplication
//purpose :
//=======================================================================
Standard_Boolean CDF_Session::HasCurrentApplication() const {
return myHasCurrentApplication;
}
//=======================================================================
//function : CurrentApplication
//purpose :
//=======================================================================
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() {
myMetaDataDriver=Handle(CDF_MetaDataDriverFactory)::DownCast(Plugin::Load(Standard_GUID("a148e300-5740-11d1-a904-080036aaa103")))->Build();
}

187
src/CDF/CDF_Store.cdl Executable file
View File

@@ -0,0 +1,187 @@
-- File: CDF_Store.cdl
-- Created: Mon Nov 13 10:46:37 1995
-- Author: Jean-Louis Frenkel
-- <rmi@pernox>
---Copyright: Matra Datavision 1995
class Store from CDF
uses Document from CDM,
TryStoreStatus from CDF,
StoreSetNameStatus from CDF,
SubComponentStatus from CDF,
ExtendedString from TCollection,
StoreList from CDF,
StoreStatus from CDF,
ExtendedString from TCollection
is
Create is private;
Create (aDocument: Document from CDM)
returns Store from CDF;
---Purpose: creates a store list from the document of the current selection.
--
---Category: Checks methods
--
Check(me: in out)
---Purpose: 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
--
returns TryStoreStatus from CDF;
LastName(me) returns ExtString from Standard;
---Purpose: in the case of a subcomponent for which no storage driver exists,
-- returns the name of the subcomponent if there is one.
---Category: Inquire Methods
--
-- The store list contains one or more documents. One of them is the current document.
--
Folder(me)
returns ExtString from Standard;
---Purpose: returns the folder in which the current document will be stored.
Name(me) returns ExtString from Standard;
---Purpose: returns the name under which the current document will be stored
IsStored(me) returns Boolean from Standard;
---Purpose: returns true if the current document is already stored
IsModified(me) returns Boolean from Standard;
CurrentIsConsistent(me) returns Boolean from Standard;
IsConsistent(me) returns Boolean from Standard;
HasAPreviousVersion(me) returns Boolean from Standard;
PreviousVersion(me) returns ExtString from Standard;
IsMainDocument(me) returns Boolean from Standard;
---Purpose: returns true if the currentdocument is the main one, ie the document
-- of the current selection.
---Category: Set methods
--
SetFolder(me: in out; aFolder: ExtendedString from TCollection)
---Purpose: defines the folder in which the document should be
-- stored. returns Standard_True if the Folder exists,
-- Standard_False otherwise.
returns Boolean from Standard;
SetName(me: in out; aName: ExtString from Standard)
---Purpose: defines the name under which the document should be stored.
returns StoreSetNameStatus from CDF;
SetComment(me: in out; aComment: ExtString from Standard);
Comment(me) returns ExtString from Standard;
RecheckName(me: in out)
---Purpose: defines the name under which the document should be stored.
-- uses for example after modification of the folder.
returns StoreSetNameStatus from CDF;
SetPreviousVersion(me: in out; aPreviousVersion: ExtString from Standard)
returns Boolean from Standard;
Realize(me: in out);
Path(me) returns ExtString from Standard;
---Purpose: returns the complete path of the created meta-data.
MetaDataPath(me) returns ExtString from Standard;
---Purpose: returns the path of the previous store is the object
-- is already stored, otherwise an empty string;
Description(me) returns ExtString from Standard;
---Purpose: returns the description of the format of the main object.
---Category: subcomponents management.
InitComponent (me: in out);
---Purpose : Allows to Start a new Iteration from beginning
MoreComponent (me) returns Boolean from Standard;
---Purpose : Returns True if there are more entries to return
NextComponent (me: in out);
---Purpose : Go to the next entry
-- (if there is not, Value will raise an exception)
SetCurrent(me: in out);
Component (me) returns ExtString from Standard;
---Purpose : Returns item value of current entry
HasSubComponents(me) returns Boolean from Standard;
SubComponentStatus(me; aPresentation: ExtString from Standard)
returns SubComponentStatus from CDF;
SetCurrent(me: in out; aPresentation: ExtString from Standard);
SetMain(me: in out);
---Category: Status method
---Purpose: the two following methods can
-- be used just after Realize or Import -- method to know if
-- thes methods worked correctly, and if not why.
StoreStatus(me) returns StoreStatus from CDF;
AssociatedStatusText(me) returns ExtString from Standard;
---Category: Private methods
FindDefault(me: in out) is private;
Init(me: in out) is private;
SetName(me: in out; aName: ExtendedString from TCollection)
---Purpose: defines the name under which the document should be stored.
returns StoreSetNameStatus from CDF;
---Category: compatibility
SetFolder(me: in out; aFolder: ExtString from Standard)
---Purpose: defines the folder in which the document should be
-- stored. returns Standard_True if the Folder exists,
-- Standard_False otherwise.
returns Boolean from Standard;
fields
myList: StoreList from CDF ;
myMainDocument: Document from CDM ;
myCurrentDocument: Document from CDM ;
myHasSubComponents: Boolean from Standard ;
myIsMainDocument: Boolean from Standard ;
myLastName: ExtendedString from TCollection;
myPath: ExtendedString from TCollection;
myText: ExtendedString from TCollection;
myStatus: StoreStatus from CDF;
end Store from CDF;

306
src/CDF/CDF_Store.cxx Executable file
View File

@@ -0,0 +1,306 @@
// Modified by rmi, Thu Dec 4 14:24:24 1997
#include <CDF_Store.ixx>
#include <CDF_Session.hxx>
#include <CDF_Application.hxx>
#include <CDF_StoreStatus.hxx>
#include <CDF_StoreSetNameStatus.hxx>
#include <Standard_ProgramError.hxx>
#include <CDF_MetaDataDriver.hxx>
#include <PCDM_StorageDriver.hxx>
#include <PCDM.hxx>
#include <TCollection_ExtendedString.hxx>
#include <CDM_MetaData.hxx>
#define theMetaDataDriver CDF_Session::CurrentSession()->MetaDataDriver()
static TCollection_ExtendedString blank("");
CDF_Store::CDF_Store() {}
CDF_Store::CDF_Store(const Handle(CDM_Document)& aDocument):myHasSubComponents(Standard_False) {
myMainDocument = aDocument;
Init();
}
void CDF_Store::Init() {
myCurrentDocument = myMainDocument;
myList = new CDF_StoreList(myCurrentDocument);
myIsMainDocument = Standard_True;
FindDefault();
// getting the subcomponents.
//
myIsMainDocument = Standard_False;
myList->Init();
for ( myList->Init(); myList->More(); myList->Next()) {
myCurrentDocument = myList->Value();
if(myCurrentDocument != myMainDocument) {
myHasSubComponents = Standard_True;
FindDefault();
}
}
myIsMainDocument = Standard_True;
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())
retv = myCurrentDocument->RequestedFolder();
else
retv= blank;
return retv.ToExtString();
}
Standard_ExtString CDF_Store::Name() const {
static TCollection_ExtendedString retv;
retv = myCurrentDocument->RequestedName();
return retv.ToExtString();
}
Standard_Boolean CDF_Store::SetFolder(const Standard_ExtString aFolder) {
TCollection_ExtendedString f(aFolder);
return SetFolder(f);
}
Standard_Boolean CDF_Store::SetFolder(const TCollection_ExtendedString& aFolder) {
TCollection_ExtendedString theFolder(aFolder);
Standard_Integer l = theFolder.Length();
// if the last character is the folder separator (which is always the first character)
// it is removed.
// This is correct for Unix systems but not for Windows! VMS and MAC? Thomas Haller, 23.11.01
if(l > 1) {
#ifndef WNT
if(theFolder.Value(l) == theFolder.Value(1)) theFolder.Trunc(l-1);
#else
if (theFolder.Value(l) == '/' || theFolder.Value(l) == '\\')
theFolder.Trunc(l-1);
#endif
}
if(theMetaDataDriver->FindFolder(theFolder)) {
myCurrentDocument->SetRequestedFolder(theFolder);
return Standard_True;
}
return Standard_False;
}
CDF_StoreSetNameStatus CDF_Store::RecheckName () {
return SetName(myCurrentDocument->RequestedName());
}
CDF_StoreSetNameStatus CDF_Store::SetName(const TCollection_ExtendedString& aName)
{
TCollection_ExtendedString theName=theMetaDataDriver->SetName(myCurrentDocument,aName);
if(myCurrentDocument->IsStored ()) {
Handle(CDM_MetaData) E = myCurrentDocument->MetaData();
if( E->Folder() == myCurrentDocument->RequestedFolder()
&& E->Name() == theName) return CDF_SSNS_OK;
}
if(myCurrentDocument->HasRequestedFolder()) {
if (theMetaDataDriver->Find(myCurrentDocument->RequestedFolder(),theName)) {
if(theMetaDataDriver->MetaData(myCurrentDocument->RequestedFolder(),theName)->IsRetrieved())
return CDF_SSNS_OpenDocument;
else {
myCurrentDocument->SetRequestedName(theName);
return CDF_SSNS_ReplacingAnExistentDocument;
}
}
}
myCurrentDocument->SetRequestedName(theName);
return CDF_SSNS_OK;
}
CDF_StoreSetNameStatus CDF_Store::SetName(const Standard_ExtString aName)
{
TCollection_ExtendedString theName(aName);
return SetName(theName);
}
void CDF_Store::Realize() {
Standard_ProgramError_Raise_if(!myList->IsConsistent(),"information are missing");
Handle(CDM_MetaData) m;
myText = "";
myStatus = myList->Store(m,myText);
if(myStatus==CDF_SS_OK) myPath = m->Path();
}
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();
}
Standard_ExtString CDF_Store::Description() const {
static TCollection_ExtendedString retv;
if(myMainDocument->FindDescription())
retv = myMainDocument->Description();
else
retv= blank;
return retv.ToExtString();
}
Standard_Boolean CDF_Store::IsStored() const {
return myCurrentDocument->IsStored();
}
Standard_Boolean CDF_Store::IsModified() const {
return myCurrentDocument->IsModified();
}
Standard_Boolean CDF_Store::CurrentIsConsistent() const {
if(!myCurrentDocument->IsStored())
return myCurrentDocument->HasRequestedFolder();
return Standard_True;
}
Standard_Boolean CDF_Store::IsConsistent() const {
return myList->IsConsistent();
}
Standard_Boolean CDF_Store::HasAPreviousVersion() const {
return myCurrentDocument->HasRequestedPreviousVersion();
}
Standard_ExtString CDF_Store::PreviousVersion() const {
static TCollection_ExtendedString retv;
if(myCurrentDocument->HasRequestedPreviousVersion())
retv= myCurrentDocument->RequestedPreviousVersion();
else
retv=blank;
return retv.ToExtString();
}
Standard_Boolean CDF_Store::SetPreviousVersion (const Standard_ExtString aPreviousVersion) {
if(theMetaDataDriver->HasVersionCapability()) {
if(myCurrentDocument->HasRequestedFolder()) {
if(theMetaDataDriver->Find(myCurrentDocument->RequestedFolder(),myCurrentDocument->RequestedName(),aPreviousVersion)){
myCurrentDocument->SetRequestedPreviousVersion(aPreviousVersion);
return Standard_True;
}
else
return Standard_False;
}
else
return Standard_False;
}
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);
myIsMainDocument = myCurrentDocument == myMainDocument;
}
void CDF_Store::SetMain() {
myCurrentDocument = myMainDocument;
myIsMainDocument = Standard_True;
}
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;
}
CDF_StoreStatus CDF_Store::StoreStatus() const {
return myStatus;
}
Standard_ExtString CDF_Store::AssociatedStatusText() const {
return myText.ToExtString();
}
void CDF_Store::FindDefault() {
if (!myCurrentDocument->IsStored ()) {
myCurrentDocument->SetRequestedFolder(CDF_Session::CurrentSession()->CurrentApplication()->DefaultFolder());
// myCurrentDocument->SetRequestedName(theMetaDataDriver->SetName(myCurrentDocument,myCurrentDocument->Presentation()));
myCurrentDocument->SetRequestedName(theMetaDataDriver->SetName(myCurrentDocument,myCurrentDocument->RequestedName()));
}
}
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();
}

48
src/CDF/CDF_StoreList.cdl Executable file
View File

@@ -0,0 +1,48 @@
-- File: CDF_StoreList.cdl
-- Created: Wed Mar 22 08:15:57 1995
-- Author: Jean-Louis Frenkel
-- <rmi@pernox>
---Copyright: Matra Datavision 1995
private class StoreList from CDF inherits Transient from Standard
uses Document from CDM, StackOfDocument from CDM, MapOfDocument from CDM, MapIteratorOfMapOfDocument from CDM, StackIteratorOfStackOfDocument from CDM,MetaData from CDM, ExtendedString from TCollection, StoreStatus from CDF
raises NoSuchObject from Standard
is
Create(aDocument: Document from CDM)
returns mutable StoreList from CDF;
IsConsistent(me) returns Boolean from Standard;
Store(me: mutable; aMetaData: out MetaData from CDM;
aStatusAssociatedText: out ExtendedString from TCollection)
returns StoreStatus from CDF
---Purpose: stores each object of the storelist in the reverse
-- order of which they had been added.
raises NoSuchObject from Standard;
---Warning: if the active dbunit cannot be found
---Category: Private methods.
Add(me: mutable; aDocument: Document from CDM)
is private;
---Category: iteration methods
Init(me: mutable);
More(me) returns Boolean from Standard;
Next(me: mutable);
Value(me) returns Document from CDM;
fields
myItems: MapOfDocument from CDM;
myStack: StackOfDocument from CDM;
myIterator: MapIteratorOfMapOfDocument from CDM;
myMainDocument: Document from CDM;
end StoreList from CDF;

127
src/CDF/CDF_StoreList.cxx Executable file
View File

@@ -0,0 +1,127 @@
// File: CDF_StoreList.cxx
// Created: Fri Aug 8 16:03:07 1997
// Author: Jean-Louis Frenkel
// <rmi@frilox.paris1.matra-dtv.fr>
#include <CDF_StoreList.ixx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Macro.hxx>
#include <CDM_ReferenceIterator.hxx>
#include <PCDM.hxx>
#include <PCDM_Document.hxx>
#include <PCDM_StorageDriver.hxx>
#include <CDF_MetaDataDriverError.hxx>
#include <CDF_MetaDataDriver.hxx>
#include <CDF_Session.hxx>
#include <CDF_Application.hxx>
#include <CDF_Timer.hxx>
static void CAUGHT(TCollection_ExtendedString& status,const TCollection_ExtendedString& what) {
Handle(Standard_Failure) F = Standard_Failure::Caught();
status += what;
status += F->GetMessageString();
}
CDF_StoreList::CDF_StoreList(const Handle(CDM_Document)& aDocument) {
myMainDocument = aDocument;
Add(aDocument);
}
void CDF_StoreList::Add(const Handle(CDM_Document)& aDocument) {
if(!myItems.Contains(aDocument) && aDocument != myMainDocument) myItems.Add(aDocument);
myStack.Push(aDocument);
CDM_ReferenceIterator it(aDocument);
for (;it.More();it.Next()) {
if(it.Document()->IsModified()) Add(it.Document());
}
}
Standard_Boolean CDF_StoreList::IsConsistent () const {
Standard_Boolean yes = Standard_True;
CDM_MapIteratorOfMapOfDocument it (myItems);
for ( ; it.More() && yes ; it.Next()) {
yes = it.Key()->HasRequestedFolder();
}
return yes && myMainDocument->HasRequestedFolder();
}
void CDF_StoreList::Init() {
myIterator = CDM_MapIteratorOfMapOfDocument(myItems);
}
Standard_Boolean CDF_StoreList::More() const {
return myIterator.More();
}
void CDF_StoreList::Next() {
myIterator.Next();
}
Handle(CDM_Document) CDF_StoreList::Value() const {
return myIterator.Key();
}
CDF_StoreStatus CDF_StoreList::Store (Handle(CDM_MetaData)& aMetaData, TCollection_ExtendedString& aStatusAssociatedText) {
Handle(CDF_MetaDataDriver) theMetaDataDriver = CDF_Session::CurrentSession()->MetaDataDriver();
static CDF_StoreStatus status ;
status = CDF_SS_OK;
{
try {
OCC_CATCH_SIGNALS
for (; !myStack.IsEmpty(); myStack.Pop()) {
Handle(CDM_Document) theDocument = myStack.Top();
if( theDocument == myMainDocument || theDocument->IsModified()) {
if(!PCDM::FindStorageDriver(theDocument)){
Standard_SStream aMsg;
aMsg <<"No storage driver does exist for this format: " << theDocument->StorageFormat() << (char)0;
Standard_Failure::Raise(aMsg);
}
if(!theMetaDataDriver->FindFolder(theDocument->RequestedFolder())) {
Standard_SStream aMsg; aMsg << "could not find the active dbunit";
aMsg << TCollection_ExtendedString(theDocument->RequestedFolder())<< (char)0;
Standard_NoSuchObject::Raise(aMsg);
}
TCollection_ExtendedString theName=theMetaDataDriver->BuildFileName(theDocument);
CDF_Timer theTimer;
PCDM::StorageDriver(theDocument)->Write(theDocument,theName);
theTimer.ShowAndRestart("Driver->Write: ");
aMetaData = theMetaDataDriver->CreateMetaData(theDocument,theName);
theTimer.ShowAndStop("metadata creating: ");
theDocument->SetMetaData(aMetaData);
CDM_ReferenceIterator it(theDocument);
for(; it.More();it.Next()) {
theMetaDataDriver->CreateReference(aMetaData,it.Document()->MetaData(),it.ReferenceIdentifier(),it.DocumentVersion());
}
}
}
}
catch (CDF_MetaDataDriverError) {
CAUGHT(aStatusAssociatedText,TCollection_ExtendedString("metadatadriver failed; reason:"));
status = CDF_SS_DriverFailure;
}
catch (Standard_Failure) {
CAUGHT(aStatusAssociatedText,TCollection_ExtendedString("driver failed; reason:"));
status = CDF_SS_Failure;
}
}
return status;
}

25
src/CDF/CDF_Timer.cdl Executable file
View File

@@ -0,0 +1,25 @@
-- File: CDF_Timer.cdl
-- Created: Fri Jul 17 08:03:18 1998
-- Author: Jean-Louis Frenkel
-- <rmi@frilox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
private class Timer from CDF
uses Timer from OSD
is
Create returns Timer from CDF;
ShowAndRestart(me: in out; aMessage: CString from Standard);
ShowAndStop(me: in out; aMessage: CString from Standard);
Show(me: in out; aMessage: CString from Standard)
is private;
MustShow(me: in out) returns Boolean from Standard;
fields
myTimer: Timer from OSD;
end Timer from OSD;

38
src/CDF/CDF_Timer.cxx Executable file
View File

@@ -0,0 +1,38 @@
// File: CDF_Timer.cxx
// Created: Fri Jul 17 08:08:27 1998
// Author: Jean-Louis Frenkel
// <rmi@frilox.paris1.matra-dtv.fr>
#include <CDF_Timer.ixx>
#include <stdlib.h>
CDF_Timer::CDF_Timer() {
myTimer.Start();
}
void CDF_Timer::ShowAndRestart(const Standard_CString aMessage) {
if(MustShow()) {
Show(aMessage);
myTimer.Reset();
myTimer.Start();
}
}
void CDF_Timer::ShowAndStop(const Standard_CString aMessage) {
if(MustShow()) {
Show(aMessage);
myTimer.Stop();
}
}
void CDF_Timer::Show(const Standard_CString aMessage) {
Standard_Integer minutes,hours; Standard_Real seconds,CPUtime;
myTimer.Show(seconds,minutes,hours,CPUtime);
cout << aMessage << hours << "h " << minutes << "' " << seconds << "'' (cpu: " << CPUtime << ")" << endl;
}
Standard_Boolean CDF_Timer::MustShow() {
static Standard_Boolean theMustShow=getenv("STORETIMER") != NULL;
return theMustShow;
}

0
src/CDF/EXTERNLIB Executable file
View File

1
src/CDF/FILES Executable file
View File

@@ -0,0 +1 @@
EXTERNLIB