34 #ifndef _Parameter_HXX_
35 #define _Parameter_HXX_
46 _defaultValue(defaultValue),
47 _value(defaultValue) {
62 _defaultValue = defVal;
94 std::string paramName = _parent->getName() +
"." + _name;
95 if(pf.
isSet(paramName)) {
96 if(pf.
get<std::string>(paramName).substr(0,1) ==
"@")
97 throw std::runtime_error(paramName
98 +
" : Attempt to overwrite Reference.");
99 else if(_value == _defaultValue)
102 pf.
set<T>(paramName, _value);
104 else if (_value != _defaultValue)
105 pf.
set<T>(paramName, _value);
108 template <
typename T>
110 std::string paramName = _followLink(pf, _parent->getName() +
"." + _name);
111 if (pf.
isSet(paramName))
112 _value = pf.
get<T>(paramName);
114 _value = _defaultValue;
117 template <
typename T>
119 std::ostringstream strStr;
120 strStr << _defaultValue;
124 template <
typename T>
130 template <
typename T>
132 _defaultValue = defaultValue;
134 _value = pf.
getList<T>(
"", defaultValue);
137 template <
typename T>
141 template <
typename T>
147 template <
typename T>
154 template <
typename T>
159 template <
typename T>
164 template <
typename T>
169 template <
typename T>
174 template <
typename T>
176 std::stringstream stream;
177 std::string paramName = _parent->getName() +
"." + _name;
178 this->intoStream(stream);
180 if(pf.
isSet(paramName)) {
181 if(pf.
get<std::string>(paramName).substr(0,1) ==
"@")
182 throw std::runtime_error(paramName
183 +
" : Attempt to overwrite Reference.");
184 else if(stream.str() == _defaultValue)
187 pf.
set<T>(paramName, _value);
189 else if (stream.str() != _defaultValue)
190 pf.
set<T>(paramName, _value);
193 template <
typename T>
195 std::string paramName = _followLink(pf, _parent->getName() +
"." + _name);
196 if(pf.
isSet(paramName))
197 _value = pf.
getList<T>(paramName);
200 temp.
set(
"temp", _defaultValue);
201 _value = temp.
getList<T>(
"temp");
205 template <
typename T>
207 _defaultValue = defVal;
210 template <
typename T>
212 return _defaultValue;
215 template <
typename T>
218 for(
unsigned int i = 0; i < _value.size()-1; i++) {
219 os << _value[i] <<
";";
221 os << _value[_value.size()-1];
225 template <
typename T>
227 return _value.size();
230 template <
typename T>
235 template <
typename T>
240 #endif // _Parameter_HXX_
virtual const T & operator[](std::size_t pos) const
Access to specific member (read-only).
This class serves to store parameters used within the Charon Project.
void erase(std::string parameter)
Delete a parameter from the parameter list.
virtual void load(const ParameterFile &pf)
Load from ParameterFile.
std::vector< T > & operator()()
Call operator to get a reference to the parameter list content.
Declaration of class TypeDetector.
std::vector< T > getList(std::string parameter) const
If multiple values are set, return a list containing these values.
virtual std::string guessType() const
Try to guess type.
virtual std::string getDefaultString()
Get default value.
virtual std::size_t size() const
Access to number of members.
Declaration of the base class ParameteredObject.
ParameterList(std::string defaultValue="")
Create parameter list.
void setDefault(const std::string &value)
Set default value.
T _defaultValue
default value
Implementation of the AbstractParameter interface for one single parameter.
void setDefault(const T &value)
Set default value.
virtual T & operator=(const T &B)
Assignment operator for internal value.
Implementation of the AbstractParameter interface for a list of parameters.
void set(std::string parameter, const T &value=T())
Set a parameter to the given single value.
virtual void intoStream(std::ostream &os) const
Inserts the value of the Parameter at the end of a stream.
T get(std::string parameter) const
Get the value of a specified parameter.
bool isSet(std::string parameter) const
Check if a givem parameter has already been set.
virtual void save(ParameterFile &pf) const
Save to ParameterFile.
virtual std::string getDefaultString()
Get default value.
virtual void load(const ParameterFile &pf)
Load from ParameterFile.
std::vector< T > _value
Internal value (list).
Parameter(T defaultValue=T())
Create parameter.
virtual std::vector< T > & operator=(const std::vector< T > &B)
Assign parameter content.
virtual void intoStream(std::ostream &os) const
Inserts the value of the ParameterList at the end of a stream.
charon_core_DLL_PUBLIC std::string type(const std::string &typeInfo)
Get type representation.
virtual std::string guessType() const
Try to guess type.
std::string _defaultValue
Default value, string representation, separated by ";".
virtual void save(ParameterFile &pf) const
Save to ParameterFile.
virtual const T & operator()() const
Call operator.