summaryrefslogtreecommitdiffstats
path: root/src/RemoteControl.h
diff options
context:
space:
mode:
authorMatthias P. Braendli (think) <matthias@mpb.li>2012-08-16 17:45:04 +0200
committerMatthias P. Braendli (think) <matthias@mpb.li>2012-08-16 17:45:04 +0200
commit521ee81560be5d065bd090002a2c6b92a322a034 (patch)
treed4e575707616c423e602ede9118aef88a5b31f83 /src/RemoteControl.h
parentf419f8cb2e3768789cb23593cfa7c850acc0fe72 (diff)
downloaddabmod-521ee81560be5d065bd090002a2c6b92a322a034.tar.gz
dabmod-521ee81560be5d065bd090002a2c6b92a322a034.tar.bz2
dabmod-521ee81560be5d065bd090002a2c6b92a322a034.zip
crc-dabmod: RemoteControl simplifications
Diffstat (limited to 'src/RemoteControl.h')
-rw-r--r--src/RemoteControl.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/RemoteControl.h b/src/RemoteControl.h
index ab3f6fb..2830210 100644
--- a/src/RemoteControl.h
+++ b/src/RemoteControl.h
@@ -39,6 +39,15 @@
#include <boost/thread.hpp>
#include <stdexcept>
+
+#define ADD_PARAMETER(p, desc) { \
+ vector<string> p; \
+ p.push_back(#p); \
+ p.push_back(desc); \
+ parameters_.push_back(p); \
+}
+
+
using namespace std;
using boost::asio::ip::tcp;
@@ -65,6 +74,9 @@ class BaseRemoteController {
/* Objects that support remote control must implement the following class */
class RemoteControllable {
public:
+
+ RemoteControllable(string name) : name_(name) {}
+
/* return a short name used to identify the controllable.
* It might be used in the commands the user has to type, so keep
* it short
@@ -77,7 +89,14 @@ class RemoteControllable {
}
/* Return a list of possible parameters that can be set */
- virtual list<string> get_supported_parameters() = 0;
+ virtual list<string> get_supported_parameters() {
+ cerr << "get_sup_par" << parameters_.size() << endl;
+ list<string> parameterlist;
+ for (list< vector<string> >::iterator it = parameters_.begin(); it != parameters_.end(); it++) {
+ parameterlist.push_back((*it)[0]);
+ }
+ return parameterlist;
+ }
/* Return a mapping of the descriptions of all parameters */
virtual std::list< std::vector<std::string> > get_parameter_descriptions() = 0;
@@ -91,6 +110,10 @@ class RemoteControllable {
/* Getting a parameter always returns a string. */
virtual string get_parameter(string parameter) = 0;
+
+ protected:
+ std::string name_;
+ std::list< std::vector<std::string> > parameters_;
};
/* Implements a Remote controller based on a simple telnet CLI
@@ -162,6 +185,7 @@ class RemoteControllerTelnet : public BaseRemoteController {
list< vector<string> > allparams;
list<string> params = controllable->get_supported_parameters();
+ cerr << "# of supported parameters " << params.size() << endl;
for (list<string>::iterator it = params.begin(); it != params.end(); it++) {
vector<string> item;
item.push_back(*it);