11#ifndef RPCSERVER_THRIFT_H
12#define RPCSERVER_THRIFT_H
14#include "thrift/ControlPort.h"
15#include "thrift/gnuradio_types.h"
25#define S__LINE__ S_(__LINE__)
44 void getKnobs(GNURadio::KnobMap&,
const GNURadio::KnobIDList&);
45 void getRe(GNURadio::KnobMap&,
const GNURadio::KnobIDList&);
46 void properties(GNURadio::KnobPropMap&,
const GNURadio::KnobIDList& knobs);
73 const std::string& port,
74 const std::string&
msg);
84 typedef std::map<std::string, configureCallback_t> ConfigureCallbackMap_t;
85 ConfigureCallbackMap_t d_setcallbackmap;
87 typedef std::map<std::string, queryCallback_t> QueryCallbackMap_t;
88 QueryCallbackMap_t d_getcallbackmap;
90 typedef std::map<std::string, handlerCallback_t> HandlerCallbackMap_t;
91 HandlerCallbackMap_t d_handlercallbackmap;
104 std::ostringstream
msg;
106 <<
" requires PRIVLVL <= " << _handlerCallback.
priv
107 <<
" to set, currently at: " <<
cur_priv;
113 template <
typename T,
typename TMap>
114 struct set_f :
public std::unary_function<T, void> {
115 set_f(TMap& _setcallbackmap,
const priv_lvl_t& _cur_priv)
116 : d_setcallbackmap(_setcallbackmap),
cur_priv(_cur_priv)
121 void operator()(
const T& p)
123 ConfigureCallbackMap_t::const_iterator iter(d_setcallbackmap.find(p.first));
124 if (iter != d_setcallbackmap.end()) {
125 if (cur_priv <= iter->second.priv) {
126 (*iter->second.callback)
129 std::ostringstream
msg;
130 msg <<
"Key " << p.first
131 <<
" requires PRIVLVL <= " << iter->second.priv
132 <<
" to set, currently at: " <<
cur_priv;
136 throw apache::thrift::TApplicationException(__FILE__
" " S__LINE__);
140 TMap& d_setcallbackmap;
144 template <
typename T,
typename TMap>
145 struct get_f :
public std::unary_function<T, void> {
146 get_f(TMap& _getcallbackmap,
148 GNURadio::KnobMap& _outknobs)
149 : d_getcallbackmap(_getcallbackmap),
cur_priv(_cur_priv), outknobs(_outknobs)
153 void operator()(
const T& p)
155 QueryCallbackMap_t::const_iterator iter(d_getcallbackmap.find(p));
156 if (iter != d_getcallbackmap.end()) {
157 if (cur_priv <= iter->second.priv) {
161 std::ostringstream
msg;
162 msg <<
"Key " << iter->first
163 <<
" requires PRIVLVL: <= " << iter->second.priv
164 <<
" to get, currently at: " <<
cur_priv;
168 std::ostringstream smsgs;
169 smsgs <<
"Ctrlport Key called with unregistered key (" << p <<
")\n";
171 throw apache::thrift::TApplicationException(__FILE__
" " S__LINE__);
175 TMap& d_getcallbackmap;
177 GNURadio::KnobMap& outknobs;
180 template <
typename T,
typename TMap,
typename TKnobMap>
181 struct get_all_f :
public std::unary_function<T, void> {
182 get_all_f(TMap& _getcallbackmap,
const priv_lvl_t& _cur_priv, TKnobMap& _outknobs)
183 : d_getcallbackmap(_getcallbackmap),
cur_priv(_cur_priv), outknobs(_outknobs)
188 void operator()(
const T& p)
194 std::ostringstream
msg;
195 msg <<
"Key " << p.first <<
" requires PRIVLVL: <= " << p.second.priv
196 <<
" to get, currently at: " <<
cur_priv;
201 TMap& d_getcallbackmap;
206 template <
typename T,
typename TMap,
typename TKnobMap>
207 struct properties_all_f :
public std::unary_function<T, void> {
208 properties_all_f(QueryCallbackMap_t& _getcallbackmap,
210 GNURadio::KnobPropMap& _outknobs)
211 : d_getcallbackmap(_getcallbackmap),
cur_priv(_cur_priv), outknobs(_outknobs)
216 void operator()(
const T& p)
219 GNURadio::KnobProp prop;
221 prop.units = p.second.units;
222 prop.description = p.second.description;
225 prop.display =
static_cast<uint32_t
>(p.second.display);
226 outknobs[p.first] = prop;
228 std::ostringstream
msg;
229 msg <<
"Key " << p.first <<
" requires PRIVLVL: <= " << p.second.priv
230 <<
" to get, currently at: " <<
cur_priv;
235 TMap& d_getcallbackmap;
240 template <
class T,
typename TMap,
typename TKnobMap>
241 struct properties_f :
public std::unary_function<T, void> {
242 properties_f(TMap& _getcallbackmap,
245 : d_getcallbackmap(_getcallbackmap),
cur_priv(_cur_priv), outknobs(_outknobs)
250 void operator()(
const T& p)
252 typename TMap::const_iterator iter(d_getcallbackmap.find(p));
253 if (iter != d_getcallbackmap.end()) {
254 if (cur_priv <= iter->second.priv) {
255 GNURadio::KnobProp prop;
257 prop.units = iter->second.units;
258 prop.description = iter->second.description;
261 prop.display =
static_cast<uint32_t
>(iter->second.display);
264 std::ostringstream
msg;
265 msg <<
"Key " << iter->first
266 <<
" requires PRIVLVL: <= " << iter->second.priv
267 <<
" to get, currently at: " <<
cur_priv;
271 throw apache::thrift::TApplicationException(__FILE__
" " S__LINE__);
275 TMap& d_getcallbackmap;
Definition: rpccallbackregister_base.h:83
Tsptr callback
Definition: rpccallbackregister_base.h:105
static To_PMT instance
Definition: rpcpmtconverters_thrift.h:79
Definition: rpcserver_base.h:17
priv_lvl_t cur_priv
Definition: rpcserver_base.h:39
Definition: rpcserver_thrift.h:28
void unregisterQueryCallback(const std::string &id)
void registerConfigureCallback(const std::string &id, const configureCallback_t callback)
virtual ~rpcserver_thrift()
void getRe(GNURadio::KnobMap &, const GNURadio::KnobIDList &)
void setKnobs(const GNURadio::KnobMap &)
void properties(GNURadio::KnobPropMap &, const GNURadio::KnobIDList &knobs)
void getKnobs(GNURadio::KnobMap &, const GNURadio::KnobIDList &)
void registerQueryCallback(const std::string &id, const queryCallback_t callback)
void postMessage(const std::string &alias, const std::string &port, const std::string &msg)
Call this to post a message to the port for the block identified by alias.
void unregisterHandlerCallback(const std::string &id)
void registerHandlerCallback(const std::string &id, const handlerCallback_t callback)
void unregisterConfigureCallback(const std::string &id)
#define GR_LOG_ERROR(log, msg)
Definition: logger.h:251
GR_RUNTIME_API const pmt::pmt_t msg()
boost::mutex mutex
Definition: thread.h:37
std::shared_ptr< logger > logger_ptr
Definition: logger.h:208
std::shared_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting).
Definition: pmt.h:83
GNURadio::Knob from_pmt(const pmt::pmt_t &knob)
#define PMT_NIL
Definition: pmt.h:121
priv_lvl_t
Definition: rpccallbackregister_base.h:34
@ KNOBDOUBLE
Definition: rpccallbackregister_base.h:41
#define S__LINE__
Definition: rpcserver_thrift.h:25
std::string description
Definition: rpccallbackregister_base.h:76
priv_lvl_t priv
Definition: rpccallbackregister_base.h:75