10 #ifndef _Parameter_HPP_ 11 #define _Parameter_HPP_ 23 #include <boost/serialization/level.hpp> 24 #include <boost/serialization/nvp.hpp> 25 #include <boost/serialization/serialization.hpp> 26 #include <boost/serialization/shared_ptr.hpp> 27 #include <boost/serialization/tracking.hpp> 30 namespace FunctionTree {
46 static const char *
const ParNames[7] = {
"UNDEFINED",
"COMPLEX",
"DOUBLE",
47 "INTEGER",
"MCOMPLEX",
"MDOUBLE",
55 template <>
inline ParType typeName<std::vector<std::complex<double>>>(void) {
58 template <>
inline ParType typeName<std::vector<double>>(void) {
61 template <>
inline ParType typeName<std::vector<int>>(void) {
64 template <>
inline ParType typeName<std::complex<double>>(void) {
88 virtual std::string
name()
const {
return Name; }
97 virtual std::string
className()
const = 0;
104 void attach(std::weak_ptr<ParObserver> newObserver) {
112 [](
auto x) {
return x.expired(); }),
124 std::shared_ptr<Parameter> b) {
125 return out << b->to_str();
133 virtual std::string
to_str()
const = 0;
154 friend class boost::serialization::access;
155 template <
class archive>
156 void serialize(archive &ar,
const unsigned int version) {
157 ar &BOOST_SERIALIZATION_NVP(Name);
158 ar &BOOST_SERIALIZATION_NVP(Type);
164 BOOST_SERIALIZATION_SHARED_PTR(
Parameter);
166 BOOST_CLASS_IMPLEMENTATION(
168 boost::serialization::level_type::object_serializable)
void serialize(archive &ar, const unsigned int version)
void attach(std::weak_ptr< ParObserver > newObserver)
Attaches a new TreeNode as Observer.
virtual std::string val_to_str() const =0
A public function returning a string with parameter value.
Base class for internal parameter.
virtual bool isParameter() const
Parameter(std::string name, ParType type=ParType::UNDEFINED)
Constructor with name of parameter and optional type.
virtual std::string name() const
Getter for name of object.
void detachExpired()
Removes TreeNodes not needed as Observer anymore.
ParType typeName(void)
Template functions which return above specified parameter types.
virtual ~Parameter()=default
std::string Name
Name of parameter.
friend std::ostream & operator<<(std::ostream &out, Parameter &b)
static const char *const ParNames[7]
Names of the parameter types, should be extended if an new parameter type is added.
ParType typeName< int >(void)
virtual ParType type() const
Getter for type of object.
ParType Type
Type of parameter (e.g. Double, Integer, ...)
friend std::ostream & operator<<(std::ostream &out, std::shared_ptr< Parameter > b)
void notify()
Notify all observing TreeNodes that parameter changed.
ParType typeName< double >(void)
ParType
Enums for the type of the parameter, should be extended if an new parameter type is added...
std::vector< std::weak_ptr< ParObserver > > ObservingNodes
List of observers, e.g. TreeNodes.
virtual std::string to_str() const =0
A public function returning a string with parameter information.
virtual std::string className() const =0
Getter for typename of object, to be defined by the actual implementation.
virtual void setName(std::string n)
Getter for name of object.