0026937: Eliminate NO_CXX_EXCEPTION macro support
[occt.git] / src / MoniTool / MoniTool_CaseData.hxx
CommitLineData
42cf5bc1 1// Created on: 1998-04-01
2// Created by: Christian CAILLET
3// Copyright (c) 1998-1999 Matra Datavision
4// Copyright (c) 1999-2014 OPEN CASCADE SAS
5//
6// This file is part of Open CASCADE Technology software library.
7//
8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _MoniTool_CaseData_HeaderFile
18#define _MoniTool_CaseData_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
23#include <Standard_Integer.hxx>
24#include <TCollection_AsciiString.hxx>
25#include <TColStd_SequenceOfTransient.hxx>
26#include <TColStd_SequenceOfInteger.hxx>
27#include <TColStd_SequenceOfAsciiString.hxx>
28#include <MMgt_TShared.hxx>
29#include <Standard_CString.hxx>
30#include <Standard_Boolean.hxx>
31#include <Standard_Real.hxx>
32#include <Standard_Type.hxx>
33class Standard_Transient;
34class TopoDS_Shape;
35class gp_XYZ;
36class gp_XY;
37class TCollection_AsciiString;
38class Message_Msg;
39
40
41class MoniTool_CaseData;
42DEFINE_STANDARD_HANDLE(MoniTool_CaseData, MMgt_TShared)
43
44//! This class is intended to record data attached to a case to be
45//! exploited.
46//! Cases can be :
47//! * internal, i.e. for immediate debug
48//! for instance, on an abnormal exception, fill a CaseData
49//! in a DB (see class DB) then look at its content by XSDRAW
50//! * to record abnormal situation, which cause a warning or fail
51//! message, for instance during a transfer
52//! This will allow, firstly to build a more comprehensive
53//! message (with associated data), secondly to help seeing
54//! "what happened"
55//! * to record data in order to fix a problem
56//! If a CASE is well defined and its fix is well known too,
57//! recording a CaseData which identifies the CASE will allow
58//! to furstherly call the appropriate fix routine
59//!
60//! A CaseData is defined by
61//! * an optional CASE identifier
62//! If it is defined, this will allow systematic exploitation
63//! such as calling a fix routine
64//! * an optional Check Status, Warning or Fail, else it is Info
65//! * a NAME : it just allows to identify where this CaseData was
66//! created (help to debug)
67//! * a LIST OF DATA
68//!
69//! Each Data has a type (integer, real etc...) and can have a name
70//! Hence, each data may be identified by :
71//! * its absolute rank (from 1 to NbData)
72//! * its name if it has one (exact matching)
73//! * else, an interpreted identifier, which gives the type and
74//! the rank in the type (for instance, first integer; etc)
75//! (See NameRank)
76class MoniTool_CaseData : public MMgt_TShared
77{
78
79public:
80
81
82 //! Creates a CaseData with a CaseId and a Name
83 //! (by default not defined)
84 Standard_EXPORT MoniTool_CaseData(const Standard_CString caseid = "", const Standard_CString name = "");
85
86 //! Sets a CaseId
87 Standard_EXPORT void SetCaseId (const Standard_CString caseid);
88
89 //! Sets a Name
90 Standard_EXPORT void SetName (const Standard_CString name);
91
92 //! Returns the CaseId
93 Standard_EXPORT Standard_CString CaseId() const;
94
95 //! Returns the Name
96 Standard_EXPORT Standard_CString Name() const;
97
98 //! Tells if <me> is Check (Warning or Fail), else it is Info
99 Standard_EXPORT Standard_Boolean IsCheck() const;
100
101 //! Tells if <me> is Warning
102 Standard_EXPORT Standard_Boolean IsWarning() const;
103
104 //! Tells if <me> is Fail
105 Standard_EXPORT Standard_Boolean IsFail() const;
106
107 //! Resets Check Status, i.e. sets <me> as Info
108 Standard_EXPORT void ResetCheck();
109
110 //! Sets <me> as Warning
111 Standard_EXPORT void SetWarning();
112
113 //! Sets <me> as Fail
114 Standard_EXPORT void SetFail();
115
116 //! Sets the next Add... not to add but to change the data item
117 //! designated by its name.
118 //! If next Add... is not called with a name, SetChange is ignored
119 //! Reset by next Add... , whatever <num> is correct or not
120 Standard_EXPORT void SetChange();
121
122 //! Sets the next Add... not to add but to replace the data item
123 //! <num>, if <num> is between 1 and NbData.
124 //! Reset by next Add... , whatever <num> is correct or not
125 Standard_EXPORT void SetReplace (const Standard_Integer num);
126
127 //! Unitary adding a data; rather internal
128 Standard_EXPORT void AddData (const Handle(Standard_Transient)& val, const Standard_Integer kind, const Standard_CString name = "");
129
130 //! Adds the currently caught exception
9775fa61 131 Standard_EXPORT void AddRaised (const Handle(Standard_Failure)& theException, const Standard_CString name = "");
42cf5bc1 132
133 //! Adds a Shape (recorded as a HShape)
134 Standard_EXPORT void AddShape (const TopoDS_Shape& sh, const Standard_CString name = "");
135
136 //! Adds a XYZ
137 Standard_EXPORT void AddXYZ (const gp_XYZ& aXYZ, const Standard_CString name = "");
138
139 //! Adds a XY
140 Standard_EXPORT void AddXY (const gp_XY& aXY, const Standard_CString name = "");
141
142 //! Adds a Real
143 Standard_EXPORT void AddReal (const Standard_Real val, const Standard_CString name = "");
144
145 //! Adds two reals (for instance, two parameters)
146 Standard_EXPORT void AddReals (const Standard_Real v1, const Standard_Real v2, const Standard_CString name = "");
147
148 //! Adds the CPU time between lastCPU and now
149 //! if <curCPU> is given, the CPU amount is curCPU-lastCPU
150 //! else it is currently measured CPU - lastCPU
151 //! lastCPU has been read by call to GetCPU
152 //! See GetCPU to get amount, and LargeCPU to test large amount
153 Standard_EXPORT void AddCPU (const Standard_Real lastCPU, const Standard_Real curCPU = 0, const Standard_CString name = "");
154
155 //! Returns the current amount of CPU
156 //! This allows to laterly test and record CPU amount
157 //! Its value has to be given to LargeCPU and AddCPU
158 Standard_EXPORT Standard_Real GetCPU() const;
159
160 //! Tells if a CPU time amount is large
161 //! <maxCPU> gives the amount over which an amount is large
162 //! <lastCPU> gives the start CPU amount
163 //! if <curCPU> is given, the tested CPU amount is curCPU-lastCPU
164 //! else it is currently measured CPU - lastCPU
165 Standard_EXPORT Standard_Boolean LargeCPU (const Standard_Real maxCPU, const Standard_Real lastCPU, const Standard_Real curCPU = 0) const;
166
167 //! Adds a Geometric as a Transient (Curve, Surface ...)
168 Standard_EXPORT void AddGeom (const Handle(Standard_Transient)& geom, const Standard_CString name = "");
169
170 //! Adds a Transient, as an Entity from an InterfaceModel for
171 //! instance : it will then be printed with the help of a DBPE
172 Standard_EXPORT void AddEntity (const Handle(Standard_Transient)& ent, const Standard_CString name = "");
173
174 //! Adds a Text (as HAsciiString)
175 Standard_EXPORT void AddText (const Standard_CString text, const Standard_CString name = "");
176
177 //! Adds an Integer
178 Standard_EXPORT void AddInteger (const Standard_Integer val, const Standard_CString name = "");
179
180 //! Adds a Transient, with no more meaning
181 Standard_EXPORT void AddAny (const Handle(Standard_Transient)& val, const Standard_CString name = "");
182
183 //! Removes a Data from its rank. Does nothing if out of range
184 Standard_EXPORT void RemoveData (const Standard_Integer num);
185
186 //! Returns the count of data recorded to a set
187 Standard_EXPORT Standard_Integer NbData() const;
188
189 //! Returns a data item (n0 <nd> in the set <num>)
190 Standard_EXPORT Handle(Standard_Transient) Data (const Standard_Integer nd) const;
191
192 //! Returns a data item, under control of a Type
193 //! If the data item is kind of this type, it is returned in <val>
194 //! and the returned value is True
195 //! Else, <val> is unchanged and the returned value is False
196 Standard_EXPORT Standard_Boolean GetData (const Standard_Integer nd, const Handle(Standard_Type)& type, Handle(Standard_Transient)& val) const;
197
198 //! Returns the kind of a data :
199 //! KIND TYPE MEANING
200 //! 0 ANY any (not one of the followings)
201 //! 1 EX raised exception
202 //! 2 EN entity
203 //! 3 G geom
204 //! 4 SH shape
205 //! 5 XYZ XYZ
206 //! 6 XY or UV XY
207 //! 7 RR 2 reals
208 //! 8 R 1 real
209 //! 9 CPU CPU (1 real)
210 //! 10 T text
211 //! 11 I integer
212 //!
213 //! For NameNum, these codes for TYPE must be given exact
214 //! i.e. SH for a Shape, not S nor SHAPE nor SOLID etc
215 Standard_EXPORT Standard_Integer Kind (const Standard_Integer nd) const;
216
217 //! Returns the name of a data. If it has no name, the string is
218 //! empty (length = 0)
219 Standard_EXPORT const TCollection_AsciiString& Name (const Standard_Integer nd) const;
220
221 //! Returns the first suitable data rank for a given name
222 //! Exact maching (exact case, no completion) is required
223 //! Firstly checks the recorded names
224 //! If not found, considers the name as follows :
225 //! Name = "TYPE" : search for the first item with this TYPE
226 //! Name = "TYPE:nn" : search for the nn.th item with this TYPE
227 //! See allowed values in method Kind
228 Standard_EXPORT Standard_Integer NameNum (const Standard_CString name) const;
229
230 //! Returns a data as a shape, Null if not a shape
231 Standard_EXPORT TopoDS_Shape Shape (const Standard_Integer nd) const;
232
233 //! Returns a data as a XYZ (i.e. Geom_CartesianPoint)
234 //! Returns False if not the good type
235 Standard_EXPORT Standard_Boolean XYZ (const Standard_Integer nd, gp_XYZ& val) const;
236
237 //! Returns a data as a XY (i.e. Geom2d_CartesianPoint)
238 //! Returns False if not the good type
239 Standard_EXPORT Standard_Boolean XY (const Standard_Integer nd, gp_XY& val) const;
240
241 //! Returns a couple of reals (stored in Geom2d_CartesianPoint)
242 Standard_EXPORT Standard_Boolean Reals (const Standard_Integer nd, Standard_Real& v1, Standard_Real& v2) const;
243
244 //! Returns a real or CPU amount (stored in Geom2d_CartesianPoint)
245 //! (allows an Integer converted to a Real)
246 Standard_EXPORT Standard_Boolean Real (const Standard_Integer nd, Standard_Real& val) const;
247
248 //! Returns a text (stored in TCollection_HAsciiString)
249 Standard_EXPORT Standard_Boolean Text (const Standard_Integer nd, Standard_CString& text) const;
250
251 //! Returns an Integer
252 Standard_EXPORT Standard_Boolean Integer (const Standard_Integer nd, Standard_Integer& val) const;
253
254 //! Returns a Msg from a CaseData : it is build from DefMsg, which
255 //! gives the message code plus the designation of items of the
256 //! CaseData to be added to the Msg
257 //! Empty if no message attached
258 //!
259 //! Remains to be implemented
260 Standard_EXPORT Message_Msg Msg() const;
261
262 //! Sets a Code to give a Warning
263 Standard_EXPORT static void SetDefWarning (const Standard_CString acode);
264
265 //! Sets a Code to give a Fail
266 Standard_EXPORT static void SetDefFail (const Standard_CString acode);
267
268 //! Returns Check Status for a Code : 0 non/info (default),
269 //! 1 warning, 2 fail
270 //!
271 //! Remark : DefCheck is used to set the check status of a
272 //! CaseData when it is attached to a case code, it can be changed
273 //! later (by SetFail, SetWarning, ResetCheck)
274 Standard_EXPORT static Standard_Integer DefCheck (const Standard_CString acode);
275
276 //! Attaches a message definition to a case code
277 //! This definition includes the message code plus designation of
278 //! items of the CaseData to be added to the message (this part
279 //! not yet implemented)
280 Standard_EXPORT static void SetDefMsg (const Standard_CString casecode, const Standard_CString mesdef);
281
282 //! Returns the message definition for a case code
283 //! Empty if no message attached
284 Standard_EXPORT static Standard_CString DefMsg (const Standard_CString casecode);
285
286
287
288
92efcf78 289 DEFINE_STANDARD_RTTIEXT(MoniTool_CaseData,MMgt_TShared)
42cf5bc1 290
291protected:
292
293
294
295
296private:
297
298
299 Standard_Integer thecheck;
300 Standard_Integer thesubst;
301 TCollection_AsciiString thecase;
302 TCollection_AsciiString thename;
303 TColStd_SequenceOfTransient thedata;
304 TColStd_SequenceOfInteger thekind;
305 TColStd_SequenceOfAsciiString thednam;
306
307
308};
309
310
311
312
313
314
315
316#endif // _MoniTool_CaseData_HeaderFile