22 template <
class Tnode,
class Tedge>
26 nodeDefaultValue = Tnode::defaultValue();
27 edgeDefaultValue = Tedge::defaultValue();
28 nodeProperties.setAll(Tnode::defaultValue());
29 edgeProperties.setAll(Tedge::defaultValue());
30 metaValueCalculator = NULL;
33 template <
class Tnode,
class Tedge>
35 return nodeDefaultValue;
38 template <
class Tnode,
class Tedge>
40 return edgeDefaultValue;
43 template <
class Tnode,
class Tedge>
46 return nodeProperties.get(n.
id);
49 template <
class Tnode,
class Tedge>
52 return edgeProperties.get(e.
id);
55 template <
class Tnode,
class Tedge>
58 notifyBeforeSetNodeValue(n);
59 nodeProperties.set(n.
id,v);
60 notifyAfterSetNodeValue(n);
63 template <
class Tnode,
class Tedge>
66 notifyBeforeSetEdgeValue(e);
67 edgeProperties.set(e.
id,v);
68 notifyAfterSetEdgeValue(e);
71 template <
class Tnode,
class Tedge>
73 notifyBeforeSetAllNodeValue();
75 nodeProperties.setAll(v);
76 notifyAfterSetAllNodeValue();
79 template <
class Tnode,
class Tedge>
81 notifyBeforeSetAllEdgeValue();
83 edgeProperties.setAll(v);
84 notifyAfterSetAllEdgeValue();
87 template <
class Tnode,
class Tedge>
89 const typename Tnode::RealType& n1Value = getNodeValue(n1);
90 const typename Tnode::RealType& n2Value = getNodeValue(n2);
91 return (n1Value < n2Value) ? -1 : ((n1Value == n2Value) ? 0 : 1);
94 template <
class Tnode,
class Tedge>
96 const typename Tedge::RealType& e1Value = getEdgeValue(e1);
97 const typename Tedge::RealType& e2Value = getEdgeValue(e2);
98 return (e1Value < e2Value) ? -1 : ((e1Value == e2Value) ? 0 : 1);
104 #ifndef DOXYGEN_NOTFOR_DEVEL
105 template <
typename ELT_TYPE>
106 class GraphEltIterator :
public tlp::Iterator<ELT_TYPE> {
109 ELT_TYPE tmp = curElt;
111 if ((_hasnext = it->hasNext())) {
114 while (!(_hasnext = (!graph || graph->isElement(curElt)))) {
115 if (!it->hasNext())
break;
123 GraphEltIterator(
const tlp::Graph* g, tlp::Iterator<ELT_TYPE>* itN)
124 :it(itN), graph(g), curElt(ELT_TYPE()), _hasnext(false) {
131 ~GraphEltIterator() {
136 tlp::Iterator<ELT_TYPE> *it;
141 #endif // DOXYGEN_NOTFOR_DEVEL
143 template <
class Tnode,
class Tedge>
145 tlp::Iterator<tlp::node> *it =
146 new tlp::UINTIterator<tlp::node>(nodeProperties.findAll(nodeDefaultValue,
false));
152 return new GraphEltIterator<tlp::node>(g != NULL ? g : graph, it);
154 return ((g == NULL) || (g == graph)) ? it :
new GraphEltIterator<tlp::node>(g, it);
157 template <
class Tnode,
class Tedge>
159 tlp::Iterator<tlp::edge>* it =
160 new tlp::UINTIterator<tlp::edge>(edgeProperties.findAll(edgeDefaultValue,
false));
166 return new GraphEltIterator<tlp::edge>(g != NULL ? g : graph, it);
168 return ((g == NULL) || (g == graph)) ? it :
new GraphEltIterator<tlp::edge>(g, it);
171 template <
typename vectType,
typename eltType>
172 tlp::AbstractVectorProperty<vectType, eltType>::AbstractVectorProperty(
tlp::Graph* g, std::string name) :
AbstractProperty<vectType, vectType>(g, name) {}
174 template <
typename vectType,
typename eltType>
175 void tlp::AbstractVectorProperty<vectType, eltType>::setNodeEltValue(
const node n,
unsigned int i,
typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v) {
178 typename vectType::RealType& vect =
179 AbstractProperty<vectType, vectType>::nodeProperties.get(n, isNotDefault);
180 assert(vect.size() > i);
181 this->notifyBeforeSetNodeValue(n);
186 typename vectType::RealType tmp(vect);
188 AbstractProperty<vectType, vectType>::nodeProperties.set(n.id, tmp);
191 this->notifyAfterSetNodeValue(n);
194 template <
typename vectType,
typename eltType>
195 typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue
196 tlp::AbstractVectorProperty<vectType, eltType>::getNodeEltValue(
const node n,
unsigned int i)
const {
198 const typename vectType::RealType& vect =
199 AbstractProperty<vectType, vectType>::nodeProperties.get(n);
200 assert(vect.size() > i);
204 template <
typename vectType,
typename eltType>
205 void tlp::AbstractVectorProperty<vectType, eltType>::pushBackNodeEltValue(
const node n,
typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v) {
208 typename vectType::RealType& vect =
209 AbstractProperty<vectType, vectType>::nodeProperties.get(n, isNotDefault);
210 this->notifyBeforeSetNodeValue(n);
215 typename vectType::RealType tmp(vect);
217 AbstractProperty<vectType, vectType>::nodeProperties.set(n, tmp);
220 this->notifyAfterSetNodeValue(n);
223 template <
typename vectType,
typename eltType>
224 void tlp::AbstractVectorProperty<vectType, eltType>::popBackNodeEltValue(
const node n) {
227 typename vectType::RealType& vect =
228 AbstractProperty<vectType, vectType>::nodeProperties.get(n, isNotDefault);
229 this->notifyBeforeSetNodeValue(n);
230 assert(isNotDefault);
232 this->notifyAfterSetNodeValue(n);
235 template <
typename vectType,
typename eltType>
236 void tlp::AbstractVectorProperty<vectType, eltType>::resizeNodeValue(
const node n,
size_t size,
typename eltType::RealType elt) {
239 typename vectType::RealType& vect =
240 AbstractProperty<vectType, vectType>::nodeProperties.get(n, isNotDefault);
241 assert(isNotDefault);
242 this->notifyBeforeSetNodeValue(n);
243 vect.resize(size, elt);
244 this->notifyAfterSetNodeValue(n);
247 template <
typename vectType,
typename eltType>
248 void tlp::AbstractVectorProperty<vectType, eltType>::setEdgeEltValue(
const edge e,
unsigned int i,
typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v) {
251 typename vectType::RealType& vect =
252 AbstractProperty<vectType, vectType>::edgeProperties.get(e, isNotDefault);
253 assert(vect.size() > i);
254 this->notifyBeforeSetEdgeValue(e);
259 typename vectType::RealType tmp(vect);
261 AbstractProperty<vectType, vectType>::edgeProperties.set(e, tmp);
264 this->notifyAfterSetEdgeValue(e);
267 template <
typename vectType,
typename eltType>
268 typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue
269 tlp::AbstractVectorProperty<vectType, eltType>::getEdgeEltValue(
const edge e,
unsigned int i)
const {
271 const typename vectType::RealType& vect =
272 AbstractProperty<vectType, vectType>::edgeProperties.get(e);
273 assert(vect.size() > i);
276 template <
typename vectType,
typename eltType>
277 void tlp::AbstractVectorProperty<vectType, eltType>::pushBackEdgeEltValue(
const edge e,
typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v) {
280 typename vectType::RealType& vect =
281 AbstractProperty<vectType, vectType>::edgeProperties.get(e, isNotDefault);
282 this->notifyBeforeSetEdgeValue(e);
287 typename vectType::RealType tmp(vect);
289 AbstractProperty<vectType, vectType>::edgeProperties.set(e, tmp);
292 this->notifyAfterSetEdgeValue(e);
295 template <
typename vectType,
typename eltType>
296 void tlp::AbstractVectorProperty<vectType, eltType>::popBackEdgeEltValue(
const edge e) {
299 typename vectType::RealType& vect =
300 AbstractProperty<vectType, vectType>::edgeProperties.get(e, isNotDefault);
301 this->notifyBeforeSetEdgeValue(e);
302 assert(isNotDefault);
304 this->notifyAfterSetEdgeValue(e);
307 template <
typename vectType,
typename eltType>
308 void tlp::AbstractVectorProperty<vectType, eltType>::resizeEdgeValue(
const edge e,
size_t size,
typename eltType::RealType elt) {
311 typename vectType::RealType& vect =
312 AbstractProperty<vectType, vectType>::edgeProperties.get(e, isNotDefault);
313 assert(isNotDefault);
314 this->notifyBeforeSetEdgeValue(e);
315 vect.resize(size, elt);
316 this->notifyAfterSetEdgeValue(e);