Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:22

0001 // Created on: 2004-11-23
0002 // Created by: Pavel TELKOV
0003 // Copyright (c) 2004-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 // The original implementation Copyright: (C) RINA S.p.A
0017 
0018 #ifndef TObj_Application_HeaderFile
0019 #define TObj_Application_HeaderFile
0020 
0021 #include <TDocStd_Application.hxx>
0022 #include <Message_Gravity.hxx>
0023 #include <Message_Messenger.hxx>
0024 
0025 //!
0026 //! This is a base class for OCAF based TObj models
0027 //!  with declared virtual methods
0028 //!
0029 class TObj_Application : public TDocStd_Application
0030 {
0031 public:
0032   //! Returns static instance of the application
0033   Standard_EXPORT static Handle(TObj_Application) GetInstance();
0034  
0035   //! Returns reference to associated messenger handle
0036   Handle(Message_Messenger) &Messenger() { return myMessenger; }
0037     
0038  public:
0039   /**
0040   *    Load/Save support
0041   */
0042 
0043   //! Saving the OCAF document to a file
0044   Standard_EXPORT virtual Standard_Boolean SaveDocument
0045                         (const Handle(TDocStd_Document)&   theSourceDoc,
0046                          const TCollection_ExtendedString& theTargetFile);
0047 
0048   //! Saving the OCAF document to a stream
0049   Standard_EXPORT virtual Standard_Boolean SaveDocument
0050                         (const Handle(TDocStd_Document)&   theSourceDoc,
0051                          Standard_OStream&                 theOStream);
0052 
0053   //! Loading the OCAF document from a file
0054   Standard_EXPORT virtual Standard_Boolean LoadDocument
0055                          (const TCollection_ExtendedString& theSourceFile,
0056                           Handle(TDocStd_Document)&         theTargetDoc);
0057 
0058   //! Loading the OCAF document from a stream
0059   Standard_EXPORT virtual Standard_Boolean LoadDocument
0060                         (Standard_IStream&                 theIStream,
0061                          Handle(TDocStd_Document)&         theTargetDoc);
0062 
0063   //! Create the OCAF document from scratch
0064   virtual Standard_EXPORT Standard_Boolean CreateNewDocument
0065                          (Handle(TDocStd_Document)&         theDoc,
0066                           const TCollection_ExtendedString& theFormat);
0067 
0068   //! Signal error during Load or Save
0069   //! Default imiplementation is empty
0070   virtual Standard_EXPORT void ErrorMessage
0071                         (const TCollection_ExtendedString &theMsg,
0072                          const Message_Gravity theLevel);
0073 
0074   //! Signal error during Load or Save
0075   //! Default imiplementation invoke previous declaration with 0
0076   virtual void ErrorMessage
0077                         (const TCollection_ExtendedString &theMsg)
0078   { ErrorMessage( theMsg, Message_Alarm ); }
0079 
0080 
0081   //! Sets the verbose flag, meaning that load/save models should show
0082   //! CPU and elapsed times
0083   void SetVerbose (const Standard_Boolean isVerbose)
0084   { myIsVerbose = isVerbose; }
0085 
0086   //! Returns the verbose flag
0087   Standard_Boolean IsVerbose () const
0088   { return myIsVerbose; }
0089 
0090   //! Dumps the content of me into the stream
0091   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0092 
0093  public:
0094   /** 
0095   * Redefined OCAF methods
0096   */
0097 
0098   //! Return name of resource (i.e. "TObj")
0099   virtual Standard_EXPORT Standard_CString ResourcesName() Standard_OVERRIDE;
0100 
0101  protected:
0102   /**
0103   * Constructor
0104   */
0105 
0106   //! Constructor is protected. Use method GetInstance() method to obtain 
0107   //! the static instance of the object (or derive your own application)
0108   Standard_EXPORT TObj_Application();
0109 
0110   //! Sets an error occurred on storage of a document.
0111   void SetError (const PCDM_StoreStatus theStatus, const TCollection_ExtendedString& theInfo);
0112 
0113   //! Sets an error occurred on reading of a document.
0114   void SetError (const PCDM_ReaderStatus theStatus, const TCollection_ExtendedString& theInfo);
0115 
0116  private:
0117   /**
0118   * Fields
0119   */
0120 
0121   Standard_Boolean          myIsError;       //!< error flag
0122   Standard_Boolean          myIsVerbose;     //!< verbose flag
0123   Handle(Message_Messenger) myMessenger;     //!< messenger
0124 
0125  public:
0126   //! CASCADE RTTI
0127   DEFINE_STANDARD_RTTIEXT(TObj_Application,TDocStd_Application)
0128 };
0129 
0130 
0131 //! Define handle class 
0132 DEFINE_STANDARD_HANDLE(TObj_Application,TDocStd_Application)
0133 
0134 #endif