summaryrefslogtreecommitdiffstats
path: root/src/RemoteControl.h
diff options
context:
space:
mode:
authorMatthias P. Braendli (think) <matthias@mpb.li>2012-08-16 17:11:17 +0200
committerMatthias P. Braendli (think) <matthias@mpb.li>2012-08-16 17:11:17 +0200
commitf419f8cb2e3768789cb23593cfa7c850acc0fe72 (patch)
tree57b37507d5175aae6b7a104af16dabf2a5fcbcb6 /src/RemoteControl.h
parent2a4ec6dd6a48668589c7db2206c97e8781b644b3 (diff)
downloaddabmod-f419f8cb2e3768789cb23593cfa7c850acc0fe72.tar.gz
dabmod-f419f8cb2e3768789cb23593cfa7c850acc0fe72.tar.bz2
dabmod-f419f8cb2e3768789cb23593cfa7c850acc0fe72.zip
crc-dabmod: RemoteControl cleanup
Diffstat (limited to 'src/RemoteControl.h')
-rw-r--r--src/RemoteControl.h69
1 files changed, 34 insertions, 35 deletions
diff --git a/src/RemoteControl.h b/src/RemoteControl.h
index 8b0a30f..ab3f6fb 100644
--- a/src/RemoteControl.h
+++ b/src/RemoteControl.h
@@ -26,6 +26,7 @@
#define _REMOTECONTROL_H
#include <list>
+#include <map>
#include <string>
#include <iostream>
#include <string>
@@ -78,6 +79,9 @@ class RemoteControllable {
/* Return a list of possible parameters that can be set */
virtual list<string> get_supported_parameters() = 0;
+ /* Return a mapping of the descriptions of all parameters */
+ virtual std::list< std::vector<std::string> > get_parameter_descriptions() = 0;
+
/* Base function to set parameters. */
virtual void set_parameter(string parameter, string value) = 0;
@@ -133,54 +137,49 @@ class RemoteControllerTelnet : public BaseRemoteController {
return all_tokens;
}
- list<string> get_param_list_(string controllable) {
+ RemoteControllable* get_controllable_(string name) {
for (list<RemoteControllable*>::iterator it = cohort_.begin(); it != cohort_.end(); it++) {
- if ((*it)->get_rc_name() == controllable)
+ if ((*it)->get_rc_name() == name)
{
- return (*it)->get_supported_parameters();
+ return *it;
}
}
throw ParameterError("Module name unknown");
}
- list< vector<string> > get_param_list_values_(string controllable) {
+ list< vector<string> > get_parameter_descriptions_(string name) {
+ RemoteControllable* controllable = get_controllable_(name);
+ return controllable->get_parameter_descriptions();
+ }
+
+ list<string> get_param_list_(string name) {
+ RemoteControllable* controllable = get_controllable_(name);
+ return controllable->get_supported_parameters();
+ }
+
+ list< vector<string> > get_param_list_values_(string name) {
+ RemoteControllable* controllable = get_controllable_(name);
+
list< vector<string> > allparams;
- for (list<RemoteControllable*>::iterator it = cohort_.begin(); it != cohort_.end(); it++) {
- if ((*it)->get_rc_name() == controllable)
- {
- list<string> params = (*it)->get_supported_parameters();
- for (list<string>::iterator it2 = params.begin(); it2 != params.end(); it2++) {
- vector<string> item;
- item.push_back(*it2);
- item.push_back((*it)->get_parameter(*it2));
-
- allparams.push_back(item);
- }
- return allparams;
- }
+ list<string> params = controllable->get_supported_parameters();
+ for (list<string>::iterator it = params.begin(); it != params.end(); it++) {
+ vector<string> item;
+ item.push_back(*it);
+ item.push_back(controllable->get_parameter(*it));
+
+ allparams.push_back(item);
}
- throw ParameterError("Module name unknown");
+ return allparams;
}
- string get_param_(string controllable, string param) {
- for (list<RemoteControllable*>::iterator it = cohort_.begin(); it != cohort_.end(); it++) {
- if ((*it)->get_rc_name() == controllable)
- {
- return (*it)->get_parameter(param);
- }
- }
- throw ParameterError("Module name unknown");
+ string get_param_(string name, string param) {
+ RemoteControllable* controllable = get_controllable_(name);
+ return controllable->get_parameter(param);
}
- void set_param_(string controllable, string param, string value) {
- for (list<RemoteControllable*>::iterator it = cohort_.begin(); it != cohort_.end(); it++) {
- if ((*it)->get_rc_name() == controllable)
- {
- (*it)->set_parameter(param, value);
- return;
- }
- }
- throw ParameterError("Module name unknown");
+ void set_param_(string name, string param, string value) {
+ RemoteControllable* controllable = get_controllable_(name);
+ return controllable->set_parameter(param, value);
}
bool running_;