Tulip  5.1.0
Large graphs analysis and drawing
AbstractProperty.h
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 
20 #ifndef ABSTRACT_PROPERTY_H
21 #define ABSTRACT_PROPERTY_H
22 
23 #include <typeinfo>
24 #include <string>
25 #include <cstdlib>
26 #include <tulip/tulipconf.h>
27 #include <tulip/StoredType.h>
28 #include <tulip/MutableContainer.h>
29 #include <tulip/PropertyInterface.h>
30 #include <tulip/Iterator.h>
31 #include <tulip/PropertyAlgorithm.h>
32 #include <tulip/DataSet.h>
33 #include <tulip/Graph.h>
34 
35 namespace tlp {
36 
37 class GraphView;
38 
39 //==============================================================
40 
41 /**
42  * @ingroup Graph
43  * @brief This class extends upon PropertyInterface, and adds type-safe methods to
44  * get and set the node and edge values, through the magic of template programming.
45  *
46  * Nodes and Edges can have different types (e.g. tlp::LayoutProperty has tlp::PointType as node type and tlp::LineType as edge type),
47  * but most of the time they have the same type (e.g. tlp::DoubleProperty, tlp::IntegerProperty).
48  *
49  * Some of the pure virtual functions of PropertyInterface are implemented in this class (e.g. erase()).
50  *
51  * The actual data is stored in this class, and it manages the default values.
52  */
53 template <class Tnode, class Tedge, class Tprop=PropertyInterface>
54 class TLP_SCOPE AbstractProperty : public Tprop {
55  friend class Graph;
56  friend class GraphView;
57 
58 public:
59  AbstractProperty(Graph *, const std::string& n = "");
60 
61  /**
62  * @brief Gets the default node value of the property.
63  * @return The default value of nodes.
64  */
65  typename Tnode::RealType getNodeDefaultValue() const;
66 
67  /**
68  * @brief Gets the default edge value of the property.
69  * @return The default value of edges.
70  **/
71  typename Tedge::RealType getEdgeDefaultValue() const;
72 
73  /**
74  * @brief Returns the value associated with the node n in this property.
75  * If there is no value, it returns the default node value.
76  *
77  * @param n The node for which we want to get the value of the property.
78  * @return :StoredType< Tnode::RealType >::ReturnedConstValue The value of the property for this node.
79  **/
80  typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue getNodeValue(const node n ) const;
81 
82  /**
83  * @brief Returns the value associated to the edge e in this property.
84  * If there is no value, it returns the default edge value.
85  *
86  * @param e The edge for which we want to get the value of the property.
87  * @return :StoredType< Tedge::RealType >::ReturnedConstValue The value of the property for this edge.
88  **/
89  typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue getEdgeValue(const edge e) const;
90 
91  /**
92  * Returns an iterator through all nodes belonging to g
93  * whose associated value is equal to val.
94  * If g is NULL, the graph given when creating the property is considered.
95  */
96  virtual tlp::Iterator<node> *getNodesEqualTo(typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue v, const Graph *g = NULL) const;
97 
98  /**
99  * Returns an iterator through all edges belonging to g
100  * whose associated value is equal to val.
101  * If g is NULL, the graph given when creating the property is considered.
102  */
103  virtual tlp::Iterator<edge> *getEdgesEqualTo(typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v, const Graph *g = NULL) const;
104 
105  /**
106  * @brief Sets the value of a node and notify the observers of a modification.
107  *
108  * @param n The node to set the value of.
109  * @param v The value to affect for this node.
110  **/
111  virtual void setNodeValue(const node n, typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue v);
112 
113  /**
114  * @brief Set the value of an edge and notify the observers of a modification.
115  *
116  * @param e The edge to set the value of.
117  * @param v The value to affect for this edge.
118  **/
119  virtual void setEdgeValue(const edge e, typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v);
120 
121  /**
122  * @brief Sets the value of all nodes and notify the observers.
123  * All previous values are lost and the given value is assigned as the default one to the future added nodes.
124  *
125  * @param v The value to set to all nodes.
126  *
127  **/
128  virtual void setAllNodeValue(typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue v);
129 
130  /**
131  * @brief Sets the value assigned as the default one to the future added nodes.
132  *
133  * @since Tulip 5.0
134  *
135  * @param v the new value to set on future added nodes.
136  *
137  * @return Whether the given string was a correct representation for this property's type. If not, the default value is not set.
138  */
139  virtual void setNodeDefaultValue(typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue v);
140 
141  /**
142  * @brief Sets the value of all nodes in a graph and notify the observers.
143  * Only the nodes from that graph will have their value modified in the property
144  * and the default node value will not be modified.
145  *
146  * @since Tulip 4.10
147  *
148  * @deprecated Since Tulip 5.0 this method signature is deprecated, use method setValueToGraphNodes instead
149  *
150  * @param v The value to set to all nodes.
151  * @param graph A graph that defines the set of nodes
152  *
153  *
154  * @warning If the provided graph is not a descendant of the one associated to that property (including itself),
155  * no node value will be modified.
156  *
157  **/
158  _DEPRECATED virtual void setAllNodeValue(typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue v, const Graph *graph);
159 
160  /**
161  * @brief Sets the value of all nodes in a graph and notify the observers.
162  * Only the nodes from that graph will have their value modified in the property
163  * and the default node value will not be modified.
164  *
165  * @since Tulip 5.0
166  *
167  * @param v The value to set to all nodes.
168  * @param graph A graph that defines the set of nodes
169  *
170  *
171  * @warning If the provided graph is not a descendant of the one associated to that property (including itself),
172  * no node value will be modified.
173  *
174  **/
175  virtual void setValueToGraphNodes(typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue v, const Graph *graph);
176 
177  /**
178  * @brief Sets the value assigned as the default one to the future added edges.
179  *
180  * @since Tulip 5.0
181  *
182  * @param value the new value to set on future added edges.
183  *
184  * @return Whether the given string was a correct representation for this property's type. If not, the default value is not set.
185  */
186  virtual void setEdgeDefaultValue(typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v);
187 
188  /**
189  * @brief Sets the value of all edges and notify the observers.
190  * All previous values are lost and the given value is assigned as the default one to the future added edges.
191  *
192  * @param v The value to set to all edges.
193  *
194  **/
195  virtual void setAllEdgeValue(typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v);
196 
197  /**
198  * @brief Sets the value of all edges in a graph and notify the observers.
199  * Only the edges from that graph will have their value modified in the property
200  * and the default edge value will not be modified.
201  *
202  * @since Tulip 4.10
203  *
204  * @deprecated Since Tulip 5.0 this method signature is deprecated, use method setValueToGraphEdges instead
205  *
206  * @param v The value to set to all edges.
207  * @param graph A graph that defines the set of edges
208  *
209  *
210  * @warning If the provided graph is not a descendant of the one associated to that property (including itself),
211  * no edge value will be modified.
212  *
213  **/
214  _DEPRECATED virtual void setAllEdgeValue(typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v, const Graph *graph);
215 
216  /**
217  * @brief Sets the value of all edges in a graph and notify the observers.
218  * Only the edges from that graph will have their value modified in the property
219  * and the default edge value will not be modified.
220  *
221  * @since Tulip 5.0
222  *
223  * @param v The value to set to all edges.
224  * @param graph A graph on which to modify
225  *
226  *
227  * @warning If the provided graph is not a descendant of the one associated to that property (including itself),
228  * no edge value will be modified.
229  *
230  **/
231  virtual void setValueToGraphEdges(typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v, const Graph *graph);
232  //=================================================================================
233 
234  /**
235  * @brief Resets the value of a node to the default value.
236  *
237  * @param n The node to reset the value of.
238  *
239  **/
240  inline void erase(const node n) {
241  setNodeValue(n, nodeDefaultValue);
242  }
243  //=================================================================================
244 
245  /**
246  * @brief Resets the value of an edge to the default value.
247  *
248  * @param e The edge to reset the value of.
249  *
250  **/
251  inline void erase(const edge e) {
252  setEdgeValue(e, edgeDefaultValue);
253  }
254  //=================================================================================
255  /**
256  * @brief This operator overload allows to copy a property using the following syntax :
257  *
258  * @code
259  * IntegerProperty* shape = graph->getProperty<IntegerProperty>("viewShape");
260  * IntegerProperty* backup = graph->getProperty<IntegerProperty>("shapeBackup");
261  * *backup = *shape; // all the values from 'shape' will be copied into 'backup'.
262  * @endcode
263  * @param prop The property to copy the values from.
264  * @return This property with the values copied.
265  */
267  if (this!= &prop) {
268  if (Tprop::graph == NULL) Tprop::graph = prop.Tprop::graph;
269 
270  if (Tprop::graph == prop.Tprop::graph) {
271  setAllNodeValue(prop.getNodeDefaultValue());
272  setAllEdgeValue(prop.getEdgeDefaultValue());
273  Iterator<node> *itN = prop.getNonDefaultValuatedNodes();
274 
275  while (itN->hasNext()) {
276  node itn = itN->next();
277  setNodeValue(itn, prop.getNodeValue(itn));
278  }
279 
280  delete itN;
281  Iterator<edge> *itE = prop.getNonDefaultValuatedEdges();
282 
283  while (itE->hasNext()) {
284  edge ite = itE->next();
285  setEdgeValue(ite, prop.getEdgeValue(ite));
286  }
287 
288  delete itE;
289  }
290  else {
291  //==============================================================*
292  const std::vector<node>& nodes = Tprop::graph->nodes();
293  unsigned int nbElts = nodes.size();
294 
295  for(unsigned int i = 0; i < nbElts; ++i) {
296  node n = nodes[i];
297 
298  if (prop.Tprop::graph->isElement(n))
299  setNodeValue(n, prop.getNodeValue(n));
300  }
301 
302  const std::vector<edge>& edges = Tprop::graph->edges();
303  nbElts = edges.size();
304 
305  for(unsigned int i = 0; i < nbElts; ++i) {
306  edge e = edges[i];
307 
308  if (prop.Tprop::graph->isElement(e))
309  setEdgeValue(e, prop.getEdgeValue(e));
310  }
311  }
312 
313  clone_handler(prop);
314  }
315 
316  return *this;
317  }
318  //=================================================================================
319  // Untyped accessors inherited from PropertyInterface, documentation is inherited
320  virtual std::string getNodeDefaultStringValue() const {
321  typename Tnode::RealType v = getNodeDefaultValue();
322  return Tnode::toString( v );
323  }
324  virtual std::string getEdgeDefaultStringValue() const {
325  typename Tedge::RealType v = getEdgeDefaultValue();
326  return Tedge::toString( v );
327  }
328  virtual std::string getNodeStringValue( const node n ) const {
329  typename Tnode::RealType v = getNodeValue( n );
330  return Tnode::toString( v );
331  }
332  virtual std::string getEdgeStringValue( const edge e ) const {
333  typename Tedge::RealType v = getEdgeValue( e );
334  return Tedge::toString( v );
335  }
336  virtual bool setNodeStringValue( const node inN, const std::string & inV ) {
337  typename Tnode::RealType v;
338 
339  if( !Tnode::fromString( v, inV ) )
340  return false;
341 
342  setNodeValue( inN, v );
343  return true;
344  }
345  virtual bool setEdgeStringValue( const edge inE, const std::string & inV ) {
346  typename Tedge::RealType v;
347 
348  if( !Tedge::fromString( v, inV ) )
349  return false;
350 
351  setEdgeValue( inE, v );
352  return true;
353  }
354  virtual bool setNodeDefaultStringValue( const std::string & inV ) {
355  typename Tnode::RealType v;
356 
357  if( !Tnode::fromString( v, inV ) )
358  return false;
359 
360  setNodeDefaultValue( v );
361  return true;
362  }
363  virtual bool setAllNodeStringValue( const std::string & inV ) {
364  typename Tnode::RealType v;
365 
366  if( !Tnode::fromString( v, inV ) )
367  return false;
368 
369  setAllNodeValue( v );
370  return true;
371  }
372  _DEPRECATED virtual bool setAllNodeStringValue( const std::string & inV , const Graph *graph ) {
373  return setStringValueToGraphNodes(inV, graph);
374  }
375  virtual bool setStringValueToGraphNodes( const std::string & inV , const Graph *graph ) {
376  typename Tnode::RealType v;
377 
378  if( !Tnode::fromString( v, inV ) )
379  return false;
380 
381  setValueToGraphNodes( v , graph );
382  return true;
383  }
384  virtual bool setEdgeDefaultStringValue( const std::string & inV ) {
385  typename Tedge::RealType v;
386 
387  if( !Tedge::fromString(v ,inV ) )
388  return false;
389 
390  setEdgeDefaultValue( v );
391  return true;
392  }
393  virtual bool setAllEdgeStringValue( const std::string & inV ) {
394  typename Tedge::RealType v;
395 
396  if( !Tedge::fromString(v ,inV ) )
397  return false;
398 
399  setAllEdgeValue( v );
400  return true;
401  }
402  _DEPRECATED virtual bool setAllEdgeStringValue( const std::string & inV , const Graph *graph ) {
403  return setStringValueToGraphEdges(inV, graph);
404  }
405  virtual bool setStringValueToGraphEdges( const std::string & inV , const Graph *graph ) {
406  typename Tedge::RealType v;
407 
408  if( !Tedge::fromString(v,inV) )
409  return false;
410 
411  setValueToGraphEdges( v , graph );
412  return true;
413  }
414  virtual tlp::Iterator<node>* getNonDefaultValuatedNodes(const Graph* g = NULL) const;
415  virtual unsigned int numberOfNonDefaultValuatedNodes(const Graph* g = NULL) const;
416  virtual unsigned int nodeValueSize() const;
417  virtual void writeNodeDefaultValue(std::ostream&) const;
418  virtual void writeNodeValue(std::ostream&, node) const;
419  virtual bool readNodeDefaultValue(std::istream&);
420  virtual bool readNodeValue(std::istream&, node);
421  virtual tlp::Iterator<edge>* getNonDefaultValuatedEdges(const Graph* g = NULL) const;
422  virtual unsigned int numberOfNonDefaultValuatedEdges(const Graph* = NULL) const;
423  virtual unsigned int edgeValueSize() const;
424  virtual void writeEdgeDefaultValue(std::ostream&) const;
425  virtual void writeEdgeValue(std::ostream&, edge) const;
426  virtual bool readEdgeDefaultValue(std::istream&);
427  virtual bool readEdgeValue(std::istream&, edge);
428  virtual bool copy(const node destination, const node source, PropertyInterface *property,
429  bool ifNotDefault = false) {
430  if (property == NULL)
431  return false;
432 
434  dynamic_cast<tlp::AbstractProperty<Tnode,Tedge,Tprop>*>(property);
435  assert(tp);
436  bool notDefault;
437  typename StoredType<typename Tnode::RealType>::ReturnedValue value =
438  tp->nodeProperties.get(source.id, notDefault);
439 
440  if (ifNotDefault && !notDefault)
441  return false;
442 
443  setNodeValue(destination, value);
444  return true;
445  }
446  virtual bool copy(const edge destination, const edge source, PropertyInterface *property,
447  bool ifNotDefault = false) {
448  if (property == NULL)
449  return false;
450 
452  dynamic_cast<tlp::AbstractProperty<Tnode,Tedge,Tprop>*>(property);
453  assert(tp);
454  bool notDefault;
455  typename StoredType<typename Tedge::RealType>::ReturnedValue value =
456  tp->edgeProperties.get(source.id, notDefault);
457 
458  if (ifNotDefault && !notDefault)
459  return false;
460 
461  setEdgeValue(destination, value);
462  return true;
463  }
464  virtual void copy(PropertyInterface* property) {
466  dynamic_cast<typename tlp::AbstractProperty<Tnode,Tedge,Tprop>*>(property);
467  assert(prop != NULL);
468  *this = *prop;
469  }
470  // for performance reason and use in GraphUpdatesRecorder
471  virtual DataMem* getNodeDefaultDataMemValue() const {
472  return new TypedValueContainer<typename Tnode::RealType>(getNodeDefaultValue());
473  }
474  virtual DataMem* getEdgeDefaultDataMemValue() const {
475  return new TypedValueContainer<typename Tedge::RealType>(getEdgeDefaultValue());
476  }
477  virtual DataMem* getNodeDataMemValue(const node n) const {
478  return new TypedValueContainer<typename Tnode::RealType>(getNodeValue(n));
479  }
480  virtual DataMem* getEdgeDataMemValue(const edge e) const {
481  return new TypedValueContainer<typename Tedge::RealType>(getEdgeValue(e));
482  }
483  virtual DataMem* getNonDefaultDataMemValue( const node n ) const {
484  bool notDefault;
485  typename StoredType<typename Tnode::RealType>::ReturnedValue value = nodeProperties.get(n.id, notDefault);
486 
487  if (notDefault)
488  return new TypedValueContainer<typename Tnode::RealType>(value);
489 
490  return NULL;
491  }
492  virtual DataMem* getNonDefaultDataMemValue( const edge e ) const {
493  bool notDefault;
494  typename StoredType<typename Tedge::RealType>::ReturnedValue value = edgeProperties.get(e.id, notDefault);
495 
496  if (notDefault)
497  return new TypedValueContainer<typename Tedge::RealType>(value);
498 
499  return NULL;
500  }
501  virtual void setNodeDataMemValue( const node n, const DataMem* v) {
502  setNodeValue(n, ((TypedValueContainer<typename Tnode::RealType> *) v)->value);
503  }
504  virtual void setEdgeDataMemValue( const edge e, const DataMem* v) {
505  setEdgeValue(e, ((TypedValueContainer<typename Tedge::RealType> *) v)->value);
506  }
507  virtual void setAllNodeDataMemValue(const DataMem* v) {
508  setAllNodeValue(((TypedValueContainer<typename Tnode::RealType> *) v)->value);
509  }
510  virtual void setAllEdgeDataMemValue(const DataMem* v) {
511  setAllEdgeValue(((TypedValueContainer<typename Tedge::RealType> *) v)->value);
512  }
513 
514  // PropertyInterface methods
515  // mN is the meta node, sg is the corresponding subgraph
516  // and mg is the graph owning mN
517  virtual void computeMetaValue(node n, Graph* sg, Graph* mg) {
518  if (Tprop::metaValueCalculator)
520  Tprop::metaValueCalculator)->computeMetaValue(this, n, sg, mg);
521  }
522  // mE is the meta edge, itE is an iterator on the underlying edges
523  // mg is the graph owning mE
524  virtual void computeMetaValue(edge e, tlp::Iterator<edge>* itE, Graph* mg) {
525  if (Tprop::metaValueCalculator)
526  ((typename tlp::AbstractProperty<Tnode,Tedge,Tprop>::MetaValueCalculator *) Tprop::metaValueCalculator)->computeMetaValue(this, e, itE, mg);
527  }
528  virtual void setMetaValueCalculator(PropertyInterface::MetaValueCalculator *mvCalc) {
529  if (mvCalc && !dynamic_cast<typename tlp::AbstractProperty<Tnode,Tedge,Tprop>::MetaValueCalculator *>(mvCalc)) {
530  tlp::warning() << "Warning : " << __PRETTY_FUNCTION__ << " ... invalid conversion of " << typeid(mvCalc).name() << "into " << typeid(typename tlp::AbstractProperty<Tnode,Tedge,Tprop>::MetaValueCalculator *).name() << std::endl;
531  abort();
532  }
533 
534  Tprop::metaValueCalculator = mvCalc;
535  }
536 
537  int compare(const node n1, const node n2) const;
538  int compare(const edge e1, const edge e2) const;
539 
540 
541  /**
542  * @brief This class is used to delegate the computation of the values associated to meta nodes or edges.
543  **/
545  public:
546  // computes the value of the meta node mN of the graph mg
547  // for the property prop, according to the values associated
548  // to the underlying nodes i.e the nodes of the subgraph sg.
549  virtual void computeMetaValue(AbstractProperty<Tnode,Tedge,Tprop>*,
550  node, Graph*, Graph*) {}
551  // computes the value of the meta node mE of the graph mg
552  // for the property prop, according to the values associated
553  // to the underlying edges given by the iterator itE.
554  // The method do not have to delete the iterator
555  virtual void computeMetaValue(AbstractProperty<Tnode,Tedge,Tprop>*,
556  edge, tlp::Iterator<edge>*, Graph*) {}
557  };
558 
559 protected:
560  //=================================================================================
561  ///Enable to clone part of sub_class
563 
564  MutableContainer<typename Tnode::RealType> nodeProperties;
565  MutableContainer<typename Tedge::RealType> edgeProperties;
566  typename Tnode::RealType nodeDefaultValue;
567  typename Tedge::RealType edgeDefaultValue;
568 };
569 
570 template <typename vectType,typename eltType,typename propType=VectorPropertyInterface>
571 class TLP_SCOPE AbstractVectorProperty : public AbstractProperty<vectType, vectType, propType> {
572 public:
573  AbstractVectorProperty(Graph *, const std::string& name = "");
574 
575  // 2 methods inherited from VectorPropertyInterface
576  bool setNodeStringValueAsVector(const node, const std::string&,
577  char, char, char);
578 
579  bool setEdgeStringValueAsVector(const edge, const std::string&,
580  char, char, char);
581 
582  /**
583  * @brief Sets the value for node n, at index i, to v, and notify the observers of a modification.
584  *
585  * @param n The node to set a value of.
586  * @param i The index at which the value should be set.
587  * @param v The value to set.
588  *
589  **/
590  void setNodeEltValue(const node n, unsigned int i, typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v);
591  /**
592  * @brief Gets the value associated to node n, at index i.
593  *
594  * @param n The node to set a value of.
595  * @param i The index at which to set the value.
596  * @return const eltType& The value at index i in the vector for node n.
597  **/
598  typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue getNodeEltValue(const node n, unsigned int i) const;
599  /**
600  * @brief Appends a new value at the end of the vector associated to node n, and notify the observers of a modification.
601  *
602  * @param n The node to add a value to.
603  * @param v The value to append at the end of the vector.
604  *
605  **/
606  void pushBackNodeEltValue(const node n, typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v);
607  /**
608  * @brief Removes the value at the end of the vector associated to node n, and notify the observers of a modification.
609  *
610  * @param n The node to remove a value from.
611  *
612  **/
613  void popBackNodeEltValue(const node n);
614  /**
615  * @brief Resizes the vector associated to node n, and notify the observers of a modification.
616  *
617  * @param n The node associated to the vector to resize.
618  * @param size The new size of the vector.
619  * @param elt The default value to set at indices where there was no value before. Defaults to eltType().
620  *
621  **/
622  void resizeNodeValue(const node n, size_t size, typename eltType::RealType elt = eltType::defaultValue());
623  /**
624  * @brief Sets the value for edge e, at index i, to v, and notify the observers of a modification.
625  *
626  * @param e The edge to set the value of.
627  * @param i The index at which the value should be set.
628  * @param v The value to set.
629  *
630  **/
631  void setEdgeEltValue(const edge e, unsigned int i, typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v);
632  /**
633  * @brief Gets the value associated to edge e, at index i.
634  *
635  * @param e The edge to set a value of.
636  * @param i The index at which to set the value.
637  * @return const eltType& The value at index i in the vector for node n.
638  **/
639  typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue getEdgeEltValue(const edge n, unsigned int i) const;
640  /**
641  * @brief Appends a new value at the end of the vector associated to edge e, and notify the observers of a modification.
642  *
643  * @param e The node to add a value to.
644  * @param v The value to append at the end of the vector.
645  *
646  **/
647  void pushBackEdgeEltValue(const edge e, typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v);
648  /**
649  * @brief Removes the value at the end of the vector associated to edge e, and notify the observers of a modification.
650  *
651  * @param e The edge to remove a value from.
652  *
653  **/
654  void popBackEdgeEltValue(const edge e);
655  /**
656  * @brief Resizes the vector associated to edge e, and notify the observers of a modification.
657  *
658  * @param e The edge associated to the vector to resize.
659  * @param size The new size of the vector.
660  * @param elt The default value to set at indices where there was no value before. Defaults to eltType().
661  *
662  **/
663  void resizeEdgeValue(const edge e, size_t size, typename eltType::RealType elt = eltType::defaultValue());
664 };
665 
666 
667 }
668 #if !defined(_MSC_VER) || defined(DLL_TULIP) //When using VC++, we only want to include this when we are in the TULIP dll. With any other compiler, include it all the time
669 # include "cxx/AbstractProperty.cxx"
670 #endif
671 #endif
This class extends upon PropertyInterface, and adds type-safe methods to get and set the node and edg...
tlp::StoredType< typename Tnode::RealType >::ReturnedConstValue getNodeValue(const node n) const
Returns the value associated with the node n in this property. If there is no value, it returns the default node value.
PropertyInterface describes the interface of a graph property.
Tnode::RealType getNodeDefaultValue() const
Gets the default node value of the property.
void erase(const edge e)
Resets the value of an edge to the default value.
The edge struct represents an edge in a Graph object.
Definition: Edge.h:39
The node struct represents a node in a Graph object.
Definition: Node.h:39
This class is used to delegate the computation of the values associated to meta nodes or edges...
tlp::StoredType< typename Tedge::RealType >::ReturnedConstValue getEdgeValue(const edge e) const
Returns the value associated to the edge e in this property. If there is no value, it returns the default edge value.
Base class for computing values on meta nodes and edges.
Tedge::RealType getEdgeDefaultValue() const
Gets the default edge value of the property.
virtual void clone_handler(AbstractProperty< Tnode, Tedge, Tprop > &)
Enable to clone part of sub_class.
unsigned int id
id The identifier of the node.
Definition: Node.h:43
virtual AbstractProperty< Tnode, Tedge, Tprop > & operator=(AbstractProperty< Tnode, Tedge, Tprop > &prop)
This operator overload allows to copy a property using the following syntax :
void erase(const node n)
Resets the value of a node to the default value.
unsigned int id
id The identifier of the edge.
Definition: Edge.h:43