|
|
|||
File indexing completed on 2026-09-16 09:17:56
0001 // Created on: 1998-04-01 0002 // Created by: Christian CAILLET 0003 // Copyright (c) 1998-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _MoniTool_CaseData_HeaderFile 0018 #define _MoniTool_CaseData_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_Type.hxx> 0022 0023 #include <Standard_Integer.hxx> 0024 #include <TCollection_AsciiString.hxx> 0025 #include <Standard_Transient.hxx> 0026 #include <NCollection_Sequence.hxx> 0027 class TopoDS_Shape; 0028 class gp_XYZ; 0029 class gp_XY; 0030 class Message_Msg; 0031 0032 //! This class is intended to record data attached to a case to be 0033 //! exploited. 0034 //! Cases can be : 0035 //! * internal, i.e. for immediate debug 0036 //! for instance, on an abnormal exception, fill a CaseData 0037 //! in a DB (see class DB) then look at its content by XSDRAW 0038 //! * to record abnormal situation, which cause a warning or fail 0039 //! message, for instance during a transfer 0040 //! This will allow, firstly to build a more comprehensive 0041 //! message (with associated data), secondly to help seeing 0042 //! "what happened" 0043 //! * to record data in order to fix a problem 0044 //! If a CASE is well defined and its fix is well known too, 0045 //! recording a CaseData which identifies the CASE will allow 0046 //! to furstherly call the appropriate fix routine 0047 //! 0048 //! A CaseData is defined by 0049 //! * an optional CASE identifier 0050 //! If it is defined, this will allow systematic exploitation 0051 //! such as calling a fix routine 0052 //! * an optional Check Status, Warning or Fail, else it is Info 0053 //! * a NAME : it just allows to identify where this CaseData was 0054 //! created (help to debug) 0055 //! * a LIST OF DATA 0056 //! 0057 //! Each Data has a type (integer, real etc...) and can have a name 0058 //! Hence, each data may be identified by : 0059 //! * its absolute rank (from 1 to NbData) 0060 //! * its name if it has one (exact matching) 0061 //! * else, an interpreted identifier, which gives the type and 0062 //! the rank in the type (for instance, first integer; etc) 0063 //! (See NameRank) 0064 class MoniTool_CaseData : public Standard_Transient 0065 { 0066 0067 public: 0068 //! Creates a CaseData with a CaseId and a Name 0069 //! (by default not defined) 0070 Standard_EXPORT MoniTool_CaseData(const char* const caseid = "", const char* const name = ""); 0071 0072 //! Sets a CaseId 0073 Standard_EXPORT void SetCaseId(const char* const caseid); 0074 0075 //! Sets a Name 0076 Standard_EXPORT void SetName(const char* const name); 0077 0078 //! Returns the CaseId 0079 Standard_EXPORT const char* CaseId() const; 0080 0081 //! Returns the Name 0082 Standard_EXPORT const char* Name() const; 0083 0084 //! Tells if <me> is Check (Warning or Fail), else it is Info 0085 Standard_EXPORT bool IsCheck() const; 0086 0087 //! Tells if <me> is Warning 0088 Standard_EXPORT bool IsWarning() const; 0089 0090 //! Tells if <me> is Fail 0091 Standard_EXPORT bool IsFail() const; 0092 0093 //! Resets Check Status, i.e. sets <me> as Info 0094 Standard_EXPORT void ResetCheck(); 0095 0096 //! Sets <me> as Warning 0097 Standard_EXPORT void SetWarning(); 0098 0099 //! Sets <me> as Fail 0100 Standard_EXPORT void SetFail(); 0101 0102 //! Sets the next Add... not to add but to change the data item 0103 //! designated by its name. 0104 //! If next Add... is not called with a name, SetChange is ignored 0105 //! Reset by next Add... , whatever <num> is correct or not 0106 Standard_EXPORT void SetChange(); 0107 0108 //! Sets the next Add... not to add but to replace the data item 0109 //! <num>, if <num> is between 1 and NbData. 0110 //! Reset by next Add... , whatever <num> is correct or not 0111 Standard_EXPORT void SetReplace(const int num); 0112 0113 //! Unitary adding a data; rather internal 0114 Standard_EXPORT void AddData(const occ::handle<Standard_Transient>& val, 0115 const int kind, 0116 const char* const name = ""); 0117 0118 //! Adds the currently caught exception 0119 Standard_EXPORT void AddRaised(const Standard_Failure& theException, const char* const name = ""); 0120 0121 //! Adds a Shape (recorded as a HShape) 0122 Standard_EXPORT void AddShape(const TopoDS_Shape& sh, const char* const name = ""); 0123 0124 //! Adds a XYZ 0125 Standard_EXPORT void AddXYZ(const gp_XYZ& aXYZ, const char* const name = ""); 0126 0127 //! Adds a XY 0128 Standard_EXPORT void AddXY(const gp_XY& aXY, const char* const name = ""); 0129 0130 //! Adds a Real 0131 Standard_EXPORT void AddReal(const double val, const char* const name = ""); 0132 0133 //! Adds two reals (for instance, two parameters) 0134 Standard_EXPORT void AddReals(const double v1, const double v2, const char* const name = ""); 0135 0136 //! Adds the CPU time between lastCPU and now 0137 //! if <curCPU> is given, the CPU amount is curCPU-lastCPU 0138 //! else it is currently measured CPU - lastCPU 0139 //! lastCPU has been read by call to GetCPU 0140 //! See GetCPU to get amount, and LargeCPU to test large amount 0141 Standard_EXPORT void AddCPU(const double lastCPU, 0142 const double curCPU = 0, 0143 const char* const name = ""); 0144 0145 //! Returns the current amount of CPU 0146 //! This allows to laterly test and record CPU amount 0147 //! Its value has to be given to LargeCPU and AddCPU 0148 Standard_EXPORT double GetCPU() const; 0149 0150 //! Tells if a CPU time amount is large 0151 //! <maxCPU> gives the amount over which an amount is large 0152 //! <lastCPU> gives the start CPU amount 0153 //! if <curCPU> is given, the tested CPU amount is curCPU-lastCPU 0154 //! else it is currently measured CPU - lastCPU 0155 Standard_EXPORT bool LargeCPU(const double maxCPU, 0156 const double lastCPU, 0157 const double curCPU = 0) const; 0158 0159 //! Adds a Geometric as a Transient (Curve, Surface ...) 0160 Standard_EXPORT void AddGeom(const occ::handle<Standard_Transient>& geom, 0161 const char* const name = ""); 0162 0163 //! Adds a Transient, as an Entity from an InterfaceModel for 0164 //! instance : it will then be printed with the help of a DBPE 0165 Standard_EXPORT void AddEntity(const occ::handle<Standard_Transient>& ent, 0166 const char* const name = ""); 0167 0168 //! Adds a Text (as HAsciiString) 0169 Standard_EXPORT void AddText(const char* const text, const char* const name = ""); 0170 0171 //! Adds an Integer 0172 Standard_EXPORT void AddInteger(const int val, const char* const name = ""); 0173 0174 //! Adds a Transient, with no more meaning 0175 Standard_EXPORT void AddAny(const occ::handle<Standard_Transient>& val, 0176 const char* const name = ""); 0177 0178 //! Removes a Data from its rank. Does nothing if out of range 0179 Standard_EXPORT void RemoveData(const int num); 0180 0181 //! Returns the count of data recorded to a set 0182 Standard_EXPORT int NbData() const; 0183 0184 //! Returns a data item (n0 <nd> in the set <num>) 0185 Standard_EXPORT occ::handle<Standard_Transient> Data(const int nd) const; 0186 0187 //! Returns a data item, under control of a Type 0188 //! If the data item is kind of this type, it is returned in <val> 0189 //! and the returned value is True 0190 //! Else, <val> is unchanged and the returned value is False 0191 Standard_EXPORT bool GetData(const int nd, 0192 const occ::handle<Standard_Type>& type, 0193 occ::handle<Standard_Transient>& val) const; 0194 0195 //! Returns the kind of a data : 0196 //! KIND TYPE MEANING 0197 //! 0 ANY any (not one of the following) 0198 //! 1 EX raised exception 0199 //! 2 EN entity 0200 //! 3 G geom 0201 //! 4 SH shape 0202 //! 5 XYZ XYZ 0203 //! 6 XY or UV XY 0204 //! 7 RR 2 reals 0205 //! 8 R 1 real 0206 //! 9 CPU CPU (1 real) 0207 //! 10 T text 0208 //! 11 I integer 0209 //! 0210 //! For NameNum, these codes for TYPE must be given exact 0211 //! i.e. SH for a Shape, not S nor SHAPE nor SOLID etc 0212 Standard_EXPORT int Kind(const int nd) const; 0213 0214 //! Returns the name of a data. If it has no name, the string is 0215 //! empty (length = 0) 0216 Standard_EXPORT const TCollection_AsciiString& Name(const int nd) const; 0217 0218 //! Returns the first suitable data rank for a given name 0219 //! Exact matching (exact case, no completion) is required 0220 //! Firstly checks the recorded names 0221 //! If not found, considers the name as follows : 0222 //! Name = "TYPE" : search for the first item with this TYPE 0223 //! Name = "TYPE:nn" : search for the nn.th item with this TYPE 0224 //! See allowed values in method Kind 0225 Standard_EXPORT int NameNum(const char* const name) const; 0226 0227 //! Returns a data as a shape, Null if not a shape 0228 Standard_EXPORT TopoDS_Shape Shape(const int nd) const; 0229 0230 //! Returns a data as a XYZ (i.e. Geom_CartesianPoint) 0231 //! Returns False if not the good type 0232 Standard_EXPORT bool XYZ(const int nd, gp_XYZ& val) const; 0233 0234 //! Returns a data as a XY (i.e. Geom2d_CartesianPoint) 0235 //! Returns False if not the good type 0236 Standard_EXPORT bool XY(const int nd, gp_XY& val) const; 0237 0238 //! Returns a couple of reals (stored in Geom2d_CartesianPoint) 0239 Standard_EXPORT bool Reals(const int nd, double& v1, double& v2) const; 0240 0241 //! Returns a real or CPU amount (stored in Geom2d_CartesianPoint) 0242 //! (allows an Integer converted to a Real) 0243 Standard_EXPORT bool Real(const int nd, double& val) const; 0244 0245 //! Returns a text (stored in TCollection_HAsciiString) 0246 Standard_EXPORT bool Text(const int nd, const char*& text) const; 0247 0248 //! Returns an Integer 0249 Standard_EXPORT bool Integer(const int nd, int& val) const; 0250 0251 //! Returns a Msg from a CaseData : it is build from DefMsg, which 0252 //! gives the message code plus the designation of items of the 0253 //! CaseData to be added to the Msg 0254 //! Empty if no message attached 0255 //! 0256 //! Remains to be implemented 0257 Standard_EXPORT Message_Msg Msg() const; 0258 0259 //! Sets a Code to give a Warning 0260 Standard_EXPORT static void SetDefWarning(const char* const acode); 0261 0262 //! Sets a Code to give a Fail 0263 Standard_EXPORT static void SetDefFail(const char* const acode); 0264 0265 //! Returns Check Status for a Code : 0 non/info (default), 0266 //! 1 warning, 2 fail 0267 //! 0268 //! Remark : DefCheck is used to set the check status of a 0269 //! CaseData when it is attached to a case code, it can be changed 0270 //! later (by SetFail, SetWarning, ResetCheck) 0271 Standard_EXPORT static int DefCheck(const char* const acode); 0272 0273 //! Attaches a message definition to a case code 0274 //! This definition includes the message code plus designation of 0275 //! items of the CaseData to be added to the message (this part 0276 //! not yet implemented) 0277 Standard_EXPORT static void SetDefMsg(const char* const casecode, const char* const mesdef); 0278 0279 //! Returns the message definition for a case code 0280 //! Empty if no message attached 0281 Standard_EXPORT static const char* DefMsg(const char* const casecode); 0282 0283 DEFINE_STANDARD_RTTIEXT(MoniTool_CaseData, Standard_Transient) 0284 0285 private: 0286 int thecheck; 0287 int thesubst; 0288 TCollection_AsciiString thecase; 0289 TCollection_AsciiString thename; 0290 NCollection_Sequence<occ::handle<Standard_Transient>> thedata; 0291 NCollection_Sequence<int> thekind; 0292 NCollection_Sequence<TCollection_AsciiString> thednam; 0293 }; 0294 0295 #endif // _MoniTool_CaseData_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|