11#ifndef RPCREGISTERHELPERS_H
12#define RPCREGISTERHELPERS_H
22typedef std::shared_ptr<rpcbasic_base> rpcbasic_sptr;
35template <
typename T,
typename Tto>
49 throw std::runtime_error(
50 "rpcextractor_base: no post defined for this data type.");
69 throw std::runtime_error(
70 "rpcextractor_base: no post defined for this data type.");
81template <
typename T,
typename Tto>
101template <
typename T,
typename Tfrom>
124template <
typename T,
typename Tfrom>
484 std::vector<signed char>
vec(
569 std::vector<int64_t>
vec(
598 std::vector<std::complex<float>>
vec(
655 std::vector<uint8_t>
vec(
712 std::complex<double> k(
776template <
typename T,
typename Tto>
805 const char* functionbase,
806 void (T::*function)(Tto),
810 const char* units_ =
"",
811 const char* desc_ =
"",
820 d_minpriv = minpriv_;
821 d_display = display_;
822 d_object =
dynamic_cast<T*
>(
824#ifdef GR_RPCSERVER_ENABLED
834 std::ostringstream oss(std::ostringstream::out);
835 oss << block_alias <<
"::" << functionbase;
866 const char* functionbase,
868 void (T::*function)(Tto),
872 const char* units_ =
"",
873 const char* desc_ =
"",
882 d_minpriv = minpriv_;
883 d_display = display_;
885#ifdef GR_RPCSERVER_ENABLED
895 std::ostringstream oss(std::ostringstream::out);
896 oss << name <<
"::" << functionbase;
905#ifdef GR_RPCSERVER_ENABLED
914 std::string
units()
const {
return d_units; }
922 void units(std::string u) { d_units = u; }
930 std::string d_units, d_desc;
985 const char* functionbase,
986 void (T::*function)(),
987 const char* desc_ =
"",
991 d_minpriv = minpriv_;
992 d_object =
dynamic_cast<T*
>(
994#ifdef GR_RPCSERVER_ENABLED
999 std::ostringstream oss(std::ostringstream::out);
1000 oss << block_alias <<
"::" << functionbase;
1026 const char* functionbase,
1028 void (T::*function)(),
1029 const char* desc_ =
"",
1033 d_minpriv = minpriv_;
1035#ifdef GR_RPCSERVER_ENABLED
1039 std::string(desc_));
1040 std::ostringstream oss(std::ostringstream::out);
1041 oss << name <<
"::" << functionbase;
1050#ifdef GR_RPCSERVER_ENABLED
1105template <
typename T,
typename Tfrom>
1136 const char* functionbase,
1137 Tfrom (T::*function)(),
1141 const char* units_ =
"",
1142 const char* desc_ =
"",
1151 d_minpriv = minpriv_;
1152 d_display = display_;
1153 d_object =
dynamic_cast<T*
>(
1155#ifdef GR_RPCSERVER_ENABLED
1159 std::string(units_),
1165 std::ostringstream oss(std::ostringstream::out);
1166 oss << block_alias <<
"::" << functionbase;
1179 const char* functionbase,
1180 Tfrom (T::*function)()
const,
1184 const char* units_ =
"",
1185 const char* desc_ =
"",
1194 d_minpriv = minpriv_;
1195 d_display = display_;
1196 d_object =
dynamic_cast<T*
>(
1198#ifdef GR_RPCSERVER_ENABLED
1202 std::string(units_),
1208 std::ostringstream oss(std::ostringstream::out);
1209 oss << block_alias <<
"::" << functionbase;
1242 const char* functionbase,
1244 Tfrom (T::*function)(),
1248 const char* units_ =
"",
1249 const char* desc_ =
"",
1258 d_minpriv = minpriv_;
1259 d_display = display_;
1261#ifdef GR_RPCSERVER_ENABLED
1265 std::string(units_),
1271 std::ostringstream oss(std::ostringstream::out);
1272 oss << name <<
"::" << functionbase;
1285 const char* functionbase,
1287 Tfrom (T::*function)()
const,
1291 const char* units_ =
"",
1292 const char* desc_ =
"",
1301 d_minpriv = minpriv_;
1302 d_display = display_;
1304#ifdef GR_RPCSERVER_ENABLED
1308 std::string(units_),
1314 std::ostringstream oss(std::ostringstream::out);
1315 oss << name <<
"::" << functionbase;
1325#ifdef GR_RPCSERVER_ENABLED
1333 std::string
units()
const {
return d_units; }
1341 void units(std::string u) { d_units = u; }
1349 std::string d_units, d_desc;
1393template <
typename Tfrom>
1424 throw std::runtime_error(
1425 "ERROR: rpcbasic_register_variable called with no args. If this happens, "
1426 "someone has tried to use rpcbasic_register_variable incorrectly.");
1448 const char* functionbase,
1453 const char* units_ =
"",
1454 const char* desc_ =
"",
1510template <
typename Tfrom>
1521 : d_rpc_regset(
"FAIL",
1533 throw std::runtime_error(
1534 "ERROR: rpcbasic_register_variable_rw called with no args. if this happens "
1535 "someone used rpcbasic_register_variable_rw incorrectly.");
1562 const char* functionbase,
1567 const char* units_ =
"",
1568 const char* desc_ =
"",
1572 namebase, functionbase, variable,
min, max, def, units_, desc_),
1573 d_rpc_regset(namebase,
1594template <
typename T>
1615 const char* handler,
1616 const char* units_ =
"",
1617 const char* desc_ =
"",
1623 d_minpriv = minpriv_;
1624 d_display = display_;
1625 d_object =
dynamic_cast<T*
>(
1627#ifdef GR_RPCSERVER_ENABLED
1631 std::string(units_),
1637 std::ostringstream oss(std::ostringstream::out);
1638 oss << block_alias <<
"::" << handler;
1647#ifdef GR_RPCSERVER_ENABLED
1652 std::string
units()
const {
return d_units; }
1657 void units(std::string u) { d_units = u; }
1664 std::string d_units, d_desc;
GR_RUNTIME_API gr::block_registry global_block_registry
Definition: rpccallbackregister_base.h:83
basic_block_sptr block_lookup(pmt::pmt_t symbol)
Virtual base class that accepts messages.
Definition: messages/msg_accepter.h:25
Virtual base class that produces messages.
Definition: msg_producer.h:25
Definition: rpcregisterhelpers.h:734
rpcbasic_base()
Definition: rpcregisterhelpers.h:736
virtual ~rpcbasic_base()
Definition: rpcregisterhelpers.h:737
Templated parent class for registering a ControlPort Extractor.
Definition: rpcregisterhelpers.h:182
rpcbasic_handler(T *source, const char *handler)
Definition: rpcregisterhelpers.h:184
pmt::pmt_t retrieve()
send msg to msg_producer
Definition: rpcregisterhelpers.h:710
rpcbasic_inserter(T *source, std::complex< double >(T::*func)())
Definition: rpcregisterhelpers.h:704
rpcbasic_inserter(T *source, std::complex< double >(T::*func)() const)
Definition: rpcregisterhelpers.h:698
pmt::pmt_t retrieve()
send msg to msg_producer
Definition: rpcregisterhelpers.h:682
rpcbasic_inserter(T *source, std::complex< float >(T::*func)())
Definition: rpcregisterhelpers.h:676
rpcbasic_inserter(T *source, std::complex< float >(T::*func)() const)
Definition: rpcregisterhelpers.h:670
rpcbasic_inserter(T *source, std::vector< float >(T::*func)())
Definition: rpcregisterhelpers.h:619
pmt::pmt_t retrieve()
send msg to msg_producer
Definition: rpcregisterhelpers.h:625
rpcbasic_inserter(T *source, std::vector< float >(T::*func)() const)
Definition: rpcregisterhelpers.h:613
rpcbasic_inserter(T *source, std::vector< int64_t >(T::*func)() const)
Definition: rpcregisterhelpers.h:555
rpcbasic_inserter(T *source, std::vector< int64_t >(T::*func)())
Definition: rpcregisterhelpers.h:561
pmt::pmt_t retrieve()
send msg to msg_producer
Definition: rpcregisterhelpers.h:567
pmt::pmt_t retrieve()
send msg to msg_producer
Definition: rpcregisterhelpers.h:539
rpcbasic_inserter(T *source, std::vector< int >(T::*func)())
Definition: rpcregisterhelpers.h:533
rpcbasic_inserter(T *source, std::vector< int >(T::*func)() const)
Definition: rpcregisterhelpers.h:527
rpcbasic_inserter(T *source, std::vector< short >(T::*func)() const)
Definition: rpcregisterhelpers.h:499
rpcbasic_inserter(T *source, std::vector< short >(T::*func)())
Definition: rpcregisterhelpers.h:505
pmt::pmt_t retrieve()
send msg to msg_producer
Definition: rpcregisterhelpers.h:511
pmt::pmt_t retrieve()
send msg to msg_producer
Definition: rpcregisterhelpers.h:482
rpcbasic_inserter(T *source, std::vector< signed char >(T::*func)() const)
Definition: rpcregisterhelpers.h:470
rpcbasic_inserter(T *source, std::vector< signed char >(T::*func)())
Definition: rpcregisterhelpers.h:476
pmt::pmt_t retrieve()
send msg to msg_producer
Definition: rpcregisterhelpers.h:596
rpcbasic_inserter(T *source, std::vector< std::complex< float > >(T::*func)())
Definition: rpcregisterhelpers.h:590
rpcbasic_inserter(T *source, std::vector< std::complex< float > >(T::*func)() const)
Definition: rpcregisterhelpers.h:584
rpcbasic_inserter(T *source, std::vector< uint8_t >(T::*func)() const)
Definition: rpcregisterhelpers.h:641
pmt::pmt_t retrieve()
send msg to msg_producer
Definition: rpcregisterhelpers.h:653
rpcbasic_inserter(T *source, std::vector< uint8_t >(T::*func)())
Definition: rpcregisterhelpers.h:647
rpcbasic_inserter(T *source, uint64_t(T::*func)() const)
Definition: rpcregisterhelpers.h:443
rpcbasic_inserter(T *source, uint64_t(T::*func)())
Definition: rpcregisterhelpers.h:449
pmt::pmt_t retrieve()
send msg to msg_producer
Definition: rpcregisterhelpers.h:455
Templated parent class for registering a ControlPort Inserter.
Definition: rpcregisterhelpers.h:126
rpcbasic_inserter(T *source, Tfrom(T::*func)() const)
Definition: rpcregisterhelpers.h:128
rpcbasic_inserter(T *source, Tfrom(T::*func)())
Definition: rpcregisterhelpers.h:134
pmt::pmt_t retrieve()
send msg to msg_producer
Definition: rpcregisterhelpers.h:140
Registers a 'get' function to get a parameter over ControlPort.
Definition: rpcregisterhelpers.h:1107
std::string units() const
Definition: rpcregisterhelpers.h:1333
void set_def(pmt::pmt_t p)
Definition: rpcregisterhelpers.h:1340
rpcbasic_register_get(const std::string &block_alias, const char *functionbase, Tfrom(T::*function)() const, const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def, const char *units_="", const char *desc_="", priv_lvl_t minpriv_=RPC_PRIVLVL_MIN, DisplayType display_=DISPNULL)
Same as rpcbasic_register_get::rpcbasic_register_get that allows using '[variable]() const' getter fu...
Definition: rpcregisterhelpers.h:1178
pmt::pmt_t def() const
Definition: rpcregisterhelpers.h:1332
DisplayType default_display() const
Definition: rpcregisterhelpers.h:1336
void description(std::string d)
Definition: rpcregisterhelpers.h:1342
rpcbasic_register_get(const std::string &name, const char *functionbase, T *obj, Tfrom(T::*function)() const, const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def, const char *units_="", const char *desc_="", priv_lvl_t minpriv_=RPC_PRIVLVL_MIN, DisplayType display_=DISPNULL)
Same as above that allows using '[variable]() const' getter functions.
Definition: rpcregisterhelpers.h:1284
void set_min(pmt::pmt_t p)
Definition: rpcregisterhelpers.h:1338
~rpcbasic_register_get() override
Definition: rpcregisterhelpers.h:1323
std::string description() const
Definition: rpcregisterhelpers.h:1334
rpcbasic_register_get(const std::string &block_alias, const char *functionbase, Tfrom(T::*function)(), const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def, const char *units_="", const char *desc_="", priv_lvl_t minpriv_=RPC_PRIVLVL_MIN, DisplayType display_=DISPNULL)
Adds the ability to get the variable over ControlPort.
Definition: rpcregisterhelpers.h:1135
void default_display(DisplayType d)
Definition: rpcregisterhelpers.h:1344
pmt::pmt_t max() const
Definition: rpcregisterhelpers.h:1331
priv_lvl_t privilege_level() const
Definition: rpcregisterhelpers.h:1335
void units(std::string u)
Definition: rpcregisterhelpers.h:1341
pmt::pmt_t min() const
Definition: rpcregisterhelpers.h:1330
void set_max(pmt::pmt_t p)
Definition: rpcregisterhelpers.h:1339
rpcbasic_register_get(const std::string &name, const char *functionbase, T *obj, Tfrom(T::*function)(), const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def, const char *units_="", const char *desc_="", priv_lvl_t minpriv_=RPC_PRIVLVL_MIN, DisplayType display_=DISPNULL)
Adds the ability to get the variable over ControlPort.
Definition: rpcregisterhelpers.h:1241
void privilege_level(priv_lvl_t p)
Definition: rpcregisterhelpers.h:1343
Registers a message handler function to post a message to a block's handler.
Definition: rpcregisterhelpers.h:1596
void description(std::string d)
Definition: rpcregisterhelpers.h:1658
std::string description() const
Definition: rpcregisterhelpers.h:1653
void privilege_level(priv_lvl_t p)
Definition: rpcregisterhelpers.h:1659
~rpcbasic_register_handler() override
Definition: rpcregisterhelpers.h:1645
rpcbasic_register_handler(const std::string &block_alias, const char *handler, const char *units_="", const char *desc_="", priv_lvl_t minpriv_=RPC_PRIVLVL_MIN, DisplayType display_=DISPNULL)
Adds the ability to pass a message over ControlPort.
Definition: rpcregisterhelpers.h:1614
DisplayType default_display() const
Definition: rpcregisterhelpers.h:1655
priv_lvl_t privilege_level() const
Definition: rpcregisterhelpers.h:1654
void units(std::string u)
Definition: rpcregisterhelpers.h:1657
std::string units() const
Definition: rpcregisterhelpers.h:1652
void default_display(DisplayType d)
Definition: rpcregisterhelpers.h:1660
Registers a read/write function to get and set a parameter over ControlPort.
Definition: rpcregisterhelpers.h:1512
rpcbasic_register_variable_rw(const std::string &namebase, const char *functionbase, Tfrom *variable, const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def, const char *units_="", const char *desc_="", priv_lvl_t minpriv=RPC_PRIVLVL_MIN, DisplayType display_=DISPNULL)
Adds the ability to set and get the variable over ControlPort.
Definition: rpcregisterhelpers.h:1561
void set(Tfrom _variable)
Definition: rpcregisterhelpers.h:1538
rpcbasic_register_variable_rw()
Definition: rpcregisterhelpers.h:1520
Registers a read-only function to get a parameter over ControlPort.
Definition: rpcregisterhelpers.h:1395
Tfrom * d_variable
Definition: rpcregisterhelpers.h:1398
Tfrom get()
Definition: rpcregisterhelpers.h:1399
rpcbasic_register_variable(const std::string &namebase, const char *functionbase, Tfrom *variable, const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def, const char *units_="", const char *desc_="", priv_lvl_t minpriv_=RPC_PRIVLVL_MIN, DisplayType display_=DISPNULL)
Adds the ability to get the variable over ControlPort.
Definition: rpcregisterhelpers.h:1447
void setptr(Tfrom *_variable)
Definition: rpcregisterhelpers.h:1402
rpcbasic_register_variable()
Definition: rpcregisterhelpers.h:1410
rpcbasic_register_get< rpcbasic_register_variable< Tfrom >, Tfrom > d_rpc_reg
Definition: rpcregisterhelpers.h:1397
Base class for registering a ControlPort Handler. Acts as a message acceptor.
Definition: rpcregisterhelpers.h:158
T * _source
Definition: rpcregisterhelpers.h:172
rpchandler_base(T *source, const char *handler)
Definition: rpcregisterhelpers.h:160
~rpchandler_base() override
Definition: rpcregisterhelpers.h:164
void post(pmt::pmt_t which_port, pmt::pmt_t msg) override
send msg to msg_accepter on port which_port
Definition: rpcregisterhelpers.h:166
const char * _handler
Definition: rpcregisterhelpers.h:173
Base class for registering a ControlPort Inserter. Produces a message.
Definition: rpcregisterhelpers.h:103
Tfrom(T::* _func)()
Definition: rpcregisterhelpers.h:116
pmt::pmt_t retrieve() override
send msg to msg_producer
Definition: rpcregisterhelpers.h:108
rpcinserter_base()
Definition: rpcregisterhelpers.h:106
T * _source
Definition: rpcregisterhelpers.h:115
rpcinserter_base(T *source, Tfrom(T::*func)())
Definition: rpcregisterhelpers.h:105
static rpcserver_booter_base * get()
void unregisterHandlerCallback(const std::string &id) override=0
void registerQueryCallback(const std::string &id, const queryCallback_t callback) override=0
void registerHandlerCallback(const std::string &id, const handlerCallback_t callback) override=0
void unregisterConfigureCallback(const std::string &id) override=0
void registerConfigureCallback(const std::string &id, const configureCallback_t callback) override=0
void unregisterQueryCallback(const std::string &id) override=0
virtual rpcserver_base * i()=0
GR_RUNTIME_API const pmt::pmt_t msg()
GR_RUNTIME_API const pmt::pmt_t vec()
float min(float a, float b)
PMT_API double to_double(pmt_t x)
Convert pmt to double if possible.
PMT_API pmt_t from_complex(double re, double im)
Return a complex number constructed of the given real and imaginary parts.
PMT_API pmt_t init_s8vector(size_t k, const int8_t *data)
PMT_API std::complex< double > to_complex(pmt_t z)
PMT_API pmt_t init_s16vector(size_t k, const int16_t *data)
PMT_API pmt_t intern(const std::string &s)
Alias for pmt_string_to_symbol.
PMT_API pmt_t init_s32vector(size_t k, const int32_t *data)
PMT_API long to_long(pmt_t x)
Convert pmt to long if possible.
PMT_API pmt_t init_f32vector(size_t k, const float *data)
PMT_API bool to_bool(pmt_t val)
Return true if val is pmt::True, return false when val is pmt::PMT_F,.
PMT_API const std::string symbol_to_string(const pmt_t &sym)
PMT_API pmt_t init_c32vector(size_t k, const std::complex< float > *data)
static pmt_t mp(const std::string &s)
Make pmt symbol.
Definition: pmt_sugar.h:24
std::shared_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting).
Definition: pmt.h:83
PMT_API pmt_t init_u8vector(size_t k, const uint8_t *data)
PMT_API pmt_t init_s64vector(size_t k, const int64_t *data)
PMT_API pmt_t from_uint64(uint64_t x)
Return the pmt value that represents the uint64 x.
#define PMT_NIL
Definition: pmt.h:121
constexpr uint32_t DISPNULL
DisplayType Plotting types.
Definition: rpccallbackregister_base.h:20
priv_lvl_t
Definition: rpccallbackregister_base.h:34
@ RPC_PRIVLVL_MIN
Definition: rpccallbackregister_base.h:34
uint32_t DisplayType
Definition: rpccallbackregister_base.h:17
Base class for registering a ControlPort function.
Definition: rpcregisterhelpers.h:723
rpc_register_base()
Definition: rpcregisterhelpers.h:724
static int count
Definition: rpcregisterhelpers.h:727
Registers a 'set' function to set a parameter over ControlPort.
Definition: rpcregisterhelpers.h:777
rpcbasic_register_set(const std::string &name, const char *functionbase, T *obj, void(T::*function)(Tto), const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def, const char *units_="", const char *desc_="", priv_lvl_t minpriv_=RPC_PRIVLVL_MIN, DisplayType display_=DISPNULL)
Adds the ability to set the variable over ControlPort.
Definition: rpcregisterhelpers.h:865
std::string units() const
Definition: rpcregisterhelpers.h:914
void description(std::string d)
Definition: rpcregisterhelpers.h:923
pmt::pmt_t min() const
Definition: rpcregisterhelpers.h:911
~rpcbasic_register_set() override
Definition: rpcregisterhelpers.h:903
rpcbasic_register_set(const std::string &block_alias, const char *functionbase, void(T::*function)(Tto), const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def, const char *units_="", const char *desc_="", priv_lvl_t minpriv_=RPC_PRIVLVL_MIN, DisplayType display_=DISPNULL)
Adds the ability to set the variable over ControlPort.
Definition: rpcregisterhelpers.h:804
void set_max(pmt::pmt_t p)
Definition: rpcregisterhelpers.h:920
std::string description() const
Definition: rpcregisterhelpers.h:915
void privilege_level(priv_lvl_t p)
Definition: rpcregisterhelpers.h:924
void set_min(pmt::pmt_t p)
Definition: rpcregisterhelpers.h:919
void set_def(pmt::pmt_t p)
Definition: rpcregisterhelpers.h:921
pmt::pmt_t def() const
Definition: rpcregisterhelpers.h:913
priv_lvl_t privilege_level() const
Definition: rpcregisterhelpers.h:916
void default_display(DisplayType d)
Definition: rpcregisterhelpers.h:925
DisplayType default_display() const
Definition: rpcregisterhelpers.h:917
pmt::pmt_t max() const
Definition: rpcregisterhelpers.h:912
void units(std::string u)
Definition: rpcregisterhelpers.h:922
Registers a 'trigger' function to trigger an action over ControlPort.
Definition: rpcregisterhelpers.h:962
void description(std::string d)
Definition: rpcregisterhelpers.h:1059
std::string description() const
Definition: rpcregisterhelpers.h:1056
priv_lvl_t privilege_level() const
Definition: rpcregisterhelpers.h:1057
void privilege_level(priv_lvl_t p)
Definition: rpcregisterhelpers.h:1060
rpcbasic_register_trigger(const std::string &name, const char *functionbase, T *obj, void(T::*function)(), const char *desc_="", priv_lvl_t minpriv_=RPC_PRIVLVL_MIN)
Adds the ability to trigger a function over ControlPort.
Definition: rpcregisterhelpers.h:1025
~rpcbasic_register_trigger() override
Definition: rpcregisterhelpers.h:1048
rpcbasic_register_trigger(const std::string &block_alias, const char *functionbase, void(T::*function)(), const char *desc_="", priv_lvl_t minpriv_=RPC_PRIVLVL_MIN)
Adds the ability to trigger a function over ControlPort.
Definition: rpcregisterhelpers.h:984