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