1 // Created on: 1992-02-03
2 // Created by: Christian CAILLET
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Interface_Check_HeaderFile
18 #define _Interface_Check_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <TColStd_HSequenceOfHAsciiString.hxx>
24 #include <Standard_Transient.hxx>
25 #include <Standard_CString.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <Standard_Integer.hxx>
28 #include <Interface_CheckStatus.hxx>
29 class Standard_Transient;
30 class Standard_OutOfRange;
32 class TCollection_HAsciiString;
33 class Message_Messenger;
35 // resolve name collisions with X11 headers
40 class Interface_Check;
41 DEFINE_STANDARD_HANDLE(Interface_Check, Standard_Transient)
43 //! Defines a Check, as a list of Fail or Warning Messages under
44 //! a literal form, which can be empty. A Check can also bring an
45 //! Entity, which is the Entity to which the messages apply
46 //! (this Entity may be any Transient Object).
48 //! Messages can be stored in two forms : the definitive form
49 //! (the only one by default), and another form, the original
50 //! form, which can be different if it contains values to be
51 //! inserted (integers, reals, strings)
52 //! The original form can be more suitable for some operations
53 //! such as counting messages
54 class Interface_Check : public Standard_Transient
60 //! Allows definition of a Sequence. Used also for Global Check
61 //! of an InterfaceModel (which stores global messages for file)
62 Standard_EXPORT Interface_Check();
64 //! Defines a Check on an Entity
65 Standard_EXPORT Interface_Check(const Handle(Standard_Transient)& anentity);
67 //! New name for AddFail (Msg)
68 Standard_EXPORT void SendFail (const Message_Msg& amsg);
70 //! Records a new Fail message
71 Standard_EXPORT void AddFail (const Handle(TCollection_HAsciiString)& amess);
73 //! Records a new Fail message under two forms : final,original
74 Standard_EXPORT void AddFail (const Handle(TCollection_HAsciiString)& amess, const Handle(TCollection_HAsciiString)& orig);
76 //! Records a new Fail message given as "error text" directly
77 //! If <orig> is given, a distinct original form is recorded
78 //! else (D), the original form equates <amess>
79 Standard_EXPORT void AddFail (const Standard_CString amess, const Standard_CString orig = "");
81 //! Records a new Fail from the definition of a Msg (Original+Value)
82 Standard_EXPORT void AddFail (const Message_Msg& amsg);
84 //! Returns True if Check brings at least one Fail Message
85 Standard_EXPORT Standard_Boolean HasFailed() const;
87 //! Returns count of recorded Fails
88 Standard_EXPORT Standard_Integer NbFails() const;
90 //! Returns Fail Message as a String
91 //! Final form by default, Original form if <final> is False
92 Standard_EXPORT const Handle(TCollection_HAsciiString)& Fail (const Standard_Integer num, const Standard_Boolean final = Standard_True) const;
94 //! Same as above, but returns a CString (to be printed ...)
95 //! Final form by default, Original form if <final> is False
96 Standard_EXPORT Standard_CString CFail (const Standard_Integer num, const Standard_Boolean final = Standard_True) const;
98 //! Returns the list of Fails, for a frontal-engine logic
99 //! Final forms by default, Original forms if <final> is False
101 Standard_EXPORT Handle(TColStd_HSequenceOfHAsciiString) Fails (const Standard_Boolean final = Standard_True) const;
103 //! New name for AddWarning
104 Standard_EXPORT void SendWarning (const Message_Msg& amsg);
106 //! Records a new Warning message
107 Standard_EXPORT void AddWarning (const Handle(TCollection_HAsciiString)& amess);
109 //! Records a new Warning message under two forms : final,original
110 Standard_EXPORT void AddWarning (const Handle(TCollection_HAsciiString)& amess, const Handle(TCollection_HAsciiString)& orig);
112 //! Records a Warning message given as "warning message" directly
113 //! If <orig> is given, a distinct original form is recorded
114 //! else (D), the original form equates <amess>
115 Standard_EXPORT void AddWarning (const Standard_CString amess, const Standard_CString orig = "");
117 //! Records a new Warning from the definition of a Msg (Original+Value)
118 Standard_EXPORT void AddWarning (const Message_Msg& amsg);
120 //! Returns True if Check brings at least one Warning Message
121 Standard_EXPORT Standard_Boolean HasWarnings() const;
123 //! Returns count of recorded Warning messages
124 Standard_EXPORT Standard_Integer NbWarnings() const;
126 //! Returns Warning message as a String
127 //! Final form by default, Original form if <final> is False
128 Standard_EXPORT const Handle(TCollection_HAsciiString)& Warning (const Standard_Integer num, const Standard_Boolean final = Standard_True) const;
130 //! Same as above, but returns a CString (to be printed ...)
131 //! Final form by default, Original form if <final> is False
132 Standard_EXPORT Standard_CString CWarning (const Standard_Integer num, const Standard_Boolean final = Standard_True) const;
134 //! Returns the list of Warnings, for a frontal-engine logic
135 //! Final forms by default, Original forms if <final> is False
137 Standard_EXPORT Handle(TColStd_HSequenceOfHAsciiString) Warnings (const Standard_Boolean final = Standard_True) const;
139 //! Records an information message
140 //! This does not change the status of the Check
141 Standard_EXPORT void SendMsg (const Message_Msg& amsg);
143 //! Returns the count of recorded information messages
144 Standard_EXPORT Standard_Integer NbInfoMsgs() const;
146 //! Returns information message as a String
147 Standard_EXPORT const Handle(TCollection_HAsciiString)& InfoMsg (const Standard_Integer num, const Standard_Boolean final = Standard_True) const;
149 //! Same as above, but returns a CString (to be printed ...)
150 //! Final form by default, Original form if <final> is False
151 Standard_EXPORT Standard_CString CInfoMsg (const Standard_Integer num, const Standard_Boolean final = Standard_True) const;
153 //! Returns the list of Info Msg, for a frontal-engine logic
154 //! Final forms by default, Original forms if <final> is False
156 Standard_EXPORT Handle(TColStd_HSequenceOfHAsciiString) InfoMsgs (const Standard_Boolean final = Standard_True) const;
158 //! Returns the Check Status : OK, Warning or Fail
159 Standard_EXPORT Interface_CheckStatus Status() const;
161 //! Tells if Check Status complies with a given one
162 //! (i.e. also status for query)
163 Standard_EXPORT Standard_Boolean Complies (const Interface_CheckStatus status) const;
165 //! Tells if a message is brought by a Check, as follows :
166 //! <incl> = 0 : <mess> exactly matches one of the messages
167 //! <incl> < 0 : <mess> is contained by one of the messages
168 //! <incl> > 0 : <mess> contains one of the messages
169 //! For <status> : for CheckWarning and CheckFail, considers only
170 //! resp. Warning or Check messages. for CheckAny, considers all
171 //! other values are ignored (answer will be false)
172 Standard_EXPORT Standard_Boolean Complies (const Handle(TCollection_HAsciiString)& mess, const Standard_Integer incl, const Interface_CheckStatus status) const;
174 //! Returns True if a Check is devoted to an entity; else, it is
175 //! global (for InterfaceModel's storing of global error messages)
176 Standard_EXPORT Standard_Boolean HasEntity() const;
178 //! Returns the entity on which the Check has been defined
179 Standard_EXPORT const Handle(Standard_Transient)& Entity() const;
181 //! Clears a check, in order to receive informations from transfer
182 //! (Messages and Entity)
183 Standard_EXPORT void Clear();
185 //! Clears the Fail Messages (for instance to keep only Warnings)
186 Standard_EXPORT void ClearFails();
188 //! Clears the Warning Messages (for instance to keep only Fails)
189 Standard_EXPORT void ClearWarnings();
191 //! Clears the Info Messages
192 Standard_EXPORT void ClearInfoMsgs();
194 //! Removes the messages which comply with <mess>, as follows :
195 //! <incl> = 0 : <mess> exactly matches one of the messages
196 //! <incl> < 0 : <mess> is contained by one of the messages
197 //! <incl> > 0 : <mess> contains one of the messages
198 //! For <status> : for CheckWarning and CheckFail, considers only
199 //! resp. Warning or Check messages. for CheckAny, considers all
200 //! other values are ignored (nothing is done)
201 //! Returns True if at least one message has been removed, False else
202 Standard_EXPORT Standard_Boolean Remove (const Handle(TCollection_HAsciiString)& mess, const Standard_Integer incl, const Interface_CheckStatus status);
204 //! Mends messages, according <pref> and <num>
205 //! According to <num>, works on the whole list of Fails if = 0(D)
206 //! or only one Fail message, given its rank
207 //! If <pref> is empty, converts Fail(s) to Warning(s)
208 //! Else, does the conversion but prefixes the new Warning(s) but
209 //! <pref> followed by a semi-column
210 //! Some reserved values of <pref> are :
211 //! "FM" : standard prefix "Mended" (can be translated)
212 //! "CF" : clears Fail(s)
213 //! "CW" : clears Warning(s) : here, <num> refers to Warning list
214 //! "CA" : clears all messages : here, <num> is ignored
215 Standard_EXPORT Standard_Boolean Mend (const Standard_CString pref, const Standard_Integer num = 0);
217 //! Receives an entity result of a Transfer
218 Standard_EXPORT void SetEntity (const Handle(Standard_Transient)& anentity);
220 //! same as SetEntity (old form kept for compatibility)
221 //! Warning : Does nothing if Entity field is not yet clear
222 Standard_EXPORT void GetEntity (const Handle(Standard_Transient)& anentity);
224 //! Copies messages stored in another Check, cumulating
225 //! Does not regard other's Entity. Used to cumulate messages
226 Standard_EXPORT void GetMessages (const Handle(Interface_Check)& other);
228 //! Copies messages converted into Warning messages
229 //! If failsonly is true, only Fails are taken, and converted
230 //! else, Warnings are taken too. Does not regard Entity
231 //! Used to keep Fail messages as Warning, after a recovery
232 Standard_EXPORT void GetAsWarning (const Handle(Interface_Check)& other, const Standard_Boolean failsonly);
234 //! Prints the messages of the check to an Messenger
235 //! <level> = 1 : only fails
236 //! <level> = 2 : fails and warnings
237 //! <level> = 3 : all (fails, warnings, info msg)
238 //! <final> : if positive (D) prints final values of messages
239 //! if negative, prints originals
240 //! if null, prints both forms
241 Standard_EXPORT void Print (const Handle(Message_Messenger)& S, const Standard_Integer level, const Standard_Integer final = 1) const;
243 //! Prints the messages of the check to the default trace file
244 //! By default, according to the default standard level
245 //! Else, according level (see method Print)
246 Standard_EXPORT void Trace (const Standard_Integer level = -1, const Standard_Integer final = 1) const;
251 DEFINE_STANDARD_RTTIEXT(Interface_Check,Standard_Transient)
261 Handle(TColStd_HSequenceOfHAsciiString) thefails;
262 Handle(TColStd_HSequenceOfHAsciiString) thefailo;
263 Handle(TColStd_HSequenceOfHAsciiString) thewarns;
264 Handle(TColStd_HSequenceOfHAsciiString) thewarno;
265 Handle(TColStd_HSequenceOfHAsciiString) theinfos;
266 Handle(TColStd_HSequenceOfHAsciiString) theinfoo;
267 Handle(Standard_Transient) theent;
278 #endif // _Interface_Check_HeaderFile