From b946ff6bceef6150f19da0a86950ed9ebbf0c2cb Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli (think)" Date: Thu, 16 Aug 2012 18:05:40 +0200 Subject: crc-dabmod: removed useless set_parameters from remote_control --- src/testremotecontrol/test.cpp | 41 ++++++++--------------------------------- 1 file changed, 8 insertions(+), 33 deletions(-) (limited to 'src/testremotecontrol') diff --git a/src/testremotecontrol/test.cpp b/src/testremotecontrol/test.cpp index 07b761f..40f0e25 100644 --- a/src/testremotecontrol/test.cpp +++ b/src/testremotecontrol/test.cpp @@ -1,6 +1,7 @@ #include #include #include + #include "RemoteControl.h" using namespace std; @@ -10,23 +11,22 @@ class TestControllable : public RemoteControllable public: TestControllable(string name) : RemoteControllable(name) { - ADD_PARAMETER(foo, "That's the foo"); - ADD_PARAMETER(bar, "That's the bar"); - ADD_PARAMETER(baz, "That's the baz"); + RC_ADD_PARAMETER(foo, "That's the foo"); + RC_ADD_PARAMETER(bar, "That's the bar"); + RC_ADD_PARAMETER(baz, "That's the baz"); } - string get_rc_name() { return name_; }; - void set_parameter(string parameter, string value) { + stringstream ss(value); + ss.exceptions ( stringstream::failbit | stringstream::badbit ); + if (parameter == "foo") { - stringstream ss(value); ss >> foo_; } else if (parameter == "bar") { bar_ = value; } else if (parameter == "baz") { - stringstream ss(value); ss >> baz_; } else { @@ -36,30 +36,9 @@ class TestControllable : public RemoteControllable } } - void set_parameter(string parameter, double value) { - if (parameter == "baz") { - baz_ = value; - } - else { - stringstream ss; - ss << "Parameter '" << parameter << "' is not a double in controllable " << get_rc_name(); - throw ParameterError(ss.str()); - } - } - - void set_parameter(string parameter, long value) { - if (parameter == "foo") { - foo_ = value; - } - else { - stringstream ss; - ss << "Parameter '" << parameter << "' is not a long in controllable " << get_rc_name(); - throw ParameterError(ss.str()); - } - } - string get_parameter(string parameter) { stringstream ss; + if (parameter == "foo") { ss << foo_; } @@ -77,10 +56,6 @@ class TestControllable : public RemoteControllable return ss.str(); } - std::list< std::vector > get_parameter_descriptions() { - return parameters_; - } - private: long foo_; std::string bar_; -- cgit v1.2.3