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 <MMgt_TShared.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;
36 class Interface_Check;
37 DEFINE_STANDARD_HANDLE(Interface_Check, MMgt_TShared)
39 //! Defines a Check, as a list of Fail or Warning Messages under
40 //! a literal form, which can be empty. A Check can also bring an
41 //! Entity, which is the Entity to which the messages apply
42 //! (this Entity may be any Transient Object).
44 //! Messages can be stored in two forms : the definitive form
45 //! (the only one by default), and another form, the original
46 //! form, which can be different if it contains values to be
47 //! inserted (integers, reals, strings)
48 //! The original form can be more suitable for some operations
49 //! such as counting messages
50 class Interface_Check : public MMgt_TShared
56 //! Allows definition of a Sequence. Used also for Global Check
57 //! of an InterfaceModel (which stores global messages for file)
58 Standard_EXPORT Interface_Check();
60 //! Defines a Check on an Entity
61 Standard_EXPORT Interface_Check(const Handle(Standard_Transient)& anentity);
63 //! New name for AddFail (Msg)
64 Standard_EXPORT void SendFail (const Message_Msg& amsg);
66 //! Records a new Fail message
67 Standard_EXPORT void AddFail (const Handle(TCollection_HAsciiString)& amess);
69 //! Records a new Fail message under two forms : final,original
70 Standard_EXPORT void AddFail (const Handle(TCollection_HAsciiString)& amess, const Handle(TCollection_HAsciiString)& orig);
72 //! Records a new Fail message given as "error text" directly
73 //! If <orig> is given, a distinct original form is recorded
74 //! else (D), the original form equates <amess>
75 Standard_EXPORT void AddFail (const Standard_CString amess, const Standard_CString orig = "");
77 //! Records a new Fail from the definition of a Msg (Original+Value)
78 Standard_EXPORT void AddFail (const Message_Msg& amsg);
80 //! Returns True if Check brings at least one Fail Message
81 Standard_EXPORT Standard_Boolean HasFailed() const;
83 //! Returns count of recorded Fails
84 Standard_EXPORT Standard_Integer NbFails() const;
86 //! Returns Fail Message as a String
87 //! Final form by default, Original form if <final> is False
88 Standard_EXPORT const Handle(TCollection_HAsciiString)& Fail (const Standard_Integer num, const Standard_Boolean final = Standard_True) const;
90 //! Same as above, but returns a CString (to be printed ...)
91 //! Final form by default, Original form if <final> is False
92 Standard_EXPORT Standard_CString CFail (const Standard_Integer num, const Standard_Boolean final = Standard_True) const;
94 //! Returns the list of Fails, for a frontal-engine logic
95 //! Final forms by default, Original forms if <final> is False
97 Standard_EXPORT Handle(TColStd_HSequenceOfHAsciiString) Fails (const Standard_Boolean final = Standard_True) const;
99 //! New name for AddWarning
100 Standard_EXPORT void SendWarning (const Message_Msg& amsg);
102 //! Records a new Warning message
103 Standard_EXPORT void AddWarning (const Handle(TCollection_HAsciiString)& amess);
105 //! Records a new Warning message under two forms : final,original
106 Standard_EXPORT void AddWarning (const Handle(TCollection_HAsciiString)& amess, const Handle(TCollection_HAsciiString)& orig);
108 //! Records a Warning message given as "warning message" directly
109 //! If <orig> is given, a distinct original form is recorded
110 //! else (D), the original form equates <amess>
111 Standard_EXPORT void AddWarning (const Standard_CString amess, const Standard_CString orig = "");
113 //! Records a new Warning from the definition of a Msg (Original+Value)
114 Standard_EXPORT void AddWarning (const Message_Msg& amsg);
116 //! Returns True if Check brings at least one Warning Message
117 Standard_EXPORT Standard_Boolean HasWarnings() const;
119 //! Returns count of recorded Warning messages
120 Standard_EXPORT Standard_Integer NbWarnings() const;
122 //! Returns Warning message as a String
123 //! Final form by default, Original form if <final> is False
124 Standard_EXPORT const Handle(TCollection_HAsciiString)& Warning (const Standard_Integer num, const Standard_Boolean final = Standard_True) const;
126 //! Same as above, but returns a CString (to be printed ...)
127 //! Final form by default, Original form if <final> is False
128 Standard_EXPORT Standard_CString CWarning (const Standard_Integer num, const Standard_Boolean final = Standard_True) const;
130 //! Returns the list of Warnings, for a frontal-engine logic
131 //! Final forms by default, Original forms if <final> is False
133 Standard_EXPORT Handle(TColStd_HSequenceOfHAsciiString) Warnings (const Standard_Boolean final = Standard_True) const;
135 //! Records an information message
136 //! This does not change the status of the Check
137 Standard_EXPORT void SendMsg (const Message_Msg& amsg);
139 //! Returns the count of recorded information messages
140 Standard_EXPORT Standard_Integer NbInfoMsgs() const;
142 //! Returns information message as a String
143 Standard_EXPORT const Handle(TCollection_HAsciiString)& InfoMsg (const Standard_Integer num, const Standard_Boolean final = Standard_True) const;
145 //! Same as above, but returns a CString (to be printed ...)
146 //! Final form by default, Original form if <final> is False
147 Standard_EXPORT Standard_CString CInfoMsg (const Standard_Integer num, const Standard_Boolean final = Standard_True) const;
149 //! Returns the list of Info Msg, for a frontal-engine logic
150 //! Final forms by default, Original forms if <final> is False
152 Standard_EXPORT Handle(TColStd_HSequenceOfHAsciiString) InfoMsgs (const Standard_Boolean final = Standard_True) const;
154 //! Returns the Check Status : OK, Warning or Fail
155 Standard_EXPORT Interface_CheckStatus Status() const;
157 //! Tells if Check Status complies with a given one
158 //! (i.e. also status for query)
159 Standard_EXPORT Standard_Boolean Complies (const Interface_CheckStatus status) const;
161 //! Tells if a message is brought by a Check, as follows :
162 //! <incl> = 0 : <mess> exactly matches one of the messages
163 //! <incl> < 0 : <mess> is contained by one of the messages
164 //! <incl> > 0 : <mess> contains one of the messages
165 //! For <status> : for CheckWarning and CheckFail, considers only
166 //! resp. Warning or Check messages. for CheckAny, considers all
167 //! other values are ignored (answer will be false)
168 Standard_EXPORT Standard_Boolean Complies (const Handle(TCollection_HAsciiString)& mess, const Standard_Integer incl, const Interface_CheckStatus status) const;
170 //! Returns True if a Check is devoted to an entity; else, it is
171 //! global (for InterfaceModel's storing of global error messages)
172 Standard_EXPORT Standard_Boolean HasEntity() const;
174 //! Returns the entity on which the Check has been defined
175 Standard_EXPORT const Handle(Standard_Transient)& Entity() const;
177 //! Clears a check, in order to receive informations from transfer
178 //! (Messages and Entity)
179 Standard_EXPORT void Clear();
181 //! Clears the Fail Messages (for instance to keep only Warnings)
182 Standard_EXPORT void ClearFails();
184 //! Clears the Warning Messages (for instance to keep only Fails)
185 Standard_EXPORT void ClearWarnings();
187 //! Clears the Info Messages
188 Standard_EXPORT void ClearInfoMsgs();
190 //! Removes the messages which comply with <mess>, as follows :
191 //! <incl> = 0 : <mess> exactly matches one of the messages
192 //! <incl> < 0 : <mess> is contained by one of the messages
193 //! <incl> > 0 : <mess> contains one of the messages
194 //! For <status> : for CheckWarning and CheckFail, considers only
195 //! resp. Warning or Check messages. for CheckAny, considers all
196 //! other values are ignored (nothing is done)
197 //! Returns True if at least one message has been removed, False else
198 Standard_EXPORT Standard_Boolean Remove (const Handle(TCollection_HAsciiString)& mess, const Standard_Integer incl, const Interface_CheckStatus status);
200 //! Mends messages, according <pref> and <num>
201 //! According to <num>, works on the whole list of Fails if = 0(D)
202 //! or only one Fail message, given its rank
203 //! If <pref> is empty, converts Fail(s) to Warning(s)
204 //! Else, does the conversion but prefixes the new Warning(s) but
205 //! <pref> followed by a semi-column
206 //! Some reserved values of <pref> are :
207 //! "FM" : standard prefix "Mended" (can be translated)
208 //! "CF" : clears Fail(s)
209 //! "CW" : clears Warning(s) : here, <num> refers to Warning list
210 //! "CA" : clears all messages : here, <num> is ignored
211 Standard_EXPORT Standard_Boolean Mend (const Standard_CString pref, const Standard_Integer num = 0);
213 //! Receives an entity result of a Transfer
214 Standard_EXPORT void SetEntity (const Handle(Standard_Transient)& anentity);
216 //! same as SetEntity (old form kept for compatibility)
217 //! Warning : Does nothing if Entity field is not yet clear
218 Standard_EXPORT void GetEntity (const Handle(Standard_Transient)& anentity);
220 //! Copies messages stored in another Check, cumulating
221 //! Does not regard other's Entity. Used to cumulate messages
222 Standard_EXPORT void GetMessages (const Handle(Interface_Check)& other);
224 //! Copies messages converted into Warning messages
225 //! If failsonly is true, only Fails are taken, and converted
226 //! else, Warnings are taken too. Does not regard Entity
227 //! Used to keep Fail messages as Warning, after a recovery
228 Standard_EXPORT void GetAsWarning (const Handle(Interface_Check)& other, const Standard_Boolean failsonly);
230 //! Prints the messages of the check to an Messenger
231 //! <level> = 1 : only fails
232 //! <level> = 2 : fails and warnings
233 //! <level> = 3 : all (fails, warnings, info msg)
234 //! <final> : if positive (D) prints final values of messages
235 //! if negative, prints originals
236 //! if null, prints both forms
237 Standard_EXPORT void Print (const Handle(Message_Messenger)& S, const Standard_Integer level, const Standard_Integer final = 1) const;
239 //! Prints the messages of the check to the default trace file
240 //! By default, according to the default standard level
241 //! Else, according level (see method Print)
242 Standard_EXPORT void Trace (const Standard_Integer level = -1, const Standard_Integer final = 1) const;
247 DEFINE_STANDARD_RTTIEXT(Interface_Check,MMgt_TShared)
257 Handle(TColStd_HSequenceOfHAsciiString) thefails;
258 Handle(TColStd_HSequenceOfHAsciiString) thefailo;
259 Handle(TColStd_HSequenceOfHAsciiString) thewarns;
260 Handle(TColStd_HSequenceOfHAsciiString) thewarno;
261 Handle(TColStd_HSequenceOfHAsciiString) theinfos;
262 Handle(TColStd_HSequenceOfHAsciiString) theinfoo;
263 Handle(Standard_Transient) theent;
274 #endif // _Interface_Check_HeaderFile