summaryrefslogtreecommitdiff
path: root/inc/TObj_Application.hxx
blob: 4747e307d026768c50655aa8d2fb0bda616a3266 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// File:        TObj_Application.hxx
// Created:     Tue Nov 23 11:01:33 2004
// Author:      Pavel TELKOV
// Copyright:   Open CASCADE  2007
// The original implementation Copyright: (C) RINA S.p.A

#ifndef TObj_Application_HeaderFile
#define TObj_Application_HeaderFile

#include <TDocStd_Application.hxx>
#include <TObj_Common.hxx>
#include <Message_Gravity.hxx>
#include <Message_Messenger.hxx>

class Handle(TObj_Application);
class TColStd_SequenceOfExtendedString;

//!
//! This is a base class for OCAF based TObj models
//!  with declared virtual methods
//!

class TObj_Application : public TDocStd_Application
{
public:
  //! Returns static instance of the application
  Standard_EXPORT static Handle(TObj_Application) GetInstance();
 
  //! Returns reference to associated messenger handle
  Standard_EXPORT Handle(Message_Messenger) &Messenger() { return myMessenger; }
    
 public:
  /**
  *    Load/Save support
  */

  //! Saving the OCAF document to a file
  virtual Standard_EXPORT Standard_Boolean SaveDocument
                         (const Handle(TDocStd_Document)& theSourceDoc,
                          const char*                     theTargetFile);

  //! Loading the OCAF document from a file
  virtual Standard_EXPORT Standard_Boolean LoadDocument
                         (const char*                     theSourceFile,
                          Handle(TDocStd_Document)&       theTargetDoc);

  //! Create the OCAF document from scratch
  virtual Standard_EXPORT Standard_Boolean CreateNewDocument
                         (Handle(TDocStd_Document)&         theDoc,
                          const TCollection_ExtendedString& theFormat);

  //! Signal error during Load or Save
  //! Default imiplementation is empty
  virtual Standard_EXPORT void ErrorMessage
                        (const TCollection_ExtendedString &theMsg,
                         const Message_Gravity theLevel);

  //! Signal error during Load or Save
  //! Default imiplementation invoke previous declaration with 0
  virtual Standard_EXPORT void ErrorMessage
                        (const TCollection_ExtendedString &theMsg)
  { ErrorMessage( theMsg, Message_Alarm ); }


  //! Sets the verbose flag, meaning that load/save models should show
  //! CPU and elapsed times
  void SetVerbose (const Standard_Boolean isVerbose)
  { myIsVerbose = isVerbose; }

  //! Returns the verbose flag
  Standard_Boolean IsVerbose () const
  { return myIsVerbose; }

 public:
  /** 
  * Redefined OCAF methods
  */

  //! Return name of resource (i.e. "TObj")
  virtual Standard_EXPORT Standard_CString ResourcesName();

  //! Return format (i.e "TObj")
  virtual Standard_EXPORT void Formats(TColStd_SequenceOfExtendedString& theFormats);

  //! Defines message driver for CDM layer
  virtual Standard_EXPORT Handle(CDM_MessageDriver) MessageDriver()
  { return myMessageDriver; }

 protected:
  /**
  * Constructor
  */

  //! Constructor is protected. Use method GetInstance() method to obtain 
  //! the static instance of the object (or derive your own application)
  Standard_EXPORT TObj_Application();

 private:
  /**
  * Fields
  */

  Standard_Boolean          myIsError;       //!< error flag
  Standard_Boolean          myIsVerbose;     //!< verbose flag
  Handle(Message_Messenger) myMessenger;     //!< messenger
  Handle(CDM_MessageDriver) myMessageDriver; //!< message driver

 public:
  //! CASCADE RTTI
  DEFINE_STANDARD_RTTI(TObj_Application)
};


//! Define handle class 
DEFINE_STANDARD_HANDLE(TObj_Application,TDocStd_Application)

#endif

#ifdef _MSC_VER
#pragma once
#endif