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