Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-09 10:27:13

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