10 #ifndef ParameterT_hpp 11 #define ParameterT_hpp 16 namespace FunctionTree {
19 std::ostream &operator<<(std::ostream &stream, const std::vector<T> &values) {
20 auto n = values.size();
23 auto first = values.begin();
24 auto last = values.begin();
25 std::advance(last, n);
26 std::copy(first, last, std::ostream_iterator<T>(stream,
", "));
27 if (values.size() > n)
57 operator T()
const {
return Val; };
70 std::stringstream stream;
84 std::string
name =
"") {
85 std::shared_ptr<Parameter> p;
88 p = std::make_shared<Value<std::vector<std::complex<double>>>>(
name);
92 p = std::make_shared<Value<std::vector<double>>>(
name);
96 p = std::make_shared<Value<std::vector<int>>>(
name);
100 p = std::make_shared<Value<std::complex<double>>>(
name);
104 p = std::make_shared<Value<double>>(
name);
108 p = std::make_shared<Value<int>>(
name);
112 throw BadParameter(
"ValueFactory() | Parameter type " + std::to_string(t) +
119 inline std::shared_ptr<Value<std::vector<std::complex<double>>>>
121 std::complex<double> el = std::complex<double>(0., 0.)) {
123 return std::make_shared<Value<std::vector<std::complex<double>>>>(
124 name, std::vector<std::complex<double>>(s, el));
127 inline std::shared_ptr<Value<std::vector<std::complex<double>>>>
128 MComplex(std::string name, std::vector<std::complex<double>> v) {
130 return std::make_shared<Value<std::vector<std::complex<double>>>>(
name, v);
133 inline std::shared_ptr<Value<std::vector<double>>>
134 MDouble(std::string name,
size_t s,
double el = 0.) {
136 return std::make_shared<Value<std::vector<double>>>(
137 name, std::vector<double>(s, el));
140 inline std::shared_ptr<Value<std::vector<double>>>
141 MDouble(std::string name, std::vector<double> v) {
143 return std::make_shared<Value<std::vector<double>>>(
name, v);
146 inline std::shared_ptr<Value<std::vector<int>>>
147 MInteger(std::string name,
size_t s,
int el = 0.) {
149 return std::make_shared<Value<std::vector<int>>>(
name,
150 std::vector<int>(s, el));
153 inline std::shared_ptr<Value<std::vector<int>>>
MInteger(std::string name,
154 std::vector<int> v) {
156 return std::make_shared<Value<std::vector<int>>>(
name, v);
Implementations of Parameter for various data types.
Base class for internal parameter.
Value(std::string name="")
virtual std::string name() const
Getter for name of object.
virtual std::string val_to_str() const
A public function returning a string with parameter value.
std::shared_ptr< Value< std::vector< double > > > MDouble(std::string name, size_t s, double el=0.)
virtual void setValue(T inVal)
std::string Name
Name of parameter.
virtual std::string className() const
Getter for typename of object, to be defined by the actual implementation.
Value(std::string name, T val)
static const char *const ParNames[7]
Names of the parameter types, should be extended if an new parameter type is added.
const T & operator()() const
std::shared_ptr< Parameter > ValueFactory(ParType t, std::string name="")
std::shared_ptr< Value< std::vector< int > > > MInteger(std::string name, size_t s, int el=0.)
std::shared_ptr< Value< std::vector< std::complex< double > > > > MComplex(std::string name, size_t s, std::complex< double > el=std::complex< double >(0., 0.))
virtual std::string to_str() const
A public function returning a string with parameter information.
ParType Type
Type of parameter (e.g. Double, Integer, ...)
void notify()
Notify all observing TreeNodes that parameter changed.
ParType
Enums for the type of the parameter, should be extended if an new parameter type is added...
virtual T & values()
Reference on the value.