Tulip  5.6.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  DEFINE_GET_CPP_CLASS_NAME;
51  void setNodeValue(const node n, tlp::StoredType<int>::ReturnedConstValue v) override;
52  void setEdgeValue(const edge e, tlp::StoredType<int>::ReturnedConstValue v) override;
53  void setAllNodeValue(tlp::StoredType<int>::ReturnedConstValue v) override;
54 
55  void setValueToGraphNodes(tlp::StoredType<int>::ReturnedConstValue v,
56  const Graph *graph) override;
57  void setAllEdgeValue(tlp::StoredType<int>::ReturnedConstValue v) override;
58  void setValueToGraphEdges(tlp::StoredType<int>::ReturnedConstValue v,
59  const Graph *graph) override;
60 
61  int compare(const node n1, const node n2) const override;
62  int compare(const edge e1, const edge e2) const override;
63 
64  // NumericProperty interface
65  double getNodeDoubleValue(const node n) const override {
66  return getNodeValue(n);
67  }
68  double getNodeDoubleDefaultValue() const override {
69  return getNodeDefaultValue();
70  }
71  double getNodeDoubleMin(const Graph *g = nullptr) override {
72  return getNodeMin(g);
73  }
74  double getNodeDoubleMax(const Graph *g = nullptr) override {
75  return getNodeMax(g);
76  }
77  double getEdgeDoubleValue(const edge e) const override {
78  return getEdgeValue(e);
79  }
80  double getEdgeDoubleDefaultValue() const override {
81  return getEdgeDefaultValue();
82  }
83  double getEdgeDoubleMin(const Graph *g = nullptr) override {
84  return getEdgeMin(g);
85  }
86  double getEdgeDoubleMax(const Graph *g = nullptr) override {
87  return getEdgeMax(g);
88  }
89 
90  void nodesUniformQuantification(unsigned int) override;
91 
92  void edgesUniformQuantification(unsigned int) override;
93 
94  NumericProperty *copyProperty(Graph *g) override {
95  IntegerProperty *newProp = new IntegerProperty(g);
96  newProp->copy(this);
97 
98  return newProp;
99  }
100 
101 protected:
102  void clone_handler(
103  AbstractProperty<tlp::IntegerType, tlp::IntegerType, tlp::NumericProperty> &) override;
104 
105 private:
106  // override Observable::treatEvent
107  void treatEvent(const Event &) override;
108 };
109 
110 /**
111  * @ingroup Graph
112  * @brief A graph property that maps a std::vector<int> value to graph elements.
113  */
114 class TLP_SCOPE IntegerVectorProperty
115  : public AbstractVectorProperty<tlp::IntegerVectorType, tlp::IntegerType> {
116 public:
117  IntegerVectorProperty(Graph *g, const std::string &n = "")
118  : AbstractVectorProperty<IntegerVectorType, tlp::IntegerType>(g, n) {}
119  // redefinition of some PropertyInterface methods
120  PropertyInterface *clonePrototype(Graph *, const std::string &) const override;
121  static const std::string propertyTypename;
122  const std::string &getTypename() const override {
123  return propertyTypename;
124  }
125  DEFINE_GET_CPP_CLASS_NAME;
126 };
127 } // namespace tlp
128 #endif
129 ///@endcond
tlp::IntegerProperty
A graph property that maps an integer value to graph elements.
Definition: IntegerProperty.h:40
tlp::Graph
Definition: Graph.h:234
tlp::IntegerVectorProperty::getTypename
const std::string & getTypename() const override
Gets a string describing the type of the property value (e.g. "graph", "double", "layout",...
Definition: IntegerProperty.h:122
tlp::PropertyInterface
PropertyInterface describes the interface of a graph property.
Definition: PropertyInterface.h:60
tlp::IntegerProperty::getTypename
const std::string & getTypename() const override
Gets a string describing the type of the property value (e.g. "graph", "double", "layout",...
Definition: IntegerProperty.h:47
tlp::IntegerVectorProperty
A graph property that maps a std::vector<int> value to graph elements.
Definition: IntegerProperty.h:114
tlp
Definition: AbstractProperty.h:34
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::MinMaxProperty
Abstracts the computation of minimal and maximal values on node and edge values of properties.
Definition: minmaxproperty.h:46