Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 1992-02-03
0002 // Created by: Christian CAILLET
0003 // Copyright (c) 1992-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 _Interface_Check_HeaderFile
0018 #define _Interface_Check_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 
0022 #include <TColStd_HSequenceOfHAsciiString.hxx>
0023 #include <Standard_Transient.hxx>
0024 #include <Standard_Integer.hxx>
0025 #include <Interface_CheckStatus.hxx>
0026 class Message_Msg;
0027 class TCollection_HAsciiString;
0028 
0029 // resolve name collisions with X11 headers
0030 #ifdef Status
0031   #undef Status
0032 #endif
0033 
0034 class Interface_Check;
0035 DEFINE_STANDARD_HANDLE(Interface_Check, Standard_Transient)
0036 
0037 //! Defines a Check, as a list of Fail or Warning Messages under
0038 //! a literal form, which can be empty. A Check can also bring an
0039 //! Entity, which is the Entity to which the messages apply
0040 //! (this Entity may be any Transient Object).
0041 //!
0042 //! Messages can be stored in two forms : the definitive form
0043 //! (the only one by default), and another form, the original
0044 //! form, which can be different if it contains values to be
0045 //! inserted (integers, reals, strings)
0046 //! The original form can be more suitable for some operations
0047 //! such as counting messages
0048 class Interface_Check : public Standard_Transient
0049 {
0050 
0051 public:
0052 
0053   
0054   //! Allows definition of a Sequence. Used also for Global Check
0055   //! of an InterfaceModel (which stores global messages for file)
0056   Standard_EXPORT Interface_Check();
0057   
0058   //! Defines a Check on an Entity
0059   Standard_EXPORT Interface_Check(const Handle(Standard_Transient)& anentity);
0060   
0061   //! New name for AddFail (Msg)
0062   Standard_EXPORT void SendFail (const Message_Msg& amsg);
0063   
0064   //! Records a new Fail message
0065   Standard_EXPORT void AddFail (const Handle(TCollection_HAsciiString)& amess);
0066   
0067   //! Records a new Fail message under two forms : final,original
0068   Standard_EXPORT void AddFail (const Handle(TCollection_HAsciiString)& amess, const Handle(TCollection_HAsciiString)& orig);
0069   
0070   //! Records a new Fail message given as "error text" directly
0071   //! If <orig> is given, a distinct original form is recorded
0072   //! else (D), the original form equates <amess>
0073   Standard_EXPORT void AddFail (const Standard_CString amess, const Standard_CString orig = "");
0074   
0075   //! Records a new Fail from the definition of a Msg (Original+Value)
0076   Standard_EXPORT void AddFail (const Message_Msg& amsg);
0077   
0078   //! Returns True if Check brings at least one Fail Message
0079   Standard_EXPORT Standard_Boolean HasFailed() const;
0080   
0081   //! Returns count of recorded Fails
0082   Standard_EXPORT Standard_Integer NbFails() const;
0083   
0084   //! Returns Fail Message as a String
0085   //! Final form by default, Original form if <final> is False
0086   Standard_EXPORT const Handle(TCollection_HAsciiString)& Fail (const Standard_Integer num, const Standard_Boolean final = Standard_True) const;
0087   
0088   //! Same as above, but returns a CString (to be printed ...)
0089   //! Final form by default, Original form if <final> is False
0090   Standard_EXPORT Standard_CString CFail (const Standard_Integer num, const Standard_Boolean final = Standard_True) const;
0091   
0092   //! Returns the list of Fails, for a frontal-engine logic
0093   //! Final forms by default, Original forms if <final> is False
0094   //! Can be empty
0095   Standard_EXPORT Handle(TColStd_HSequenceOfHAsciiString) Fails (const Standard_Boolean final = Standard_True) const;
0096   
0097   //! New name for AddWarning
0098   Standard_EXPORT void SendWarning (const Message_Msg& amsg);
0099   
0100   //! Records a new Warning message
0101   Standard_EXPORT void AddWarning (const Handle(TCollection_HAsciiString)& amess);
0102   
0103   //! Records a new Warning message under two forms : final,original
0104   Standard_EXPORT void AddWarning (const Handle(TCollection_HAsciiString)& amess, const Handle(TCollection_HAsciiString)& orig);
0105   
0106   //! Records a Warning message given as "warning message" directly
0107   //! If <orig> is given, a distinct original form is recorded
0108   //! else (D), the original form equates <amess>
0109   Standard_EXPORT void AddWarning (const Standard_CString amess, const Standard_CString orig = "");
0110   
0111   //! Records a new Warning from the definition of a Msg (Original+Value)
0112   Standard_EXPORT void AddWarning (const Message_Msg& amsg);
0113   
0114   //! Returns True if Check brings at least one Warning Message
0115   Standard_EXPORT Standard_Boolean HasWarnings() const;
0116   
0117   //! Returns count of recorded Warning messages
0118   Standard_EXPORT Standard_Integer NbWarnings() const;
0119   
0120   //! Returns Warning message as a String
0121   //! Final form by default, Original form if <final> is False
0122   Standard_EXPORT const Handle(TCollection_HAsciiString)& Warning (const Standard_Integer num, const Standard_Boolean final = Standard_True) const;
0123   
0124   //! Same as above, but returns a CString (to be printed ...)
0125   //! Final form by default, Original form if <final> is False
0126   Standard_EXPORT Standard_CString CWarning (const Standard_Integer num, const Standard_Boolean final = Standard_True) const;
0127   
0128   //! Returns the list of Warnings, for a frontal-engine logic
0129   //! Final forms by default, Original forms if <final> is False
0130   //! Can be empty
0131   Standard_EXPORT Handle(TColStd_HSequenceOfHAsciiString) Warnings (const Standard_Boolean final = Standard_True) const;
0132   
0133   //! Records an information message
0134   //! This does not change the status of the Check
0135   Standard_EXPORT void SendMsg (const Message_Msg& amsg);
0136   
0137   //! Returns the count of recorded information messages
0138   Standard_EXPORT Standard_Integer NbInfoMsgs() const;
0139   
0140   //! Returns information message as a String
0141   Standard_EXPORT const Handle(TCollection_HAsciiString)& InfoMsg (const Standard_Integer num, const Standard_Boolean final = Standard_True) const;
0142   
0143   //! Same as above, but returns a CString (to be printed ...)
0144   //! Final form by default, Original form if <final> is False
0145   Standard_EXPORT Standard_CString CInfoMsg (const Standard_Integer num, const Standard_Boolean final = Standard_True) const;
0146   
0147   //! Returns the list of Info Msg, for a frontal-engine logic
0148   //! Final forms by default, Original forms if <final> is False
0149   //! Can be empty
0150   Standard_EXPORT Handle(TColStd_HSequenceOfHAsciiString) InfoMsgs (const Standard_Boolean final = Standard_True) const;
0151   
0152   //! Returns the Check Status : OK, Warning or Fail
0153   Standard_EXPORT Interface_CheckStatus Status() const;
0154   
0155   //! Tells if Check Status complies with a given one
0156   //! (i.e. also status for query)
0157   Standard_EXPORT Standard_Boolean Complies (const Interface_CheckStatus status) const;
0158   
0159   //! Tells if a message is brought by a Check, as follows :
0160   //! <incl> = 0 : <mess> exactly matches one of the messages
0161   //! <incl> < 0 : <mess> is contained by one of the messages
0162   //! <incl> > 0 : <mess> contains one of the messages
0163   //! For <status> : for CheckWarning and CheckFail, considers only
0164   //! resp. Warning or Check messages. for CheckAny, considers all
0165   //! other values are ignored (answer will be false)
0166   Standard_EXPORT Standard_Boolean Complies (const Handle(TCollection_HAsciiString)& mess, const Standard_Integer incl, const Interface_CheckStatus status) const;
0167   
0168   //! Returns True if a Check is devoted to an entity; else, it is
0169   //! global (for InterfaceModel's storing of global error messages)
0170   Standard_EXPORT Standard_Boolean HasEntity() const;
0171   
0172   //! Returns the entity on which the Check has been defined
0173   Standard_EXPORT const Handle(Standard_Transient)& Entity() const;
0174   
0175   //! Clears a check, in order to receive information from transfer
0176   //! (Messages and Entity)
0177   Standard_EXPORT void Clear();
0178   
0179   //! Clears the Fail Messages (for instance to keep only Warnings)
0180   Standard_EXPORT void ClearFails();
0181   
0182   //! Clears the Warning Messages (for instance to keep only Fails)
0183   Standard_EXPORT void ClearWarnings();
0184   
0185   //! Clears the Info Messages
0186   Standard_EXPORT void ClearInfoMsgs();
0187   
0188   //! Removes the messages which comply with <mess>, as follows :
0189   //! <incl> = 0 : <mess> exactly matches one of the messages
0190   //! <incl> < 0 : <mess> is contained by one of the messages
0191   //! <incl> > 0 : <mess> contains one of the messages
0192   //! For <status> : for CheckWarning and CheckFail, considers only
0193   //! resp. Warning or Check messages. for CheckAny, considers all
0194   //! other values are ignored (nothing is done)
0195   //! Returns True if at least one message has been removed, False else
0196   Standard_EXPORT Standard_Boolean Remove (const Handle(TCollection_HAsciiString)& mess, const Standard_Integer incl, const Interface_CheckStatus status);
0197   
0198   //! Mends messages, according <pref> and <num>
0199   //! According to <num>, works on the whole list of Fails if = 0(D)
0200   //! or only one Fail message, given its rank
0201   //! If <pref> is empty, converts Fail(s) to Warning(s)
0202   //! Else, does the conversion but prefixes the new Warning(s) but
0203   //! <pref> followed by a semi-column
0204   //! Some reserved values of <pref> are :
0205   //! "FM" : standard prefix "Mended" (can be translated)
0206   //! "CF" : clears Fail(s)
0207   //! "CW" : clears Warning(s) : here, <num> refers to Warning list
0208   //! "CA" : clears all messages : here, <num> is ignored
0209   Standard_EXPORT Standard_Boolean Mend (const Standard_CString pref, const Standard_Integer num = 0);
0210   
0211   //! Receives an entity result of a Transfer
0212   Standard_EXPORT void SetEntity (const Handle(Standard_Transient)& anentity);
0213   
0214   //! same as SetEntity (old form kept for compatibility)
0215   //! Warning : Does nothing if Entity field is not yet clear
0216   Standard_EXPORT void GetEntity (const Handle(Standard_Transient)& anentity);
0217   
0218   //! Copies messages stored in another Check, cumulating
0219   //! Does not regard other's Entity. Used to cumulate messages
0220   Standard_EXPORT void GetMessages (const Handle(Interface_Check)& other);
0221   
0222   //! Copies messages converted into Warning messages
0223   //! If failsonly is true, only Fails are taken, and converted
0224   //! else, Warnings are taken too. Does not regard Entity
0225   //! Used to keep Fail messages as Warning, after a recovery
0226   Standard_EXPORT void GetAsWarning (const Handle(Interface_Check)& other, const Standard_Boolean failsonly);
0227   
0228   //! Prints the messages of the check to an Messenger
0229   //! <level> = 1 : only fails
0230   //! <level> = 2 : fails and warnings
0231   //! <level> = 3 : all (fails, warnings, info msg)
0232   //! <final> : if positive (D) prints final values of messages
0233   //! if negative, prints originals
0234   //! if null, prints both forms
0235   Standard_EXPORT void Print (Standard_OStream& S, const Standard_Integer level, const Standard_Integer final = 1) const;
0236   
0237   //! Prints the messages of the check to the default trace file
0238   //! By default, according to the default standard level
0239   //! Else, according level (see method Print)
0240   Standard_EXPORT void Trace (const Standard_Integer level = -1, const Standard_Integer final = 1) const;
0241 
0242 
0243 
0244 
0245   DEFINE_STANDARD_RTTIEXT(Interface_Check,Standard_Transient)
0246 
0247 protected:
0248 
0249 
0250 
0251 
0252 private:
0253 
0254 
0255   Handle(TColStd_HSequenceOfHAsciiString) thefails;
0256   Handle(TColStd_HSequenceOfHAsciiString) thefailo;
0257   Handle(TColStd_HSequenceOfHAsciiString) thewarns;
0258   Handle(TColStd_HSequenceOfHAsciiString) thewarno;
0259   Handle(TColStd_HSequenceOfHAsciiString) theinfos;
0260   Handle(TColStd_HSequenceOfHAsciiString) theinfoo;
0261   Handle(Standard_Transient) theent;
0262 
0263 
0264 };
0265 
0266 
0267 
0268 
0269 
0270 
0271 
0272 #endif // _Interface_Check_HeaderFile