Tulip 6.1.0
Large graphs analysis and drawing
Loading...
Searching...
No Matches
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
26namespace tlp {
27class PluginContext;
28static 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 **/
35class TLP_SCOPE PropertyAlgorithm : public tlp::Algorithm {
36public:
37 PropertyAlgorithm(const tlp::PluginContext *context) : Algorithm(context) {}
38 std::string category() const override {
39 return PROPERTY_ALGORITHM_CATEGORY;
40 }
41};
42
43template <class Property>
44class TLP_SCOPE TypedPropertyAlgorithm : public PropertyAlgorithm {
45public:
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
72class BooleanProperty;
73static 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 */
80class TLP_SCOPE BooleanAlgorithm : public TypedPropertyAlgorithm<tlp::BooleanProperty> {
81protected:
82 BooleanAlgorithm(const tlp::PluginContext *, bool needInOutResult = false);
83
84public:
85 std::string category() const override {
86 return BOOLEAN_ALGORITHM_CATEGORY;
87 }
88};
89
90class ColorProperty;
91static 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 */
97class TLP_SCOPE ColorAlgorithm : public TypedPropertyAlgorithm<tlp::ColorProperty> {
98protected:
99 ColorAlgorithm(const tlp::PluginContext *, bool needInOutResult = false);
100
101public:
102 std::string category() const override {
103 return COLOR_ALGORITHM_CATEGORY;
104 }
105};
106
107class DoubleProperty;
108static 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 */
115class TLP_SCOPE DoubleAlgorithm : public TypedPropertyAlgorithm<tlp::DoubleProperty> {
116protected:
117 ///
118 DoubleAlgorithm(const tlp::PluginContext *, bool needInOutResult = false);
119
120public:
121 std::string category() const override {
122 return DOUBLE_ALGORITHM_CATEGORY;
123 }
124};
125
126class IntegerProperty;
127static 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 */
134class TLP_SCOPE IntegerAlgorithm : public TypedPropertyAlgorithm<tlp::IntegerProperty> {
135protected:
136 IntegerAlgorithm(const tlp::PluginContext *, bool needInOutResult = false);
137
138public:
139 std::string category() const override {
140 return INTEGER_ALGORITHM_CATEGORY;
141 }
142};
143
144class LayoutProperty;
145static 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 */
152class TLP_SCOPE LayoutAlgorithm : public TypedPropertyAlgorithm<tlp::LayoutProperty> {
153protected:
154 ///
155 LayoutAlgorithm(const tlp::PluginContext *, bool needInOutResult = false);
156
157public:
158 std::string category() const override {
159 return LAYOUT_ALGORITHM_CATEGORY;
160 }
161};
162
163class SizeProperty;
164static 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 */
170class TLP_SCOPE SizeAlgorithm : public TypedPropertyAlgorithm<tlp::SizeProperty> {
171protected:
172 SizeAlgorithm(const tlp::PluginContext *, bool needInOutResult = false);
173
174public:
175 std::string category() const override {
176 return SIZE_ALGORITHM_CATEGORY;
177 }
178};
179
180class StringProperty;
181static 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 */
188class TLP_SCOPE StringAlgorithm : public TypedPropertyAlgorithm<tlp::StringProperty> {
189protected:
190 ///
191 StringAlgorithm(const tlp::PluginContext *, bool needInOutResult = false);
192
193public:
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
Algorithm(const PluginContext *context)
Constructs an algorithm and initializes members from the AlgorithmContext.
Definition Algorithm.h:55
std::string category() const override
A string identifier for a plugin used for categorization purposes.
A graph property that maps a Boolean value to graph elements.
std::string category() const override
A string identifier for a plugin used for categorization purposes.
std::string category() const override
A string identifier for a plugin used for categorization purposes.
std::string category() const override
A string identifier for a plugin used for categorization purposes.
std::string category() const override
A string identifier for a plugin used for categorization purposes.
Contains runtime parameters for a plugin.
std::string category() const override
A string identifier for a plugin used for categorization purposes.
std::string category() const override
A string identifier for a plugin used for categorization purposes.
std::string category() const override
A string identifier for a plugin used for categorization purposes.