From 97785c838e088f978c8dd2c4c796cdcbeafebffc Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 13 Feb 2010 09:22:12 -0800 Subject: Compiling under old fedora8 with boost 1.37. Fixed somethings that caused errors and warnings. Cannot get rid of all warnings on this system. --- lib/gain_handler.cpp | 31 ++++++++++++++++++------------- lib/usrp/mboard/test.cpp | 1 - 2 files changed, 18 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/gain_handler.cpp b/lib/gain_handler.cpp index 85cacd2a5..b03d5bda2 100644 --- a/lib/gain_handler.cpp +++ b/lib/gain_handler.cpp @@ -72,35 +72,40 @@ void gain_handler::_check_key(const wax::obj &key_){ catch(const std::assert_error &){} } +static gain_t gain_max(gain_t a, gain_t b){ + return std::max(a, b); +} +static gain_t gain_sum(gain_t a, gain_t b){ + return std::sum(a, b); +} + bool gain_handler::intercept_get(const wax::obj &key, wax::obj &val){ _check_key(key); //verify the key - // use a vector of tuples to map properties to a reducer function - // we cant use a map because the wax::obj cant be sorted - typedef boost::function reducer_t; - typedef boost::tuple tuple_t; - reducer_t reducer_sum = boost::bind(std::sum, _1, _2); - reducer_t reducer_max = boost::bind(std::max, _1, _2); - std::vector prop_to_reducer = boost::assign::tuple_list_of - (_gain_prop, reducer_sum)(_gain_min_prop, reducer_sum) - (_gain_max_prop, reducer_sum)(_gain_step_prop, reducer_max); + std::vector gain_props = boost::assign::list_of + (_gain_prop)(_gain_min_prop)(_gain_max_prop)(_gain_step_prop); /*! * Handle getting overall gains when a name is not specified. * For the gain props below, set the overall value and return true. */ - BOOST_FOREACH(tuple_t p2r, prop_to_reducer){ - if (_is_equal(key, p2r.get<0>())){ + BOOST_FOREACH(wax::obj prop_key, gain_props){ + if (_is_equal(key, prop_key)){ //form the gains vector from the props vector prop_names_t prop_names = GET_PROP_NAMES(); std::vector gains(prop_names.size()); std::transform( prop_names.begin(), prop_names.end(), gains.begin(), - boost::bind(get_named_gain, _wax_obj_ptr, p2r.get<0>(), _1) + boost::bind(get_named_gain, _wax_obj_ptr, key, _1) ); //reduce across the gain vector - val = std::reduce(gains.begin(), gains.end(), p2r.get<1>()); + if (_is_equal(key, _gain_step_prop)){ + val = std::reduce(gains.begin(), gains.end(), gain_max); + } + else{ + val = std::reduce(gains.begin(), gains.end(), gain_sum); + } return true; } } diff --git a/lib/usrp/mboard/test.cpp b/lib/usrp/mboard/test.cpp index c533c97b4..67d3c70fa 100644 --- a/lib/usrp/mboard/test.cpp +++ b/lib/usrp/mboard/test.cpp @@ -91,7 +91,6 @@ private: } case DBOARD_PROP_CODEC: - val = NULL; //TODO return; } } -- cgit v1.2.3