diff options
author | michael-west <michael.west@ettus.com> | 2014-02-21 18:08:56 -0800 |
---|---|---|
committer | michael-west <michael.west@ettus.com> | 2014-02-21 18:08:56 -0800 |
commit | 2a185eee04a4b7f7414392bd3cc10ad7db621014 (patch) | |
tree | 0941f3ea83be221eaa95cb842ce0c253c2480d37 /host | |
parent | a8caec5f93976c081d488118f53a72dca49efdf6 (diff) | |
download | uhd-2a185eee04a4b7f7414392bd3cc10ad7db621014.tar.gz uhd-2a185eee04a4b7f7414392bd3cc10ad7db621014.tar.bz2 uhd-2a185eee04a4b7f7414392bd3cc10ad7db621014.zip |
Addressed comments from code review.
- Created macro for gain name error.
- Fixed typos.
Diffstat (limited to 'host')
-rw-r--r-- | host/lib/usrp/multi_usrp.cpp | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 182e774fc..d8322a39f 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -35,14 +35,20 @@ using namespace uhd::usrp; const std::string multi_usrp::ALL_GAINS = ""; -UHD_INLINE std::string string_vector_to_string(std::vector<std::string> values, std::string delimeter = std::string(" ")) +UHD_INLINE std::string string_vector_to_string(std::vector<std::string> values, std::string delimiter = std::string(" ")) { std::string out = ""; for (std::vector<std::string>::iterator iter = values.begin(); iter != values.end(); iter++) - out += delimeter + *iter; + { + out += (iter != values.begin() ? delimiter : "") + *iter; + } return out; } +#define THROW_GAIN_NAME_ERROR(name,chan,dir) throw uhd::exception::runtime_error( \ + (boost::format("%s: gain \"%s\" not found for channel %d.\nAvailable gains: %s\n") % \ + __FUNCTION__ % name % chan % string_vector_to_string(get_##dir##_gain_names(chan))).str()); + /*********************************************************************** * Helper methods **********************************************************************/ @@ -671,10 +677,7 @@ public: try { return rx_gain_group(chan)->set_value(gain, name); } catch (uhd::key_error &e) { - std::stringstream err; - err << __FUNCTION__ << "(\"" << name << "\"): gain not found.\n" << - "Available gains: " << string_vector_to_string(get_rx_gain_names(chan)) << std::endl; - throw uhd::exception::runtime_error(err.str()); + THROW_GAIN_NAME_ERROR(name,chan,rx); } } @@ -682,10 +685,7 @@ public: try { return rx_gain_group(chan)->get_value(name); } catch (uhd::key_error &e) { - std::stringstream err; - err << __FUNCTION__ << "(\"" << name << "\"): gain not found.\n" << - "Available gains: " << string_vector_to_string(get_rx_gain_names(chan)) << std::endl; - throw uhd::exception::runtime_error(err.str()); + THROW_GAIN_NAME_ERROR(name,chan,rx); } } @@ -693,10 +693,7 @@ public: try { return rx_gain_group(chan)->get_range(name); } catch (uhd::key_error &e) { - std::stringstream err; - err << __FUNCTION__ << "(\"" << name << "\"): gain not found.\n" << - "Available gains: " << string_vector_to_string(get_rx_gain_names(chan)) << std::endl; - throw uhd::exception::runtime_error(err.str()); + THROW_GAIN_NAME_ERROR(name,chan,rx); } } @@ -861,10 +858,7 @@ public: try { return tx_gain_group(chan)->set_value(gain, name); } catch (uhd::key_error &e) { - std::stringstream err; - err << __FUNCTION__ << "(\"" << name << "\"): gain not found.\n" << - "Available gains: " << string_vector_to_string(get_rx_gain_names(chan)) << std::endl; - throw uhd::exception::runtime_error(err.str()); + THROW_GAIN_NAME_ERROR(name,chan,tx); } } @@ -872,10 +866,7 @@ public: try { return tx_gain_group(chan)->get_value(name); } catch (uhd::key_error &e) { - std::stringstream err; - err << __FUNCTION__ << "(\"" << name << "\"): gain not found.\n" << - "Available gains: " << string_vector_to_string(get_rx_gain_names(chan)) << std::endl; - throw uhd::exception::runtime_error(err.str()); + THROW_GAIN_NAME_ERROR(name,chan,tx); } } @@ -883,10 +874,7 @@ public: try { return tx_gain_group(chan)->get_range(name); } catch (uhd::key_error &e) { - std::stringstream err; - err << __FUNCTION__ << "(\"" << name << "\"): gain not found.\n" << - "Available gains: " << string_vector_to_string(get_rx_gain_names(chan)) << std::endl; - throw uhd::exception::runtime_error(err.str()); + THROW_GAIN_NAME_ERROR(name,chan,tx); } } |