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 #include <Standard_IStream.hxx>
34 class Standard_NoSuchObject;
38 class TCollection_ExtendedString;
43 class CDF_Application;
44 DEFINE_STANDARD_HANDLE(CDF_Application, CDM_Application)
47 class CDF_Application : public CDM_Application
53 //! plugs an application.
56 //! - for opening a Document that has been created in an application
57 //! - for opening a Document from the database
58 //! - for opening a Document from a file.
59 //! The Open methods always add the document in the session directory and
60 //! calls the virtual Activate method. The document is considered to be
61 //! opened until Close is used. To be storable, a document must be
62 //! opened by an application since the application resources are
63 //! needed to store it.
64 Standard_EXPORT static Handle(CDF_Application) Load (const Standard_GUID& aGUID);
66 //! puts the document in the current session directory
67 //! and calls the virtual method Activate on it.
68 Standard_EXPORT void Open (const Handle(CDM_Document)& aDocument);
70 Standard_EXPORT CDM_CanCloseStatus CanClose (const Handle(CDM_Document)& aDocument);
72 //! removes the document of the current session directory
73 //! and closes the document;
74 Standard_EXPORT void Close (const Handle(CDM_Document)& aDocument);
76 //! This method retrieves a document from the database.
77 //! If the Document references other documents which have
78 //! been updated, the latest version of these documents will
79 //! be used if {UseStorageConfiguration} is Standard_True.
80 //! The content of {aFolder}, {aName} and {aVersion} depends on
81 //! the Database Manager system. If the DBMS is only based on
82 //! the OS, {aFolder} is a directory and {aName} is the name of a
83 //! file. In this case the use of the syntax with {aVersion}
84 //! has no sense. For example:
86 //! Handle(CDM_Document) theDocument=myApplication->Retrieve("/home/cascade","box.dsg");
87 //! If the DBMS is EUCLID/Design Manager, {aFolder}, {aName}
88 //! have the form they have in EUCLID/Design Manager. For example:
90 //! Handle(CDM_Document) theDocument=myApplication->Retrieve("|user|cascade","box");
92 //! Since the version is not specified in this syntax, the latest wil be used.
93 //! A link is kept with the database through an instance of CDM_MetaData
94 Standard_EXPORT Handle(CDM_Document) Retrieve (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const Standard_Boolean UseStorageConfiguration = Standard_True);
96 //! This method retrieves a document from the database.
97 //! If the Document references other documents which have
98 //! been updated, the latest version of these documents
99 //! will be used if {UseStorageConfiguration} is
100 //! Standard_True. -- If the DBMS is only based on the
101 //! OS, this syntax should not be used.
103 //! If the DBMS is EUCLID/Design Manager, {aFolder}, {aName}
104 //! and {aVersion} have the form they have in
105 //! EUCLID/Design Manager. For example:
107 //! Handle(CDM_Document) theDocument=myApplication->Retrieve("|user|cascade","box","2");
108 //! A link is kept with the database through an instance
110 Standard_EXPORT Handle(CDM_Document) Retrieve (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aVersion, const Standard_Boolean UseStorageConfiguration = Standard_True);
112 Standard_EXPORT PCDM_ReaderStatus CanRetrieve (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName);
114 Standard_EXPORT PCDM_ReaderStatus CanRetrieve (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aVersion);
116 Standard_EXPORT virtual void Formats (TColStd_SequenceOfExtendedString& Formats) = 0;
118 //! Checks status after Retrieve
119 PCDM_ReaderStatus GetRetrieveStatus() const;
121 Standard_EXPORT Standard_Boolean FindReader (const TCollection_ExtendedString& aFileName);
123 Standard_EXPORT Handle(PCDM_Reader) Reader (const TCollection_ExtendedString& aFileName);
125 //! Reads aDoc from standard SEEKABLE stream theIStream,
126 //! the stream should support SEEK fuctionality
127 Standard_EXPORT Handle(CDM_Document) Read (Standard_IStream& theIStream);
129 Standard_EXPORT Standard_Boolean FindReaderFromFormat (const TCollection_ExtendedString& aFormat);
131 Standard_EXPORT Handle(PCDM_Reader) ReaderFromFormat (const TCollection_ExtendedString& aFormat);
133 //! try to retrieve a Format directly in the file or in
134 //! application resource by using extension. returns
136 Standard_EXPORT Standard_Boolean Format (const TCollection_ExtendedString& aFileName, TCollection_ExtendedString& theFormat);
138 Standard_EXPORT Standard_ExtString DefaultFolder();
140 Standard_EXPORT Standard_Boolean SetDefaultFolder (const Standard_ExtString aFolder);
142 Standard_EXPORT Standard_ExtString DefaultExtension();
145 friend class CDF_Session;
148 DEFINE_STANDARD_RTTIEXT(CDF_Application,CDM_Application)
153 Standard_EXPORT CDF_Application();
155 PCDM_ReaderStatus myRetrievableStatus;
161 //! Informs the application that aDocument has been
162 //! activated. A document is activated when it is created or
164 //! aTypeOfActivation will be:
165 //! - CDF_TOA_New if the document is a new one
166 //! (even empty or retrieved from the database for
168 //! - CDF_TOA_Unchanged if the document was already
169 //! retrieved but had no changes since the previous retrieval.
170 //! - CDF_TOA_Modified if the document was already
171 //! retrieved and modified since the previous retrieval.
172 //! You do not need to call <Activate>, but you should redefine
173 //! this method to implement application specific behavior.
174 Standard_EXPORT virtual void Activate (const Handle(CDM_Document)& aDocument, const CDF_TypeOfActivation aTypeOfActivation);
176 Standard_EXPORT Handle(CDM_Document) Retrieve (const Handle(CDM_MetaData)& aMetaData, const Standard_Boolean UseStorageConfiguration) Standard_OVERRIDE;
178 Standard_EXPORT Handle(CDM_Document) Retrieve (const Handle(CDM_MetaData)& aMetaData, const Standard_Boolean UseStorageConfiguration, const Standard_Boolean IsComponent);
180 Standard_EXPORT Standard_Integer DocumentVersion (const Handle(CDM_MetaData)& theMetaData) Standard_OVERRIDE;
182 Standard_EXPORT Standard_Boolean FindReader (const TCollection_ExtendedString& aFileName, Standard_GUID& PluginIn, TCollection_ExtendedString& ResourceName);
184 Standard_EXPORT Standard_Boolean FindReaderFromFormat (const TCollection_ExtendedString& aFormat, Standard_GUID& PluginIn, TCollection_ExtendedString& ResourceName);
186 Standard_EXPORT CDF_TypeOfActivation TypeOfActivation (const Handle(CDM_MetaData)& aMetaData);
188 Standard_EXPORT PCDM_ReaderStatus CanRetrieve (const Handle(CDM_MetaData)& aMetaData);
190 TCollection_ExtendedString myDefaultFolder;
196 #include <CDF_Application.lxx>
202 #endif // _CDF_Application_HeaderFile