View on GitHub

Vistle

Distributed Data-parallel Scientific Visualization in VR

parametermanager.h
Go to the documentation of this file.
1#ifndef VISTLE_PARAMETER_MANAGER_H
2#define VISTLE_PARAMETER_MANAGER_H
3
4#include "export.h"
5
8
9#include <string>
10#include <memory>
11#include <vector>
12#include <map>
13
14namespace vistle {
15
17public:
18 ParameterManager(const std::string &name, int id);
19 virtual ~ParameterManager();
20
22 void setCurrentParameterGroup(const std::string &group = std::string());
23 const std::string &currentParameterGroup() const;
24
25 virtual Parameter *addParameterGeneric(const std::string &name, std::shared_ptr<Parameter> parameter);
26 bool updateParameter(const std::string &name, const Parameter *parameter, const message::SetParameter *inResponseTo,
27 Parameter::RangeType rt = Parameter::Value);
28
29 template<class T>
30 Parameter *addParameter(const std::string &name, const std::string &description, const T &value,
32 template<class T>
33 bool setParameter(const std::string &name, const T &value, const message::SetParameter *inResponseTo = nullptr);
34 template<class T>
35 bool setParameter(ParameterBase<T> *param, const T &value, const message::SetParameter *inResponseTo = nullptr);
36 template<class T>
37 bool setParameterMinimum(ParameterBase<T> *param, const T &minimum);
38 template<class T>
39 bool setParameterMaximum(ParameterBase<T> *param, const T &maximum);
40 template<class T>
41 bool setParameterRange(const std::string &name, const T &minimum, const T &maximum);
42 template<class T>
43 bool setParameterRange(ParameterBase<T> *param, const T &minimum, const T &maximum);
44 template<class T>
45 bool getParameter(const std::string &name, T &value) const;
46 void setParameterChoices(const std::string &name, const std::vector<std::string> &choices);
47 void setParameterChoices(Parameter *param, const std::vector<std::string> &choices);
48 void setParameterFilters(const std::string &name, const std::string &filters);
49 void setParameterFilters(StringParameter *param, const std::string &filters);
50
51 StringParameter *addStringParameter(const std::string &name, const std::string &description,
52 const std::string &value, Parameter::Presentation p = Parameter::Generic);
53 bool setStringParameter(const std::string &name, const std::string &value,
54 const message::SetParameter *inResponseTo = NULL);
55 std::string getStringParameter(const std::string &name) const;
56
57 FloatParameter *addFloatParameter(const std::string &name, const std::string &description, const Float value);
58 bool setFloatParameter(const std::string &name, const Float value,
59 const message::SetParameter *inResponseTo = NULL);
60 Float getFloatParameter(const std::string &name) const;
61
62 IntParameter *addIntParameter(const std::string &name, const std::string &description, const Integer value,
64 bool setIntParameter(const std::string &name, const Integer value,
65 const message::SetParameter *inResponseTo = NULL);
66 Integer getIntParameter(const std::string &name) const;
67
68 VectorParameter *addVectorParameter(const std::string &name, const std::string &description,
69 const ParamVector &value);
70 bool setVectorParameter(const std::string &name, const ParamVector &value,
71 const message::SetParameter *inResponseTo = NULL);
72 ParamVector getVectorParameter(const std::string &name) const;
73
74 IntVectorParameter *addIntVectorParameter(const std::string &name, const std::string &description,
75 const IntParamVector &value);
76 bool setIntVectorParameter(const std::string &name, const IntParamVector &value,
77 const message::SetParameter *inResponseTo = NULL);
78 IntParamVector getIntVectorParameter(const std::string &name) const;
79
80 bool removeParameter(const std::string &name);
81 virtual bool removeParameter(Parameter *param);
82
83 std::shared_ptr<Parameter> findParameter(const std::string &name) const;
84
85 void init();
86 void quit();
87 bool handleMessage(const message::SetParameter &message);
88 virtual void sendParameterMessage(const message::Message &message, const buffer *payload = nullptr) const = 0;
89 template<class Payload>
90 void sendParameterMessageWithPayload(message::Message &message, Payload &payload);
91 virtual bool changeParameters(std::set<const Parameter *> params); //< notify that some parameters have been changed
92 virtual bool changeParameter(const Parameter *p); //< notify that a parameter has been changed
93 void setId(int id);
94 int id() const;
95 void setName(const std::string &name);
96
97 void applyDelayedChanges();
98
99private:
100 bool parameterChangedWrapper(const Parameter *p); //< wrapper to prevent recursive calls to parameterChanged
101
102 int m_id = message::Id::Invalid;
103 std::string m_name = std::string("ParameterManager");
104 std::string m_currentParameterGroup;
105 std::map<std::string, std::shared_ptr<Parameter>> parameters;
106 bool m_inParameterChanged = false;
107 std::vector<const Parameter *> m_delayedChanges;
108};
109
110} // namespace vistle
111
113#endif
Definition: parameter.h:100
Definition: parametermanager.h:16
virtual void sendParameterMessage(const message::Message &message, const buffer *payload=nullptr) const =0
bool removeParameter(const std::string &name)
Definition: paramvector.h:18
Definition: parameter.h:26
Generic(Filename)(ExistingFilename)(Directory)(ExistingDirectory)(NewPathname)(Boolean)(Choice)(Slider)(Color)(InvalidPresentation)) DEFINE_ENUM_WITH_STRING_CONVERSIONS(RangeType
Minimum() Value(Maximum)) Parameter(int moduleId
Minimum() const std::string Presentation
Definition: parameter.h:52
Definition: message.h:157
request parameter value update or notify that a parameter value has been changed
Definition: messages.h:501
#define V_COREEXPORT
Definition: export.h:9
Definition: allobjects.cpp:30
std::vector< char, allocator< char > > buffer
Definition: buffer.h:9
double Float
Definition: scalar.h:18
int64_t Integer
Definition: scalar.h:19