Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:17

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