Version: 8.3.0
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
SALOME GUI Developer
Todo List
Namespaces
Classes
Files
File List
idl
src
CAF
CAM
CASCatch
DDS
Event
GLViewer
GraphicsView
GuiHelpers
HelpBrowser
ImageComposer
LightApp
LogWindow
ObjBrowser
OBJECT
OCCViewer
OpenGLUtils
Plot2d
Prs
PVServerService
PVViewer
PyViewer
QDS
Qtx
Qtx.cxx
Qtx.h
QtxAction.cxx
QtxAction.h
QtxActionGroup.cxx
QtxActionGroup.h
QtxActionMenuMgr.cxx
QtxActionMenuMgr.h
QtxActionMgr.cxx
QtxActionMgr.h
QtxActionSet.cxx
QtxActionSet.h
QtxActionToolMgr.cxx
QtxActionToolMgr.h
QtxBackgroundTool.cxx
QtxBackgroundTool.h
QtxBiColorTool.cxx
QtxBiColorTool.h
QtxColorButton.cxx
QtxColorButton.h
QtxColorScale.cxx
QtxColorScale.h
QtxComboBox.cxx
QtxComboBox.h
QtxDialog.cxx
QtxDialog.h
QtxDockAction.cxx
QtxDockAction.h
QtxDockWidget.cxx
QtxDockWidget.h
QtxDoubleSpinBox.cxx
QtxDoubleSpinBox.h
QtxDoubleSpinSlider.cxx
QtxDoubleSpinSlider.h
QtxEvalExpr.cxx
QtxEvalExpr.h
QtxFontEdit.cxx
QtxFontEdit.h
QtxGridBox.cxx
QtxGridBox.h
QtxGroupBox.cxx
QtxGroupBox.h
QtxIntSpinBox.cxx
QtxIntSpinBox.h
QtxIntSpinSlider.cxx
QtxIntSpinSlider.h
QtxListAction.cxx
QtxListAction.h
QtxListBox.cxx
QtxListBox.h
QtxLogoMgr.cxx
QtxLogoMgr.h
QtxMainWindow.cxx
QtxMainWindow.h
QtxMap.h
QtxMenu.cxx
QtxMenu.h
QtxMRUAction.cxx
QtxMRUAction.h
QtxMultiAction.cxx
QtxMultiAction.h
QtxPagePrefMgr.cxx
QtxPagePrefMgr.h
QtxPathDialog.cxx
QtxPathDialog.h
QtxPathEdit.cxx
QtxPathEdit.h
QtxPathListEdit.cxx
QtxPathListEdit.h
QtxPopupMgr.cxx
QtxPopupMgr.h
QtxPreferenceMgr.cxx
QtxPreferenceMgr.h
QtxResourceMgr.cxx
QtxResourceMgr.h
QtxRubberBand.cxx
QtxRubberBand.h
QtxSearchTool.cxx
QtxSearchTool.h
QtxShortcutEdit.cxx
QtxShortcutEdit.h
QtxSlider.cxx
QtxSlider.h
QtxSplash.cxx
QtxSplash.h
QtxTable.cxx
QtxTable.h
QtxToolBar.cxx
QtxToolBar.h
QtxToolButton.cxx
QtxToolButton.h
QtxToolTip.cxx
QtxToolTip.h
QtxTranslator.cxx
QtxTranslator.h
QtxTreeView.cxx
QtxTreeView.h
QtxValidator.cxx
QtxValidator.h
QtxWebBrowser.cxx
QtxWebBrowser.h
QtxWorkspace.cxx
QtxWorkspace.h
QtxWorkspaceAction.cxx
QtxWorkspaceAction.h
QtxWorkstack.cxx
QtxWorkstack.h
QtxWorkstackAction.cxx
QtxWorkstackAction.h
QxScene
SALOME_PY
SALOME_PYQT
SALOME_SWIG
SalomeApp
Session
SOCC
SPlot2d
STD
Style
SUIT
SUITApp
SVTK
TOOLSGUI
TreeData
ViewerData
ViewerTools
VTKViewer
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
QtxMap.h
Go to the documentation of this file.
1
// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2
//
3
// This library is free software; you can redistribute it and/or
4
// modify it under the terms of the GNU Lesser General Public
5
// License as published by the Free Software Foundation; either
6
// version 2.1 of the License, or (at your option) any later version.
7
//
8
// This library is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
// Lesser General Public License for more details.
12
//
13
// You should have received a copy of the GNU Lesser General Public
14
// License along with this library; if not, write to the Free Software
15
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
//
17
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18
//
19
20
// File : QtxMap.h
21
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
22
//
23
#ifndef QTXMAP_H
24
#define QTXMAP_H
25
26
template
<
class
Key,
class
Value>
class
IMap
;
27
template
<
class
Key,
class
Value>
class
IMapIterator
;
28
template
<
class
Key,
class
Value>
class
IMapConstIterator
;
29
33
template
<
class
Key,
class
Value>
class
IMap
34
{
35
public
:
36
typedef
IMapIterator<Key,Value>
Iterator
;
37
typedef
IMapConstIterator<Key,Value>
ConstIterator
;
38
39
public
:
40
IMap
() {}
41
IMap
(
const
IMap
& m ) :
myKeys
( m.
myKeys
),
myData
( m.
myData
) {}
42
IMap
&
operator=
(
const
IMap
& m ) {
myKeys
= m.
myKeys
;
myData
= m.
myData
;
return
*
this
; }
43
44
int
count
()
const
{
return
myData
.count(); }
45
int
size
()
const
{
return
myData
.count(); }
46
bool
empty
()
const
{
return
myData
.empty(); }
47
bool
isEmpty
()
const
{
return
myData
.empty(); }
48
49
void
clear
() {
myKeys
.clear();
myData
.clear(); }
50
51
QList<Key>
keys
()
const
{
return
myKeys
; }
52
QList<Value>
values
()
const
{
QList<Value>
l;
for
(
int
i = 0; i <
count
(); i++ ) l.append(
value
( i ) );
return
l; }
53
bool
contains
(
const
Key&
key
)
const
{
return
myData
.contains( key ); }
54
55
Iterator
begin
() {
return
Iterator
(
this
); }
56
Iterator
end
() {
return
Iterator
(
this
,
count
() ); }
57
ConstIterator
begin
()
const
{
return
ConstIterator
(
this
); }
58
ConstIterator
end
()
const
{
return
ConstIterator
(
this
,
count
() ); }
59
60
Iterator
insert
(
const
Key&
key
,
const
Value&
value
,
bool
overwrite =
true
)
61
{
62
if
(
myData
.find( key ) ==
myData
.end() || overwrite )
63
{
64
if
(
myData
.find( key ) !=
myData
.end() && overwrite )
65
myKeys
.removeAt(
myKeys
.indexOf( key ) );
66
myKeys
.append( key );
67
myData
[
key
] =
value
;
68
}
69
return
Iterator
(
this
,
index
( key ) );
70
}
71
72
Iterator
replace
(
const
Key&
key
,
const
Value&
value
)
73
{
74
if
(
myData
.find( key ) ==
myData
.end() )
75
myKeys
.append( key );
76
myData
[
key
] =
value
;
77
return
Iterator
(
this
,
index
( key ) );
78
}
79
80
int
index
(
const
Key&
key
)
const
{
return
myKeys
.indexOf( key ); }
81
Iterator
at
(
const
int
index
) {
return
Iterator
(
this
, index ); }
82
ConstIterator
at
(
const
int
index
)
const
{
return
ConstIterator
(
this
, index ); }
83
84
Key&
key
(
const
int
index
)
85
{
86
if
( index < 0 || index >= (
int
)
myKeys
.count() )
87
return
dummyKey
;
88
return
myKeys
[
index
];
89
}
90
91
Value
value
(
const
int
index
)
92
{
93
if
( index < 0 || index >= (
int
)
myKeys
.count() )
94
return
dummyValue
;
95
return
myData
[
myKeys
[
index
] ];
96
}
97
98
Value
operator[]
(
const
Key&
key
)
99
{
100
if
(
myData
.find( key ) ==
myData
.end() )
101
insert
( key, Value() );
102
return
myData
[
key
];
103
}
104
105
const
Value
operator[]
(
const
Key&
key
)
const
106
{
107
if
(
myData
.find( key ) ==
myData
.end() )
108
return
dummyValue
;
109
return
myData
[
key
];
110
}
111
112
void
erase
(
Iterator
it ) {
remove
( it ); }
113
void
erase
(
const
Key&
key
) {
remove
(
key
); }
114
void
erase
(
const
int
index
) {
remove
(
index
); }
115
void
remove
(
Iterator
it ) {
if
( it.myMap !=
this
)
return
;
remove
( it.myIndex ); }
116
void
remove
(
const
Key&
key
) {
remove
(
index
(
key
) ); }
117
void
remove
(
const
int
index
)
118
{
119
if
(
index
>= 0 &&
index
< (
int
)
myKeys
.count() )
120
{
121
myData
.remove(
myKeys
[
index
] );
122
myKeys
.removeAt( index );
123
}
124
}
125
126
private
:
127
QList<Key>
myKeys
;
128
QMap<Key,Value>
myData
;
129
Key
dummyKey
;
130
Value
dummyValue
;
131
132
friend
class
IMapIterator
<Key,Value>;
133
friend
class
IMapConstIterator
<Key,Value>;
134
};
135
139
template
<
class
Key,
class
Value>
class
IMapIterator
140
{
141
public
:
142
IMapIterator
() :
myMap
( 0 ),
myIndex
( 0 ) {
init
(); }
143
IMapIterator
(
const
IMap<Key,Value>
* m ) :
myMap
( const_cast<
IMap
<Key,Value>* >( m ) ),
myIndex
( 0 ) {
init
(); }
144
IMapIterator
(
const
IMapIterator
& i ) :
myMap
( i.
myMap
),
myIndex
( i.
myIndex
) {
init
(); }
145
146
bool
operator==
(
const
IMapIterator
& i ) {
return
!
operator!=
( i ); }
147
bool
operator!=
(
const
IMapIterator
& i ) {
return
!
myMap
||
myMap
!= i.
myMap
||
myIndex
!= i.
myIndex
; }
148
149
operator
bool()
const
{
return
myIndex
>= 0; }
150
151
const
Key&
key
()
const
{
return
myMap
->key(
myIndex
); }
152
Value&
value
() {
return
myMap
->value(
myIndex
); }
153
const
Value&
value
()
const
{
return
myMap
->value(
myIndex
); }
154
155
Value&
operator*
() {
return
value
(); }
156
157
IMapIterator
&
operator++
() {
myIndex
++;
init
();
return
*
this
; }
158
IMapIterator
operator++
(
int
) {
IMapIterator
i = *
this
;
myIndex
++;
init
();
return
i; }
159
IMapIterator
&
operator--
() {
myIndex
--;
init
();
return
*
this
; }
160
IMapIterator
operator--
(
int
) {
IMapIterator
i = *
this
;
myIndex
--;
init
();
return
i; }
161
162
private
:
163
IMapIterator
(
const
IMap<Key,Value>
* m,
const
int
index ) :
myMap
( const_cast<
IMap
<Key,Value>* >( m ) ),
myIndex
( index ) {
init
(); }
164
void
init
() {
if
( !
myMap
||
myIndex
>=
myMap
->count() )
myIndex
= -1; }
165
166
private
:
167
IMap<Key,Value>
*
myMap
;
168
int
myIndex
;
169
170
friend
class
IMap
<Key, Value>;
171
friend
class
IMapConstIterator
<Key, Value>;
172
};
173
177
template
<
class
Key,
class
Value>
class
IMapConstIterator
178
{
179
public
:
180
IMapConstIterator
() :
myMap
( 0 ),
myIndex
( 0 ) {
init
(); }
181
IMapConstIterator
(
const
IMap<Key,Value>
* m ) :
myMap
( const_cast<
IMap
<Key,Value>* >( m ) ),
myIndex
( 0 ) {
init
(); }
182
IMapConstIterator
(
const
IMapConstIterator
& i ) :
myMap
( i.
myMap
),
myIndex
( i.
myIndex
) {
init
(); }
183
IMapConstIterator
(
const
IMapIterator<Key, Value>
& i ) :
myMap
( i.
myMap
),
myIndex
( i.
myIndex
) {
init
(); }
184
185
bool
operator==
(
const
IMapConstIterator
& i ) {
return
!
operator!=
( i ); }
186
bool
operator!=
(
const
IMapConstIterator
& i ) {
return
!
myMap
||
myMap
!= i.
myMap
||
myIndex
!= i.
myIndex
; }
187
188
operator
bool()
const
{
return
myIndex
>= 0; }
189
190
const
Key&
key
()
const
{
return
myMap
->key(
myIndex
); }
191
const
Value
value
()
const
{
return
myMap
->value(
myIndex
); }
192
193
const
Value
operator*
()
const
{
return
value
(); }
194
195
IMapConstIterator
&
operator++
() {
myIndex
++;
init
();
return
*
this
; }
196
IMapConstIterator
operator++
(
int
) {
IMapConstIterator
i = *
this
;
myIndex
++;
init
();
return
i; }
197
IMapConstIterator
&
operator--
() {
myIndex
--;
init
();
return
*
this
; }
198
IMapConstIterator
operator--
(
int
) {
IMapConstIterator
i = *
this
;
myIndex
--;
init
();
return
i; }
199
200
private
:
201
IMapConstIterator
(
const
IMap<Key,Value>
* m,
const
int
index ):
myMap
( const_cast<
IMap
<Key,Value>* >( m ) ),
myIndex
( index ) {
init
(); }
202
void
init
() {
if
( !
myMap
||
myIndex
>=
myMap
->count() )
myIndex
= -1; }
203
204
private
:
205
IMap<Key,Value>
*
myMap
;
206
int
myIndex
;
207
208
friend
class
IMap
<Key,Value>;
209
};
210
211
#endif // QTXMAP_H
src
Qtx
QtxMap.h
Copyright © 2007-2017 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS