Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-20 09:19:24

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 occ::handle<TObj_Application> GetInstance();
0034 
0035   //! Returns reference to associated messenger handle
0036   occ::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 bool SaveDocument(const occ::handle<TDocStd_Document>& theSourceDoc,
0045                                             const TCollection_ExtendedString&    theTargetFile);
0046 
0047   //! Saving the OCAF document to a stream
0048   Standard_EXPORT virtual bool SaveDocument(const occ::handle<TDocStd_Document>& theSourceDoc,
0049                                             Standard_OStream&                    theOStream);
0050 
0051   //! Loading the OCAF document from a file
0052   Standard_EXPORT virtual bool LoadDocument(const TCollection_ExtendedString& theSourceFile,
0053                                             occ::handle<TDocStd_Document>&    theTargetDoc);
0054 
0055   //! Loading the OCAF document from a stream
0056   Standard_EXPORT virtual bool LoadDocument(Standard_IStream&              theIStream,
0057                                             occ::handle<TDocStd_Document>& theTargetDoc);
0058 
0059   //! Create the OCAF document from scratch
0060   virtual Standard_EXPORT bool CreateNewDocument(occ::handle<TDocStd_Document>&    theDoc,
0061                                                  const TCollection_ExtendedString& theFormat);
0062 
0063   //! Signal error during Load or Save
0064   //! Default imiplementation is empty
0065   virtual Standard_EXPORT void ErrorMessage(const TCollection_ExtendedString& theMsg,
0066                                             const Message_Gravity             theLevel);
0067 
0068   //! Signal error during Load or Save
0069   //! Default imiplementation invoke previous declaration with 0
0070   virtual void ErrorMessage(const TCollection_ExtendedString& theMsg)
0071   {
0072     ErrorMessage(theMsg, Message_Alarm);
0073   }
0074 
0075   //! Sets the verbose flag, meaning that load/save models should show
0076   //! CPU and elapsed times
0077   void SetVerbose(const bool isVerbose) { myIsVerbose = isVerbose; }
0078 
0079   //! Returns the verbose flag
0080   bool IsVerbose() const { return myIsVerbose; }
0081 
0082   //! Dumps the content of me into the stream
0083   Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const;
0084 
0085 public:
0086   /**
0087    * Redefined OCAF methods
0088    */
0089 
0090   //! Return name of resource (i.e. "TObj")
0091   Standard_EXPORT const char* ResourcesName() override;
0092 
0093 protected:
0094   /**
0095    * Constructor
0096    */
0097 
0098   //! Constructor is protected. Use method GetInstance() method to obtain
0099   //! the static instance of the object (or derive your own application)
0100   Standard_EXPORT TObj_Application();
0101 
0102   //! Sets an error occurred on storage of a document.
0103   void SetError(const PCDM_StoreStatus theStatus, const TCollection_ExtendedString& theInfo);
0104 
0105   //! Sets an error occurred on reading of a document.
0106   void SetError(const PCDM_ReaderStatus theStatus, const TCollection_ExtendedString& theInfo);
0107 
0108 private:
0109   /**
0110    * Fields
0111    */
0112 
0113   bool                           myIsError;   //!< error flag
0114   bool                           myIsVerbose; //!< verbose flag
0115   occ::handle<Message_Messenger> myMessenger; //!< messenger
0116 
0117 public:
0118   //! CASCADE RTTI
0119   DEFINE_STANDARD_RTTIEXT(TObj_Application, TDocStd_Application)
0120 };
0121 
0122 //! Define handle class
0123 #endif