22 #ifndef _TULIPWITHPARAMETER
23 #define _TULIPWITHPARAMETER
29 #include <tulip/tulipconf.h>
35 template <
class itType>
48 enum ParameterDirection { IN_PARAM = 0, OUT_PARAM = 1, INOUT_PARAM = 2 };
70 class TLP_SCOPE ParameterDescription {
75 std::string defaultValue;
77 ParameterDirection direction;
80 ParameterDescription() {}
81 ParameterDescription(
const std::string &name,
const std::string &type,
const std::string &help,
82 const std::string &defaultValue,
bool mandatory,
83 ParameterDirection direction)
84 : name(name), type(type), help(help), defaultValue(defaultValue), mandatory(mandatory),
85 direction(direction) {}
90 const std::string &getName()
const {
96 const std::string &getTypeName()
const {
102 const std::string &getHelp()
const {
108 const std::string &getDefaultValue()
const {
114 void setDefaultValue(
const std::string &defVal) {
115 defaultValue = defVal;
120 bool isMandatory()
const {
126 ParameterDirection getDirection()
const {
132 void setDirection(ParameterDirection dir) {
138 bool isEditable()
const {
140 return (direction != OUT_PARAM) ||
142 (type.find(
"Property") != std::string::npos);
154 struct TLP_SCOPE ParameterDescriptionList {
156 ParameterDescriptionList() {}
168 template <
typename T>
169 void add(
const std::string ¶meterName,
const std::string &help,
170 const std::string &defaultValue,
bool isMandatory =
true,
171 ParameterDirection direction = IN_PARAM,
172 const std::string &valuesDescription = std::string()) {
173 for (
unsigned int i = 0; i < parameters.size(); ++i) {
174 if (parameters[i].getName() == parameterName) {
176 tlp::warning() <<
"ParameterDescriptionList::add " << parameterName <<
" already exists"
183 ParameterDescription newParameter(
184 parameterName,
typeid(T).name(),
185 generateParameterHTMLDocumentation(parameterName, help,
typeid(T).name(), defaultValue,
186 valuesDescription, direction),
187 defaultValue, isMandatory, direction);
188 parameters.push_back(newParameter);
197 void remove(
const std::string ¶meterName);
212 const std::string &getDefaultValue(
const std::string ¶meterName)
const;
221 void setDefaultValue(
const std::string ¶meterName,
const std::string &value);
229 ParameterDirection getDirection(
const std::string ¶meterName)
const;
238 void setDirection(
const std::string ¶meterName, ParameterDirection direction);
247 bool isMandatory(
const std::string ¶meterName)
const;
259 void buildDefaultDataSet(DataSet &ioDataSet, Graph *inG =
nullptr)
const;
266 inline unsigned int size()
const {
267 return parameters.size();
275 inline bool empty()
const {
276 return parameters.empty();
280 ParameterDescription *getParameter(
const std::string ¶meterName);
281 std::string generateParameterHTMLDocumentation(
const std::string &name,
const std::string &help,
282 const std::string &type,
283 const std::string &defaultValue,
284 const std::string &valuesDescription,
285 const ParameterDirection &direction);
286 std::vector<ParameterDescription> parameters;
298 struct TLP_SCOPE WithParameter {
305 const tlp::ParameterDescriptionList &getParameters()
const;
322 template <
typename T>
323 void addInParameter(
const std::string &name,
const std::string &help,
324 const std::string &defaultValue,
bool isMandatory =
true,
325 const std::string &valuesDescription = std::string()) {
326 parameters.template add<T>(name, help, defaultValue, isMandatory, IN_PARAM, valuesDescription);
344 template <
typename T>
345 void addOutParameter(
const std::string &name,
const std::string &help = std::string(),
346 const std::string &defaultValue = std::string(),
bool isMandatory =
true,
347 const std::string &valuesDescription = std::string()) {
348 parameters.template add<T>(name, help, defaultValue, isMandatory, OUT_PARAM, valuesDescription);
366 template <
typename T>
367 void addInOutParameter(
const std::string &name,
const std::string &help = std::string(),
368 const std::string &defaultValue = std::string(),
bool isMandatory =
true,
369 const std::string &valuesDescription = std::string()) {
370 parameters.template add<T>(name, help, defaultValue, isMandatory, INOUT_PARAM,
379 bool inputRequired()
const;
385 ParameterDescriptionList parameters;
389 void removeParameter(
const std::string &name) {
390 parameters.remove(name);
Interface for Tulip iterators. Allows basic iteration operations only.