1 // Created on: 1997-08-07
2 // Created by: Jean-Louis Frenkel
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _CDF_Application_HeaderFile
18 #define _CDF_Application_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <TCollection_ExtendedString.hxx>
24 #include <PCDM_ReaderStatus.hxx>
25 #include <CDM_Application.hxx>
26 #include <CDM_CanCloseStatus.hxx>
27 #include <Standard_Boolean.hxx>
28 #include <TColStd_SequenceOfExtendedString.hxx>
29 #include <CDF_TypeOfActivation.hxx>
30 #include <Standard_ExtString.hxx>
31 #include <Standard_Integer.hxx>
32 class Standard_NoSuchObject;
36 class TCollection_ExtendedString;
41 class CDF_Application;
42 DEFINE_STANDARD_HANDLE(CDF_Application, CDM_Application)
45 class CDF_Application : public CDM_Application
51 //! plugs an application.
54 //! - for opening a Document that has been created in an application
55 //! - for opening a Document from the database
56 //! - for opening a Document from a file.
57 //! The Open methods always add the document in the session directory and
58 //! calls the virtual Activate method. The document is considered to be
59 //! opened until Close is used. To be storable, a document must be
60 //! opened by an application since the application resources are
61 //! needed to store it.
62 Standard_EXPORT static Handle(CDF_Application) Load (const Standard_GUID& aGUID);
64 //! puts the document in the current session directory
65 //! and calls the virtual method Activate on it.
66 Standard_EXPORT void Open (const Handle(CDM_Document)& aDocument);
68 Standard_EXPORT CDM_CanCloseStatus CanClose (const Handle(CDM_Document)& aDocument);
70 //! removes the document of the current session directory
71 //! and closes the document;
72 Standard_EXPORT void Close (const Handle(CDM_Document)& aDocument);
74 //! This method retrieves a document from the database.
75 //! If the Document references other documents which have
76 //! been updated, the latest version of these documents will
77 //! be used if {UseStorageConfiguration} is Standard_True.
78 //! The content of {aFolder}, {aName} and {aVersion} depends on
79 //! the Database Manager system. If the DBMS is only based on
80 //! the OS, {aFolder} is a directory and {aName} is the name of a
81 //! file. In this case the use of the syntax with {aVersion}
82 //! has no sense. For example:
84 //! Handle(CDM_Document) theDocument=myApplication->Retrieve("/home/cascade","box.dsg");
85 //! If the DBMS is EUCLID/Design Manager, {aFolder}, {aName}
86 //! have the form they have in EUCLID/Design Manager. For example:
88 //! Handle(CDM_Document) theDocument=myApplication->Retrieve("|user|cascade","box");
90 //! Since the version is not specified in this syntax, the latest wil be used.
91 //! A link is kept with the database through an instance of CDM_MetaData
92 Standard_EXPORT Handle(CDM_Document) Retrieve (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const Standard_Boolean UseStorageConfiguration = Standard_True);
94 //! This method retrieves a document from the database.
95 //! If the Document references other documents which have
96 //! been updated, the latest version of these documents
97 //! will be used if {UseStorageConfiguration} is
98 //! Standard_True. -- If the DBMS is only based on the
99 //! OS, this syntax should not be used.
101 //! If the DBMS is EUCLID/Design Manager, {aFolder}, {aName}
102 //! and {aVersion} have the form they have in
103 //! EUCLID/Design Manager. For example:
105 //! Handle(CDM_Document) theDocument=myApplication->Retrieve("|user|cascade","box","2");
106 //! A link is kept with the database through an instance
108 Standard_EXPORT Handle(CDM_Document) Retrieve (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aVersion, const Standard_Boolean UseStorageConfiguration = Standard_True);
110 Standard_EXPORT PCDM_ReaderStatus CanRetrieve (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName);
112 Standard_EXPORT PCDM_ReaderStatus CanRetrieve (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aVersion);
114 Standard_EXPORT virtual void Formats (TColStd_SequenceOfExtendedString& Formats) = 0;
116 //! Checks status after Retrieve
117 PCDM_ReaderStatus GetRetrieveStatus() const;
119 Standard_EXPORT Standard_Boolean FindReader (const TCollection_ExtendedString& aFileName);
121 Standard_EXPORT Handle(PCDM_Reader) Reader (const TCollection_ExtendedString& aFileName);
123 Standard_EXPORT Standard_Boolean FindReaderFromFormat (const TCollection_ExtendedString& aFormat);
125 Standard_EXPORT Handle(PCDM_Reader) ReaderFromFormat (const TCollection_ExtendedString& aFormat);
127 //! try to retrieve a Format directly in the file or in
128 //! application resource by using extension. returns
130 Standard_EXPORT Standard_Boolean Format (const TCollection_ExtendedString& aFileName, TCollection_ExtendedString& theFormat);
132 Standard_EXPORT Standard_ExtString DefaultFolder();
134 Standard_EXPORT Standard_Boolean SetDefaultFolder (const Standard_ExtString aFolder);
136 Standard_EXPORT Standard_ExtString DefaultExtension();
139 friend class CDF_Session;
142 DEFINE_STANDARD_RTTI(CDF_Application,CDM_Application)
147 Standard_EXPORT CDF_Application();
149 PCDM_ReaderStatus myRetrievableStatus;
155 //! Informs the application that aDocument has been
156 //! activated. A document is activated when it is created or
158 //! aTypeOfActivation will be:
159 //! - CDF_TOA_New if the document is a new one
160 //! (even empty or retrieved from the database for
162 //! - CDF_TOA_Unchanged if the document was already
163 //! retrieved but had no changes since the previous retrieval.
164 //! - CDF_TOA_Modified if the document was already
165 //! retrieved and modified since the previous retrieval.
166 //! You do not need to call <Activate>, but you should redefine
167 //! this method to implement application specific behavior.
168 Standard_EXPORT virtual void Activate (const Handle(CDM_Document)& aDocument, const CDF_TypeOfActivation aTypeOfActivation);
170 Standard_EXPORT Handle(CDM_Document) Retrieve (const Handle(CDM_MetaData)& aMetaData, const Standard_Boolean UseStorageConfiguration);
172 Standard_EXPORT Handle(CDM_Document) Retrieve (const Handle(CDM_MetaData)& aMetaData, const Standard_Boolean UseStorageConfiguration, const Standard_Boolean IsComponent);
174 Standard_EXPORT Standard_Integer DocumentVersion (const Handle(CDM_MetaData)& theMetaData);
176 Standard_EXPORT Standard_Boolean FindReader (const TCollection_ExtendedString& aFileName, Standard_GUID& PluginIn, TCollection_ExtendedString& ResourceName);
178 Standard_EXPORT Standard_Boolean FindReaderFromFormat (const TCollection_ExtendedString& aFormat, Standard_GUID& PluginIn, TCollection_ExtendedString& ResourceName);
180 Standard_EXPORT CDF_TypeOfActivation TypeOfActivation (const Handle(CDM_MetaData)& aMetaData);
182 Standard_EXPORT PCDM_ReaderStatus CanRetrieve (const Handle(CDM_MetaData)& aMetaData);
184 TCollection_ExtendedString myDefaultFolder;
190 #include <CDF_Application.lxx>
196 #endif // _CDF_Application_HeaderFile