From 521ee81560be5d065bd090002a2c6b92a322a034 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli (think)" Date: Thu, 16 Aug 2012 17:45:04 +0200 Subject: crc-dabmod: RemoteControl simplifications --- src/RemoteControl.h | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/RemoteControl.h') 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 #include + +#define ADD_PARAMETER(p, desc) { \ + vector 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 get_supported_parameters() = 0; + virtual list get_supported_parameters() { + cerr << "get_sup_par" << parameters_.size() << endl; + list parameterlist; + for (list< vector >::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 > 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 > parameters_; }; /* Implements a Remote controller based on a simple telnet CLI @@ -162,6 +185,7 @@ class RemoteControllerTelnet : public BaseRemoteController { list< vector > allparams; list params = controllable->get_supported_parameters(); + cerr << "# of supported parameters " << params.size() << endl; for (list::iterator it = params.begin(); it != params.end(); it++) { vector item; item.push_back(*it); -- cgit v1.2.3