0025748: Parallel version of progress indicator
[occt.git] / src / ShapeProcess / ShapeProcess_Context.hxx
1 // Created on: 2000-08-21
2 // Created by: Andrey BETENEV
3 // Copyright (c) 2000-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _ShapeProcess_Context_HeaderFile
17 #define _ShapeProcess_Context_HeaderFile
18
19 #include <Standard.hxx>
20 #include <Standard_Type.hxx>
21
22 #include <TColStd_HSequenceOfHAsciiString.hxx>
23 #include <Standard_Integer.hxx>
24 #include <Standard_Transient.hxx>
25 #include <Standard_CString.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <Standard_Real.hxx>
28 class Resource_Manager;
29 class Message_Messenger;
30 class TCollection_AsciiString;
31
32
33 class ShapeProcess_Context;
34 DEFINE_STANDARD_HANDLE(ShapeProcess_Context, Standard_Transient)
35
36 //! Provides convenient interface to resource file
37 //! Allows to load resource file and get values of
38 //! attributes starting from some scope, for example
39 //! if scope is defined as "ToV4" and requested parameter
40 //! is "exec.op", value of "ToV4.exec.op" parameter from
41 //! the resource file will be returned
42 class ShapeProcess_Context : public Standard_Transient
43 {
44
45 public:
46
47   
48   //! Creates an empty tool
49   Standard_EXPORT ShapeProcess_Context();
50   
51   //! Creates a new tool and initialises by name of
52   //! resource file and (if specified) starting scope
53   //! Calls method Init()
54   Standard_EXPORT ShapeProcess_Context(const Standard_CString file, const Standard_CString scope = "");
55   
56   //! Initialises a tool by loading resource file and
57   //! (if specified) sets starting scope
58   //! Returns False if resource file not found
59   Standard_EXPORT Standard_Boolean Init (const Standard_CString file, const Standard_CString scope = "");
60   
61   //! Loading Resource_Manager object if this object not
62   //! equal internal static Resource_Manager object or
63   //! internal static Resource_Manager object is null
64   Standard_EXPORT Handle(Resource_Manager) LoadResourceManager (const Standard_CString file);
65   
66   //! Returns internal Resource_Manager object
67   Standard_EXPORT const Handle(Resource_Manager)& ResourceManager() const;
68   
69   //! Set a new (sub)scope
70   Standard_EXPORT void SetScope (const Standard_CString scope);
71   
72   //! Go out of current scope
73   Standard_EXPORT void UnSetScope();
74   
75   //! Returns True if parameter is defined in the resource file
76   Standard_EXPORT Standard_Boolean IsParamSet (const Standard_CString param) const;
77   
78   Standard_EXPORT Standard_Boolean GetReal (const Standard_CString param, Standard_Real& val) const;
79   
80   Standard_EXPORT Standard_Boolean GetInteger (const Standard_CString param, Standard_Integer& val) const;
81   
82   Standard_EXPORT Standard_Boolean GetBoolean (const Standard_CString param, Standard_Boolean& val) const;
83   
84   //! Get value of parameter as being of specific type
85   //! Returns False if parameter is not defined or has a wrong type
86   Standard_EXPORT Standard_Boolean GetString (const Standard_CString param, TCollection_AsciiString& val) const;
87   
88   Standard_EXPORT Standard_Real RealVal (const Standard_CString param, const Standard_Real def) const;
89   
90   Standard_EXPORT Standard_Integer IntegerVal (const Standard_CString param, const Standard_Integer def) const;
91   
92   Standard_EXPORT Standard_Boolean BooleanVal (const Standard_CString param, const Standard_Boolean def) const;
93   
94   //! Get value of parameter as being of specific type
95   //! If parameter is not defined or does not have expected
96   //! type, returns default value as specified
97   Standard_EXPORT Standard_CString StringVal (const Standard_CString param, const Standard_CString def) const;
98   
99   //! Sets Messenger used for outputting messages.
100   Standard_EXPORT void SetMessenger (const Handle(Message_Messenger)& messenger);
101   
102   //! Returns Messenger used for outputting messages.
103   Standard_EXPORT Handle(Message_Messenger) Messenger() const;
104   
105   //! Sets trace level used for outputting messages
106   //! - 0: no trace at all
107   //! - 1: errors
108   //! - 2: errors and warnings
109   //! - 3: all messages
110   //! Default is 1 : Errors traced
111   Standard_EXPORT void SetTraceLevel (const Standard_Integer tracelev);
112   
113   //! Returns trace level used for outputting messages.
114   Standard_EXPORT Standard_Integer TraceLevel() const;
115
116
117
118
119   DEFINE_STANDARD_RTTIEXT(ShapeProcess_Context,Standard_Transient)
120
121 protected:
122
123
124
125
126 private:
127
128
129   Handle(Resource_Manager) myRC;
130   Handle(TColStd_HSequenceOfHAsciiString) myScope;
131   Handle(Message_Messenger) myMessenger;
132   Standard_Integer myTraceLev;
133
134
135 };
136
137
138
139
140
141
142
143 #endif // _ShapeProcess_Context_HeaderFile