0024002: Overall code and build procedure refactoring -- manual
[occt.git] / src / CDF / CDF_Application.hxx
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>
32 class Standard_NoSuchObject;
33 class CDF_Session;
34 class Standard_GUID;
35 class CDM_Document;
36 class TCollection_ExtendedString;
37 class PCDM_Reader;
38 class CDM_MetaData;
39
40
41 class CDF_Application;
42 DEFINE_STANDARD_HANDLE(CDF_Application, CDM_Application)
43
44
45 class CDF_Application : public CDM_Application
46 {
47
48 public:
49
50   
51   //! plugs an application.
52   //!
53   //! Open is used
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);
63   
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);
67   
68   Standard_EXPORT CDM_CanCloseStatus CanClose (const Handle(CDM_Document)& aDocument);
69   
70   //! removes the document of the current session directory
71   //! and closes the document;
72   Standard_EXPORT void Close (const Handle(CDM_Document)& aDocument);
73   
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:
83   //!
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:
87   //!
88   //! Handle(CDM_Document) theDocument=myApplication->Retrieve("|user|cascade","box");
89   //!
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);
93   
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.
100   //!
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:
104   //!
105   //! Handle(CDM_Document) theDocument=myApplication->Retrieve("|user|cascade","box","2");
106   //! A link is kept with the database through an instance
107   //! of CDM_MetaData
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);
109   
110   Standard_EXPORT PCDM_ReaderStatus CanRetrieve (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName);
111   
112   Standard_EXPORT PCDM_ReaderStatus CanRetrieve (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aVersion);
113   
114   Standard_EXPORT virtual void Formats (TColStd_SequenceOfExtendedString& Formats) = 0;
115   
116   //! Checks  status  after  Retrieve
117     PCDM_ReaderStatus GetRetrieveStatus() const;
118   
119   Standard_EXPORT Standard_Boolean FindReader (const TCollection_ExtendedString& aFileName);
120   
121   Standard_EXPORT Handle(PCDM_Reader) Reader (const TCollection_ExtendedString& aFileName);
122   
123   Standard_EXPORT Standard_Boolean FindReaderFromFormat (const TCollection_ExtendedString& aFormat);
124   
125   Standard_EXPORT Handle(PCDM_Reader) ReaderFromFormat (const TCollection_ExtendedString& aFormat);
126   
127   //! try to  retrieve a Format  directly in the  file or in
128   //! application   resource  by using   extension. returns
129   //! True if found;
130   Standard_EXPORT Standard_Boolean Format (const TCollection_ExtendedString& aFileName, TCollection_ExtendedString& theFormat);
131   
132   Standard_EXPORT Standard_ExtString DefaultFolder();
133   
134   Standard_EXPORT Standard_Boolean SetDefaultFolder (const Standard_ExtString aFolder);
135   
136   Standard_EXPORT Standard_ExtString DefaultExtension();
137
138
139 friend class CDF_Session;
140
141
142   DEFINE_STANDARD_RTTI(CDF_Application,CDM_Application)
143
144 protected:
145
146   
147   Standard_EXPORT CDF_Application();
148
149   PCDM_ReaderStatus myRetrievableStatus;
150
151
152 private:
153
154   
155   //! Informs the  application that aDocument has  been
156   //! activated. A document is activated when it is created or
157   //! retrieved.
158   //! aTypeOfActivation will be:
159   //! - CDF_TOA_New if the document is a new one
160   //! (even empty or retrieved from the database for
161   //! the first time).
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);
169   
170   Standard_EXPORT Handle(CDM_Document) Retrieve (const Handle(CDM_MetaData)& aMetaData, const Standard_Boolean UseStorageConfiguration);
171   
172   Standard_EXPORT Handle(CDM_Document) Retrieve (const Handle(CDM_MetaData)& aMetaData, const Standard_Boolean UseStorageConfiguration, const Standard_Boolean IsComponent);
173   
174   Standard_EXPORT Standard_Integer DocumentVersion (const Handle(CDM_MetaData)& theMetaData);
175   
176   Standard_EXPORT Standard_Boolean FindReader (const TCollection_ExtendedString& aFileName, Standard_GUID& PluginIn, TCollection_ExtendedString& ResourceName);
177   
178   Standard_EXPORT Standard_Boolean FindReaderFromFormat (const TCollection_ExtendedString& aFormat, Standard_GUID& PluginIn, TCollection_ExtendedString& ResourceName);
179   
180   Standard_EXPORT CDF_TypeOfActivation TypeOfActivation (const Handle(CDM_MetaData)& aMetaData);
181   
182   Standard_EXPORT PCDM_ReaderStatus CanRetrieve (const Handle(CDM_MetaData)& aMetaData);
183
184   TCollection_ExtendedString myDefaultFolder;
185
186
187 };
188
189
190 #include <CDF_Application.lxx>
191
192
193
194
195
196 #endif // _CDF_Application_HeaderFile