23 #ifndef RPCSERVER_ICE_H
24 #define RPCSERVER_ICE_H
32 #include <Ice/Exception.h>
33 #include <boost/format.hpp>
47 virtual void set(
const GNURadio::KnobMap&,
const Ice::Current&);
49 GNURadio::KnobMap
get(
const GNURadio::KnobIDList&,
const Ice::Current&);
51 GNURadio::KnobMap
getRe(
const GNURadio::KnobIDList&,
const Ice::Current&);
53 GNURadio::KnobPropMap
properties(
const GNURadio::KnobIDList&,
const Ice::Current&);
55 virtual void shutdown(
const Ice::Current&);
58 typedef std::map<std::string, configureCallback_t> ConfigureCallbackMap_t;
59 ConfigureCallbackMap_t d_setcallbackmap;
61 typedef std::map<std::string, queryCallback_t> QueryCallbackMap_t;
62 QueryCallbackMap_t d_getcallbackmap;
64 template<
typename T,
typename TMap>
struct set_f
65 :
public std::unary_function<T,void>
67 set_f(
const Ice::Current& _c, TMap& _setcallbackmap,
const priv_lvl_t& _cur_priv) :
68 c(_c), d_setcallbackmap(_setcallbackmap),
cur_priv(_cur_priv)
71 void operator()(
const T& p)
73 ConfigureCallbackMap_t::const_iterator iter(d_setcallbackmap.find(p.first));
74 if(iter != d_setcallbackmap.end()) {
75 if(cur_priv <= iter->second.priv) {
79 std::cout <<
"Key " << p.first <<
" requires PRIVLVL <= "
80 << iter->second.priv <<
" to set, currently at: "
85 throw IceUtil::NullHandleException(__FILE__, __LINE__);
89 const Ice::Current& c;
90 TMap& d_setcallbackmap;
94 template<
typename T,
typename TMap>
95 struct get_f :
public std::unary_function<T,void>
97 get_f(
const Ice::Current& _c, TMap& _getcallbackmap,
98 const priv_lvl_t& _cur_priv, GNURadio::KnobMap& _outknobs) :
99 c(_c), d_getcallbackmap(_getcallbackmap),
cur_priv(_cur_priv), outknobs(_outknobs)
102 void operator()(
const T& p)
104 QueryCallbackMap_t::const_iterator iter(d_getcallbackmap.find(p));
105 if(iter != d_getcallbackmap.end()) {
106 if(cur_priv <= iter->second.priv) {
110 std::cout <<
"Key " << iter->first <<
" requires PRIVLVL: <= "
111 << iter->second.priv <<
" to get, currently at: "
116 std::stringstream ss;
117 ss <<
"Ctrlport Key called with unregistered key (" << p <<
")\n";
118 std::cout << ss.str();
119 throw IceUtil::IllegalArgumentException(__FILE__,__LINE__,ss.str().c_str());
123 const Ice::Current& c;
124 TMap& d_getcallbackmap;
126 GNURadio::KnobMap& outknobs;
129 template<
typename T,
typename TMap,
typename TKnobMap>
130 struct get_all_f :
public std::unary_function<T,void>
132 get_all_f(
const Ice::Current& _c, TMap& _getcallbackmap,
133 const priv_lvl_t& _cur_priv, TKnobMap& _outknobs) :
134 c(_c), d_getcallbackmap(_getcallbackmap),
cur_priv(_cur_priv), outknobs(_outknobs)
137 void operator()(
const T& p)
143 std::cout <<
"Key " << p.first <<
" requires PRIVLVL <= "
144 << p.second.priv <<
" to get, currently at: "
149 const Ice::Current& c;
150 TMap& d_getcallbackmap;
155 template<
typename T,
typename TMap,
typename TKnobMap>
156 struct properties_all_f :
public std::unary_function<T,void>
158 properties_all_f(
const Ice::Current& _c, QueryCallbackMap_t& _getcallbackmap,
159 const priv_lvl_t& _cur_priv, GNURadio::KnobPropMap& _outknobs) :
160 c(_c), d_getcallbackmap(_getcallbackmap),
cur_priv(_cur_priv), outknobs(_outknobs)
163 void operator()(
const T& p)
166 GNURadio::KnobProp prop;
168 prop.units = p.second.units;
169 prop.description = p.second.description;
172 prop.display =
static_cast<uint32_t>(p.second.display);
173 outknobs[p.first] = prop;
176 std::cout <<
"Key " << p.first <<
" requires PRIVLVL <= "
177 << p.second.priv <<
" to get, currently at: "
182 const Ice::Current& c;
183 TMap& d_getcallbackmap;
188 template<
class T,
typename TMap,
typename TKnobMap>
189 struct properties_f :
public std::unary_function<T,void>
191 properties_f(
const Ice::Current& _c, TMap& _getcallbackmap,
192 const priv_lvl_t& _cur_priv, TKnobMap& _outknobs) :
193 c(_c), d_getcallbackmap(_getcallbackmap),
cur_priv(_cur_priv), outknobs(_outknobs)
196 void operator()(
const T& p)
198 typename TMap::const_iterator iter(d_getcallbackmap.find(p));
199 if(iter != d_getcallbackmap.end()) {
200 if(cur_priv <= iter->second.priv) {
201 GNURadio::KnobProp prop;
203 prop.units = iter->second.units;
204 prop.description = iter->second.description;
207 prop.display =
static_cast<uint32_t>(iter->second.display);
212 std::cout <<
"Key " << iter->first <<
" requires PRIVLVL: <= " <<
213 iter->second.priv <<
" to get, currently at: " <<
cur_priv << std::endl;
217 throw IceUtil::NullHandleException(__FILE__, __LINE__);
221 const Ice::Current& c;
222 TMap& d_getcallbackmap;
Definition: rpccallbackregister_base.h:80
virtual void set(const GNURadio::KnobMap &, const Ice::Current &)
void unregisterQueryCallback(const std::string &id)
virtual void shutdown(const Ice::Current &)
void registerQueryCallback(const std::string &id, const queryCallback_t callback)
priv_lvl_t
Definition: rpccallbackregister_base.h:46
void registerConfigureCallback(const std::string &id, const configureCallback_t callback)
Definition: rpccallbackregister_base.h:54
callback_t< gr::messages::msg_accepter, gr::messages::msg_accepter_sptr > configureCallback_t
Definition: rpccallbackregister_base.h:100
GNURadio::KnobMap getRe(const GNURadio::KnobIDList &, const Ice::Current &)
unsigned int uint32_t
Definition: stdint.h:80
void unregisterConfigureCallback(const std::string &id)
Definition: rpcserver_ice.h:35
#define PMT_NIL
Definition: pmt.h:252
Definition: rpcserver_base.h:28
GNURadio::KnobPtr from_pmt(const pmt::pmt_t &knob, const Ice::Current &c)
pmt::pmt_t to_pmt(const GNURadio::KnobPtr &knob, const Ice::Current &c)
GNURadio::KnobPropMap properties(const GNURadio::KnobIDList &, const Ice::Current &)
priv_lvl_t cur_priv
Definition: rpcserver_base.h:42