42cf5bc1 |
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 |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
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. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _Interface_CheckIterator_HeaderFile |
18 | #define _Interface_CheckIterator_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
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; |
42cf5bc1 |
37 | |
9fd2d2c3 |
38 | // resolve name collisions with X11 headers |
39 | #ifdef Status |
40 | #undef Status |
41 | #endif |
42cf5bc1 |
42 | |
43 | //! Result of a Check operation (especially from InterfaceModel) |
44 | class Interface_CheckIterator |
45 | { |
46 | public: |
47 | |
48 | DEFINE_STANDARD_ALLOC |
49 | |
50 | |
51 | //! Creates an empty CheckIterator |
52 | Standard_EXPORT Interface_CheckIterator(); |
53 | |
54 | //! Creates a CheckIterator with a name (displayed by Print as a |
55 | //! title) |
56 | Standard_EXPORT Interface_CheckIterator(const Standard_CString name); |
57 | |
58 | //! Sets / Changes the name |
59 | Standard_EXPORT void SetName (const Standard_CString name); |
60 | |
61 | //! Returns the recorded name (can be empty) |
62 | Standard_EXPORT Standard_CString Name() const; |
63 | |
64 | //! Defines a Model, used to locate entities (not required, if it |
65 | //! is absent, entities are simply less documented) |
66 | Standard_EXPORT void SetModel (const Handle(Interface_InterfaceModel)& model); |
67 | |
68 | //! Returns the stored model (can be a null handle) |
69 | Standard_EXPORT Handle(Interface_InterfaceModel) Model() const; |
70 | |
71 | //! Clears the list of checks |
72 | Standard_EXPORT void Clear(); |
73 | |
74 | //! Merges another CheckIterator into <me>, i.e. adds each of its |
75 | //! Checks. Content of <other> remains unchanged. |
76 | //! Takes also the Model but not the Name |
77 | Standard_EXPORT void Merge (Interface_CheckIterator& other); |
78 | |
79 | //! Adds a Check to the list to be iterated |
80 | //! This Check is Accompanied by Entity Number in the Model |
81 | //! (0 for Global Check or Entity unknown in the Model), if 0 and |
82 | //! Model is recorded in <me>, it is computed |
83 | Standard_EXPORT void Add (const Handle(Interface_Check)& ach, const Standard_Integer num = 0); |
84 | |
85 | //! Returns the Check which was attached to an Entity given its |
86 | //! Number in the Model. <num>=0 is for the Global Check. |
87 | //! If no Check was recorded for this Number, returns an empty |
88 | //! Check. |
89 | //! Remark : Works apart from the iteration methods (no interference) |
90 | Standard_EXPORT const Handle(Interface_Check)& Check (const Standard_Integer num) const; |
91 | |
92 | //! Returns the Check attached to an Entity |
93 | //! If no Check was recorded for this Entity, returns an empty |
94 | //! Check. |
95 | //! Remark : Works apart from the iteration methods (no interference) |
96 | Standard_EXPORT const Handle(Interface_Check)& Check (const Handle(Standard_Transient)& ent) const; |
97 | |
98 | //! Returns the Check bound to an Entity Number (0 : Global) |
99 | //! in order to be consulted or completed on the spot |
100 | //! I.e. returns the Check if is already exists, or adds it then |
101 | //! returns the new empty Check |
102 | Standard_EXPORT Handle(Interface_Check)& CCheck (const Standard_Integer num); |
103 | |
104 | //! Returns the Check bound to an Entity, in order to be consulted |
105 | //! or completed on the spot |
106 | //! I.e. returns the Check if is already exists, or adds it then |
107 | //! returns the new empty Check |
108 | Standard_EXPORT Handle(Interface_Check)& CCheck (const Handle(Standard_Transient)& ent); |
109 | |
110 | //! Returns True if : no Fail has been recorded if <failsonly> is |
111 | //! True, no Check at all if <failsonly> is False |
112 | Standard_EXPORT Standard_Boolean IsEmpty (const Standard_Boolean failsonly) const; |
113 | |
114 | //! Returns worst status among : OK, Warning, Fail |
115 | Standard_EXPORT Interface_CheckStatus Status() const; |
116 | |
117 | //! Tells if this check list complies with a given status : |
118 | //! OK (i.e. empty), Warning (at least one Warning, but no Fail), |
119 | //! Fail (at least one), Message (not OK), NoFail, Any |
120 | Standard_EXPORT Standard_Boolean Complies (const Interface_CheckStatus status) const; |
121 | |
122 | //! Returns a CheckIterator which contains the checks which comply |
123 | //! with a given status |
124 | //! Each check is added completely (no split Warning/Fail) |
125 | Standard_EXPORT Interface_CheckIterator Extract (const Interface_CheckStatus status) const; |
126 | |
127 | //! Returns a CheckIterator which contains the check which comply |
128 | //! with a message, plus some conditions as follows : |
129 | //! <incl> = 0 : <mess> exactly matches one of the messages |
130 | //! <incl> < 0 : <mess> is contained by one of the messages |
131 | //! <incl> > 0 : <mess> contains one of the messages |
132 | //! For <status> : for CheckWarning and CheckFail, considers only |
133 | //! resp. Warning or Check messages. for CheckAny, considers all |
134 | //! other values are ignored (answer will be false) |
135 | //! Each Check which complies is entirely taken |
136 | Standard_EXPORT Interface_CheckIterator Extract (const Standard_CString mess, const Standard_Integer incl, const Interface_CheckStatus status) const; |
137 | |
138 | //! Removes the messages of all Checks, under these conditions : |
139 | //! <incl> = 0 : <mess> exactly matches one of the messages |
140 | //! <incl> < 0 : <mess> is contained by one of the messages |
141 | //! <incl> > 0 : <mess> contains one of the messages |
142 | //! For <status> : for CheckWarning and CheckFail, considers only |
143 | //! resp. Warning or Check messages. for CheckAny, considers all |
144 | //! other values are ignored (nothing is done) |
145 | //! Returns True if at least one message has been removed, False else |
146 | Standard_EXPORT Standard_Boolean Remove (const Standard_CString mess, const Standard_Integer incl, const Interface_CheckStatus status); |
147 | |
148 | //! Returns the list of entities concerned by a Check |
149 | //! Only fails if <failsonly> is True, else all non-empty checks |
150 | //! If <global> is true, adds the model for a global check |
151 | //! Else, global check is ignored |
152 | Standard_EXPORT Handle(TColStd_HSequenceOfTransient) Checkeds (const Standard_Boolean failsonly, const Standard_Boolean global) const; |
153 | |
154 | //! Starts Iteration. Thus, it is possible to restart it |
155 | //! Remark : an iteration may be done with a const Iterator |
156 | //! While its content is modified (through a pointer), this allows |
157 | //! to give it as a const argument to a function |
158 | Standard_EXPORT void Start() const; |
159 | |
160 | //! Returns True if there are more Checks to get |
161 | Standard_EXPORT Standard_Boolean More() const; |
162 | |
163 | //! Sets Iteration to next Item |
164 | Standard_EXPORT void Next() const; |
165 | |
166 | //! Returns Check currently Iterated |
167 | //! It brings all other informations (status, messages, ...) |
168 | //! The Number of the Entity in the Model is given by Number below |
169 | Standard_EXPORT const Handle(Interface_Check)& Value() const; |
170 | |
171 | //! Returns Number of Entity for the Check currently iterated |
172 | //! or 0 for GlobalCheck |
173 | Standard_EXPORT Standard_Integer Number() const; |
174 | |
175 | //! Prints the list of Checks with their attached Numbers |
176 | //! If <failsonly> is True, prints only Fail messages |
177 | //! If <failsonly> is False, prints all messages |
178 | //! If <final> = 0 (D), prints also original messages if different |
179 | //! If <final> < 0, prints only original messages |
180 | //! If <final> > 0, prints only final messages |
181 | //! It uses the recorded Model if it is defined |
182 | //! Remark : Works apart from the iteration methods (no interference) |
0ebe5b0a |
183 | Standard_EXPORT void Print (Standard_OStream& S, const Standard_Boolean failsonly, const Standard_Integer final = 0) const; |
42cf5bc1 |
184 | |
185 | //! Works as Print without a model, but for entities which have |
186 | //! no attached number (Number not positive), tries to compute |
187 | //! this Number from <model> and displays "original" or "computed" |
0ebe5b0a |
188 | Standard_EXPORT void Print (Standard_OStream& S, const Handle(Interface_InterfaceModel)& model, const Standard_Boolean failsonly, const Standard_Integer final = 0) const; |
42cf5bc1 |
189 | |
190 | //! Clears data of iteration |
191 | Standard_EXPORT void Destroy(); |
192 | ~Interface_CheckIterator() |
193 | { |
194 | Destroy(); |
195 | } |
196 | |
197 | |
198 | |
199 | |
200 | protected: |
201 | |
202 | |
203 | |
204 | |
205 | |
206 | private: |
207 | |
208 | |
209 | |
210 | Handle(Interface_HSequenceOfCheck) thelist; |
211 | Handle(TColStd_HSequenceOfInteger) thenums; |
212 | Handle(Interface_InterfaceModel) themod; |
213 | TCollection_AsciiString thename; |
214 | Handle(Interface_IntVal) thecurr; |
215 | |
216 | |
217 | }; |
218 | |
219 | |
220 | |
221 | |
222 | |
223 | |
224 | |
225 | #endif // _Interface_CheckIterator_HeaderFile |