Tulip  4.4.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
tlp::Algorithm Class Referenceabstract

#include <Algorithm.h>

Inherits tlp::Plugin.

Inherited by tlp::PropertyAlgorithm.

Public Member Functions

 Algorithm (const PluginContext *context)
 
virtual std::string category () const
 
virtual bool check (std::string &)
 
std::string icon () const
 
virtual bool run ()=0
 
- Public Member Functions inherited from tlp::Plugin
virtual std::string author () const =0
 
virtual std::string date () const =0
 
virtual std::string group () const =0
 
virtual int id () const
 
virtual std::string info () const =0
 
virtual std::string major () const
 
virtual std::string minor () const
 
virtual std::string name () const =0
 
virtual std::string programmingLanguage () const
 
virtual std::string release () const =0
 
virtual std::string tulipMajor () const
 
virtual std::string tulipMinor () const
 
virtual std::string tulipRelease () const =0
 
- Public Member Functions inherited from tlp::WithParameter
template<typename T >
void addInOutParameter (const std::string &name, const std::string &help=std::string(), const std::string &defaultValue=std::string(), bool isMandatory=true)
 
template<typename T >
void addInParameter (const std::string &name, const std::string &help, const std::string &defaultValue, bool isMandatory=true)
 
template<typename T >
void addOutParameter (const std::string &name, const std::string &help=std::string(), const std::string &defaultValue=std::string(), bool isMandatory=true)
 
template<typename T >
void addParameter (const std::string &name, const std::string &help=std::string(), const std::string &defaultValue=std::string(), bool isMandatory=true)
 
const
tlp::ParameterDescriptionList
getParameters () const
 
bool inputRequired () const
 
- Public Member Functions inherited from tlp::WithDependency
void addDependency (const char *name, const char *release)
 
const std::list< Dependency > & dependencies () const
 

Public Attributes

DataSetdataSet
 
Graphgraph
 
PluginProgresspluginProgress
 

Additional Inherited Members

- Protected Attributes inherited from tlp::WithParameter
ParameterDescriptionList parameters
 
- Protected Attributes inherited from tlp::WithDependency
std::list< Dependency_dependencies
 

Detailed Description

This abstract class describes a basic algorithm plugin.

It inherits on WithParameter and WithDependency for convenience. Basic functionality consists in checking the algorithm can run on the current Graph (e.g. is the graph simple ?), running the algorithm and resetting the algorithm to re-apply it. The algorithm can and should report progress and which task it is performing if it is decomposed in multiple phases (e.g. layouting the graph, coloring it, ...).

Definition at line 45 of file Algorithm.h.

Constructor & Destructor Documentation

tlp::Algorithm::Algorithm ( const PluginContext context)
inline

Constructs an algorithm and initializes members from the AlgorithmContext.

Parameters
contextThe context this algorithm runs in, containing the graph, a DataSet for the parameters, and a PluginProgress to give feedback to the user about the tasks the algorithm is performing.

Definition at line 53 of file Algorithm.h.

Member Function Documentation

virtual std::string tlp::Algorithm::category ( ) const
inlinevirtual

A string identifier for a plugin used for categorization purposes.

Returns
std::string the category of the plugin.

Implements tlp::Plugin.

Reimplemented in tlp::StringAlgorithm, tlp::SizeAlgorithm, tlp::LayoutAlgorithm, tlp::IntegerAlgorithm, tlp::DoubleAlgorithm, tlp::ColorAlgorithm, tlp::BooleanAlgorithm, and tlp::PropertyAlgorithm.

Definition at line 77 of file Algorithm.h.

virtual bool tlp::Algorithm::check ( std::string &  )
inlinevirtual

Checks whether the algorithm can be applied on this graph or not. If not, the reason why should be reported through the PluginProgress.

Parameters
errorMessageA string whose value will be modified to an error message, if the check fails.
Returns
bool Whether the plug-in can run on this Graph.

Definition at line 87 of file Algorithm.h.

std::string tlp::Algorithm::icon ( ) const
inlinevirtual

The icon (preferably a thumbnail) of the plugin.

Returns
std::string the icon path

Reimplemented from tlp::Plugin.

Definition at line 64 of file Algorithm.h.

virtual bool tlp::Algorithm::run ( )
pure virtual

Runs the algorithm. It is a good practice to report progress through the PluginProgress, Even if your algorithm is very fast. Keep in mind that Tulip can handle very large graphs. The PluginProgress should also be used to report errors, if any.

Returns
bool Whether the algorithm execution was successful or not.

Member Data Documentation

DataSet* tlp::Algorithm::dataSet

A DataSet containing parameters for this algorithm, if any. Retrieved from the context at construction.

Definition at line 101 of file Algorithm.h.

Graph* tlp::Algorithm::graph

The graph this algorithm will be run on. Retrieved from the context at construction.

Definition at line 93 of file Algorithm.h.

PluginProgress* tlp::Algorithm::pluginProgress

A PluginProgress to give feedback to the user, retrieved from the context. It can be a NULL pointer, so use with caution.

Definition at line 97 of file Algorithm.h.