42cf5bc1 |
1 | // Created on: 1994-10-27 |
2 | // Created by: Christian CAILLET |
3 | // Copyright (c) 1994-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 _IFSelect_SignatureList_HeaderFile |
18 | #define _IFSelect_SignatureList_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
23 | #include <Standard_Boolean.hxx> |
24 | #include <Standard_Integer.hxx> |
25 | #include <TCollection_AsciiString.hxx> |
25e59720 |
26 | #include <Standard_Transient.hxx> |
42cf5bc1 |
27 | #include <Standard_CString.hxx> |
28 | #include <TColStd_HSequenceOfHAsciiString.hxx> |
29 | #include <TColStd_HSequenceOfTransient.hxx> |
30 | #include <IFSelect_PrintCount.hxx> |
997e128f |
31 | #include <Standard_Transient.hxx> |
32 | #include <NCollection_IndexedDataMap.hxx> |
42cf5bc1 |
33 | class TCollection_HAsciiString; |
42cf5bc1 |
34 | class Interface_InterfaceModel; |
35 | |
36 | |
37 | class IFSelect_SignatureList; |
25e59720 |
38 | DEFINE_STANDARD_HANDLE(IFSelect_SignatureList, Standard_Transient) |
42cf5bc1 |
39 | |
40 | //! A SignatureList is given as result from a Counter (any kind) |
41 | //! It gives access to a list of signatures, with counts, and |
42 | //! optionally with list of corresponding entities |
43 | //! |
44 | //! It can also be used only to give a signature, through SignOnly |
45 | //! Mode. This can be useful for a specific counter (used in a |
46 | //! Selection), while it remains better to use a Signature |
47 | //! whenever possible |
25e59720 |
48 | class IFSelect_SignatureList : public Standard_Transient |
42cf5bc1 |
49 | { |
50 | |
51 | public: |
52 | |
53 | |
54 | //! Creates a SignatureList. If <withlist> is True, entities will |
55 | //! be not only counted per signature, but also listed. |
56 | Standard_EXPORT IFSelect_SignatureList(const Standard_Boolean withlist = Standard_False); |
57 | |
58 | //! Changes the record-list status. The list is not cleared but |
59 | //! its use changes |
60 | Standard_EXPORT void SetList (const Standard_Boolean withlist); |
61 | |
62 | //! Returns modifiable the SignOnly Mode |
63 | //! If False (D), the counter normally counts |
64 | //! If True, the counting work is turned off, Add only fills the |
65 | //! LastValue, which can be used as signature, when a counter |
66 | //! works from data which are not available from a Signature |
67 | Standard_EXPORT Standard_Boolean& ModeSignOnly(); |
68 | |
69 | Standard_EXPORT virtual void Clear(); |
70 | |
71 | //! Adds an entity with its signature, i.e. : |
72 | //! - counts an item more for <sign> |
73 | //! - if record-list status is set, records the entity |
74 | //! Accepts a null entity (the signature is then for the global |
75 | //! model). But if the string is empty, counts a Null item. |
76 | //! |
77 | //! If SignOnly Mode is set, this work is replaced by just |
78 | //! setting LastValue |
79 | Standard_EXPORT void Add (const Handle(Standard_Transient)& ent, const Standard_CString sign); |
80 | |
81 | //! Returns the last value recorded by Add (only if SignMode set) |
82 | //! Cleared by Clear or Init |
83 | Standard_EXPORT Standard_CString LastValue() const; |
84 | |
85 | //! Aknowledges the list in once. Name identifies the Signature |
997e128f |
86 | Standard_EXPORT void Init (const Standard_CString name, const NCollection_IndexedDataMap<TCollection_AsciiString, Standard_Integer>& count, const NCollection_IndexedDataMap<TCollection_AsciiString, Handle(Standard_Transient)>& list, const Standard_Integer nbnuls); |
42cf5bc1 |
87 | |
88 | //! Returns the list of signatures, as a sequence of strings |
89 | //! (but without their respective counts). It is ordered. |
90 | //! By default, for all the signatures. |
91 | //! If <root> is given non empty, for the signatures which |
92 | //! begin by <root> |
93 | Standard_EXPORT Handle(TColStd_HSequenceOfHAsciiString) List (const Standard_CString root = "") const; |
94 | |
95 | //! Returns True if the list of Entities is aknowledged, else |
96 | //! the method Entities will always return a Null Handle |
97 | Standard_EXPORT Standard_Boolean HasEntities() const; |
98 | |
99 | //! Returns the count of null entities |
100 | Standard_EXPORT Standard_Integer NbNulls() const; |
101 | |
102 | //! Returns the number of times a signature was counted, |
103 | //! 0 if it has not been recorded at all |
104 | Standard_EXPORT Standard_Integer NbTimes (const Standard_CString sign) const; |
105 | |
106 | //! Returns the list of entities attached to a signature |
107 | //! It is empty if <sign> has not been recorded |
108 | //! It is a Null Handle if the list of entities is not known |
109 | Standard_EXPORT Handle(TColStd_HSequenceOfTransient) Entities (const Standard_CString sign) const; |
110 | |
111 | //! Defines a name for a SignatureList (used to print it) |
112 | Standard_EXPORT void SetName (const Standard_CString name); |
113 | |
114 | //! Returns the recorded Name. |
115 | //! Remark : default is "..." (no SetName called) |
116 | Standard_EXPORT virtual Standard_CString Name() const; |
117 | |
118 | //! Prints the counts of items (not the list) |
0ebe5b0a |
119 | Standard_EXPORT virtual void PrintCount (Standard_OStream& S) const; |
42cf5bc1 |
120 | |
121 | //! Prints the lists of items, if they are present (else, prints |
122 | //! a message "no list available") |
123 | //! Uses <model> to determine for each entity to be listed, its |
124 | //! number, and its specific identifier (by PrintLabel) |
125 | //! <mod> gives a mode for printing : |
126 | //! - CountByItem : just count (as PrintCount) |
127 | //! - ShortByItem : minimum i.e. count plus 5 first entity numbers |
128 | //! - ShortByItem(D) complete list of entity numbers (0: "Global") |
129 | //! - EntitiesByItem : list of (entity number/PrintLabel from the model) |
130 | //! other modes are ignored |
0ebe5b0a |
131 | Standard_EXPORT virtual void PrintList (Standard_OStream& S, const Handle(Interface_InterfaceModel)& model, const IFSelect_PrintCount mod = IFSelect_ListByItem) const; |
42cf5bc1 |
132 | |
133 | //! Prints a summary |
134 | //! Item which has the greatest count of entities |
135 | //! For items which are numeric values : their count, maximum, |
136 | //! minimum values, cumul, average |
0ebe5b0a |
137 | Standard_EXPORT virtual void PrintSum (Standard_OStream& S) const; |
42cf5bc1 |
138 | |
139 | |
140 | |
141 | |
25e59720 |
142 | DEFINE_STANDARD_RTTIEXT(IFSelect_SignatureList,Standard_Transient) |
42cf5bc1 |
143 | |
144 | protected: |
145 | |
146 | |
147 | |
148 | |
149 | private: |
150 | |
151 | |
152 | Standard_Boolean thesignonly; |
153 | Standard_Boolean thelistat; |
154 | Standard_Integer thenbnuls; |
155 | Handle(TCollection_HAsciiString) thename; |
156 | TCollection_AsciiString thelastval; |
997e128f |
157 | NCollection_IndexedDataMap<TCollection_AsciiString, Standard_Integer> thedicount; |
158 | NCollection_IndexedDataMap<TCollection_AsciiString, Handle(Standard_Transient)> thediclist; |
42cf5bc1 |
159 | |
160 | |
161 | }; |
162 | |
163 | |
164 | |
165 | |
166 | |
167 | |
168 | |
169 | #endif // _IFSelect_SignatureList_HeaderFile |