Moka kernel
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
Moka kernel
Todo List
Namespaces
Classes
Files
File List
lib-gmapkernel
g-map
attribute.cc
attribute.hh
attribute.icc
coverage.cc
coverage.hh
coverage.icc
dart.cc
dart.hh
dart.icc
dynamic-coverage.cc
dynamic-coverage.hh
embedding.cc
embedding.hh
embedding.icc
g-map-basic.cc
g-map-basic.hh
g-map-basic.icc
g-map.cc
g-map.hh
g-map.icc
kernel-types.hh
static-coverage.cc
static-coverage.hh
g-map-generic
g-map-vertex
tools
alt-stdint.hh
attributes-id.hh
chrono.hh
inline-macro.hh
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
embedding.icc
Go to the documentation of this file.
1
/*
2
* lib-gmapkernel : Un noyau de 3-G-cartes et des opérations.
3
* Copyright (C) 2004, Moka Team, Université de Poitiers, Laboratoire SIC
4
* http://www.sic.sp2mi.univ-poitiers.fr/
5
* Copyright (C) 2009, Guillaume Damiand, CNRS, LIRIS,
6
* guillaume.damiand@liris.cnrs.fr, http://liris.cnrs.fr/
7
*
8
* This file is part of lib-gmapkernel
9
*
10
* This program is free software: you can redistribute it and/or modify
11
* it under the terms of the GNU Lesser General Public License as published by
12
* the Free Software Foundation, either version 3 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Lesser General Public License for more details.
19
*
20
* You should have received a copy of the GNU Lesser General Public License
21
* along with this program. If not, see <http://www.gnu.org/licenses/>.
22
*/
23
24
//******************************************************************************
40
//******************************************************************************
41
#include "
attribute.hh
"
42
43
#include <cassert>
44
//******************************************************************************
45
INLINE
46
CEmbedding
*
CEmbedding::getPrev
()
const
47
{
48
return
FPrev;
49
}
50
//******************************************************************************
51
INLINE
52
void
CEmbedding::setPrev
(
CEmbedding
* AEmbedding)
53
{
54
FPrev = AEmbedding;
55
}
56
//******************************************************************************
57
INLINE
58
CEmbedding
*
CEmbedding::getNext
()
const
59
{
60
return
FNext;
61
}
62
//******************************************************************************
63
INLINE
64
void
CEmbedding::setNext
(
CEmbedding
* AEmbedding)
65
{
66
FNext = AEmbedding;
67
}
68
//******************************************************************************
69
INLINE
70
CAttribute
*
CEmbedding::getFirstAttribute
()
const
71
{
72
return
FFirstAttribute;
73
}
74
//******************************************************************************
75
INLINE
76
void
CEmbedding::setFirstAttribute
(
CAttribute
* AAttribute)
77
{
78
FFirstAttribute = AAttribute;
79
}
80
//******************************************************************************
81
INLINE
82
CEmbedding::CEmbedding
(
TOrbit
AOrbit) :
83
FFirstAttribute(NULL),
84
FId (AOrbit),
85
FPrev (NULL),
86
FNext (NULL)
87
{
88
}
89
//******************************************************************************
90
INLINE
91
CEmbedding::CEmbedding
(
const
CEmbedding
& AEmbedding) :
92
FFirstAttribute(NULL),
93
FId (AEmbedding.FId),
94
FPrev (NULL),
95
FNext (NULL)
96
97
{
98
CAttribute
*
A
= AEmbedding.
getFirstAttribute
();
99
100
while
( A!=NULL )
101
{
102
addAttribute
(A->
copy
());
103
A = A->
getNext
();
104
}
105
}
106
//******************************************************************************
107
INLINE
108
CEmbedding::~CEmbedding
()
109
{
110
CAttribute
*
A
=
getFirstAttribute
();
111
CAttribute
* tmp = NULL;
112
113
while
( A!=NULL )
114
{
115
tmp = A;
116
A = A->
getNext
();
117
tmp->
destroy
();
118
}
119
}
120
//******************************************************************************
121
INLINE
122
TOrbit
CEmbedding::getOrbit
()
const
123
{
124
return
FId;
125
}
126
//******************************************************************************
127
INLINE
128
CAttribute
*
CEmbedding::getAttribute
(
TAttributeId
AAttribType)
const
129
{
130
CAttribute
*
A
=
getFirstAttribute
();
131
132
while
( A!=NULL )
133
{
134
if
( A->
getType
()==AAttribType )
135
return
A;
// On alpha trouvé l'attribut
136
137
A = A->
getNext
();
138
}
139
140
return
NULL;
// Il n'existe pas d'attribut de ce type
141
}
142
//******************************************************************************
143
INLINE
144
void
CEmbedding::addAttribute
(
CAttribute
* AAttribute)
145
{
146
assert( AAttribute!=NULL );
147
assert( AAttribute->
getPrev
()==NULL && AAttribute->
getNext
()==NULL );
148
assert(
getAttribute
(AAttribute->
getType
())==NULL );
149
150
// Insertion en tête de la liste
151
if
(
getFirstAttribute
()!=NULL )
152
// Si la liste des attributs n'est pas vide on modifie le chaînage :
153
{
154
getFirstAttribute
()->
setPrev
(AAttribute);
155
AAttribute->
setNext
(
getFirstAttribute
());
156
}
157
158
setFirstAttribute
(AAttribute);
// Le premier attribut est AAttribute
159
}
160
//******************************************************************************
167
INLINE
168
CEmbedding
*
CEmbedding::copy
()
const
169
{
170
return
new
CEmbedding
(*
this
);
171
}
172
//******************************************************************************
177
INLINE
178
void
CEmbedding::destroy
()
179
{
180
delete
this
;
181
}
182
//******************************************************************************
189
INLINE
190
CAttribute
*
CEmbedding::removeAttribute
(
CAttribute
* AAttribute)
191
{
192
assert( AAttribute!=NULL );
193
assert(
getAttribute
(AAttribute->
getType
())==AAttribute );
194
195
if
(
getFirstAttribute
()==AAttribute )
196
// Si l'attribut à enlever est le premier :
197
{
198
assert( AAttribute->
getPrev
()==NULL );
199
// On décale le premier attribut :
200
setFirstAttribute
(AAttribute->
getNext
());
201
}
202
else
203
{
204
assert( AAttribute->
getPrev
()!=NULL );
205
// Sinon on modifie le chaînage next :
206
AAttribute->
getPrev
()->
setNext
(AAttribute->
getNext
());
207
}
208
209
if
( AAttribute->
getNext
()!=NULL )
210
// Si l'attribut supprimé n'est pas le dernier de la liste,
211
// on modifie le chaînage prev :
212
AAttribute->
getNext
()->
setPrev
(AAttribute->
getPrev
());
213
214
return
AAttribute;
215
}
216
//******************************************************************************
222
INLINE
223
CAttribute
*
CEmbedding::removeAttribute
(
TAttributeId
AAttribType)
224
{
225
CAttribute
*
A
=
getAttribute
(AAttribType);
226
227
if
(A != NULL)
228
return
removeAttribute
(A);
229
230
return
NULL;
231
}
232
//******************************************************************************
238
INLINE
239
void
CEmbedding::deleteAttribute
(
CAttribute
* AAttribute)
240
{
241
assert( AAttribute!=NULL );
242
243
removeAttribute
(AAttribute);
// Suppression l'attribut de la liste.
244
AAttribute->
destroy
();
// Appel de la méthode destroy() sur l'instance.
245
}
246
//******************************************************************************
252
INLINE
253
void
CEmbedding::deleteAttribute
(
TAttributeId
AAttribType)
254
{
255
CAttribute
*
A
=
removeAttribute
(AAttribType);
256
257
if
(A != NULL)
258
A->
destroy
();
259
}
260
//******************************************************************************
267
INLINE
268
void
CEmbedding::mergeAttribute
(
CEmbedding
* AEmbedding)
269
{
270
assert( FId==AEmbedding->FId );
// la précondition
271
272
CAttribute
*
A
= AEmbedding->
getFirstAttribute
();
273
CAttribute
* tmp = NULL;
274
275
while
(A != NULL)
// Parcours de chaque attribut de AEmbedding
276
{
277
tmp = A;
278
A = A->
getNext
();
279
280
if
(
getAttribute
(tmp->
getType
())==NULL )
281
// Si l'attribut courant du parcours n'est pas présent dans les
282
// attributs de l'instance...
283
{
284
// On enlève cet attribut de AEmbedding :
285
AEmbedding->
removeAttribute
(tmp);
286
tmp->
setPrev
(NULL);
287
tmp->
setNext
(NULL);
288
// Et on l'ajoute dans les attributs de l'instance :
289
addAttribute
(tmp);
290
}
291
}
292
}
293
//******************************************************************************
294
// Accesseur pour tester si la liste des attributs de l'instance est vide
295
INLINE
296
bool
CEmbedding::isEmpty
()
const
297
{
298
return
getFirstAttribute
() == NULL;
299
}
300
//******************************************************************************
lib-gmapkernel
g-map
embedding.icc
Generated on Tue Apr 9 2013 09:51:35 for Moka kernel by
1.8.2