42cf5bc1 |
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 <MMgt_TShared.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 Message_ProgressIndicator; |
31 | class TCollection_AsciiString; |
32 | |
33 | |
34 | class ShapeProcess_Context; |
35 | DEFINE_STANDARD_HANDLE(ShapeProcess_Context, MMgt_TShared) |
36 | |
37 | //! Provides convenient interface to resource file |
38 | //! Allows to load resource file and get values of |
39 | //! attributes starting from some scope, for example |
40 | //! if scope is defined as "ToV4" and requested parameter |
41 | //! is "exec.op", value of "ToV4.exec.op" parameter from |
42 | //! the resource file will be returned |
43 | class ShapeProcess_Context : public MMgt_TShared |
44 | { |
45 | |
46 | public: |
47 | |
48 | |
49 | //! Creates an empty tool |
50 | Standard_EXPORT ShapeProcess_Context(); |
51 | |
52 | //! Creates a new tool and initialises by name of |
53 | //! resource file and (if specified) starting scope |
54 | //! Calls method Init() |
55 | Standard_EXPORT ShapeProcess_Context(const Standard_CString file, const Standard_CString scope = ""); |
56 | |
57 | //! Initialises a tool by loading resource file and |
58 | //! (if specified) sets starting scope |
59 | //! Returns False if resource file not found |
60 | Standard_EXPORT Standard_Boolean Init (const Standard_CString file, const Standard_CString scope = ""); |
61 | |
62 | //! Loading Resource_Manager object if this object not |
63 | //! equal internal static Resource_Manager object or |
64 | //! internal static Resource_Manager object is null |
65 | Standard_EXPORT Handle(Resource_Manager) LoadResourceManager (const Standard_CString file); |
66 | |
67 | //! Returns internal Resource_Manager object |
68 | Standard_EXPORT const Handle(Resource_Manager)& ResourceManager() const; |
69 | |
70 | //! Set a new (sub)scope |
71 | Standard_EXPORT void SetScope (const Standard_CString scope); |
72 | |
73 | //! Go out of current scope |
74 | Standard_EXPORT void UnSetScope(); |
75 | |
76 | //! Returns True if parameter is defined in the resource file |
77 | Standard_EXPORT Standard_Boolean IsParamSet (const Standard_CString param) const; |
78 | |
79 | Standard_EXPORT Standard_Boolean GetReal (const Standard_CString param, Standard_Real& val) const; |
80 | |
81 | Standard_EXPORT Standard_Boolean GetInteger (const Standard_CString param, Standard_Integer& val) const; |
82 | |
83 | Standard_EXPORT Standard_Boolean GetBoolean (const Standard_CString param, Standard_Boolean& val) const; |
84 | |
85 | //! Get value of parameter as being of specific type |
86 | //! Returns False if parameter is not defined or has a wrong type |
87 | Standard_EXPORT Standard_Boolean GetString (const Standard_CString param, TCollection_AsciiString& val) const; |
88 | |
89 | Standard_EXPORT Standard_Real RealVal (const Standard_CString param, const Standard_Real def) const; |
90 | |
91 | Standard_EXPORT Standard_Integer IntegerVal (const Standard_CString param, const Standard_Integer def) const; |
92 | |
93 | Standard_EXPORT Standard_Boolean BooleanVal (const Standard_CString param, const Standard_Boolean def) const; |
94 | |
95 | //! Get value of parameter as being of specific type |
96 | //! If parameter is not defined or does not have expected |
97 | //! type, returns default value as specified |
98 | Standard_EXPORT Standard_CString StringVal (const Standard_CString param, const Standard_CString def) const; |
99 | |
100 | //! Sets Messenger used for outputting messages. |
101 | Standard_EXPORT void SetMessenger (const Handle(Message_Messenger)& messenger); |
102 | |
103 | //! Returns Messenger used for outputting messages. |
104 | Standard_EXPORT Handle(Message_Messenger) Messenger() const; |
105 | |
106 | //! Sets Progress Indicator. |
107 | Standard_EXPORT void SetProgress (const Handle(Message_ProgressIndicator)& theProgress); |
108 | |
109 | //! Returns Progress Indicator. |
110 | Standard_EXPORT Handle(Message_ProgressIndicator) Progress() const; |
111 | |
112 | //! Sets trace level used for outputting messages |
113 | //! - 0: no trace at all |
114 | //! - 1: errors |
115 | //! - 2: errors and warnings |
116 | //! - 3: all messages |
117 | //! Default is 1 : Errors traced |
118 | Standard_EXPORT void SetTraceLevel (const Standard_Integer tracelev); |
119 | |
120 | //! Returns trace level used for outputting messages. |
121 | Standard_EXPORT Standard_Integer TraceLevel() const; |
122 | |
123 | |
124 | |
125 | |
92efcf78 |
126 | DEFINE_STANDARD_RTTIEXT(ShapeProcess_Context,MMgt_TShared) |
42cf5bc1 |
127 | |
128 | protected: |
129 | |
130 | |
131 | |
132 | |
133 | private: |
134 | |
135 | |
136 | Handle(Resource_Manager) myRC; |
137 | Handle(TColStd_HSequenceOfHAsciiString) myScope; |
138 | Handle(Message_Messenger) myMessenger; |
139 | Handle(Message_ProgressIndicator) myProgress; |
140 | Standard_Integer myTraceLev; |
141 | |
142 | |
143 | }; |
144 | |
145 | |
146 | |
147 | |
148 | |
149 | |
150 | |
151 | #endif // _ShapeProcess_Context_HeaderFile |