10 #ifndef DDSegmentation_SEGMENTATIONPARAMETER_H_
11 #define DDSegmentation_SEGMENTATIONPARAMETER_H_
19 namespace DDSegmentation {
23 inline std::vector<std::string>
splitString(
const std::string&
s,
char delimiter =
' ') {
24 std::vector<std::string> elements;
25 std::stringstream ss(s);
27 while (std::getline(ss, item, delimiter)) {
28 elements.push_back(item);
35 static const char*
name() {
36 return typeid(TYPE).
name();
42 static const char*
name() {
49 static const char*
name() {
56 static const char*
name() {
63 static const char*
name() {
69 template<>
struct TypeName<std::vector<int> > {
70 static const char*
name() {
76 template<>
struct TypeName<std::vector<float> > {
77 static const char*
name() {
83 template<>
struct TypeName<std::vector<double> > {
84 static const char*
name() {
90 template<>
struct TypeName<std::vector<std::string> > {
91 static const char*
name() {
107 const std::string&
name()
const {
119 virtual std::string
type()
const = 0;
121 virtual std::string
value()
const = 0;
142 bool isOpt =
false) :
160 bool isOpt =
false) :
239 s << TypeName<TYPE>::name() <<
"vec";
246 typename std::vector<TYPE>::const_iterator it =
_value.begin();
247 for (; it !=
_value.end(); ++it) {
256 std::vector<std::string> elements =
splitString(val);
258 for (std::vector<std::string>::const_iterator it = elements.begin(); it != elements.end(); ++it) {
259 if (not it->empty()) {
272 typename std::vector<TYPE>::const_iterator it =
_defaultValue.begin();
const std::string & description() const
Access to the parameter description.
std::vector< TYPE > _defaultValue
static const char * name()
const TYPE & typedValue() const
Access to the parameter value.
bool _isOptional
Store if parameter is optional.
std::string type() const
Access to the parameter type.
std::vector< std::string > splitString(const std::string &s, char delimiter= ' ')
Helper method to split string into tokens.
std::string value() const
Access to the parameter value in string representation.
Helper class to extract type names.
const std::string & name() const
Access to the parameter name.
static const char * name()
UnitType _unitType
The unit type.
UnitType
Defines the parameter unit type (useful to convert to default set of units)
UnitType unitType() const
Access to the unit type.
std::string _name
The parameter name.
static const char * name()
static const char * name()
std::string defaultValue() const
Access to the parameter default value in string representation.
void setValue(const std::string &val)
Set the parameter value in string representation.
TypedSegmentationParameter(const std::string &nam, const std::string &desc, std::vector< TYPE > &val, const std::vector< TYPE > &defaultVal, SegmentationParameter::UnitType unitTyp=SegmentationParameter::NoUnit, bool isOpt=false)
Default constructor.
bool isOptional() const
Check if this parameter is optional.
virtual ~SegmentationParameter()
Destructor.
SegmentationParameter(const std::string &nam, const std::string &desc, UnitType unitTyp=NoUnit, bool isOpt=false)
Default constructor used by derived classes.
static const char * name()
void setTypedValue(const std::vector< TYPE > &val)
Set the parameter value.
static const char * name()
virtual std::string value() const =0
Access to the parameter value in string representation.
std::string toString() const
Printable version.
virtual void setValue(const std::string &value)=0
Set the parameter value in string representation.
static const char * name()
virtual std::string type() const =0
Access to the parameter type.
void setValue(const std::string &val)
Set the parameter value in string representation.
void setTypedValue(const TYPE &val)
Set the parameter value.
std::string _description
The parameter description.
std::string defaultValue() const
Access to the parameter default value in string representation.
const std::vector< TYPE > & typedDefaultValue() const
Access to the parameter default value.
virtual std::string defaultValue() const =0
Access to the parameter default value in string representation.
static const char * name()
Class to hold a segmentation parameter with its description.
const TYPE & typedDefaultValue() const
Access to the parameter default value.
std::string value() const
Access to the parameter value in string representation.
static const char * name()
const std::vector< TYPE > & typedValue() const
Access to the parameter value.
std::vector< TYPE > & _value
TypedSegmentationParameter(const std::string &nam, const std::string &desc, TYPE &val, const TYPE &default_Value, SegmentationParameter::UnitType unitTyp=SegmentationParameter::NoUnit, bool isOpt=false)
Default constructor.
std::string type() const
Access to the parameter type.