Tulip
5.3.1
Large graphs analysis and drawing
TemplateAlgorithm.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_PROPERTY_H
21
#define TULIP_PROPERTY_H
22
23
#include <tulip/Algorithm.h>
24
#include <tulip/Graph.h>
25
26
#include <sstream>
27
28
namespace
tlp
{
29
class
PluginContext;
30
static
const
std::string PROPERTY_ALGORITHM_CATEGORY =
"Property"
;
31
32
/**
33
* @ingroup Plugins
34
* @brief A non-template interface for tlp::TemplateAlgorithm
35
* @see tlp::TemplateAlgorithm
36
**/
37
class
TLP_SCOPE
PropertyAlgorithm
:
public
tlp::Algorithm
{
38
public
:
39
PropertyAlgorithm
(
const
tlp::PluginContext
*context) :
Algorithm
(context) {}
40
std::string
category
()
const override
{
41
return
PROPERTY_ALGORITHM_CATEGORY;
42
}
43
};
44
45
/**
46
* @ingroup Plugins
47
* @brief The TemplateAlgorithm class describes a plugin that can operate on a single graph's
48
* property.
49
* @param Property The property template arguments gives the type of the property the algorithm
50
* operates on.
51
*
52
* A TemplateAlgorithm takes a graph as input (plus additional parameters defined via
53
* tlp::WithParameter) and outputs its results in a tlp::PropertyInterface subclass.
54
* The output property is defined as an output parameter named "result" and as a class member called
55
* result.
56
*
57
* @warning Subclassing TemplateAlgorithm is not recommended since template specifications are
58
* available for every Tulip property types.
59
*
60
* @see tlp::BooleanAlgorithm
61
* @see tlp::StringAlgorithm
62
* @see tlp::DoubleAlgorithm
63
* @see tlp::IntegerAlgorithm
64
* @see tlp::LayoutAlgorithm
65
* @see tlp::SizeAlgorithm
66
*/
67
template
<
class
Property>
68
class
TLP_SCOPE
TemplateAlgorithm
:
public
PropertyAlgorithm
{
69
public
:
70
Property *result;
71
TemplateAlgorithm
(
const
tlp::PluginContext
*context)
72
:
tlp::PropertyAlgorithm
(context), result(
nullptr
) {
73
if
(dataSet !=
nullptr
) {
74
if
(!dataSet->exists(
"result"
)) {
75
std::stringstream propname;
76
propname <<
"result"
;
77
unsigned
number = 0;
78
79
while
(graph->existProperty(propname.str())) {
80
propname.clear();
81
propname <<
"result"
<< number;
82
++number;
83
}
84
85
result = graph->getProperty<Property>(propname.str());
86
}
else
{
87
dataSet->get(
"result"
, result);
88
}
89
}
90
}
91
};
92
}
// namespace tlp
93
#endif
tlp::TemplateAlgorithm
The TemplateAlgorithm class describes a plugin that can operate on a single graph's property...
Definition:
TemplateAlgorithm.h:68
tlp
Definition:
AbstractProperty.h:34
tlp::PropertyAlgorithm
A non-template interface for tlp::TemplateAlgorithm.
Definition:
TemplateAlgorithm.h:37
tlp::Algorithm
This abstract class describes a basic algorithm plugin.
Definition:
Algorithm.h:46
tlp::PluginContext
Contains runtime parameters for a plugin.
Definition:
PluginContext.h:42
tlp::PropertyAlgorithm::category
std::string category() const override
A string identifier for a plugin used for categorization purposes.
Definition:
TemplateAlgorithm.h:40
library
tulip-core
include
tulip
TemplateAlgorithm.h
Generated on Thu Jul 4 2019 08:31:05 for Tulip by
1.8.13