Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:20

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