diff options
author | Josh Blum <josh@joshknows.com> | 2010-10-21 15:29:03 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-10-21 15:29:03 -0700 |
commit | 1e57eec9999e1a9d0a735c04173c78164ce8afcd (patch) | |
tree | e34b3e52fe4c7a34a6588e15efbb8416b29d81b5 /host/lib/utils | |
parent | 5bf9e60baf7b85db3da0d41b97d9fe4e9b3e64bd (diff) | |
parent | e2f76bddae7845024056b479658651c6da2b0f4d (diff) | |
download | uhd-1e57eec9999e1a9d0a735c04173c78164ce8afcd.tar.gz uhd-1e57eec9999e1a9d0a735c04173c78164ce8afcd.tar.bz2 uhd-1e57eec9999e1a9d0a735c04173c78164ce8afcd.zip |
Merge branch 'master' into flow_ctrl
Diffstat (limited to 'host/lib/utils')
-rw-r--r-- | host/lib/utils/gain_group.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/host/lib/utils/gain_group.cpp b/host/lib/utils/gain_group.cpp index 078fe56b2..54146726a 100644 --- a/host/lib/utils/gain_group.cpp +++ b/host/lib/utils/gain_group.cpp @@ -63,7 +63,9 @@ public: /*NOP*/ } - gain_range_t get_range(void){ + gain_range_t get_range(const std::string &name){ + if (not name.empty()) return _name_to_fcns[name].get_range(); + float overall_min = 0, overall_max = 0, overall_step = 0; BOOST_FOREACH(const gain_fcns_t &fcns, get_all_fcns()){ const gain_range_t range = fcns.get_range(); @@ -76,7 +78,9 @@ public: return gain_range_t(overall_min, overall_max, overall_step); } - float get_value(void){ + float get_value(const std::string &name){ + if (not name.empty()) return _name_to_fcns[name].get_value(); + float overall_gain = 0; BOOST_FOREACH(const gain_fcns_t &fcns, get_all_fcns()){ overall_gain += fcns.get_value(); @@ -84,7 +88,9 @@ public: return overall_gain; } - void set_value(float gain){ + void set_value(float gain, const std::string &name){ + if (not name.empty()) return _name_to_fcns[name].set_value(gain); + std::vector<gain_fcns_t> all_fcns = get_all_fcns(); if (all_fcns.size() == 0) return; //nothing to set! @@ -140,10 +146,21 @@ public: } } + const std::vector<std::string> get_names(void){ + return _name_to_fcns.keys(); + } + void register_fcns( - const gain_fcns_t &gain_fcns, size_t priority + const std::string &name, + const gain_fcns_t &gain_fcns, + size_t priority ){ + if (name.empty() or _name_to_fcns.has_key(name)){ + //ensure the name name is unique and non-empty + return register_fcns(name + "_", gain_fcns, priority); + } _registry[priority].push_back(gain_fcns); + _name_to_fcns[name] = gain_fcns; } private: @@ -158,6 +175,7 @@ private: } uhd::dict<size_t, std::vector<gain_fcns_t> > _registry; + uhd::dict<std::string, gain_fcns_t> _name_to_fcns; }; /*********************************************************************** |