Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-17 08:17:10

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 class CDF_Application;
0037 DEFINE_STANDARD_HANDLE(CDF_Application, CDM_Application)
0038 
0039 class CDF_Application : public CDM_Application
0040 {
0041 
0042 public:
0043   //! plugs an application.
0044   //!
0045   //! Open is used
0046   //! - for opening a Document that has been created in an application
0047   //! - for opening a Document from the database
0048   //! - for opening a Document from a file.
0049   //! The Open methods always add the document in the session directory and
0050   //! calls the virtual Activate method. The document is considered to be
0051   //! opened until Close is used. To be storable, a document must be
0052   //! opened by an application since the application resources are
0053   //! needed to store it.
0054   Standard_EXPORT static Handle(CDF_Application) Load(const Standard_GUID& aGUID);
0055 
0056   //! Constructs an new empty document.
0057   //! This document will have the specified format.
0058   //! If InitDocument() is redefined for a specific
0059   //! application, the new document is handled by the
0060   //! applicative session.
0061   Standard_EXPORT virtual void NewDocument(const TCollection_ExtendedString& theFormat,
0062                                            Handle(CDM_Document)&             theDoc);
0063 
0064   //! Initialize a document for the applicative session.
0065   //! This virtual function is called by NewDocument
0066   //! and should be redefined for each specific application.
0067   Standard_EXPORT virtual void InitDocument(const Handle(CDM_Document)& theDoc) const;
0068 
0069   //! puts the document in the current session directory
0070   //! and calls the virtual method Activate on it.
0071   Standard_EXPORT void Open(const Handle(CDM_Document)& aDocument);
0072 
0073   Standard_EXPORT CDM_CanCloseStatus CanClose(const Handle(CDM_Document)& aDocument);
0074 
0075   //! removes the document of the current session directory
0076   //! and closes the document;
0077   Standard_EXPORT void Close(const Handle(CDM_Document)& aDocument);
0078 
0079   //! This method retrieves a document from the database.
0080   //! If the Document references other documents which have
0081   //! been updated, the latest version of these documents will
0082   //! be used if {UseStorageConfiguration} is Standard_True.
0083   //! The content of {aFolder}, {aName} and {aVersion} depends on
0084   //! the Database Manager system. If the DBMS is only based on
0085   //! the OS, {aFolder} is a directory and {aName} is the name of a
0086   //! file. In this case the use of the syntax with {aVersion}
0087   //! has no sense. For example:
0088   //!
0089   //! Handle(CDM_Document) theDocument=myApplication->Retrieve("/home/cascade","box.dsg");
0090   //! If the DBMS is EUCLID/Design Manager, {aFolder}, {aName}
0091   //! have the form they have in EUCLID/Design Manager. For example:
0092   //!
0093   //! Handle(CDM_Document) theDocument=myApplication->Retrieve("|user|cascade","box");
0094   //!
0095   //! Since  the version is not specified in  this syntax, the  latest will be used.
0096   //! A link is kept with the database through an instance of CDM_MetaData
0097   Standard_EXPORT Handle(CDM_Document) Retrieve(
0098     const TCollection_ExtendedString& aFolder,
0099     const TCollection_ExtendedString& aName,
0100     const Standard_Boolean            UseStorageConfiguration = Standard_True,
0101     const Handle(PCDM_ReaderFilter)&  theFilter               = Handle(PCDM_ReaderFilter)(),
0102     const Message_ProgressRange&      theRange                = Message_ProgressRange());
0103 
0104   //! This method retrieves  a  document from the database.
0105   //! If the  Document references other documents which have
0106   //! been  updated, the  latest version of  these documents
0107   //! will    be   used  if   {UseStorageConfiguration}  is
0108   //! Standard_True.  --  If the DBMS is  only  based on the
0109   //! OS, this syntax  should not be used.
0110   //!
0111   //! If the DBMS is EUCLID/Design Manager, {aFolder}, {aName}
0112   //! and  {aVersion} have the form they have in
0113   //! EUCLID/Design Manager. For example:
0114   //!
0115   //! Handle(CDM_Document) theDocument=myApplication->Retrieve("|user|cascade","box","2");
0116   //! A link is kept with the database through an instance
0117   //! of CDM_MetaData
0118   Standard_EXPORT Handle(CDM_Document) Retrieve(
0119     const TCollection_ExtendedString& aFolder,
0120     const TCollection_ExtendedString& aName,
0121     const TCollection_ExtendedString& aVersion,
0122     const Standard_Boolean            UseStorageConfiguration = Standard_True,
0123     const Handle(PCDM_ReaderFilter)&  theFilter               = Handle(PCDM_ReaderFilter)(),
0124     const Message_ProgressRange&      theRange                = Message_ProgressRange());
0125 
0126   Standard_EXPORT PCDM_ReaderStatus CanRetrieve(const TCollection_ExtendedString& theFolder,
0127                                                 const TCollection_ExtendedString& theName,
0128                                                 const bool                        theAppendMode);
0129 
0130   Standard_EXPORT PCDM_ReaderStatus CanRetrieve(const TCollection_ExtendedString& theFolder,
0131                                                 const TCollection_ExtendedString& theName,
0132                                                 const TCollection_ExtendedString& theVersion,
0133                                                 const bool                        theAppendMode);
0134 
0135   //! Checks  status  after  Retrieve
0136   PCDM_ReaderStatus GetRetrieveStatus() const { return myRetrievableStatus; }
0137 
0138   //! Reads theDocument from standard SEEKABLE stream theIStream,
0139   //! the stream should support SEEK functionality
0140   Standard_EXPORT void Read(
0141     Standard_IStream&                theIStream,
0142     Handle(CDM_Document)&            theDocument,
0143     const Handle(PCDM_ReaderFilter)& theFilter = Handle(PCDM_ReaderFilter)(),
0144     const Message_ProgressRange&     theRange  = Message_ProgressRange());
0145 
0146   //! Returns instance of read driver for specified format.
0147   //!
0148   //! Default implementation uses plugin mechanism to load reader dynamically.
0149   //! For this to work, application resources should define GUID of
0150   //! the plugin as value of [Format].RetrievalPlugin, and "Plugin"
0151   //! resource should define name of plugin library to be loaded as
0152   //! value of [GUID].Location. Plugin library should provide
0153   //! method PLUGINFACTORY returning instance of the reader for the
0154   //! same GUID (see Plugin_Macro.hxx).
0155   //!
0156   //! In case if reader is not available, will raise Standard_NoSuchObject
0157   //! or other exception if raised by plugin loader.
0158   Standard_EXPORT virtual Handle(PCDM_Reader) ReaderFromFormat(
0159     const TCollection_ExtendedString& aFormat);
0160 
0161   //! Returns instance of storage driver for specified format.
0162   //!
0163   //! Default implementation uses plugin mechanism to load driver dynamically.
0164   //! For this to work, application resources should define GUID of
0165   //! the plugin as value of [Format].StoragePlugin, and "Plugin"
0166   //! resource should define name of plugin library to be loaded as
0167   //! value of [GUID].Location. Plugin library should provide
0168   //! method PLUGINFACTORY returning instance of the reader for the
0169   //! same GUID (see Plugin_Macro.hxx).
0170   //!
0171   //! In case if driver is not available, will raise Standard_NoSuchObject
0172   //! or other exception if raised by plugin loader.
0173   Standard_EXPORT virtual Handle(PCDM_StorageDriver) WriterFromFormat(
0174     const TCollection_ExtendedString& aFormat);
0175 
0176   //! try to  retrieve a Format  directly in the  file or in
0177   //! application   resource  by using   extension. returns
0178   //! True if found;
0179   Standard_EXPORT Standard_Boolean Format(const TCollection_ExtendedString& aFileName,
0180                                           TCollection_ExtendedString&       theFormat);
0181 
0182   Standard_EXPORT Standard_ExtString DefaultFolder();
0183 
0184   Standard_EXPORT Standard_Boolean SetDefaultFolder(const Standard_ExtString aFolder);
0185 
0186   //! returns MetaDatdDriver of this application
0187   Standard_EXPORT Handle(CDF_MetaDataDriver) MetaDataDriver() const;
0188 
0189   DEFINE_STANDARD_RTTIEXT(CDF_Application, CDM_Application)
0190 
0191   Handle(CDF_MetaDataDriver) myMetaDataDriver;
0192   Handle(CDF_Directory)      myDirectory;
0193 
0194 private:
0195   //! Informs the  application that aDocument has  been
0196   //! activated. A document is activated when it is created or
0197   //! retrieved.
0198   //! aTypeOfActivation will be:
0199   //! - CDF_TOA_New if the document is a new one
0200   //! (even empty or retrieved from the database for
0201   //! the first time).
0202   //! - CDF_TOA_Unchanged if the document was already
0203   //! retrieved but had no changes since the previous retrieval.
0204   //! - CDF_TOA_Modified if the document was already
0205   //! retrieved and modified since the previous retrieval.
0206   //! You do not need to call <Activate>, but you should  redefine
0207   //! this method to implement application specific behavior.
0208   Standard_EXPORT virtual void Activate(const Handle(CDM_Document)& aDocument,
0209                                         const CDF_TypeOfActivation  aTypeOfActivation);
0210 
0211   Standard_EXPORT Handle(CDM_Document) Retrieve(
0212     const Handle(CDM_MetaData)&      aMetaData,
0213     const Standard_Boolean           UseStorageConfiguration,
0214     const Handle(PCDM_ReaderFilter)& theFilter = Handle(PCDM_ReaderFilter)(),
0215     const Message_ProgressRange&     theRange  = Message_ProgressRange()) Standard_OVERRIDE;
0216 
0217   Standard_EXPORT Handle(CDM_Document) Retrieve(
0218     const Handle(CDM_MetaData)&      aMetaData,
0219     const Standard_Boolean           UseStorageConfiguration,
0220     const Standard_Boolean           IsComponent,
0221     const Handle(PCDM_ReaderFilter)& theFilter = Handle(PCDM_ReaderFilter)(),
0222     const Message_ProgressRange&     theRange  = Message_ProgressRange());
0223 
0224   Standard_EXPORT Standard_Integer DocumentVersion(const Handle(CDM_MetaData)& theMetaData)
0225     Standard_OVERRIDE;
0226 
0227   Standard_EXPORT CDF_TypeOfActivation TypeOfActivation(const Handle(CDM_MetaData)& aMetaData);
0228 
0229   Standard_EXPORT PCDM_ReaderStatus CanRetrieve(const Handle(CDM_MetaData)& aMetaData,
0230                                                 const bool                  theAppendMode);
0231 
0232 protected:
0233   Standard_EXPORT CDF_Application();
0234 
0235   PCDM_ReaderStatus myRetrievableStatus;
0236   NCollection_IndexedDataMap<TCollection_ExtendedString, Handle(PCDM_RetrievalDriver)> myReaders;
0237   NCollection_IndexedDataMap<TCollection_ExtendedString, Handle(PCDM_StorageDriver)>   myWriters;
0238 
0239 private:
0240   TCollection_ExtendedString myDefaultFolder;
0241 };
0242 
0243 #endif // _CDF_Application_HeaderFile