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