1 // Created on: 1992-10-28
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_CheckIterator_HeaderFile
18 #define _Interface_CheckIterator_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Interface_HSequenceOfCheck.hxx>
25 #include <TColStd_HSequenceOfInteger.hxx>
26 #include <TCollection_AsciiString.hxx>
27 #include <Standard_CString.hxx>
28 #include <Standard_Integer.hxx>
29 #include <Standard_Boolean.hxx>
30 #include <Interface_CheckStatus.hxx>
31 #include <TColStd_HSequenceOfTransient.hxx>
32 class Interface_InterfaceModel;
33 class Interface_IntVal;
34 class Standard_NoSuchObject;
35 class Interface_Check;
36 class Standard_Transient;
37 class Message_Messenger;
39 // resolve name collisions with X11 headers
44 //! Result of a Check operation (especially from InterfaceModel)
45 class Interface_CheckIterator
52 //! Creates an empty CheckIterator
53 Standard_EXPORT Interface_CheckIterator();
55 //! Creates a CheckIterator with a name (displayed by Print as a
57 Standard_EXPORT Interface_CheckIterator(const Standard_CString name);
59 //! Sets / Changes the name
60 Standard_EXPORT void SetName (const Standard_CString name);
62 //! Returns the recorded name (can be empty)
63 Standard_EXPORT Standard_CString Name() const;
65 //! Defines a Model, used to locate entities (not required, if it
66 //! is absent, entities are simply less documented)
67 Standard_EXPORT void SetModel (const Handle(Interface_InterfaceModel)& model);
69 //! Returns the stored model (can be a null handle)
70 Standard_EXPORT Handle(Interface_InterfaceModel) Model() const;
72 //! Clears the list of checks
73 Standard_EXPORT void Clear();
75 //! Merges another CheckIterator into <me>, i.e. adds each of its
76 //! Checks. Content of <other> remains unchanged.
77 //! Takes also the Model but not the Name
78 Standard_EXPORT void Merge (Interface_CheckIterator& other);
80 //! Adds a Check to the list to be iterated
81 //! This Check is Accompanied by Entity Number in the Model
82 //! (0 for Global Check or Entity unknown in the Model), if 0 and
83 //! Model is recorded in <me>, it is computed
84 Standard_EXPORT void Add (const Handle(Interface_Check)& ach, const Standard_Integer num = 0);
86 //! Returns the Check which was attached to an Entity given its
87 //! Number in the Model. <num>=0 is for the Global Check.
88 //! If no Check was recorded for this Number, returns an empty
90 //! Remark : Works apart from the iteration methods (no interference)
91 Standard_EXPORT const Handle(Interface_Check)& Check (const Standard_Integer num) const;
93 //! Returns the Check attached to an Entity
94 //! If no Check was recorded for this Entity, returns an empty
96 //! Remark : Works apart from the iteration methods (no interference)
97 Standard_EXPORT const Handle(Interface_Check)& Check (const Handle(Standard_Transient)& ent) const;
99 //! Returns the Check bound to an Entity Number (0 : Global)
100 //! in order to be consulted or completed on the spot
101 //! I.e. returns the Check if is already exists, or adds it then
102 //! returns the new empty Check
103 Standard_EXPORT Handle(Interface_Check)& CCheck (const Standard_Integer num);
105 //! Returns the Check bound to an Entity, in order to be consulted
106 //! or completed on the spot
107 //! I.e. returns the Check if is already exists, or adds it then
108 //! returns the new empty Check
109 Standard_EXPORT Handle(Interface_Check)& CCheck (const Handle(Standard_Transient)& ent);
111 //! Returns True if : no Fail has been recorded if <failsonly> is
112 //! True, no Check at all if <failsonly> is False
113 Standard_EXPORT Standard_Boolean IsEmpty (const Standard_Boolean failsonly) const;
115 //! Returns worst status among : OK, Warning, Fail
116 Standard_EXPORT Interface_CheckStatus Status() const;
118 //! Tells if this check list complies with a given status :
119 //! OK (i.e. empty), Warning (at least one Warning, but no Fail),
120 //! Fail (at least one), Message (not OK), NoFail, Any
121 Standard_EXPORT Standard_Boolean Complies (const Interface_CheckStatus status) const;
123 //! Returns a CheckIterator which contains the checks which comply
124 //! with a given status
125 //! Each check is added completely (no split Warning/Fail)
126 Standard_EXPORT Interface_CheckIterator Extract (const Interface_CheckStatus status) const;
128 //! Returns a CheckIterator which contains the check which comply
129 //! with a message, plus some conditions as follows :
130 //! <incl> = 0 : <mess> exactly matches one of the messages
131 //! <incl> < 0 : <mess> is contained by one of the messages
132 //! <incl> > 0 : <mess> contains one of the messages
133 //! For <status> : for CheckWarning and CheckFail, considers only
134 //! resp. Warning or Check messages. for CheckAny, considers all
135 //! other values are ignored (answer will be false)
136 //! Each Check which complies is entirely taken
137 Standard_EXPORT Interface_CheckIterator Extract (const Standard_CString mess, const Standard_Integer incl, const Interface_CheckStatus status) const;
139 //! Removes the messages of all Checks, under these conditions :
140 //! <incl> = 0 : <mess> exactly matches one of the messages
141 //! <incl> < 0 : <mess> is contained by one of the messages
142 //! <incl> > 0 : <mess> contains one of the messages
143 //! For <status> : for CheckWarning and CheckFail, considers only
144 //! resp. Warning or Check messages. for CheckAny, considers all
145 //! other values are ignored (nothing is done)
146 //! Returns True if at least one message has been removed, False else
147 Standard_EXPORT Standard_Boolean Remove (const Standard_CString mess, const Standard_Integer incl, const Interface_CheckStatus status);
149 //! Returns the list of entities concerned by a Check
150 //! Only fails if <failsonly> is True, else all non-empty checks
151 //! If <global> is true, adds the model for a global check
152 //! Else, global check is ignored
153 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) Checkeds (const Standard_Boolean failsonly, const Standard_Boolean global) const;
155 //! Starts Iteration. Thus, it is possible to restart it
156 //! Remark : an iteration may be done with a const Iterator
157 //! While its content is modified (through a pointer), this allows
158 //! to give it as a const argument to a function
159 Standard_EXPORT void Start() const;
161 //! Returns True if there are more Checks to get
162 Standard_EXPORT Standard_Boolean More() const;
164 //! Sets Iteration to next Item
165 Standard_EXPORT void Next() const;
167 //! Returns Check currently Iterated
168 //! It brings all other informations (status, messages, ...)
169 //! The Number of the Entity in the Model is given by Number below
170 Standard_EXPORT const Handle(Interface_Check)& Value() const;
172 //! Returns Number of Entity for the Check currently iterated
173 //! or 0 for GlobalCheck
174 Standard_EXPORT Standard_Integer Number() const;
176 //! Prints the list of Checks with their attached Numbers
177 //! If <failsonly> is True, prints only Fail messages
178 //! If <failsonly> is False, prints all messages
179 //! If <final> = 0 (D), prints also original messages if different
180 //! If <final> < 0, prints only original messages
181 //! If <final> > 0, prints only final messages
182 //! It uses the recorded Model if it is defined
183 //! Remark : Works apart from the iteration methods (no interference)
184 Standard_EXPORT void Print (const Handle(Message_Messenger)& S, const Standard_Boolean failsonly, const Standard_Integer final = 0) const;
186 //! Works as Print without a model, but for entities which have
187 //! no attached number (Number not positive), tries to compute
188 //! this Number from <model> and displays "original" or "computed"
189 Standard_EXPORT void Print (const Handle(Message_Messenger)& S, const Handle(Interface_InterfaceModel)& model, const Standard_Boolean failsonly, const Standard_Integer final = 0) const;
191 //! Clears data of iteration
192 Standard_EXPORT void Destroy();
193 ~Interface_CheckIterator()
211 Handle(Interface_HSequenceOfCheck) thelist;
212 Handle(TColStd_HSequenceOfInteger) thenums;
213 Handle(Interface_InterfaceModel) themod;
214 TCollection_AsciiString thename;
215 Handle(Interface_IntVal) thecurr;
226 #endif // _Interface_CheckIterator_HeaderFile