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