42cf5bc1 |
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 |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
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. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _CDF_Application_HeaderFile |
18 | #define _CDF_Application_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
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> |
4ff92abe |
32 | #include <Standard_IStream.hxx> |
33 | |
42cf5bc1 |
34 | class Standard_NoSuchObject; |
35 | class CDF_Session; |
36 | class Standard_GUID; |
37 | class CDM_Document; |
38 | class TCollection_ExtendedString; |
39 | class PCDM_Reader; |
40 | class CDM_MetaData; |
41 | |
42 | |
43 | class CDF_Application; |
44 | DEFINE_STANDARD_HANDLE(CDF_Application, CDM_Application) |
45 | |
46 | |
47 | class CDF_Application : public CDM_Application |
48 | { |
49 | |
50 | public: |
51 | |
52 | |
53 | //! plugs an application. |
54 | //! |
55 | //! Open is used |
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); |
65 | |
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); |
69 | |
70 | Standard_EXPORT CDM_CanCloseStatus CanClose (const Handle(CDM_Document)& aDocument); |
71 | |
72 | //! removes the document of the current session directory |
73 | //! and closes the document; |
74 | Standard_EXPORT void Close (const Handle(CDM_Document)& aDocument); |
75 | |
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: |
85 | //! |
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: |
89 | //! |
90 | //! Handle(CDM_Document) theDocument=myApplication->Retrieve("|user|cascade","box"); |
91 | //! |
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); |
95 | |
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. |
102 | //! |
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: |
106 | //! |
107 | //! Handle(CDM_Document) theDocument=myApplication->Retrieve("|user|cascade","box","2"); |
108 | //! A link is kept with the database through an instance |
109 | //! of CDM_MetaData |
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); |
111 | |
112 | Standard_EXPORT PCDM_ReaderStatus CanRetrieve (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName); |
113 | |
114 | Standard_EXPORT PCDM_ReaderStatus CanRetrieve (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aVersion); |
115 | |
116 | Standard_EXPORT virtual void Formats (TColStd_SequenceOfExtendedString& Formats) = 0; |
117 | |
118 | //! Checks status after Retrieve |
119 | PCDM_ReaderStatus GetRetrieveStatus() const; |
120 | |
121 | Standard_EXPORT Standard_Boolean FindReader (const TCollection_ExtendedString& aFileName); |
122 | |
123 | Standard_EXPORT Handle(PCDM_Reader) Reader (const TCollection_ExtendedString& aFileName); |
4ff92abe |
124 | |
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); |
128 | |
42cf5bc1 |
129 | Standard_EXPORT Standard_Boolean FindReaderFromFormat (const TCollection_ExtendedString& aFormat); |
130 | |
131 | Standard_EXPORT Handle(PCDM_Reader) ReaderFromFormat (const TCollection_ExtendedString& aFormat); |
132 | |
133 | //! try to retrieve a Format directly in the file or in |
134 | //! application resource by using extension. returns |
135 | //! True if found; |
136 | Standard_EXPORT Standard_Boolean Format (const TCollection_ExtendedString& aFileName, TCollection_ExtendedString& theFormat); |
137 | |
138 | Standard_EXPORT Standard_ExtString DefaultFolder(); |
139 | |
140 | Standard_EXPORT Standard_Boolean SetDefaultFolder (const Standard_ExtString aFolder); |
141 | |
142 | Standard_EXPORT Standard_ExtString DefaultExtension(); |
143 | |
144 | |
145 | friend class CDF_Session; |
146 | |
147 | |
92efcf78 |
148 | DEFINE_STANDARD_RTTIEXT(CDF_Application,CDM_Application) |
42cf5bc1 |
149 | |
150 | protected: |
151 | |
152 | |
153 | Standard_EXPORT CDF_Application(); |
154 | |
155 | PCDM_ReaderStatus myRetrievableStatus; |
156 | |
157 | |
158 | private: |
159 | |
160 | |
161 | //! Informs the application that aDocument has been |
162 | //! activated. A document is activated when it is created or |
163 | //! retrieved. |
164 | //! aTypeOfActivation will be: |
165 | //! - CDF_TOA_New if the document is a new one |
166 | //! (even empty or retrieved from the database for |
167 | //! the first time). |
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); |
175 | |
79104795 |
176 | Standard_EXPORT Handle(CDM_Document) Retrieve (const Handle(CDM_MetaData)& aMetaData, const Standard_Boolean UseStorageConfiguration) Standard_OVERRIDE; |
42cf5bc1 |
177 | |
178 | Standard_EXPORT Handle(CDM_Document) Retrieve (const Handle(CDM_MetaData)& aMetaData, const Standard_Boolean UseStorageConfiguration, const Standard_Boolean IsComponent); |
179 | |
79104795 |
180 | Standard_EXPORT Standard_Integer DocumentVersion (const Handle(CDM_MetaData)& theMetaData) Standard_OVERRIDE; |
42cf5bc1 |
181 | |
182 | Standard_EXPORT Standard_Boolean FindReader (const TCollection_ExtendedString& aFileName, Standard_GUID& PluginIn, TCollection_ExtendedString& ResourceName); |
183 | |
184 | Standard_EXPORT Standard_Boolean FindReaderFromFormat (const TCollection_ExtendedString& aFormat, Standard_GUID& PluginIn, TCollection_ExtendedString& ResourceName); |
185 | |
186 | Standard_EXPORT CDF_TypeOfActivation TypeOfActivation (const Handle(CDM_MetaData)& aMetaData); |
187 | |
188 | Standard_EXPORT PCDM_ReaderStatus CanRetrieve (const Handle(CDM_MetaData)& aMetaData); |
189 | |
190 | TCollection_ExtendedString myDefaultFolder; |
191 | |
192 | |
193 | }; |
194 | |
195 | |
196 | #include <CDF_Application.lxx> |
197 | |
198 | |
199 | |
200 | |
201 | |
202 | #endif // _CDF_Application_HeaderFile |