Tulip  5.2.1
Large graphs analysis and drawing
IntegerProperty.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 TULIP_INT_H
21 #define TULIP_INT_H
22 
23 #include <tulip/tuliphash.h>
24 #include <tulip/PropertyTypes.h>
25 #include <tulip/AbstractProperty.h>
26 #include <tulip/PropertyAlgorithm.h>
27 #include <tulip/Observable.h>
28 #include <tulip/minmaxproperty.h>
29 #include <tulip/NumericProperty.h>
30 
31 namespace tlp {
32 
33 class Graph;
34 class PropertyContext;
35 
36 typedef MinMaxProperty<tlp::IntegerType, tlp::IntegerType, tlp::NumericProperty>
37  IntegerMinMaxProperty;
38 
39 /**
40  * @ingroup Graph
41  * @brief A graph property that maps an integer value to graph elements.
42  */
43 class TLP_SCOPE IntegerProperty : public IntegerMinMaxProperty {
44 
45 public:
46  IntegerProperty(Graph *, const std::string &n = "");
47 
48  PropertyInterface *clonePrototype(Graph *, const std::string &) const override;
49  static const std::string propertyTypename;
50  const std::string &getTypename() const override {
51  return propertyTypename;
52  }
53  void setNodeValue(const node n, tlp::StoredType<int>::ReturnedConstValue v) override;
54  void setEdgeValue(const edge e, tlp::StoredType<int>::ReturnedConstValue v) override;
55  void setAllNodeValue(tlp::StoredType<int>::ReturnedConstValue v) override;
56 
57  void setValueToGraphNodes(tlp::StoredType<int>::ReturnedConstValue v,
58  const Graph *graph) override;
59  void setAllEdgeValue(tlp::StoredType<int>::ReturnedConstValue v) override;
60  void setValueToGraphEdges(tlp::StoredType<int>::ReturnedConstValue v,
61  const Graph *graph) override;
62 
63  int compare(const node n1, const node n2) const override;
64  int compare(const edge e1, const edge e2) const override;
65 
66  // NumericProperty interface
67  double getNodeDoubleValue(const node n) const override {
68  return getNodeValue(n);
69  }
70  double getNodeDoubleDefaultValue() const override {
71  return getNodeDefaultValue();
72  }
73  double getNodeDoubleMin(const Graph *g = nullptr) override {
74  return getNodeMin(g);
75  }
76  double getNodeDoubleMax(const Graph *g = nullptr) override {
77  return getNodeMax(g);
78  }
79  double getEdgeDoubleValue(const edge e) const override {
80  return getEdgeValue(e);
81  }
82  double getEdgeDoubleDefaultValue() const override {
83  return getEdgeDefaultValue();
84  }
85  double getEdgeDoubleMin(const Graph *g = nullptr) override {
86  return getEdgeMin(g);
87  }
88  double getEdgeDoubleMax(const Graph *g = nullptr) override {
89  return getEdgeMax(g);
90  }
91 
92  void nodesUniformQuantification(unsigned int) override;
93 
94  void edgesUniformQuantification(unsigned int) override;
95 
96  NumericProperty *copyProperty(Graph *g) override {
97  IntegerProperty *newProp = new IntegerProperty(g);
98  newProp->copy(this);
99 
100  return newProp;
101  }
102 
103  _DEPRECATED void setAllNodeValue(tlp::StoredType<int>::ReturnedConstValue v,
104  const Graph *graph) override;
105  _DEPRECATED void setAllEdgeValue(tlp::StoredType<int>::ReturnedConstValue v,
106  const Graph *graph) override;
107 
108 protected:
109  void clone_handler(
111 
112 private:
113  // override Observable::treatEvent
114  void treatEvent(const Event &) override;
115 };
116 
117 /**
118  * @ingroup Graph
119  * @brief A graph property that maps a std::vector<int> value to graph elements.
120  */
121 class TLP_SCOPE IntegerVectorProperty
122  : public AbstractVectorProperty<tlp::IntegerVectorType, tlp::IntegerType> {
123 public:
124  IntegerVectorProperty(Graph *g, const std::string &n = "")
125  : AbstractVectorProperty<IntegerVectorType, tlp::IntegerType>(g, n) {}
126  // redefinition of some PropertyInterface methods
127  PropertyInterface *clonePrototype(Graph *, const std::string &) const override;
128  static const std::string propertyTypename;
129  const std::string &getTypename() const override {
130  return propertyTypename;
131  }
132 };
133 } // namespace tlp
134 #endif
135 ///@endcond
This class extends upon PropertyInterface, and adds type-safe methods to get and set the node and edg...
PropertyInterface describes the interface of a graph property.
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
A graph property that maps a std::vector<int> value to graph elements.
Event is the base class for all events used in the Observation mechanism.
Definition: Observable.h:51
Interface all numerical properties. Property values are always returned as double.
A graph property that maps an integer value to graph elements.