Tulip  6.0.0
Large graphs analysis and drawing
PropertyAlgorithm.h
1 /*
2  *
3  * This file is part of Tulip (https://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 PROPERTYALGORITHM_H
21 #define PROPERTYALGORITHM_H
22 
23 #include <tulip/Algorithm.h>
24 #include <tulip/Graph.h>
25 
26 namespace tlp {
27 class PluginContext;
28 static const std::string PROPERTY_ALGORITHM_CATEGORY = "Property";
29 
30 /**
31  * @ingroup Plugins
32  * @brief A non-template interface for tlp::TypedPropertyAlgorithm
33  * @see tlp::TypedPropertyAlgorithm
34  **/
35 class TLP_SCOPE PropertyAlgorithm : public tlp::Algorithm {
36 public:
37  PropertyAlgorithm(const tlp::PluginContext *context) : Algorithm(context) {}
38  std::string category() const override {
39  return PROPERTY_ALGORITHM_CATEGORY;
40  }
41 };
42 
43 template <class Property>
44 class TLP_SCOPE TypedPropertyAlgorithm : public PropertyAlgorithm {
45 public:
46  Property *result;
47  TypedPropertyAlgorithm(const tlp::PluginContext *context)
48  : PropertyAlgorithm(context), result(nullptr) {
49  if (dataSet != nullptr) {
50  if (!dataSet->exists("result")) {
51  std::string propname("result");
52  unsigned number = 0;
53 
54  while (graph->existProperty(propname)) {
55  propname.clear();
56  propname += "result" + std::to_string(number);
57  ++number;
58  }
59 
60  result = graph->getProperty<Property>(propname);
61  } else {
62  dataSet->get("result", result);
63  }
64  }
65  }
66 
67  std::string category() const override {
68  return PROPERTY_ALGORITHM_CATEGORY;
69  }
70 };
71 
72 class BooleanProperty;
73 static const std::string BOOLEAN_ALGORITHM_CATEGORY = "Selection";
74 
75 /**
76  * @ingroup Plugins
77  * @brief The Boolean algorithm takes a graph as input and output its results as a
78  * tlp::BooleanProperty
79  */
80 class TLP_SCOPE BooleanAlgorithm : public TypedPropertyAlgorithm<tlp::BooleanProperty> {
81 protected:
82  BooleanAlgorithm(const tlp::PluginContext *, bool needInOutResult = false);
83 
84 public:
85  std::string category() const override {
86  return BOOLEAN_ALGORITHM_CATEGORY;
87  }
88 };
89 
90 class ColorProperty;
91 static const std::string COLOR_ALGORITHM_CATEGORY = "Coloring";
92 
93 /**
94  * @ingroup Plugins
95  * @brief The color algorithm takes a graph as input and output its results as a tlp::ColorProperty
96  */
97 class TLP_SCOPE ColorAlgorithm : public TypedPropertyAlgorithm<tlp::ColorProperty> {
98 protected:
99  ColorAlgorithm(const tlp::PluginContext *, bool needInOutResult = false);
100 
101 public:
102  std::string category() const override {
103  return COLOR_ALGORITHM_CATEGORY;
104  }
105 };
106 
107 class DoubleProperty;
108 static const std::string DOUBLE_ALGORITHM_CATEGORY = "Measure";
109 
110 /**
111  * @ingroup Plugins
112  * @brief The double algorithm takes a graph as input and output its results as a
113  * tlp::DoubleProperty
114  */
115 class TLP_SCOPE DoubleAlgorithm : public TypedPropertyAlgorithm<tlp::DoubleProperty> {
116 protected:
117  ///
118  DoubleAlgorithm(const tlp::PluginContext *, bool needInOutResult = false);
119 
120 public:
121  std::string category() const override {
122  return DOUBLE_ALGORITHM_CATEGORY;
123  }
124 };
125 
126 class IntegerProperty;
127 static const std::string INTEGER_ALGORITHM_CATEGORY = "Measure";
128 
129 /**
130  * @ingroup Plugins
131  * @brief The integer algorithm takes a graph as input and output its results as a
132  * tlp::IntegerProperty
133  */
134 class TLP_SCOPE IntegerAlgorithm : public TypedPropertyAlgorithm<tlp::IntegerProperty> {
135 protected:
136  IntegerAlgorithm(const tlp::PluginContext *, bool needInOutResult = false);
137 
138 public:
139  std::string category() const override {
140  return INTEGER_ALGORITHM_CATEGORY;
141  }
142 };
143 
144 class LayoutProperty;
145 static const std::string LAYOUT_ALGORITHM_CATEGORY = "Layout";
146 
147 /**
148  * @ingroup Plugins
149  * @brief The layout algorithm takes a graph as input and output its results as a
150  * tlp::LayoutProperty
151  */
152 class TLP_SCOPE LayoutAlgorithm : public TypedPropertyAlgorithm<tlp::LayoutProperty> {
153 protected:
154  ///
155  LayoutAlgorithm(const tlp::PluginContext *, bool needInOutResult = false);
156 
157 public:
158  std::string category() const override {
159  return LAYOUT_ALGORITHM_CATEGORY;
160  }
161 };
162 
163 class SizeProperty;
164 static const std::string SIZE_ALGORITHM_CATEGORY = "Resizing";
165 
166 /**
167  * @ingroup Plugins
168  * @brief The size algorithm takes a graph as input and output its results as a tlp::SizeProperty
169  */
170 class TLP_SCOPE SizeAlgorithm : public TypedPropertyAlgorithm<tlp::SizeProperty> {
171 protected:
172  SizeAlgorithm(const tlp::PluginContext *, bool needInOutResult = false);
173 
174 public:
175  std::string category() const override {
176  return SIZE_ALGORITHM_CATEGORY;
177  }
178 };
179 
180 class StringProperty;
181 static const std::string STRING_ALGORITHM_CATEGORY = "Labeling";
182 
183 /**
184  * @ingroup Plugins
185  * @brief The string algorithm takes a graph as input and output its results as a
186  * tlp::StringProperty
187  */
188 class TLP_SCOPE StringAlgorithm : public TypedPropertyAlgorithm<tlp::StringProperty> {
189 protected:
190  ///
191  StringAlgorithm(const tlp::PluginContext *, bool needInOutResult = false);
192 
193 public:
194  std::string category() const override {
195  return STRING_ALGORITHM_CATEGORY;
196  }
197 };
198 } // namespace tlp
199 
200 #endif // PROPERTYALGORITHM_H
This abstract class describes a basic algorithm plugin.
Definition: Algorithm.h:46
The Boolean algorithm takes a graph as input and output its results as a tlp::BooleanProperty.
std::string category() const override
A string identifier for a plugin used for categorization purposes.
The color algorithm takes a graph as input and output its results as a tlp::ColorProperty.
std::string category() const override
A string identifier for a plugin used for categorization purposes.
The double algorithm takes a graph as input and output its results as a tlp::DoubleProperty.
std::string category() const override
A string identifier for a plugin used for categorization purposes.
The integer algorithm takes a graph as input and output its results as a tlp::IntegerProperty.
std::string category() const override
A string identifier for a plugin used for categorization purposes.
The layout algorithm takes a graph as input and output its results as a tlp::LayoutProperty.
std::string category() const override
A string identifier for a plugin used for categorization purposes.
Contains runtime parameters for a plugin.
Definition: PluginContext.h:42
A non-template interface for tlp::TypedPropertyAlgorithm.
std::string category() const override
A string identifier for a plugin used for categorization purposes.
The size algorithm takes a graph as input and output its results as a tlp::SizeProperty.
std::string category() const override
A string identifier for a plugin used for categorization purposes.
The string algorithm takes a graph as input and output its results as a tlp::StringProperty.
std::string category() const override
A string identifier for a plugin used for categorization purposes.