diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-08-01 17:41:55 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-08-01 17:41:55 +0200 |
commit | 07f5c0fbfb43b099fa09b273a1074093c7579903 (patch) | |
tree | 48a2b759b46aaa483ab238d679cc172a97bdff82 /src/RemoteControl.h | |
parent | dd22ff8c7ab0ec2fae413431b7d546d2bf9367ea (diff) | |
download | dabmod-07f5c0fbfb43b099fa09b273a1074093c7579903.tar.gz dabmod-07f5c0fbfb43b099fa09b273a1074093c7579903.tar.bz2 dabmod-07f5c0fbfb43b099fa09b273a1074093c7579903.zip |
Replace some loops with iterators to foreach loops
Diffstat (limited to 'src/RemoteControl.h')
-rw-r--r-- | src/RemoteControl.h | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/src/RemoteControl.h b/src/RemoteControl.h index b94ed6c..8c3362c 100644 --- a/src/RemoteControl.h +++ b/src/RemoteControl.h @@ -102,20 +102,18 @@ class RemoteControllers { } void add_controllable(RemoteControllable *rc) { - for (std::list<BaseRemoteController*>::iterator it = m_controllers.begin(); - it != m_controllers.end(); ++it) { - (*it)->enrol(rc); + for (auto &controller : m_controllers) { + controller->enrol(rc); } } void check_faults() { - for (std::list<BaseRemoteController*>::iterator it = m_controllers.begin(); - it != m_controllers.end(); ++it) { - if ((*it)->fault_detected()) + for (auto &controller : m_controllers) { + if (controller->fault_detected()) { etiLog.level(warn) << "Detected Remote Control fault, restarting it"; - (*it)->restart(); + controller->restart(); } } } @@ -147,9 +145,8 @@ class RemoteControllable { /* Return a list of possible parameters that can be set */ virtual std::list<std::string> get_supported_parameters() const { std::list<std::string> parameterlist; - for (std::list< std::vector<std::string> >::const_iterator it = m_parameters.begin(); - it != m_parameters.end(); ++it) { - parameterlist.push_back((*it)[0]); + for (const auto& param : m_parameters) { + parameterlist.push_back(param[0]); } return parameterlist; } @@ -255,12 +252,10 @@ class RemoteControllerTelnet : public BaseRemoteController { RemoteControllable* controllable = get_controllable_(name); std::list< std::vector<std::string> > allparams; - std::list<std::string> params = controllable->get_supported_parameters(); - for (std::list<std::string>::iterator it = params.begin(); - it != params.end(); ++it) { + for (auto ¶m : controllable->get_supported_parameters()) { std::vector<std::string> item; - item.push_back(*it); - item.push_back(controllable->get_parameter(*it)); + item.push_back(param); + item.push_back(controllable->get_parameter(param)); allparams.push_back(item); } @@ -363,15 +358,15 @@ class RemoteControllerZmq : public BaseRemoteController { RemoteControllable* controllable = get_controllable_(name); std::list< std::vector<std::string> > allparams; - std::list<std::string> params = controllable->get_supported_parameters(); - for (std::list<std::string>::iterator it = params.begin(); - it != params.end(); ++it) { + + for (auto ¶m : controllable->get_supported_parameters()) { std::vector<std::string> item; - item.push_back(*it); - item.push_back(controllable->get_parameter(*it)); + item.push_back(param); + item.push_back(controllable->get_parameter(param)); allparams.push_back(item); } + return allparams; } |