|
|
|||
File indexing completed on 2026-11-13 10:44:27
0001 // Created on: 1997-08-07 0002 // Created by: Jean-Louis Frenkel 0003 // Copyright (c) 1997-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _CDF_Application_HeaderFile 0018 #define _CDF_Application_HeaderFile 0019 0020 #include <TCollection_ExtendedString.hxx> 0021 #include <PCDM_ReaderStatus.hxx> 0022 #include <CDF_TypeOfActivation.hxx> 0023 #include <CDF_MetaDataDriver.hxx> 0024 #include <CDM_Application.hxx> 0025 #include <CDM_CanCloseStatus.hxx> 0026 #include <Standard_IStream.hxx> 0027 #include <NCollection_IndexedDataMap.hxx> 0028 0029 class Standard_GUID; 0030 class CDM_Document; 0031 class PCDM_Reader; 0032 class CDM_MetaData; 0033 class PCDM_RetrievalDriver; 0034 class PCDM_StorageDriver; 0035 class CDF_Directory; 0036 0037 class CDF_Application : public CDM_Application 0038 { 0039 0040 public: 0041 //! plugs an application. 0042 //! 0043 //! Open is used 0044 //! - for opening a Document that has been created in an application 0045 //! - for opening a Document from the database 0046 //! - for opening a Document from a file. 0047 //! The Open methods always add the document in the session directory and 0048 //! calls the virtual Activate method. The document is considered to be 0049 //! opened until Close is used. To be storable, a document must be 0050 //! opened by an application since the application resources are 0051 //! needed to store it. 0052 Standard_EXPORT static occ::handle<CDF_Application> Load(const Standard_GUID& aGUID); 0053 0054 //! Constructs an new empty document. 0055 //! This document will have the specified format. 0056 //! If InitDocument() is redefined for a specific 0057 //! application, the new document is handled by the 0058 //! applicative session. 0059 Standard_EXPORT virtual void NewDocument(const TCollection_ExtendedString& theFormat, 0060 occ::handle<CDM_Document>& theDoc); 0061 0062 //! Initialize a document for the applicative session. 0063 //! This virtual function is called by NewDocument 0064 //! and should be redefined for each specific application. 0065 Standard_EXPORT virtual void InitDocument(const occ::handle<CDM_Document>& theDoc) const; 0066 0067 //! puts the document in the current session directory 0068 //! and calls the virtual method Activate on it. 0069 Standard_EXPORT void Open(const occ::handle<CDM_Document>& aDocument); 0070 0071 Standard_EXPORT CDM_CanCloseStatus CanClose(const occ::handle<CDM_Document>& aDocument); 0072 0073 //! removes the document of the current session directory 0074 //! and closes the document; 0075 Standard_EXPORT void Close(const occ::handle<CDM_Document>& aDocument); 0076 0077 //! This method retrieves a document from the database. 0078 //! If the Document references other documents which have 0079 //! been updated, the latest version of these documents will 0080 //! be used if {UseStorageConfiguration} is true. 0081 //! The content of {aFolder}, {aName} and {aVersion} depends on 0082 //! the Database Manager system. If the DBMS is only based on 0083 //! the OS, {aFolder} is a directory and {aName} is the name of a 0084 //! file. In this case the use of the syntax with {aVersion} 0085 //! has no sense. For example: 0086 //! 0087 //! occ::handle<CDM_Document> theDocument=myApplication->Retrieve("/home/cascade","box.dsg"); 0088 //! If the DBMS is EUCLID/Design Manager, {aFolder}, {aName} 0089 //! have the form they have in EUCLID/Design Manager. For example: 0090 //! 0091 //! occ::handle<CDM_Document> theDocument=myApplication->Retrieve("|user|cascade","box"); 0092 //! 0093 //! Since the version is not specified in this syntax, the latest will be used. 0094 //! A link is kept with the database through an instance of CDM_MetaData 0095 Standard_EXPORT occ::handle<CDM_Document> Retrieve( 0096 const TCollection_ExtendedString& aFolder, 0097 const TCollection_ExtendedString& aName, 0098 const bool UseStorageConfiguration = true, 0099 const occ::handle<PCDM_ReaderFilter>& theFilter = occ::handle<PCDM_ReaderFilter>(), 0100 const Message_ProgressRange& theRange = Message_ProgressRange()); 0101 0102 //! This method retrieves a document from the database. 0103 //! If the Document references other documents which have 0104 //! been updated, the latest version of these documents 0105 //! will be used if {UseStorageConfiguration} is 0106 //! true. If the DBMS is only based on the OS, 0107 //! this syntax should not be used. 0108 //! 0109 //! If the DBMS is EUCLID/Design Manager, {aFolder}, {aName} 0110 //! and {aVersion} have the form they have in 0111 //! EUCLID/Design Manager. For example: 0112 //! 0113 //! occ::handle<CDM_Document> theDocument=myApplication->Retrieve("|user|cascade","box","2"); 0114 //! A link is kept with the database through an instance 0115 //! of CDM_MetaData 0116 Standard_EXPORT occ::handle<CDM_Document> Retrieve( 0117 const TCollection_ExtendedString& aFolder, 0118 const TCollection_ExtendedString& aName, 0119 const TCollection_ExtendedString& aVersion, 0120 const bool UseStorageConfiguration = true, 0121 const occ::handle<PCDM_ReaderFilter>& theFilter = occ::handle<PCDM_ReaderFilter>(), 0122 const Message_ProgressRange& theRange = Message_ProgressRange()); 0123 0124 Standard_EXPORT PCDM_ReaderStatus CanRetrieve(const TCollection_ExtendedString& theFolder, 0125 const TCollection_ExtendedString& theName, 0126 const bool theAppendMode); 0127 0128 Standard_EXPORT PCDM_ReaderStatus CanRetrieve(const TCollection_ExtendedString& theFolder, 0129 const TCollection_ExtendedString& theName, 0130 const TCollection_ExtendedString& theVersion, 0131 const bool theAppendMode); 0132 0133 //! Checks status after Retrieve 0134 PCDM_ReaderStatus GetRetrieveStatus() const { return myRetrievableStatus; } 0135 0136 //! Reads theDocument from standard SEEKABLE stream theIStream, 0137 //! the stream should support SEEK functionality 0138 Standard_EXPORT void Read( 0139 Standard_IStream& theIStream, 0140 occ::handle<CDM_Document>& theDocument, 0141 const occ::handle<PCDM_ReaderFilter>& theFilter = occ::handle<PCDM_ReaderFilter>(), 0142 const Message_ProgressRange& theRange = Message_ProgressRange()); 0143 0144 //! Returns instance of read driver for specified format. 0145 //! 0146 //! Default implementation uses plugin mechanism to load reader dynamically. 0147 //! For this to work, application resources should define GUID of 0148 //! the plugin as value of [Format].RetrievalPlugin, and "Plugin" 0149 //! resource should define name of plugin library to be loaded as 0150 //! value of [GUID].Location. Plugin library should provide 0151 //! method PLUGINFACTORY returning instance of the reader for the 0152 //! same GUID (see Plugin_Macro.hxx). 0153 //! 0154 //! In case if reader is not available, will raise Standard_NoSuchObject 0155 //! or other exception if raised by plugin loader. 0156 Standard_EXPORT virtual occ::handle<PCDM_Reader> ReaderFromFormat( 0157 const TCollection_ExtendedString& aFormat); 0158 0159 //! Returns instance of storage driver for specified format. 0160 //! 0161 //! Default implementation uses plugin mechanism to load driver dynamically. 0162 //! For this to work, application resources should define GUID of 0163 //! the plugin as value of [Format].StoragePlugin, and "Plugin" 0164 //! resource should define name of plugin library to be loaded as 0165 //! value of [GUID].Location. Plugin library should provide 0166 //! method PLUGINFACTORY returning instance of the reader for the 0167 //! same GUID (see Plugin_Macro.hxx). 0168 //! 0169 //! In case if driver is not available, will raise Standard_NoSuchObject 0170 //! or other exception if raised by plugin loader. 0171 Standard_EXPORT virtual occ::handle<PCDM_StorageDriver> WriterFromFormat( 0172 const TCollection_ExtendedString& aFormat); 0173 0174 //! try to retrieve a Format directly in the file or in 0175 //! application resource by using extension. 0176 //! returns True if found 0177 Standard_EXPORT bool Format(const TCollection_ExtendedString& aFileName, 0178 TCollection_ExtendedString& theFormat); 0179 0180 Standard_EXPORT const char16_t* DefaultFolder(); 0181 0182 Standard_EXPORT bool SetDefaultFolder(const char16_t* const aFolder); 0183 0184 //! returns MetaDatdDriver of this application 0185 Standard_EXPORT occ::handle<CDF_MetaDataDriver> MetaDataDriver() const; 0186 0187 DEFINE_STANDARD_RTTIEXT(CDF_Application, CDM_Application) 0188 0189 occ::handle<CDF_MetaDataDriver> myMetaDataDriver; 0190 occ::handle<CDF_Directory> myDirectory; 0191 0192 private: 0193 //! Informs the application that aDocument has been 0194 //! activated. A document is activated when it is created or 0195 //! retrieved. 0196 //! aTypeOfActivation will be: 0197 //! - CDF_TOA_New if the document is a new one 0198 //! (even empty or retrieved from the database for 0199 //! the first time). 0200 //! - CDF_TOA_Unchanged if the document was already 0201 //! retrieved but had no changes since the previous retrieval. 0202 //! - CDF_TOA_Modified if the document was already 0203 //! retrieved and modified since the previous retrieval. 0204 //! You do not need to call <Activate>, but you should redefine 0205 //! this method to implement application specific behavior. 0206 Standard_EXPORT virtual void Activate(const occ::handle<CDM_Document>& aDocument, 0207 const CDF_TypeOfActivation aTypeOfActivation); 0208 0209 Standard_EXPORT occ::handle<CDM_Document> Retrieve( 0210 const occ::handle<CDM_MetaData>& aMetaData, 0211 const bool UseStorageConfiguration, 0212 const occ::handle<PCDM_ReaderFilter>& theFilter = occ::handle<PCDM_ReaderFilter>(), 0213 const Message_ProgressRange& theRange = Message_ProgressRange()) override; 0214 0215 Standard_EXPORT occ::handle<CDM_Document> Retrieve( 0216 const occ::handle<CDM_MetaData>& aMetaData, 0217 const bool UseStorageConfiguration, 0218 const bool IsComponent, 0219 const occ::handle<PCDM_ReaderFilter>& theFilter = occ::handle<PCDM_ReaderFilter>(), 0220 const Message_ProgressRange& theRange = Message_ProgressRange()); 0221 0222 Standard_EXPORT int DocumentVersion(const occ::handle<CDM_MetaData>& theMetaData) override; 0223 0224 Standard_EXPORT CDF_TypeOfActivation TypeOfActivation(const occ::handle<CDM_MetaData>& aMetaData); 0225 0226 Standard_EXPORT PCDM_ReaderStatus CanRetrieve(const occ::handle<CDM_MetaData>& aMetaData, 0227 const bool theAppendMode); 0228 0229 protected: 0230 Standard_EXPORT CDF_Application(); 0231 0232 PCDM_ReaderStatus myRetrievableStatus; 0233 NCollection_IndexedDataMap<TCollection_ExtendedString, occ::handle<PCDM_RetrievalDriver>> 0234 myReaders; 0235 NCollection_IndexedDataMap<TCollection_ExtendedString, occ::handle<PCDM_StorageDriver>> myWriters; 0236 0237 private: 0238 TCollection_ExtendedString myDefaultFolder; 0239 }; 0240 0241 #endif // _CDF_Application_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|