22 template <
class Tnode,
class Tedge,
class Tprop>
26 nodeDefaultValue = Tnode::defaultValue();
27 edgeDefaultValue = Tedge::defaultValue();
28 nodeProperties.setAll(Tnode::defaultValue());
29 edgeProperties.setAll(Tedge::defaultValue());
30 Tprop::metaValueCalculator = NULL;
33 template <
class Tnode,
class Tedge,
class Tprop>
35 return nodeDefaultValue;
38 template <
class Tnode,
class Tedge,
class Tprop>
40 return edgeDefaultValue;
43 template <
class Tnode,
class Tedge,
class Tprop>
46 return nodeProperties.get(n.
id);
49 template <
class Tnode,
class Tedge,
class Tprop>
52 return edgeProperties.get(e.
id);
55 template <
class Tnode,
class Tedge,
class Tprop>
58 Tprop::notifyBeforeSetNodeValue(n);
59 nodeProperties.set(n.
id,v);
60 Tprop::notifyAfterSetNodeValue(n);
63 template <
class Tnode,
class Tedge,
class Tprop>
66 Tprop::notifyBeforeSetEdgeValue(e);
67 edgeProperties.set(e.
id,v);
68 Tprop::notifyAfterSetEdgeValue(e);
71 template <
class Tnode,
class Tedge,
class Tprop>
73 Tprop::notifyBeforeSetAllNodeValue();
75 nodeProperties.setAll(v);
76 Tprop::notifyAfterSetAllNodeValue();
79 template <
class Tnode,
class Tedge,
class Tprop>
81 Tprop::notifyBeforeSetAllEdgeValue();
83 edgeProperties.setAll(v);
84 Tprop::notifyAfterSetAllEdgeValue();
87 template <
class Tnode,
class Tedge,
class Tprop>
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,
class Tprop>
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,
class Tprop>
145 tlp::Iterator<tlp::node> *it =
146 new tlp::UINTIterator<tlp::node>(nodeProperties.findAll(nodeDefaultValue,
false));
148 if (Tprop::name.empty())
152 return new GraphEltIterator<tlp::node>(g != NULL ? g : Tprop::graph, it);
154 return ((g == NULL) || (g == Tprop::graph)) ? it :
new GraphEltIterator<tlp::node>(g, it);
157 template <
class Tnode,
class Tedge,
class Tprop>
159 tlp::Iterator<tlp::edge>* it =
160 new tlp::UINTIterator<tlp::edge>(edgeProperties.findAll(edgeDefaultValue,
false));
162 if (Tprop::name.empty())
166 return new GraphEltIterator<tlp::edge>(g != NULL ? g : Tprop::graph, it);
168 return ((g == NULL) || (g == Tprop::graph)) ? it :
new GraphEltIterator<tlp::edge>(g, it);
171 template <
typename vectType,
typename eltType,
typename propType>
172 tlp::AbstractVectorProperty<vectType, eltType, propType>::AbstractVectorProperty(
tlp::Graph* g, std::string name) :AbstractProperty<vectType, vectType>(g, name) {}
174 template <
typename vectType,
typename eltType,
typename propType>
175 void tlp::AbstractVectorProperty<vectType, eltType, propType>::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->propType::notifyBeforeSetNodeValue(n);
186 typename vectType::RealType tmp(vect);
188 AbstractProperty<vectType, vectType>::nodeProperties.set(n.id, tmp);
191 this->propType::notifyAfterSetNodeValue(n);
194 template <
typename vectType,
typename eltType,
typename propType>
195 typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue
196 tlp::AbstractVectorProperty<vectType, eltType, propType>::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,
typename propType>
205 void tlp::AbstractVectorProperty<vectType, eltType, propType>::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->propType::notifyBeforeSetNodeValue(n);
215 typename vectType::RealType tmp(vect);
217 AbstractProperty<vectType, vectType>::nodeProperties.set(n, tmp);
220 this->propType::notifyAfterSetNodeValue(n);
223 template <
typename vectType,
typename eltType,
typename propType>
224 void tlp::AbstractVectorProperty<vectType, eltType, propType>::popBackNodeEltValue(
const node n) {
227 typename vectType::RealType& vect =
228 AbstractProperty<vectType, vectType>::nodeProperties.get(n, isNotDefault);
229 this->propType::notifyBeforeSetNodeValue(n);
230 assert(isNotDefault);
232 this->propType::notifyAfterSetNodeValue(n);
235 template <
typename vectType,
typename eltType,
typename propType>
236 void tlp::AbstractVectorProperty<vectType, eltType, propType>::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->propType::notifyBeforeSetNodeValue(n);
243 vect.resize(size, elt);
244 this->propType::notifyAfterSetNodeValue(n);
247 template <
typename vectType,
typename eltType,
typename propType>
248 void tlp::AbstractVectorProperty<vectType, eltType, propType>::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->propType::notifyBeforeSetEdgeValue(e);
259 typename vectType::RealType tmp(vect);
261 AbstractProperty<vectType, vectType>::edgeProperties.set(e, tmp);
264 this->propType::notifyAfterSetEdgeValue(e);
267 template <
typename vectType,
typename eltType,
typename propType>
268 typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue
269 tlp::AbstractVectorProperty<vectType, eltType, propType>::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,
typename propType>
277 void tlp::AbstractVectorProperty<vectType, eltType, propType>::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->propType::notifyBeforeSetEdgeValue(e);
287 typename vectType::RealType tmp(vect);
289 AbstractProperty<vectType, vectType>::edgeProperties.set(e, tmp);
292 this->propType::notifyAfterSetEdgeValue(e);
295 template <
typename vectType,
typename eltType,
typename propType>
296 void tlp::AbstractVectorProperty<vectType, eltType, propType>::popBackEdgeEltValue(
const edge e) {
299 typename vectType::RealType& vect =
300 AbstractProperty<vectType, vectType>::edgeProperties.get(e, isNotDefault);
301 this->propType::notifyBeforeSetEdgeValue(e);
302 assert(isNotDefault);
304 this->propType::notifyAfterSetEdgeValue(e);
307 template <
typename vectType,
typename eltType,
typename propType>
308 void tlp::AbstractVectorProperty<vectType, eltType, propType>::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->propType::notifyBeforeSetEdgeValue(e);
315 vect.resize(size, elt);
316 this->propType::notifyAfterSetEdgeValue(e);