20 #ifndef _TULIPWITHPARAMETER 21 #define _TULIPWITHPARAMETER 27 #include <tulip/tulipconf.h> 33 template <
class itType>
73 std::string defaultValue;
80 const std::string &defaultValue,
bool mandatory,
82 : name(name), type(type), help(help), defaultValue(defaultValue), mandatory(mandatory),
83 direction(direction) {}
113 defaultValue = defVal;
138 return (direction != OUT_PARAM) ||
140 (type.find(
"Property") != std::string::npos);
166 template <
typename T>
167 void add(
const std::string ¶meterName,
const std::string &help,
168 const std::string &defaultValue,
bool isMandatory =
true,
170 const std::string &valuesDescription = std::string()) {
171 for (
unsigned int i = 0; i < parameters.size(); ++i) {
172 if (parameters[i].getName() == parameterName) {
174 tlp::warning() <<
"ParameterDescriptionList::add " << parameterName <<
" already exists" 182 parameterName,
typeid(T).name(),
183 generateParameterHTMLDocumentation(parameterName, help,
typeid(T).name(), defaultValue,
184 valuesDescription, direction),
185 defaultValue, isMandatory, direction);
186 parameters.push_back(newParameter);
202 const std::string &getDefaultValue(
const std::string ¶meterName)
const;
211 void setDefaultValue(
const std::string ¶meterName,
const std::string &value);
229 bool isMandatory(
const std::string ¶meterName)
const;
241 void buildDefaultDataSet(
DataSet &ioDataSet,
Graph *inG =
nullptr)
const;
248 inline unsigned int size()
const {
249 return parameters.size();
258 return parameters.empty();
263 std::string generateParameterHTMLDocumentation(
const std::string &name,
const std::string &help,
264 const std::string &type,
265 const std::string &defaultValue,
266 const std::string &valuesDescription,
268 std::vector<ParameterDescription> parameters;
271 #define HTML_HELP_OPEN() \ 272 "<!DOCTYPE html><html><head>\ 273 <style type=\"text/css\">.body { font-family: \"Segoe UI\", Candara, \"Bitstream Vera Sans\", \"DejaVu Sans\", \"Bitstream Vera Sans\", \"Trebuchet MS\", Verdana, \"Verdana Ref\", sans-serif; }\ 274 .paramtable { width: 100%; border: 0px; border-bottom: 1px solid #C9C9C9; padding: 5px; }\ 275 .help { font-style: italic; font-size: 90%; }\ 276 .b { padding-left: 5px; }</style>\ 277 </head><body><table border=\"0\" class=\"paramtable\">" 279 #define HTML_HELP_DEF(A, B) "<tr><td><b>" A "</b><td class=\"b\">" B "</td></tr>" 281 #define HTML_HELP_BODY() "</table><p class=\"help\">" 283 #define HTML_HELP_CLOSE() "</p></body></html>" 315 template <
typename T>
317 const std::string &defaultValue,
bool isMandatory =
true,
318 const std::string &valuesDescription = std::string()) {
319 parameters.template add<T>(name, help, defaultValue, isMandatory, IN_PARAM, valuesDescription);
334 template <
typename T>
335 void addOutParameter(
const std::string &name,
const std::string &help = std::string(),
336 const std::string &defaultValue = std::string(),
bool isMandatory =
true,
337 const std::string &valuesDescription = std::string()) {
338 parameters.template add<T>(name, help, defaultValue, isMandatory, OUT_PARAM, valuesDescription);
353 template <
typename T>
355 const std::string &defaultValue = std::string(),
bool isMandatory =
true,
356 const std::string &valuesDescription = std::string()) {
357 parameters.template add<T>(name, help, defaultValue, isMandatory, INOUT_PARAM,
374 template <
typename T>
375 _DEPRECATED
void addParameter(
const std::string &name,
const std::string &help = std::string(),
376 const std::string &defaultValue = std::string(),
377 bool isMandatory =
true) {
378 addInParameter<T>(name, help, defaultValue, isMandatory);
386 bool inputRequired()
const;
bool empty() const
Test if the list is empty.
Interface for Tulip iterators. Allows basic iteration operations only.
void setDirection(ParameterDirection dir)
void addOutParameter(const std::string &name, const std::string &help=std::string(), const std::string &defaultValue=std::string(), bool isMandatory=true, const std::string &valuesDescription=std::string())
Adds an OUT parameter to the plug-in.
A container that can store data from any type.
void setDefaultValue(const std::string &defVal)
Set the parameter's default value.
ParameterDirection
The ParameterDirection enum describes how a parameter is passed to a plugin The parameter can be seen...
unsigned int size() const
Returns the number of parameters.
void addParameter(const std::string &name, const std::string &help=std::string(), const std::string &defaultValue=std::string(), bool isMandatory=true)
Adds an IN parameter to the plug-in (deprecated)
const std::string & getDefaultValue() const
const std::string & getName() const
ParameterDirection getDirection() const
void add(const std::string ¶meterName, const std::string &help, const std::string &defaultValue, bool isMandatory=true, ParameterDirection direction=IN_PARAM, const std::string &valuesDescription=std::string())
Adds a new parameter of type T to the list.
const std::string & getTypeName() const
void addInOutParameter(const std::string &name, const std::string &help=std::string(), const std::string &defaultValue=std::string(), bool isMandatory=true, const std::string &valuesDescription=std::string())
Adds an INOUT parameter to the plug-in.
void addInParameter(const std::string &name, const std::string &help, const std::string &defaultValue, bool isMandatory=true, const std::string &valuesDescription=std::string())
Adds an IN parameter to the plug-in.
const std::string & getHelp() const
This class describes parameters taken by a plugin.
Describes a plugin's parameter.
This class describes parameters on a plug-in.