Tulip  5.4.0
Large graphs analysis and drawing
PropertyInterface.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 PROPERTY_INTERFACE_H
21 #define PROPERTY_INTERFACE_H
22 
23 #include <string>
24 #include <iostream>
25 #include <functional>
26 
27 #include <tulip/tulipconf.h>
28 #include <tulip/Observable.h>
29 //#include <tulip/Node.h>
30 #include <tulip/Edge.h>
31 
32 namespace tlp {
33 
34 struct DataMem;
35 struct node;
36 
37 class Graph;
38 template <class itType>
39 struct Iterator;
40 
41 //=============================================================
42 /**
43  * @ingroup Graph
44  * @brief PropertyInterface describes the interface of a graph property.
45  *
46  * The intent of a property is to hold a value for each node and edge (e.g. the degree of the
47  * nodes).
48  *
49  * A property can be used in two different ways :
50  * Either it is attached to a graph; and in this case creating and deleting the property is handled
51  * by the graph
52  * (@see Graph::getProperty()).
53  *
54  * Either is is detached from a graph, and you have to handle creation and deletion yourself.
55  * This is most useful for some algorithms that need a temporary property, but do not want the
56  * property to appear on the graph
57  * after the computation.
58  */
59 class TLP_SCOPE PropertyInterface : public Observable {
60  friend class PropertyManager;
61 
62 protected:
63  // name of the property when registered as a property of a graph
64  std::string name;
65  // the graph for whom the property is registered
66  Graph *graph;
67 
68 public:
70 
71  ~PropertyInterface() override;
72 
73  /**
74  * @brief Erases the value stored for the given node.
75  * The new value for the node is the default value.
76  */
77  virtual void erase(const node) = 0;
78 
79  /**
80  * @brief Erases the value stored for the given edge.
81  * The new value for the edge is the default value.
82  */
83  virtual void erase(const edge) = 0;
84 
85  /**
86  * @brief Copies the value of a node in another property to a node in this property.
87  * @param destination The node whose value will be set.
88  * @param source The node whose value to copy.
89  * @param property The property from which to copy the source node value.
90  * @param ifNotDefault If true, the copy will only be performed if the source node's value is not
91  * the default value.
92  * @return True if the copy was performed, false otherwise.
93  */
94  virtual bool copy(const node destination, const node source, PropertyInterface *property,
95  bool ifNotDefault = false) = 0;
96  /**
97  * @brief Copies the value of an edge in another property to an edge in this property.
98  * @param destination The edge whose value will be set.
99  * @param source The edge whose value to copy.
100  * @param property The property from which to copy the source edge value.
101  * @param ifNotDefault If true, the copy will only be performed if the source edge's value is not
102  * the default value.
103  * @return True if the copy was performed, false otherwise.
104  */
105  virtual bool copy(const edge destination, const edge source, PropertyInterface *property,
106  bool ifNotDefault = false) = 0;
107 
108  /**
109  * @brief Copies the values of the source property to this property.
110  * @param source The property from which to copy values.
111  * @warning Be careful when using this method, if you are interested by observing the updates of
112  * the values of the current property, because no event is sent for nodes/edges whose value is the
113  * default value of the source property.
114  */
115  virtual void copy(PropertyInterface *source) = 0;
116 
117  /**
118  * @brief Creates a property of the same type (e.g. tlp::DoubleProperty) in the graph.
119  * The new property will not contain a copy of this property's values.
120  * @param graph The Graph in which to create the new property.
121  * @param name The name of the new property.
122  * @return The newly created property.
123  */
124  virtual PropertyInterface *clonePrototype(Graph *graph, const std::string &name) const = 0;
125 
126  /**
127  * @brief Gets a string describing the type of the property (e.g. "graph", "double", "layout",
128  * "string", "integer", "color", "size").
129  * @return The name of this property's type.
130  */
131  virtual const std::string &getTypename() const = 0;
132 
133  /**
134  * @brief Gets the name of the property (e.g. viewLayout).
135  * @return The name of this property.
136  */
137  const std::string &getName() const {
138  return name;
139  }
140 
141  /**
142  * @brief Rename a property
143  * @param the new name
144  * @return returns true if the renaming succeeded.
145  * It may fails if a property with the given name already exists
146  */
147  bool rename(const std::string &newName);
148  /**
149  * @cond DOXYGEN_HIDDEN
150  * @brief Gets the graph on which this property has been defined.
151  * This is an internal function and its behavior can change.
152  * DO NOT USE UNLESS YOU KNOW WHAT YOU ARE DOING.
153  *
154  * Be wary that is might be a different graph that the one you used to get this property.
155  * For instance:
156  * @code
157  * Graph* g = tlp::newGraph();
158  * Graph*sub = g->addCloneSubGraph();
159  *
160  * IntegerProperty* prop = g->getProperty<IntegerProperty>("test");
161  * //prop->getGraph() returns g
162  *
163  * IntegerProperty* prop2 = sub->getProperty<IntegerProperty>("test");
164  * //prop2->getGraph() returns g
165  * @endcode
166  *
167  * This is due to the inheritance system of the properties.
168  *
169  * @return The Graph this property is local to.
170  * @endcond
171  */
172  tlp::Graph *getGraph() const {
173  return graph;
174  }
175 
176  /**
177  * @brief Gets a string representation of the node default value.
178  * @param n The node to get the value of.
179  * @return A string representation of the node default value.
180  */
181  virtual std::string getNodeStringValue(const node n) const = 0;
182 
183  /**
184  * @brief Gets a string representation of the edge default value.
185  * @param e The edge to get the value of.
186  * @return A string representation of the edge default value.
187  */
188  virtual std::string getEdgeStringValue(const edge e) const = 0;
189 
190  /**
191  * @brief Sets a new value on the node, represented by the string parameter.
192  * @param n The node on which to set the new value.
193  * @param value A string representing the value to set on the node.
194  * @return Whether the string was a correct representation for this property's type. If not, the
195  * value is not set.
196  */
197  virtual bool setNodeStringValue(const node n, const std::string &value) = 0;
198 
199  /**
200  * @brief Sets a new value on the edge, represented by the string parameter.
201  * @param e The edge on which to set value on.
202  * @param value A string representing the value to set on the edge.
203  * @return Whether the string was a correct representation for this property's type. If not, the
204  * value is not set.
205  */
206  virtual bool setEdgeStringValue(const edge e, const std::string &value) = 0;
207 
208  /**
209  * @brief Gets a string representation of the node default value.
210  * @return A string representation of the node default value.
211  */
212  virtual std::string getNodeDefaultStringValue() const = 0;
213 
214  /**
215  * @brief Gets a string representation of the edge default value.
216  * @return A string representation of the edge default value.
217  */
218  virtual std::string getEdgeDefaultStringValue() const = 0;
219 
220  /**
221  * @brief Sets the value assigned as the default one to the future added nodes from a string
222  * representation.
223  *
224  * @since Tulip 5.0
225  *
226  * @param value A string representing the new value to set on future added nodes.
227  *
228  * @return Whether the given string was a correct representation for this property's type. If not,
229  * the default value is not set.
230  */
231  virtual bool setNodeDefaultStringValue(const std::string &value) = 0;
232 
233  /**
234  * @brief Sets all the nodes value to the value represented by the string. For some types, some
235  * parsing will be necessary (e.g. LayoutProperty).
236  * All previous values are lost and the represented value is assigned as the default one to the
237  * future added nodes.
238  *
239  * @param value A string representing the new value to set on all the nodes.
240  *
241  * @return Whether the given string was a correct representation for this property's type. If not,
242  * the values are not set.
243  */
244  virtual bool setAllNodeStringValue(const std::string &value) = 0;
245 
246  /**
247  * @brief Sets all the nodes value to the value represented by the string for a graph. For some
248  * types, some parsing will be necessary (e.g. LayoutProperty).
249  * Only the nodes from that graph will have their value modified in the property
250  * and the default node value will not be modified.
251  *
252  * @since Tulip 5.0
253  *
254  * @param value A string representing the new value to set on all the nodes.
255  * @param graph A graph that defines the set of nodes.
256  *
257  * @warning If the provided graph is not a descendant of the one associated to that property
258  * (including itself), no node value will be modified in it.
259  *
260  * @return Whether the given string was a correct representation for this property's type. If not,
261  * the values are not set.
262  */
263  virtual bool setStringValueToGraphNodes(const std::string &value, const Graph *graph) = 0;
264 
265  /**
266  * @brief Sets the value assigned as the default one to the future added edges from a string
267  * representation.
268  *
269  * @since Tulip 5.0
270  *
271  * @param value A string representing the new value to set on future added edges.
272  *
273  * @return Whether the given string was a correct representation for this property's type. If not,
274  * the default value is not set.
275  */
276  virtual bool setEdgeDefaultStringValue(const std::string &value) = 0;
277 
278  /**
279  * @brief Sets all the edges value to the value represented by the string. For some types, some
280  * parsing will be necessary (e.g. LayoutProperty).
281  * All previous values are lost and the represented value is assigned as the default one to the
282  * future added edges.
283  *
284  * @param value A string representing the new value to set on all the edges.
285  *
286  * @return Whether the given string was a correct representation for this property's type. If not,
287  * the values are not set.
288  */
289  virtual bool setAllEdgeStringValue(const std::string &value) = 0;
290 
291  /**
292  * @brief Sets all the edges value to the value represented by the string for a graph. For some
293  * types, some parsing will be necessary (e.g. LayoutProperty).
294  * Only the edges from that graph will have their value modified in the property
295  * and the default edge value will not be modified.
296  *
297  * @since Tulip 5.0
298  *
299  * @param value A string representing the new value to set on all the edges.
300  * @param graph A graph that defines the set of edges.
301  *
302  * @warning If the provided graph is not a descendant of the one associated to that property
303  * (including itself), no edge value will be modified in it.
304  *
305  * @return Whether the given string was a correct representation for this property's type. If not,
306  * the values are not set.
307  */
308  virtual bool setStringValueToGraphEdges(const std::string &value, const Graph *graph) = 0;
309 
310  /**
311  * @brief Gets a pointer to the tlp::DataMem structure that contains the node default value.
312  * @return The DataMem structure containing the node default value.
313  * @warning The ownership of this pointer is given to the caller.
314  */
315  virtual DataMem *getNodeDefaultDataMemValue() const = 0;
316 
317  /**
318  * @brief Gets a pointer to the tlp::DataMem structure that contains the edge default value.
319  * @return The DataMem structure containing the edge default value.
320  * @warning The ownership of this pointer is given to the caller.
321  */
322  virtual DataMem *getEdgeDefaultDataMemValue() const = 0;
323 
324  /**
325  * @brief Sets all the nodes value to the value contained in the given DataMem structure.
326  * All previous values are lost.
327  * @param value The value to set on all the nodes.
328  */
329  virtual void setAllNodeDataMemValue(const DataMem *value) = 0;
330 
331  /**
332  * @brief Sets all the edges value to the value contained in the given DataMem structure.
333  * All previous values are lost.
334  * @param value The value to set on all the edges.
335  */
336  virtual void setAllEdgeDataMemValue(const DataMem *v) = 0;
337 
338  /**
339  * @brief Gets the node value, contained in a tlp::DataMem structure.
340  * @param n The node to get the value of.
341  * @return The value of the node, in a tlp::DataMem.
342  *
343  * @warning The ownership of this pointer is given to the caller.
344  */
345  virtual DataMem *getNodeDataMemValue(const node n) const = 0;
346 
347  /**
348  * @brief Gets the edge value, contained in a tlp::DataMem structure.
349  * @param n The edge to get the value of.
350  * @return The value of the edge, in a tlp::DataMem.
351  *
352  * @warning The ownership of this pointer is given to the caller.
353  */
354  virtual DataMem *getEdgeDataMemValue(const edge e) const = 0;
355 
356  /**
357  * @brief Returns the value in a DataMem if it is not default, otherwise returns nullptr.
358  * @param n The node to get the value of.
359  * @return The value of the node if it is not default, or nullptr.
360  *
361  * @warning The ownership of this pointer is given to the caller.
362  */
363  virtual DataMem *getNonDefaultDataMemValue(const node n) const = 0;
364 
365  /**
366  * @brief Returns the value in a DataMem if it is not default, otherwise returns nullptr.
367  * @param e The edge to get the value of.
368  * @return The value of the edge if it is not default, or nullptr.
369  *
370  * @warning The ownership of this pointer is given to the caller.
371  */
372  virtual DataMem *getNonDefaultDataMemValue(const edge e) const = 0;
373 
374  /**
375  * @brief Sets the node value.
376  * @param n The node to set the value of.
377  * @param value The value to set to this node.
378  */
379  virtual void setNodeDataMemValue(const node n, const DataMem *value) = 0;
380 
381  /**
382  * @brief Sets the edge value.
383  * @param e The edge to set the value of.
384  * @param value The value to set to this edge.
385  */
386  virtual void setEdgeDataMemValue(const edge e, const DataMem *v) = 0;
387 
388  /**
389  * @brief Gets an Iterator on all non-default valuated nodes.
390  * When given a Graph as parameter, only nodes belonging to this graph are iterated over.
391  * @return An Iterator over nodes whose value is not default.
392  *
393  * @warning The ownership of the iterator is given to the caller.
394  */
395  virtual tlp::Iterator<node> *getNonDefaultValuatedNodes(const Graph * = nullptr) const = 0;
396 
397  /**
398  * @brief Returns whether the property has nodes with a non default value.
399  * When given a Graph as parameter, only the nodes with a non default value belonging to
400  * this graph are taken into account.
401  * @return false if all nodes has the default value, true if not.
402  *
403  */
404  virtual bool hasNonDefaultValuatedNodes(const Graph * = nullptr) const = 0;
405 
406  /**
407  * @brief Returns the number of nodes with a non default value.
408  * When given a Graph as parameter, only the number of nodes with a non default value belonging to
409  * this graph is returned.
410  * @return the number of nodes with a non default value.
411  *
412  */
413  virtual unsigned int numberOfNonDefaultValuatedNodes(const Graph * = nullptr) const = 0;
414 
415  /**
416  * @brief Gets an Iterator on all non-default valuated edges.
417  * When given a Graph as parameter, only edges belonging to this graph are iterated over.
418  * @return An Iterator over edges whose value is not default.
419  *
420  * @warning The ownership of the iterator is given to the caller.
421  */
422  virtual tlp::Iterator<edge> *getNonDefaultValuatedEdges(const Graph * = nullptr) const = 0;
423 
424  /**
425  * @brief Returns whether the property has edges with a non default value.
426  * When given a Graph as parameter, only the edges with a non default value belonging to
427  * this graph are taken into account.
428  * @return false if all edges has the default value, true if not.
429  *
430  */
431  virtual bool hasNonDefaultValuatedEdges(const Graph * = nullptr) const = 0;
432 
433  /**
434  * @brief Returns the number of edges with a non default value.
435  * @return the number of edges with a non default value.
436  *
437  */
438  virtual unsigned int numberOfNonDefaultValuatedEdges(const Graph * = nullptr) const = 0;
439 
440  /**
441  * @brief Returns the size in bytes of a node's value.
442  * @return the size of a node's value (0 means the size is not fixed)
443  *
444  */
445  virtual unsigned int nodeValueSize() const = 0;
446 
447  /**
448  * @brief Writes the nodes default value
449  *
450  */
451  virtual void writeNodeDefaultValue(std::ostream &) const = 0;
452 
453  /**
454  * @brief Writes the value of a node
455  *
456  */
457  virtual void writeNodeValue(std::ostream &, node) const = 0;
458 
459  /**
460  * @brief Reads the nodes default value
461  *
462  */
463  virtual bool readNodeDefaultValue(std::istream &) = 0;
464 
465  /**
466  * @brief Reads the value of a node
467  *
468  */
469  virtual bool readNodeValue(std::istream &, node) = 0;
470 
471  /**
472  * @brief Returns the size in bytes of an edge's value.
473  * @return the size of a node's value (0 means the size is not fixed)
474  *
475  */
476  virtual unsigned int edgeValueSize() const = 0;
477 
478  /**
479  * @brief Writes the edges default value
480  *
481  */
482  virtual void writeEdgeDefaultValue(std::ostream &) const = 0;
483 
484  /**
485  * @brief Writes the value of an edge
486  *
487  */
488  virtual void writeEdgeValue(std::ostream &, edge) const = 0;
489 
490  /**
491  * @brief Reads the edges default value
492  *
493  */
494  virtual bool readEdgeDefaultValue(std::istream &) = 0;
495 
496  /**
497  * @brief Reads the value of an edge
498  *
499  */
500  virtual bool readEdgeValue(std::istream &, edge) = 0;
501 
502  /**
503  * @brief Sets the value of the metanode to a computed value.
504  *
505  * The value is computed by this property's MetaValueCalculator.
506  * @param metaNode The metanode to compute a value on.
507  * @param subgraph The subgraph pointed by the metanode.
508  * @param metaGraph The graph who owns the meta node.
509  */
510  virtual void computeMetaValue(node metaNode, Graph *subgraph, Graph *metaGraph) = 0;
511 
512  /**
513  * @brief Sets the value of the metaedge to a computed value.
514  * @param metaEdge The meta edge to compute a value on.
515  * @param it The edges represented by the meta edge.
516  * @param metaGraph The graph who owns the meta edge.
517  */
518  virtual void computeMetaValue(edge metaEdge, tlp::Iterator<edge> *it, Graph *metaGraph) = 0;
519 
520  /**
521  * @brief Base class for computing values on meta nodes and edges.
522  */
524  public:
525  virtual ~MetaValueCalculator() {}
526  };
527 
528  /**
529  * @brief Gets the MetaValueCalculator of this property.
530  * @return The MetaValueCalculator of this property
531  */
533  return metaValueCalculator;
534  }
535 
536  /**
537  * @brief Sets the Calculator for meta nodes and edges.
538  * @param calculator The object containing the logic for computing the meta values for the nodes
539  * and edges.
540  *
541  * @warning The ownership of the MetaValueCalculator is not taken by the property.
542  */
543  virtual void setMetaValueCalculator(MetaValueCalculator *calculator) {
544  metaValueCalculator = calculator;
545  }
546 
547  /**
548  * @brief Compares the value this property holds for the two given nodes.
549  * @param n1 The first node to compare the value of.
550  * @param n2 The second node to compare the value of.
551  * @return 0 if the values are identical, a positive value if n1 is greater than n2, and a
552  * negative value if n1 is less than n2.
553  */
554  virtual int compare(const node n1, const node n2) const = 0;
555 
556  /**
557  * @brief Compares the value this property holds for the two given edges.
558  * @param e1 The first edge to compare the value of.
559  * @param e2 The second edge to compare the value of.
560  * @return 0 if the values are identical, a positive value if e1 is greater than e2, and a
561  * negative value if e1 is less than e2.
562  */
563  virtual int compare(const edge e1, const edge e2) const = 0;
564 
565 protected:
566  MetaValueCalculator *metaValueCalculator;
567 
568  // for notification of PropertyObserver
569  void notifyBeforeSetNodeValue(const node n);
570  void notifyAfterSetNodeValue(const node n);
571  void notifyBeforeSetEdgeValue(const edge e);
572  void notifyAfterSetEdgeValue(const edge e);
573  void notifyBeforeSetAllNodeValue();
574  void notifyAfterSetAllNodeValue();
575  void notifyBeforeSetAllEdgeValue();
576  void notifyAfterSetAllEdgeValue();
577  void notifyDestroy();
578  void notifyRename(const std::string &newName);
579 };
580 
581 /**
582  * @ingroup Graph
583  * @brief VectorPropertyInterface describes the interface of a graph property whose holded value is
584  * a vector (std::vector)
585  *
586  */
587 class TLP_SCOPE VectorPropertyInterface : public PropertyInterface {
588 public:
590 
591  ~VectorPropertyInterface() override {}
592 
593  /**
594  * @brief split an input string into a vector of strings
595  * @param str A string listing the elements of the vector to set on a node/edge.
596  * @param vect An output vector containing the string elements
597  * @param openChar an optional character opening the list of elements. Default value is '('; when
598  * set to '\0' it indicates that there is no opening character.
599  * @param sepChar an optional character separing the elements of the list. Default value is ','.
600  * @param closeChar an optional character closing the list of elements. Default value is ')'; when
601  * set to '\0' it indicates that there is no opening character.
602  * @return Whether the string was a correct representation for this property's type.
603  */
604  virtual bool tokenize(const std::string &str, std::vector<std::string> &vect, char openChar = '(',
605  char sepChar = ',', char closeChar = ')') = 0;
606 
607  /**
608  * @brief Sets a new vector represented by the vector of string parameter as the node value.
609  * @param n The node on which to set the new value.
610  * @param values A vector of strings listing the string representations of elements of the vector
611  * to set on the node.
612  * @return Whether the vector was a correct representation for this property's type. If not, the
613  * value is not set.
614  */
615  virtual bool setNodeStringValueAsVector(const node n, const std::vector<std::string> &values) = 0;
616 
617  /**
618  * @brief Sets a new vector represented by the vector of string parameter as the edge value.
619  * @param e The edge on which to set the new value.
620  * @param values A vector of strings listing the string representations of elements of the vector
621  * to set on the edge.
622  * @return Whether the vector was a correct representation for this property's type. If not, the
623  * value is not set.
624  */
625  virtual bool setEdgeStringValueAsVector(const edge e, const std::vector<std::string> &values) = 0;
626 
627  /**
628  * @brief Sets a new vector represented by the string parameter as the node value.
629  * @param n The node on which to set the new value.
630  * @param value A string listing the elements of the vector to set on the node.
631  * @param openChar an optional character opening the list of elements. Default value is '('; when
632  * set to '\0' it indicates that there is no opening character.
633  * @param sepChar an optional character separing the elements of the list. Default value is ','.
634  * @param closeChar an optional character closing the list of elements. Default value is ')'; when
635  * set to '\0' it indicates that there is no opening character.
636  * @return Whether the string was a correct representation for this property's type. If not, the
637  * value is not set.
638  */
639  virtual bool setNodeStringValueAsVector(const node n, const std::string &value,
640  char openChar = '(', char sepChar = ',',
641  char closeChar = ')') = 0;
642 
643  /**
644  * @brief Sets a new vector represented by the string parameter as the edge value.
645  * @param e The edge on which to set value on.
646  * @param value A string listing the elements of the vector to set on the edge.
647  * @param openChar an optional character opening the list of elements. Default value is '('; when
648  * set to '\0' it indicates that there is no opening character.
649  * @param sepChar an optional character separing the elements of the list. Default value is ','.
650  * @param closeChar an optional character closing the list of elements. Default value is ')'; when
651  * set to '\0' it indicates that there is no opening character.
652  * @return Whether the string was a correct representation for this property's type. If not, the
653  * value is not set.
654  */
655  virtual bool setEdgeStringValueAsVector(const edge e, const std::string &value,
656  char openChar = '(', char sepChar = ',',
657  char closeChar = ')') = 0;
658 };
659 
660 /**
661  * @ingroup Observation
662  * @brief Contains additional information about events on a property,
663  * such as the property it happened on, the node/edge eventually concerned and such.
664  * It also contains the detailed type of the event.
665  */
666 class TLP_SCOPE PropertyEvent : public Event {
667 public:
668  // be careful about the ordering of the constants
669  // in the enum below because it is used in some assertions
670  enum PropertyEventType {
671  TLP_BEFORE_SET_NODE_VALUE = 0,
672  TLP_AFTER_SET_NODE_VALUE,
673  TLP_BEFORE_SET_ALL_NODE_VALUE,
674  TLP_AFTER_SET_ALL_NODE_VALUE,
675  TLP_BEFORE_SET_ALL_EDGE_VALUE,
676  TLP_AFTER_SET_ALL_EDGE_VALUE,
677  TLP_BEFORE_SET_EDGE_VALUE,
678  TLP_AFTER_SET_EDGE_VALUE
679  };
680  PropertyEvent(const PropertyInterface &prop, PropertyEventType propEvtType,
681  Event::EventType evtType = Event::TLP_MODIFICATION, unsigned int id = UINT_MAX)
682  : Event(prop, evtType), evtType(propEvtType), eltId(id) {}
683 
684  PropertyInterface *getProperty() const {
685  return static_cast<PropertyInterface *>(sender());
686  }
687 
688  node getNode() const {
689  assert(evtType < TLP_BEFORE_SET_ALL_NODE_VALUE);
690  return node(eltId);
691  }
692 
693  edge getEdge() const {
694  assert(evtType > TLP_AFTER_SET_ALL_EDGE_VALUE);
695  return edge(eltId);
696  }
697 
698  PropertyEventType getType() const {
699  return evtType;
700  }
701 
702 protected:
703  PropertyEventType evtType;
704  unsigned int eltId;
705 };
706 } // namespace tlp
707 
708 //================================================================================
709 // these functions allow to use tlp::PropertyInterface as a key in a hash-based data structure (e.g.
710 // hashmap).
711 //================================================================================
712 
713 ///@cond DOXYGEN_HIDDEN
714 namespace std {
715 template <>
716 struct TLP_SCOPE hash<const tlp::PropertyInterface *> {
717  size_t operator()(const tlp::PropertyInterface *prop) const {
718  return size_t(prop);
719  }
720 };
721 template <>
722 struct TLP_SCOPE hash<tlp::PropertyInterface *> {
723  size_t operator()(tlp::PropertyInterface *prop) const {
724  return size_t(prop);
725  }
726 };
727 } // namespace std
728 ///@endcond
729 
730 #endif // PROPERTY_INTERFACE_H
Interface for Tulip iterators. Allows basic iteration operations only.
Definition: Graph.h:43
PropertyInterface describes the interface of a graph property.
Definition: TlpTools.h:48
Contains additional information about events on a property, such as the property it happened on...
MetaValueCalculator * getMetaValueCalculator()
Gets the MetaValueCalculator of this property.
const std::string & getName() const
Gets the name of the property (e.g. viewLayout).
The edge struct represents an edge in a Graph object.
Definition: Edge.h:40
The node struct represents a node in a Graph object.
Definition: Node.h:40
VectorPropertyInterface describes the interface of a graph property whose holded value is a vector (s...
Event is the base class for all events used in the Observation mechanism.
Definition: Observable.h:52
Base class for computing values on meta nodes and edges.
virtual void setMetaValueCalculator(MetaValueCalculator *calculator)
Sets the Calculator for meta nodes and edges.
The Observable class is the base of Tulip&#39;s observation system.
Definition: Observable.h:127