0024023: Revamp the OCCT Handle -- automatic
[occt.git] / src / TObj / TObj_Application.hxx
CommitLineData
b311480e 1// Created on: 2004-11-23
2// Created by: Pavel TELKOV
973c2be1 3// Copyright (c) 2004-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
7fd59977 16// The original implementation Copyright: (C) RINA S.p.A
17
18#ifndef TObj_Application_HeaderFile
19#define TObj_Application_HeaderFile
20
21#include <TDocStd_Application.hxx>
22#include <TObj_Common.hxx>
23#include <Message_Gravity.hxx>
24#include <Message_Messenger.hxx>
b7c077b9 25#include <TColStd_SequenceOfExtendedString.hxx>
7fd59977 26
7fd59977 27
28//!
29//! This is a base class for OCAF based TObj models
30//! with declared virtual methods
31//!
32
33class TObj_Application : public TDocStd_Application
34{
35public:
36 //! Returns static instance of the application
37 Standard_EXPORT static Handle(TObj_Application) GetInstance();
38
39 //! Returns reference to associated messenger handle
40 Standard_EXPORT Handle(Message_Messenger) &Messenger() { return myMessenger; }
41
42 public:
43 /**
44 * Load/Save support
45 */
46
47 //! Saving the OCAF document to a file
48 virtual Standard_EXPORT Standard_Boolean SaveDocument
49 (const Handle(TDocStd_Document)& theSourceDoc,
50 const char* theTargetFile);
51
52 //! Loading the OCAF document from a file
53 virtual Standard_EXPORT Standard_Boolean LoadDocument
54 (const char* theSourceFile,
55 Handle(TDocStd_Document)& theTargetDoc);
56
57 //! Create the OCAF document from scratch
58 virtual Standard_EXPORT Standard_Boolean CreateNewDocument
59 (Handle(TDocStd_Document)& theDoc,
60 const TCollection_ExtendedString& theFormat);
61
62 //! Signal error during Load or Save
63 //! Default imiplementation is empty
64 virtual Standard_EXPORT void ErrorMessage
65 (const TCollection_ExtendedString &theMsg,
66 const Message_Gravity theLevel);
67
68 //! Signal error during Load or Save
69 //! Default imiplementation invoke previous declaration with 0
70 virtual Standard_EXPORT void ErrorMessage
71 (const TCollection_ExtendedString &theMsg)
72 { ErrorMessage( theMsg, Message_Alarm ); }
73
74
75 //! Sets the verbose flag, meaning that load/save models should show
76 //! CPU and elapsed times
77 void SetVerbose (const Standard_Boolean isVerbose)
78 { myIsVerbose = isVerbose; }
79
80 //! Returns the verbose flag
81 Standard_Boolean IsVerbose () const
82 { return myIsVerbose; }
83
84 public:
85 /**
86 * Redefined OCAF methods
87 */
88
89 //! Return name of resource (i.e. "TObj")
90 virtual Standard_EXPORT Standard_CString ResourcesName();
91
92 //! Return format (i.e "TObj")
93 virtual Standard_EXPORT void Formats(TColStd_SequenceOfExtendedString& theFormats);
94
95 //! Defines message driver for CDM layer
96 virtual Standard_EXPORT Handle(CDM_MessageDriver) MessageDriver()
97 { return myMessageDriver; }
98
99 protected:
100 /**
101 * Constructor
102 */
103
104 //! Constructor is protected. Use method GetInstance() method to obtain
105 //! the static instance of the object (or derive your own application)
106 Standard_EXPORT TObj_Application();
107
108 private:
109 /**
110 * Fields
111 */
112
113 Standard_Boolean myIsError; //!< error flag
114 Standard_Boolean myIsVerbose; //!< verbose flag
115 Handle(Message_Messenger) myMessenger; //!< messenger
116 Handle(CDM_MessageDriver) myMessageDriver; //!< message driver
117
118 public:
119 //! CASCADE RTTI
ec357c5c 120 DEFINE_STANDARD_RTTI(TObj_Application, TDocStd_Application)
7fd59977 121};
122
123
124//! Define handle class
125DEFINE_STANDARD_HANDLE(TObj_Application,TDocStd_Application)
126
127#endif
128
129#ifdef _MSC_VER
130#pragma once
131#endif