Tulip  4.1.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
TemplateAlgorithm.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
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 
25 namespace tlp {
26 class PluginContext;
27 static const std::string PROPERTY_ALGORITHM_CATEGORY = QObject::trUtf8("Property").toStdString();
28 
29 /**
30  * @ingroup Plugins
31  * @brief A non-template interface for tlp::TemplateAlgorithm
32  * @see tlp::TemplateAlgorithm
33  **/
34 class TLP_SCOPE PropertyAlgorithm: public tlp::Algorithm {
35 public :
36  PropertyAlgorithm(const tlp::PluginContext* context):Algorithm(context) {}
37  virtual std::string category() const {
38  return PROPERTY_ALGORITHM_CATEGORY;
39  }
40 };
41 
42 /**
43  * @ingroup Plugins
44  * @brief The TemplateAlgorithm class describes a plugin that can operate on a single graph's property.
45  * @param Property The property template arguments gives the type of the property the algorithm operates on.
46  *
47  * A TemplateAlgorithm takes a graph as input (plus additional parameters defined via tlp::WithParameter) and outputs its results in a tlp::PropertyInterface subclass.
48  * The output property is defined as an output parameter named "result" and as a class member called result.
49  *
50  * @warning Subclassing TemplateAlgorithm is not recommended since template specifications are available for every Tulip property types.
51  *
52  * @see tlp::BooleanAlgorithm
53  * @see tlp::StringAlgorithm
54  * @see tlp::DoubleAlgorithm
55  * @see tlp::IntegerAlgorithm
56  * @see tlp::LayoutAlgorithm
57  * @see tlp::SizeAlgorithm
58  */
59 template<class Property>
60 class TLP_SCOPE TemplateAlgorithm : public PropertyAlgorithm {
61 public:
62  Property* result;
63  TemplateAlgorithm (const tlp::PluginContext* context) : tlp::PropertyAlgorithm(context), result(NULL) {
64  if (dataSet != NULL)
65  dataSet->get("result", result);
66  }
67 };
68 
69 
70 }
71 #endif