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