Class Parameter¶
Defined in File Parameters.h
Class Documentation¶
-
class Parameter¶
This class holds parameter to use with the commands. Value can be validated, applaying constraints, through a schema (another Parameter).
Public Functions
-
inline Parameter(const std::string &name)¶
uninitialized parameter constructor
-
Parameter(const std::map<std::string, std::string> &properties)¶
constructor from map
example of structure:
{ {“name”, “param1”}, {“type”, “int”}, {“value”, “23”}, {“description”, “param1 description”}, {“tags”, “tag1,tag2,tag3”}, {“min”,”0”}, {“max”,”10”} }
-
Parameter(const OpenMS::Param::ParamEntry ¶m_entry)¶
constructor from ParamEntry
-
std::string getType() const¶
returns the type of parameter as string
-
bool isValid(bool use_scheme = true) const¶
based constraints of this parameter, return wether the parameter is valid.
- Parameters
use_scheme – [in] use a schema to validate the value, if one is assigned to the parameter.
-
bool isValid(const CastValue &value, bool use_scheme = true) const¶
based constraints of this parameter, return wether the parameter is valid.
- Parameters
value – [in] a CastValue to valid with the constraints of this parameter.
use_scheme – [in] use a schema’s constraint to validate the value, if one is assigned to the parameter.
-
inline void setName(const std::string &name)¶
set name of the parameter.
- Parameters
name – [in] the name of the parameter.
-
inline const std::string &getName() const¶
get name of the parameter.
set constraints min and max.
set constraints list.
-
void setValueFromString(const std::string &value_as_string, bool allow_change_type = true)¶
set value of the parameter, from a string representation.
- Parameters
value_as_string – [in] the value, as string
allow_change_type – [in] if true, change also the type if the value suggest it. if false, a cast may be tried.
-
inline const std::string getValueAsString() const¶
return value of the parameter.
-
inline void setDescription(const std::string &description)¶
sets description of the parameter.
-
inline const std::string &getDescription(bool use_scheme = true) const¶
get the description of the parameter.
- Parameters
use_scheme – [in] if one schema is associated, use it as description
-
inline void setTags(const std::vector<std::string> &tags)¶
set tags.
- Parameters
tags – [in] the list of tags
-
inline const std::vector<std::string> &getTags(bool use_scheme = true) const¶
get tags.
- Parameters
use_scheme – [in] if set, and if a schema is assigned to this parameter, returns the tags of the schema
-
const std::string getRestrictionsAsString(bool use_scheme = true) const¶
get restrictions of the parameter, as a string representation.
- Parameters
use_scheme – [in] if set, and if a schema is assigned to this parameter, returns the restriction of the schema.
-
inline void setAsSchema(bool is_schema)¶
set parameter as schema.
-
inline bool isSchema() const¶
return wether the parameter is schema.
-
inline const std::string getDefaultValueAsString() const¶
return default value of the parameter (if schema is assigned).
-
const std::vector<CastValue> getValidStrings(bool use_scheme = true) const¶
return valid strings
- Parameters
use_scheme – [in] if set, and if a schema is assigned to this parameter, returns the valid strings of the schema.
-
bool isInList(const CastValue &value) const¶
for parameter of type list, return true if the element exists in the list
- Parameters
value – [in] the value tu check existence.
-
void addToList(const CastValue &value)¶
for parameter of type list, adds an element to the list
- Parameters
value – [in] to add to the list.
Protected Attributes
-
std::string name_¶
-
std::string description_¶
-
std::vector<std::string> tags_¶
-
bool is_schema_ = false¶
Friends
- friend class Utilities
-
inline Parameter(const std::string &name)¶