GNU Radio Manual and C++ API Reference  3.7.4.1
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
rpcregisterhelpers.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2012,2014 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef RPCREGISTERHELPERS_H
24 #define RPCREGISTERHELPERS_H
25 
26 #include <stdio.h>
27 #include <sstream>
28 #include <iostream>
30 #include <gnuradio/rpcmanager.h>
33 
34 // Fixes circular dependency issue before including block_registry.h
35 class rpcbasic_base;
37 
39 
40 
41 /*********************************************************************
42  * RPC Extractor Base Classes
43  ********************************************************************/
44 
45 /*!
46  *\brief Base class for registering a ControlPort Extractor. Acts as
47  * a message acceptor.
48  */
49 template<typename T, typename Tto>
51  : public virtual gr::messages::msg_accepter
52 {
53 public:
54  rpcextractor_base(T* source, void (T::*func)(Tto)) :
55  _source(source), _func(func) {;}
57 
58  void post(pmt::pmt_t which_port, pmt::pmt_t msg) {
59  throw std::runtime_error("rpcextractor_base: no post defined for this data type.\n");
60  }
61 
62 protected:
63  T* _source;
64  void (T::*_func)(Tto);
65 };
66 
67 template<typename T>
69  : public virtual gr::messages::msg_accepter
70 {
71 public:
72  rpcextractor_base(T* source, void (T::*func)()) :
73  _source(source), _func(func) {;}
75 
76  void post(pmt::pmt_t which_port, pmt::pmt_t msg) {
77  throw std::runtime_error("rpcextractor_base: no post defined for this data type.\n");
78  }
79 
80 protected:
81  T* _source;
82  void (T::*_func)();
83 };
84 
85 /*!
86  * \brief Templated parent class for registering a ControlPort Extractor.
87  */
88 template<typename T, typename Tto>
89 class rpcbasic_extractor : public virtual rpcextractor_base<T,Tto>
90 {
91 public:
92  rpcbasic_extractor(T* source, void (T::*func)(Tto)) :
93  rpcextractor_base<T,Tto>(source, func)
94  {;}
95 };
96 
97 
98 /*********************************************************************
99  * RPC Inserter Base Classes
100  ********************************************************************/
101 
102 /*!
103  * \brief Base class for registering a ControlPort Inserter. Produces a
104  * message.
105  */
106 template<typename T, typename Tfrom>
108 {
109 public:
110  rpcinserter_base(T* source, Tfrom (T::*func)()) : _source(source), _func(func) {;}
112 
113  pmt::pmt_t retrieve() { assert(0); return pmt::pmt_t(); }
114 
115 protected:
117  Tfrom (T::*_func)();
118 };
119 
120 
121 /*!
122  * \brief Templated parent class for registering a ControlPort
123  * Inserter.
124  */
125 template<typename T, typename Tfrom>
127  public virtual rpcinserter_base<T,Tfrom>
128 {
129 public:
130  rpcbasic_inserter(T* source, Tfrom (T::*func)()const)
131  : rpcinserter_base<T,Tfrom>(source, func)
132  {;}
133 
134  rpcbasic_inserter(T* source, Tfrom (T::*func)())
135  : rpcinserter_base<T,Tfrom>(source, func)
136  {;}
137 
139  {
142  }
143 };
144 
145 
146 /*********************************************************************
147  * RPC Specialized Extractors
148  ********************************************************************/
149 
150 /*!
151  * \brief Specialized extractor class to make calls to functions that
152  * do not take data (enable, reset, start, etc.).
153  */
154 template<typename T>
155 class rpcbasic_extractor<T,void> : public virtual rpcextractor_base<T,void>
156 {
157 public:
158  rpcbasic_extractor(T* source, void (T::*func)())
159  : rpcextractor_base<T,void>(source, func)
160  {;}
161 
162  void post(pmt::pmt_t which_port, pmt::pmt_t msg)
163  {
165  }
166 };
167 
168 /*!
169  * \brief Specialized extractor class for char data.
170  */
171 template<typename T>
172 class rpcbasic_extractor<T,char> : public virtual rpcextractor_base<T,char>
173 {
174 public:
175  rpcbasic_extractor(T* source, void (T::*func)(char))
176  : rpcextractor_base<T,char>(source, func)
177  {;}
178 
179  void post(pmt::pmt_t which_port, pmt::pmt_t msg)
180  {
182  (static_cast<char>(pmt::to_long(msg)));
183  }
184 };
185 
186 /*!
187  * \brief Specialized extractor class for short data.
188  */
189 template<typename T>
190 class rpcbasic_extractor<T,short> : public virtual rpcextractor_base<T,short>
191 {
192 public:
193  rpcbasic_extractor(T* source, void (T::*func)(short))
194  : rpcextractor_base<T,short>(source, func)
195  {;}
196 
197  void post(pmt::pmt_t which_port, pmt::pmt_t msg)
198  {
200  (static_cast<short>(pmt::to_long(msg)));
201  }
202 };
203 
204 /*!
205  * \brief Specialized extractor class for double data.
206  */
207 template<typename T>
208 class rpcbasic_extractor<T,double> : public virtual rpcextractor_base<T,double>
209 {
210 public:
211  rpcbasic_extractor(T* source, void (T::*func)(double))
212  : rpcextractor_base<T,double>(source, func)
213  {;}
214 
215  void post(pmt::pmt_t which_port, pmt::pmt_t msg)
216  {
218  (pmt::to_double(msg));
219  }
220 };
221 
222 /*!
223  * \brief Specialized extractor class for float data.
224  */
225 template<typename T>
226 class rpcbasic_extractor<T,float> : public virtual rpcextractor_base<T,float>
227 {
228 public:
229  rpcbasic_extractor(T* source, void (T::*func)(float))
230  : rpcextractor_base<T,float>(source, func)
231  {;}
232 
233  void post(pmt::pmt_t which_port, pmt::pmt_t msg)
234  {
236  (pmt::to_double(msg));
237  }
238 };
239 
240 /*!
241  * \brief Specialized extractor class for long data.
242  */
243 template<typename T>
244 class rpcbasic_extractor<T,long> : public virtual rpcextractor_base<T,long>
245 {
246 public:
247  rpcbasic_extractor(T* source, void (T::*func)(long))
248  : rpcextractor_base<T,long>(source, func)
249  {;}
250 
251  void post(pmt::pmt_t which_port, pmt::pmt_t msg)
252  {
254  (pmt::to_long(msg));
255  }
256 };
257 
258 /*!
259  * \brief Specialized extractor class for int data.
260  */
261 template<typename T>
262 class rpcbasic_extractor<T,int> : public virtual rpcextractor_base<T,int>
263 {
264 public:
265  rpcbasic_extractor(T* source, void (T::*func)(int))
266  : rpcextractor_base<T,int>(source, func)
267  {;}
268 
269  void post(pmt::pmt_t which_port, pmt::pmt_t msg)
270  {
272  (pmt::to_long(msg));
273  }
274 };
275 
276 /*!
277  * \brief Specialized extractor class for bool data.
278  */
279 template<typename T>
280 class rpcbasic_extractor<T,bool> : public virtual rpcextractor_base<T,bool>
281 {
282 public:
283  rpcbasic_extractor(T* source, void (T::*func)(bool))
284  : rpcextractor_base<T,bool>(source, func)
285  {;}
286 
287  void post(pmt::pmt_t which_port, pmt::pmt_t msg)
288  {
290  (pmt::to_bool(msg));
291  }
292 };
293 
294 /*!
295  * \brief Specialized extractor class for complex (float) data.
296  */
297 template<typename T>
298 class rpcbasic_extractor<T,std::complex<float> >
299  : public virtual rpcextractor_base<T,std::complex<float> >
300 {
301 public:
302  rpcbasic_extractor(T* source, void (T::*func)(std::complex<float>))
303  : rpcextractor_base<T,std::complex<float> >(source, func)
304  {;}
305 
306  void post(pmt::pmt_t which_port, pmt::pmt_t msg)
307  {
308  std::complex<float> k = static_cast<std::complex<float> >(pmt::to_complex(msg));
311  }
312 };
313 
314 /*!
315  * \brief Specialized extractor class for complex (double) data.
316  */
317 template<typename T>
318 class rpcbasic_extractor<T,std::complex<double> >
319  : public virtual rpcextractor_base<T,std::complex<double> >
320 {
321 public:
322  rpcbasic_extractor(T* source, void (T::*func)(std::complex<double>))
323  : rpcextractor_base<T,std::complex<double> >(source, func)
324  {;}
325 
326  void post(pmt::pmt_t which_port, pmt::pmt_t msg)
327  {
330  }
331 };
332 
333 /*!
334  * \brief Specialized extractor class for string data.
335  */
336 template<typename T>
337 class rpcbasic_extractor<T,std::string>
338  : public virtual rpcextractor_base<T,std::string>
339 {
340 public:
341  rpcbasic_extractor(T* source, void (T::*func)(std::string))
342  : rpcextractor_base<T,std::string>(source, func)
343  {;}
344 
345  void post(pmt::pmt_t which_port, pmt::pmt_t msg)
346  {
349  }
350 };
351 
352 
353 /*********************************************************************
354  * RPC Specialized Inserters
355  ********************************************************************/
356 
357 /*!
358  * \brief Specialized inserter class for uint64_t data.
359  */
360 template<typename T>
361 class rpcbasic_inserter<T,uint64_t> : public virtual rpcinserter_base<T,uint64_t>
362 {
363 public:
364  rpcbasic_inserter(T* source, uint64_t (T::*func)() const)
365  : rpcinserter_base<T,uint64_t>(source, func)
366  {;}
367 
368  rpcbasic_inserter(T* source, uint64_t (T::*func)())
369  : rpcinserter_base<T,uint64_t>(source, func)
370  {;}
371 
373  {
376  }
377 };
378 
379 /*!
380  * \brief Specialized inserter class for vectors of signed char data.
381  */
382 template<typename T>
383 class rpcbasic_inserter<T,std::vector< signed char > >
384  : public virtual rpcinserter_base<T,std::vector< signed char > >
385 {
386 public:
387  rpcbasic_inserter(T* source, std::vector< signed char > (T::*func)() const)
388  : rpcinserter_base<T,std::vector< signed char > >(source, func)
389  {;}
390 
391  rpcbasic_inserter(T* source, std::vector< signed char > (T::*func)())
392  : rpcinserter_base<T,std::vector< signed char > >(source, func)
393  {;}
394 
396  {
397  std::vector< signed char >
398  vec((rpcinserter_base<T,std::vector< signed char > >::
399  _source->*rpcinserter_base<T,std::vector< signed char > >::_func)());
400  return pmt::init_s8vector(vec.size(), &vec[0]);
401  }
402 };
403 
404 /*!
405  * \brief Specialized inserter class for vectors of short data.
406  */
407 template<typename T>
408 class rpcbasic_inserter<T,std::vector< short > >
409  : public virtual rpcinserter_base<T,std::vector< short > >
410 {
411 public:
412  rpcbasic_inserter(T* source, std::vector< short > (T::*func)() const)
413  : rpcinserter_base<T,std::vector< short > >(source, func)
414  {;}
415 
416  rpcbasic_inserter(T* source, std::vector< short > (T::*func)())
417  : rpcinserter_base<T,std::vector< short > >(source, func)
418  {;}
419 
421  {
422  std::vector< short >
423  vec((rpcinserter_base<T,std::vector< short > >::
424  _source->*rpcinserter_base<T,std::vector< short > >::_func)());
425  return pmt::init_s16vector(vec.size(), &vec[0]);
426  }
427 };
428 
429 /*!
430  * \brief Specialized inserter class for vectors of int data.
431  */
432 template<typename T>
433 class rpcbasic_inserter<T,std::vector< int > >
434  : public virtual rpcinserter_base<T,std::vector< int > >
435 {
436 public:
437  rpcbasic_inserter(T* source, std::vector<int > (T::*func)() const)
438  : rpcinserter_base<T,std::vector<int > >(source, func)
439  {;}
440 
441  rpcbasic_inserter(T* source, std::vector<int > (T::*func)())
442  : rpcinserter_base<T,std::vector<int > >(source, func)
443  {;}
444 
446  {
447  std::vector< int >
448  vec((rpcinserter_base<T,std::vector<int > >::
449  _source->*rpcinserter_base<T,std::vector< int > >::_func)());
450  return pmt::init_s32vector(vec.size(), &vec[0]);
451  }
452 };
453 
454 /*!
455  * \brief Specialized inserter class for vectors of complex (float) data.
456  */
457 template<typename T>
458 class rpcbasic_inserter<T,std::vector< std::complex<float> > >
459  : public virtual rpcinserter_base<T,std::vector< std::complex<float> > >
460 {
461 public:
462  rpcbasic_inserter(T* source, std::vector<std::complex<float> > (T::*func)() const)
463  : rpcinserter_base<T,std::vector<std::complex<float> > >(source, func)
464  {;}
465 
466  rpcbasic_inserter(T* source, std::vector<std::complex<float> > (T::*func)())
467  : rpcinserter_base<T,std::vector<std::complex<float> > >(source, func)
468  {;}
469 
471  {
472  std::vector< std::complex<float> >
473  vec((rpcinserter_base<T,std::vector<std::complex<float> > >::
474  _source->*rpcinserter_base<T,std::vector< std::complex<float> > >::_func)());
475  return pmt::init_c32vector(vec.size(), &vec[0]);
476  }
477 };
478 
479 /*!
480  * \brief Specialized inserter class for vectors of float data.
481  */
482 template<typename T>
483 class rpcbasic_inserter<T,std::vector< float> >
484  : public virtual rpcinserter_base<T,std::vector< float > >
485 {
486 public:
487  rpcbasic_inserter(T* source, std::vector<float> (T::*func)() const)
488  : rpcinserter_base<T,std::vector<float > >(source, func)
489  {;}
490 
491  rpcbasic_inserter(T* source, std::vector<float> (T::*func)())
492  : rpcinserter_base<T,std::vector<float> >(source, func)
493  {;}
494 
496  {
497  std::vector< float > vec((rpcinserter_base<T,std::vector<float> >::
498  _source->*rpcinserter_base<T,std::vector< float> >::_func)());
499  return pmt::init_f32vector(vec.size(), &vec[0]);
500  }
501 };
502 
503 /*!
504  * \brief Specialized inserter class for vectors of uint8_t data.
505  */
506 template<typename T>
507 class rpcbasic_inserter<T,std::vector< uint8_t> >
508  : public virtual rpcinserter_base<T,std::vector< uint8_t > > {
509 public:
510  rpcbasic_inserter(T* source, std::vector<uint8_t> (T::*func)() const)
511  : rpcinserter_base<T,std::vector<uint8_t > >(source, func)
512  {;}
513 
514  rpcbasic_inserter(T* source, std::vector<uint8_t> (T::*func)())
515  : rpcinserter_base<T,std::vector<uint8_t> >(source, func)
516  {;}
517 
519  {
520  std::vector< uint8_t > vec((rpcinserter_base<T,std::vector<uint8_t> >::
521  _source->*rpcinserter_base<T,std::vector< uint8_t> >::_func)());
522  return pmt::init_u8vector(vec.size(), &vec[0]);
523  }
524 };
525 
526 /*!
527  * \brief Specialized inserter class for complex (float) data.
528  */
529 template<typename T>
530 class rpcbasic_inserter<T,std::complex<float> >
531  : public virtual rpcinserter_base<T,std::complex<float > > {
532 public:
533  rpcbasic_inserter(T* source, std::complex<float> (T::*func)() const)
534  : rpcinserter_base<T,std::complex<float> >(source, func)
535  {;}
536 
537  rpcbasic_inserter(T* source, std::complex<float> (T::*func)())
538  : rpcinserter_base<T,std::complex<float> >(source, func)
539  {;}
540 
542  {
543  std::complex<float > k((rpcinserter_base<T,std::complex<float> >::
544  _source->*rpcinserter_base<T,std::complex<float> >::_func)());
545  return pmt::from_complex(k);
546  }
547 };
548 
549 /*!
550  * \brief Specialized inserter class for complex (double) data.
551  */
552 template<typename T>
553 class rpcbasic_inserter<T,std::complex<double> >
554  : public virtual rpcinserter_base<T,std::complex<double > > {
555 public:
556  rpcbasic_inserter(T* source, std::complex<double> (T::*func)() const)
557  : rpcinserter_base<T,std::complex<double> >(source, func)
558  {;}
559 
560  rpcbasic_inserter(T* source, std::complex<double> (T::*func)())
561  : rpcinserter_base<T,std::complex<double> >(source, func)
562  {;}
563 
565  {
566  std::complex<double > k((rpcinserter_base<T,std::complex<double> >::
567  _source->*rpcinserter_base<T,std::complex<double> >::_func)());
568  return pmt::from_complex(k);
569  }
570 };
571 
572 /*!
573  * \brief Base class for registering a ControlPort function.
574  */
575 template <typename T>
577 {
579 protected: static int count;
580 };
581 
582 /*!
583  * Base class to inherit from and create universal shared pointers.
584  */
586 {
587 public:
589  virtual ~rpcbasic_base() {};
590 };
591 
592 
593 
594 /*********************************************************************
595  * RPC Register Set Classes
596  ********************************************************************/
597 
598 /*!
599  * \brief Registers a 'set' function to set a parameter over
600  * ControlPort.
601  *
602  * \details
603  *
604  * This class allows us to remotely set a value or parameter of the
605  * block over ControlPort. The set occurs by calling a setter accessor
606  * function of the class, usually set_[variable](), which is passed in
607  * as \p function.
608  *
609  * We can set the (expected) minimum (\p min), maximum (\p max), and
610  * default (\p def) of the variables being set. These values are not
611  * enforced, however, but can be useful for setting up graphs and
612  * other ways of bounding the data.
613  *
614  * This class also allows us to provide information to the user about
615  * the variable being set, such as an appropriate unit (\p units_) as
616  * well as a description (\p desc_) about what the variable does.
617  *
618  * The privilege (\p minpriv_) level is the minimum privilege level a
619  * remote must identify with to be able to call this function.
620  *
621  * We also provide display hints (\p display_), which can be used by
622  * the ControlPort client application to know how to best display or
623  * even print the data. This is a mask of options for variables set in
624  * rpccallbackregister_base.h. The mask is defined by one of the
625  * "DisplayType Plotting Types" and or'd with any of the "DisplayType
626  * Options" features. See "Display Options" in \ref page_ctrlport for
627  * details.
628  */
629 template<typename T, typename Tto>
631 {
632  /*!
633  * \brief Adds the ability to set the variable over ControlPort.
634  *
635  * \details
636  *
637  * This constructor is specifically for gr::block's to use to add
638  * settable variables to ControlPort. Generally meant to be used
639  * in gr::block::setup_rpc.
640  *
641  * Uses the block's alias to create the ControlPort interface. This
642  * alias is cross-referenced by the global_block_registry (static
643  * variable of type gr::block_registry) to get the pointer to the
644  * block.
645  *
646  * \param block_alias Block's alias; use alias() to get it from the block.
647  * \param functionbase The name of the function that we'll access over ControlPort
648  * \param function A function pointer to the real function accessed when called
649  * something like: &[block class]\::set_[variable]()
650  * \param min Expected minimum value the parameter can hold
651  * \param max Expected maximum value the parameter can hold
652  * \param def Expected default value the parameter can hold
653  * \param units_ A string to describe what units to represent the variable with
654  * \param desc_ A string to describing the variable.
655  * \param minpriv_ The required minimum privilege level
656  * \param display_ The display mask
657  */
658  rpcbasic_register_set(const std::string& block_alias,
659  const char* functionbase,
660  void (T::*function)(Tto),
661  const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def,
662  const char* units_ = "",
663  const char* desc_ = "",
664  priv_lvl_t minpriv_ = RPC_PRIVLVL_MIN,
665  DisplayType display_ = DISPNULL)
666  {
667  d_min = min;
668  d_max = max;
669  d_def = def;
670  d_units = units_;
671  d_desc = desc_;
672  d_minpriv = minpriv_;
673  d_display = display_;
674  d_object = dynamic_cast<T*>(global_block_registry.block_lookup(pmt::intern(block_alias)).get());
675 #ifdef RPCSERVER_ENABLED
677  extractor(new rpcbasic_extractor<T,Tto>(d_object, function),
678  minpriv_, std::string(units_),
679  display_, std::string(desc_), min, max, def);
680  std::ostringstream oss(std::ostringstream::out);
681  oss << block_alias << "::" << functionbase;
682  d_id = oss.str();
683  //std::cerr << "REGISTERING SET: " << d_id << " " << desc_ << std::endl;
684  rpcmanager::get()->i()->registerConfigureCallback(d_id, extractor);
685 #endif
686  }
687 
688  /*!
689  * \brief Adds the ability to set the variable over ControlPort.
690  *
691  * \details
692  *
693  * Allows us to add non gr::block related objects to
694  * ControlPort. Instead of using the block's alias, we give it a \p
695  * name and the actual pointer to the object as \p obj. We just need
696  * to make sure that the pointer to this object is always valid.
697  *
698  * \param name Name of the object being set up for ControlPort access
699  * \param functionbase The name of the function that we'll access over ControlPort
700  * \param obj A pointer to the object itself
701  * \param function A function pointer to the real function accessed when called
702  * something like: &[block class]\::set_[variable]()
703  * \param min Expected minimum value the parameter can hold
704  * \param max Expected maximum value the parameter can hold
705  * \param def Expected default value the parameter can hold
706  * \param units_ A string to describe what units to represent the variable with
707  * \param desc_ A string to describing the variable.
708  * \param minpriv_ The required minimum privilege level
709  * \param display_ The display mask
710  */
711  rpcbasic_register_set(const std::string& name,
712  const char* functionbase,
713  T* obj,
714  void (T::*function)(Tto),
715  const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def,
716  const char* units_ = "",
717  const char* desc_ = "",
718  priv_lvl_t minpriv_ = RPC_PRIVLVL_MIN,
719  DisplayType display_ = DISPNULL)
720  {
721  d_min = min;
722  d_max = max;
723  d_def = def;
724  d_units = units_;
725  d_desc = desc_;
726  d_minpriv = minpriv_;
727  d_display = display_;
728  d_object = obj;
729 #ifdef RPCSERVER_ENABLED
731  extractor(new rpcbasic_extractor<T,Tto>(d_object, function),
732  minpriv_, std::string(units_),
733  display_, std::string(desc_), min, max, def);
734  std::ostringstream oss(std::ostringstream::out);
735  oss << name << "::" << functionbase;
736  d_id = oss.str();
737  //std::cerr << "REGISTERING SET: " << d_id << " " << desc_ << std::endl;
738  rpcmanager::get()->i()->registerConfigureCallback(d_id, extractor);
739 #endif
740  }
741 
743  {
744 #ifdef RPCSERVER_ENABLED
746 #endif
747  }
748 
749 
750  pmt::pmt_t min() const { return d_min; }
751  pmt::pmt_t max() const { return d_max; }
752  pmt::pmt_t def() const { return d_def; }
753  std::string units() const { return d_units; }
754  std::string description() const { return d_desc; }
755  priv_lvl_t privilege_level() const { return d_minpriv; }
756  DisplayType default_display() const { return d_display; }
757 
758  void set_min(pmt::pmt_t p) { d_min = p; }
759  void set_max(pmt::pmt_t p) { d_max = p; }
760  void set_def(pmt::pmt_t p) { d_def = p; }
761  void units(std::string u) { d_units = u; }
762  void description(std::string d) { d_desc = d; }
763  void privilege_level(priv_lvl_t p) { d_minpriv = p; }
764  void default_display(DisplayType d) { d_display = d; }
765 
766 private:
767  std::string d_id;
768  pmt::pmt_t d_min, d_max, d_def;
769  std::string d_units, d_desc;
770  priv_lvl_t d_minpriv;
771  DisplayType d_display;
772  T *d_object;
773 };
774 
775 
776 /*********************************************************************
777  * RPC Register Trigger Classes
778  ********************************************************************/
779 
780 /*!
781  * \brief Registers a 'trigger' function to trigger an action over
782  * ControlPort.
783  *
784  * \details
785  *
786  * This class allows us to set up triggered events or function calls
787  * over ControlPort. When used from a ControlPort client, the \p
788  * function established here will be activated. Generally, this is
789  * meant to enable some kind of trigger or action that a block or
790  * object will perform, such as a reset, start, stop, etc.
791  *
792  * Simpler than the rpcbasic_register_set class, the constructor here
793  * only takes a few parameters, mostly because there is not actual
794  * variable associated with these function calls. It takes in the
795  * information to set up the pointer to the object that has the \p
796  * function, a ControlPort name (\p functionbase) for the triggered
797  * action, a description (\p desc_), and a privilege level (\p
798  * minpriv_).
799  */
800 template<typename T>
802 {
803  /*!
804  * \brief Adds the ability to trigger a function over ControlPort.
805  *
806  * \details
807  *
808  * This constructor is specifically for gr::block's to use to add
809  * trigger functions to ControlPort. Generally meant to be used
810  * in gr::block::setup_rpc.
811  *
812  * Uses the block's alias to create the ControlPort interface. This
813  * alias is cross-referenced by the global_block_registry (static
814  * variable of type gr::block_registry) to get the pointer to the
815  * block.
816  *
817  * \param block_alias Block's alias; use alias() to get it from the block.
818  * \param functionbase The name of the function that we'll access over ControlPort
819  * \param function A function pointer to the real function accessed when called
820  * something like: &[block class]\::set_[variable]
821  * \param desc_ A string to describing the variable.
822  * \param minpriv_ The required minimum privilege level
823  */
824  rpcbasic_register_trigger(const std::string& block_alias,
825  const char* functionbase,
826  void (T::*function)(),
827  const char* desc_ = "",
828  priv_lvl_t minpriv_ = RPC_PRIVLVL_MIN)
829  {
830  d_desc = desc_;
831  d_minpriv = minpriv_;
832  d_object = dynamic_cast<T*>(global_block_registry.block_lookup(pmt::intern(block_alias)).get());
833 #ifdef RPCSERVER_ENABLED
835  extractor(new rpcbasic_extractor<T,void>(d_object, function),
836  minpriv_, std::string(desc_));
837  std::ostringstream oss(std::ostringstream::out);
838  oss << block_alias << "::" << functionbase;
839  d_id = oss.str();
840  //std::cerr << "REGISTERING TRIGGER: " << d_id << " " << desc_ << std::endl;
841  rpcmanager::get()->i()->registerConfigureCallback(d_id, extractor);
842 #endif
843  }
844 
845  /*!
846  * \brief Adds the ability to trigger a function over ControlPort.
847  *
848  * \details
849  *
850  * Allows us to add non gr::block related objects to
851  * ControlPort. Instead of using the block's alias, we give it a \p
852  * name and the actual pointer to the object as \p obj. We just need
853  * to make sure that the pointer to this object is always valid.
854  *
855  * \param name Name of the object being set up for ControlPort access
856  * \param functionbase The name of the function that we'll access over ControlPort
857  * \param obj A pointer to the object itself
858  * \param function A function pointer to the real function accessed when called
859  * something like: &[block class]\::set_[variable]
860  * \param desc_ A string to describing the variable.
861  * \param minpriv_ The required minimum privilege level
862  */
863  rpcbasic_register_trigger(const std::string& name,
864  const char* functionbase,
865  T* obj,
866  void (T::*function)(),
867  const char* desc_ = "",
868  priv_lvl_t minpriv_ = RPC_PRIVLVL_MIN)
869  {
870  d_desc = desc_;
871  d_minpriv = minpriv_;
872  d_object = obj;
873 #ifdef RPCSERVER_ENABLED
875  extractor(new rpcbasic_extractor<T,void>(d_object, function),
876  minpriv_, std::string(desc_));
877  std::ostringstream oss(std::ostringstream::out);
878  oss << name << "::" << functionbase;
879  d_id = oss.str();
880  //std::cerr << "REGISTERING TRIGGER: " << d_id << " " << desc_ << std::endl;
881  rpcmanager::get()->i()->registerConfigureCallback(d_id, extractor);
882 #endif
883  }
884 
886  {
887 #ifdef RPCSERVER_ENABLED
889 #endif
890  }
891 
892 
893  std::string description() const { return d_desc; }
894  priv_lvl_t privilege_level() const { return d_minpriv; }
895 
896  void description(std::string d) { d_desc = d; }
897  void privilege_level(priv_lvl_t p) { d_minpriv = p; }
898 
899 private:
900  std::string d_id;
901  std::string d_desc;
902  priv_lvl_t d_minpriv;
903  T *d_object;
904 };
905 
906 
907 
908 /*********************************************************************
909  * RPC Register Get Classes
910  ********************************************************************/
911 
912 /*!
913  * \brief Registers a 'get' function to get a parameter over
914  * ControlPort.
915  *
916  * \details
917  *
918  * This class allows us to remotely get a value or parameter of the
919  * block over ControlPort. The get occurs by calling a getter accessor
920  * function of the class, usually [variable](), which is passed in
921  * as \p function.
922  *
923  * We can set the (expected) minimum (\p min), maximum (\p max), and
924  * default (\p def) of the variables we will get. These values are not
925  * enforced, however, but can be useful for setting up graphs and
926  * other ways of bounding the data.
927  *
928  * This class also allows us to provide information to the user about
929  * the variable, such as an appropriate unit (\p units_) as well as a
930  * description (\p desc_) about what the variable does.
931  *
932  * The privilege (\p minpriv_) level is the minimum privilege level a
933  * remote must identify with to be able to call this function.
934  *
935  * We also provide display hints (\p display_), which can be used by
936  * the ControlPort client application to know how to best display or
937  * even print the data. This is a mask of options for variables set in
938  * rpccallbackregister_base.h. The mask is defined by one of the
939  * "DisplayType Plotting Types" and or'd with any of the "DisplayType
940  * Options" features. See "Display Options" in \ref page_ctrlport for
941  * details.
942  */
943 template<typename T, typename Tfrom>
945 {
946 public:
947 
948  /*!
949  * \brief Adds the ability to get the variable over ControlPort.
950  *
951  * \details
952  *
953  * This constructor is specifically for gr::block's to use to add
954  * gettable variables to ControlPort. Generally meant to be used
955  * in gr::block::setup_rpc.
956  *
957  * Uses the block's alias to create the ControlPort interface. This
958  * alias is cross-referenced by the global_block_registry (static
959  * variable of type gr::block_registry) to get the pointer to the
960  * block.
961  *
962  * \param block_alias Block's alias; use alias() to get it from the block.
963  * \param functionbase The name of the function that we'll access over ControlPort
964  * \param function A function pointer to the real function accessed when called
965  * something like: &[block class]\::[variable]()
966  * \param min Expected minimum value the parameter can hold
967  * \param max Expected maximum value the parameter can hold
968  * \param def Expected default value the parameter can hold
969  * \param units_ A string to describe what units to represent the variable with
970  * \param desc_ A string to describing the variable.
971  * \param minpriv_ The required minimum privilege level
972  * \param display_ The display mask
973  */
974  rpcbasic_register_get(const std::string& block_alias,
975  const char* functionbase,
976  Tfrom (T::*function)(),
977  const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def,
978  const char* units_ = "",
979  const char* desc_ = "",
980  priv_lvl_t minpriv_ = RPC_PRIVLVL_MIN,
981  DisplayType display_ = DISPNULL)
982  {
983  d_min = min;
984  d_max = max;
985  d_def = def;
986  d_units = units_;
987  d_desc = desc_;
988  d_minpriv = minpriv_;
989  d_display = display_;
990  d_object = dynamic_cast<T*>(global_block_registry.block_lookup(pmt::intern(block_alias)).get());
991 #ifdef RPCSERVER_ENABLED
993  inserter(new rpcbasic_inserter<T,Tfrom>(d_object, function),
994  minpriv_, std::string(units_), display_, std::string(desc_), min, max, def);
995  std::ostringstream oss(std::ostringstream::out);
996  oss << block_alias << "::" << functionbase;
997  d_id = oss.str();
998  //std::cerr << "REGISTERING GET: " << d_id << " " << desc_ << std::endl;
999  rpcmanager::get()->i()->registerQueryCallback(d_id, inserter);
1000 #endif
1001  }
1002 
1003 
1004  /*!
1005  * \brief Same as rpcbasic_register_get::rpcbasic_register_get that allows using
1006  * '[variable]() const' getter functions.
1007  */
1008  rpcbasic_register_get(const std::string& block_alias,
1009  const char* functionbase,
1010  Tfrom (T::*function)() const,
1011  const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def,
1012  const char* units_ = "",
1013  const char* desc_ = "",
1014  priv_lvl_t minpriv_ = RPC_PRIVLVL_MIN,
1015  DisplayType display_ = DISPNULL)
1016  {
1017  d_min = min;
1018  d_max = max;
1019  d_def = def;
1020  d_units = units_;
1021  d_desc = desc_;
1022  d_minpriv = minpriv_;
1023  d_display = display_;
1024  d_object = dynamic_cast<T*>(global_block_registry.block_lookup(pmt::intern(block_alias)).get());
1025 #ifdef RPCSERVER_ENABLED
1027  inserter(new rpcbasic_inserter<T,Tfrom>(d_object, (Tfrom (T::*)())function),
1028  minpriv_, std::string(units_), display_, std::string(desc_), min, max, def);
1029  std::ostringstream oss(std::ostringstream::out);
1030  oss << block_alias << "::" << functionbase;
1031  d_id = oss.str();
1032  //std::cerr << "REGISTERING GET CONST: " << d_id << " " << desc_ << " " << display_ << std::endl;
1033  rpcmanager::get()->i()->registerQueryCallback(d_id, inserter);
1034 #endif
1035  }
1036 
1037 
1038  /*!
1039  * \brief Adds the ability to get the variable over ControlPort.
1040  *
1041  * \details
1042  *
1043  * Allows us to add non gr::block related objects to
1044  * ControlPort. Instead of using the block's alias, we give it a \p
1045  * name and the actual pointer to the object as \p obj. We just need
1046  * to make sure that the pointer to this object is always valid.
1047  *
1048  * \param name Name of the object being set up for ControlPort access
1049  * \param functionbase The name of the function that we'll access over ControlPort
1050  * \param obj A pointer to the object itself
1051  * \param function A function pointer to the real function accessed when called
1052  * something like: &[block class]\::set_[variable]()
1053  * \param min Expected minimum value the parameter can hold
1054  * \param max Expected maximum value the parameter can hold
1055  * \param def Expected default value the parameter can hold
1056  * \param units_ A string to describe what units to represent the variable with
1057  * \param desc_ A string to describing the variable.
1058  * \param minpriv_ The required minimum privilege level
1059  * \param display_ The display mask
1060  */
1061  rpcbasic_register_get(const std::string& name,
1062  const char* functionbase,
1063  T* obj,
1064  Tfrom (T::*function)(),
1065  const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def,
1066  const char* units_ = "",
1067  const char* desc_ = "",
1068  priv_lvl_t minpriv_ = RPC_PRIVLVL_MIN,
1069  DisplayType display_ = DISPNULL)
1070  {
1071  d_min = min;
1072  d_max = max;
1073  d_def = def;
1074  d_units = units_;
1075  d_desc = desc_;
1076  d_minpriv = minpriv_;
1077  d_display = display_;
1078  d_object = obj;
1079 #ifdef RPCSERVER_ENABLED
1081  inserter(new rpcbasic_inserter<T,Tfrom>(d_object, function),
1082  minpriv_, std::string(units_), display_, std::string(desc_), min, max, def);
1083  std::ostringstream oss(std::ostringstream::out);
1084  oss << name << "::" << functionbase;
1085  d_id = oss.str();
1086  //std::cerr << "REGISTERING GET: " << d_id << " " << desc_ << std::endl;
1087  rpcmanager::get()->i()->registerQueryCallback(d_id, inserter);
1088 #endif
1089  }
1090 
1091 
1092  /*!
1093  * \brief Same as above that allows using '[variable]() const'
1094  * getter functions.
1095  */
1096  rpcbasic_register_get(const std::string& name,
1097  const char* functionbase,
1098  T* obj,
1099  Tfrom (T::*function)() const,
1100  const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def,
1101  const char* units_ = "",
1102  const char* desc_ = "",
1103  priv_lvl_t minpriv_ = RPC_PRIVLVL_MIN,
1104  DisplayType display_ = DISPNULL)
1105  {
1106  d_min = min;
1107  d_max = max;
1108  d_def = def;
1109  d_units = units_;
1110  d_desc = desc_;
1111  d_minpriv = minpriv_;
1112  d_display = display_;
1113  d_object = obj;
1114 #ifdef RPCSERVER_ENABLED
1116  inserter(new rpcbasic_inserter<T,Tfrom>(d_object, (Tfrom (T::*)())function),
1117  minpriv_, std::string(units_), display_, std::string(desc_), min, max, def);
1118  std::ostringstream oss(std::ostringstream::out);
1119  oss << name << "::" << functionbase;
1120  d_id = oss.str();
1121  //std::cerr << "REGISTERING GET CONST: " << d_id << " " << desc_ << " " << display_ << std::endl;
1122  rpcmanager::get()->i()->registerQueryCallback(d_id, inserter);
1123 #endif
1124  }
1125 
1127  {
1128 #ifdef RPCSERVER_ENABLED
1130 #endif
1131  }
1132 
1133  pmt::pmt_t min() const { return d_min; }
1134  pmt::pmt_t max() const { return d_max; }
1135  pmt::pmt_t def() const { return d_def; }
1136  std::string units() const { return d_units; }
1137  std::string description() const { return d_desc; }
1138  priv_lvl_t privilege_level() const { return d_minpriv; }
1139  DisplayType default_display() const { return d_display; }
1140 
1141  void set_min(pmt::pmt_t p) { d_min = p; }
1142  void set_max(pmt::pmt_t p) { d_max = p; }
1143  void set_def(pmt::pmt_t p) { d_def = p; }
1144  void units(std::string u) { d_units = u; }
1145  void description(std::string d) { d_desc = d; }
1146  void privilege_level(priv_lvl_t p) { d_minpriv = p; }
1147  void default_display(DisplayType d) { d_display = d; }
1148 
1149 private:
1150  std::string d_id;
1151  pmt::pmt_t d_min, d_max, d_def;
1152  std::string d_units, d_desc;
1153  priv_lvl_t d_minpriv;
1154  DisplayType d_display;
1155  T *d_object;
1156 };
1157 
1158 
1159 
1160 /*********************************************************************
1161  * RPC Register Variable Classes
1162  ********************************************************************/
1163 
1164 /*!
1165  * \brief Registers a read-only function to get a parameter over ControlPort.
1166  *
1167  * \details
1168  *
1169  * This class allows us to remotely get a value or parameter of the
1170  * block over ControlPort. Unlike the rpcbasic_register_get class,
1171  * this version is passed the variable directly and establishes a
1172  * getter for us, so there is no need to have a getter function
1173  * already in the object.
1174  *
1175  * This version is for read-only get access.
1176  *
1177  * We can set the (expected) minimum (\p min), maximum (\p max), and
1178  * default (\p def) of the variables we will get. These values are not
1179  * enforced, however, but can be useful for setting up graphs and
1180  * other ways of bounding the data.
1181  *
1182  * This class also allows us to provide information to the user about
1183  * the variable, such as an appropriate unit (\p units_) as well as a
1184  * description (\p desc_) about what the variable does.
1185  *
1186  * The privilege (\p minpriv_) level is the minimum privilege level a
1187  * remote must identify with to be able to call this function.
1188  *
1189  * We also provide display hints (\p display_), which can be used by
1190  * the ControlPort client application to know how to best display or
1191  * even print the data. This is a mask of options for variables set in
1192  * rpccallbackregister_base.h. The mask is defined by one of the
1193  * "DisplayType Plotting Types" and or'd with any of the "DisplayType
1194  * Options" features. See "Display Options" in \ref page_ctrlport for
1195  * details.
1196  */
1197 template<typename Tfrom>
1199  : public rpcbasic_base
1200 {
1201 protected:
1203  Tfrom *d_variable;
1204  Tfrom get() { return *d_variable; }
1205 
1206 public:
1207 
1208  void setptr(Tfrom* _variable)
1209  {
1211  }
1212 
1213  /*! Empty constructor which should never be called but needs to
1214  * exist for ues in varous STL data structures
1215  */
1217  d_rpc_reg("FAIL", "FAIL", this, &rpcbasic_register_variable::get,
1218  pmt::PMT_NIL, pmt::PMT_NIL, pmt::PMT_NIL, DISPNULL,
1219  "FAIL", "FAIL", RPC_PRIVLVL_MIN),
1220  d_variable(NULL)
1221  {
1222  throw std::runtime_error("ERROR: rpcbasic_register_variable called with no args. If this happens, someone has tried to use rpcbasic_register_variable incorrectly.");
1223  };
1224 
1225  /*!
1226  * \brief Adds the ability to get the variable over ControlPort.
1227  *
1228  * \details
1229  *
1230  * Creates a new getter accessor function to read \p variable.
1231  *
1232  * \param namebase Name of the object being set up for ControlPort access
1233  * \param functionbase The name of the function that we'll access over ControlPort
1234  * \param variable A pointer to the variable, possibly as a member of a class
1235  * \param min Expected minimum value the parameter can hold
1236  * \param max Expected maximum value the parameter can hold
1237  * \param def Expected default value the parameter can hold
1238  * \param units_ A string to describe what units to represent the variable with
1239  * \param desc_ A string to describing the variable.
1240  * \param minpriv_ The required minimum privilege level
1241  * \param display_ The display mask
1242  */
1243  rpcbasic_register_variable(const std::string& namebase,
1244  const char* functionbase,
1245  Tfrom *variable,
1246  const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def,
1247  const char* units_ = "",
1248  const char* desc_ = "",
1249  priv_lvl_t minpriv_ = RPC_PRIVLVL_MIN,
1250  DisplayType display_ = DISPNULL) :
1251  d_rpc_reg(namebase, functionbase, this, &rpcbasic_register_variable::get,
1252  min, max, def, units_, desc_, minpriv_, display_),
1253  d_variable(variable)
1254  {
1255  //std::cerr << "REGISTERING VAR: " << " " << desc_ << std::endl;
1256  }
1257 };
1258 
1259 
1260 /*!
1261  * \brief Registers a read/write function to get and set a parameter
1262  * over ControlPort.
1263  *
1264  * \details
1265  *
1266  * This class allows us to remotely get and/or set a value or
1267  * parameter of the block over ControlPort. Unlike the
1268  * rpcbasic_register_get class, this version is passed the variable
1269  * directly and establishes a getter for us, so there is no need to
1270  * have a getter function already in the object.
1271  *
1272  * This version establishes both get and set functions and so provides
1273  * read/write access to the variable.
1274  *
1275  * We can set the (expected) minimum (\p min), maximum (\p max), and
1276  * default (\p def) of the variables we will get. These values are not
1277  * enforced, however, but can be useful for setting up graphs and
1278  * other ways of bounding the data.
1279  *
1280  * This class also allows us to provide information to the user about
1281  * the variable, such as an appropriate unit (\p units_) as well as a
1282  * description (\p desc_) about what the variable does.
1283  *
1284  * The privilege (\p minpriv_) level is the minimum privilege level a
1285  * remote must identify with to be able to call this function.
1286  *
1287  * We also provide display hints (\p display_), which can be used by
1288  * the ControlPort client application to know how to best display or
1289  * even print the data. This is a mask of options for variables set in
1290  * rpccallbackregister_base.h. The mask is defined by one of the
1291  * "DisplayType Plotting Types" and or'd with any of the "DisplayType
1292  * Options" features. See "Display Options" in \ref page_ctrlport for
1293  * details.
1294  */
1295 template<typename Tfrom>
1297  : public rpcbasic_register_variable<Tfrom>
1298 {
1299 private:
1301 
1302 public:
1303  /*! Empty constructor which should never be called but needs to
1304  * exist for ues in varous STL data structures.
1305  */
1307  d_rpc_regset("FAIL", "FAIL", this,
1309  pmt::PMT_NIL, pmt::PMT_NIL, pmt::PMT_NIL,
1310  DISPNULL, "FAIL", "FAIL", RPC_PRIVLVL_MIN)
1311  {
1312  throw std::runtime_error("ERROR: rpcbasic_register_variable_rw called with no args. if this happens someone used rpcbasic_register_variable_rw incorrectly.\n");
1313  };
1314 
1315  void set(Tfrom _variable)
1316  {
1318  }
1319 
1320  /*!
1321  * \brief Adds the ability to set and get the variable over ControlPort.
1322  *
1323  * \details
1324  *
1325  * Creates new getter and setter accessor functions to read and write \p variable.
1326  *
1327  * \param namebase Name of the object being set up for ControlPort access
1328  * \param functionbase The name of the function that we'll access over ControlPort
1329  * \param variable A pointer to the variable, possibly as a member of a class
1330  * \param min Expected minimum value the parameter can hold
1331  * \param max Expected maximum value the parameter can hold
1332  * \param def Expected default value the parameter can hold
1333  * \param units_ A string to describe what units to represent the variable with
1334  * \param desc_ A string to describing the variable.
1335  * \param minpriv The required minimum privilege level
1336  * \param display_ The display mask
1337  */
1339  const std::string& namebase,
1340  const char* functionbase,
1341  Tfrom *variable,
1342  const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def,
1343  const char* units_ = "",
1344  const char* desc_ = "",
1345  priv_lvl_t minpriv = RPC_PRIVLVL_MIN,
1346  DisplayType display_=DISPNULL)
1347  : rpcbasic_register_variable<Tfrom>(namebase, functionbase, variable,
1348  min, max, def, units_, desc_),
1349  d_rpc_regset(namebase, functionbase, this,
1351  min, max, def, units_, desc_, minpriv, display_)
1352  {
1353  // no action
1354  }
1355 };
1356 
1357 
1358 
1359 
1360 #endif
Definition: rpcregisterhelpers.h:585
virtual void registerConfigureCallback(const std::string &id, const configureCallback_t callback)=0
rpcbasic_register_get< rpcbasic_register_variable< Tfrom >, Tfrom > d_rpc_reg
Definition: rpcregisterhelpers.h:1202
Definition: rpccallbackregister_base.h:80
~rpcbasic_register_trigger()
Definition: rpcregisterhelpers.h:885
pmt::pmt_t retrieve()
send msg to msg_producer
Definition: rpcregisterhelpers.h:470
pmt::pmt_t retrieve()
send msg to msg_producer
Definition: rpcregisterhelpers.h:372
Tfrom get()
Definition: rpcregisterhelpers.h:1204
PMT_API pmt_t from_complex(double re, double im)
Return a complex number constructed of the given real and imaginary parts.
rpcbasic_inserter(T *source, std::complex< double >(T::*func)())
Definition: rpcregisterhelpers.h:560
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:1096
rpcbasic_inserter(T *source, std::vector< signed char >(T::*func)())
Definition: rpcregisterhelpers.h:391
PMT_API pmt_t init_s32vector(size_t k, const int32_t *data)
rpcbasic_register_variable()
Definition: rpcregisterhelpers.h:1216
std::string units() const
Definition: rpcregisterhelpers.h:753
pmt::pmt_t retrieve()
send msg to msg_producer
Definition: rpcregisterhelpers.h:495
pmt::pmt_t def() const
Definition: rpcregisterhelpers.h:752
void set(Tfrom _variable)
Definition: rpcregisterhelpers.h:1315
PMT_API std::complex< double > to_complex(pmt_t z)
rpcbasic_inserter(T *source, std::vector< int >(T::*func)())
Definition: rpcregisterhelpers.h:441
T * _source
Definition: rpcregisterhelpers.h:116
rpcbasic_register_variable_rw()
Definition: rpcregisterhelpers.h:1306
pmt::pmt_t retrieve()
send msg to msg_producer
Definition: rpcregisterhelpers.h:113
rpcbasic_extractor(T *source, void(T::*func)(double))
Definition: rpcregisterhelpers.h:211
float min(float a, float b)
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:658
rpcbasic_extractor(T *source, void(T::*func)(float))
Definition: rpcregisterhelpers.h:229
rpcbasic_inserter(T *source, std::vector< short >(T::*func)() const)
Definition: rpcregisterhelpers.h:412
PMT_API pmt_t init_u8vector(size_t k, const uint8_t *data)
Templated parent class for registering a ControlPort Extractor.
Definition: rpcregisterhelpers.h:89
void post(pmt::pmt_t which_port, pmt::pmt_t msg)
send msg to msg_accepter on port which_port
Definition: rpcregisterhelpers.h:287
rpcbasic_inserter(T *source, std::complex< float >(T::*func)())
Definition: rpcregisterhelpers.h:537
rpcbasic_extractor(T *source, void(T::*func)())
Definition: rpcregisterhelpers.h:158
Tfrom * d_variable
Definition: rpcregisterhelpers.h:1203
Registers a read/write function to get and set a parameter over ControlPort.
Definition: rpcregisterhelpers.h:1296
Base class for registering a ControlPort function.
Definition: rpcregisterhelpers.h:576
rpcbasic_inserter(T *source, std::vector< short >(T::*func)())
Definition: rpcregisterhelpers.h:416
void post(pmt::pmt_t which_port, pmt::pmt_t msg)
send msg to msg_accepter on port which_port
Definition: rpcregisterhelpers.h:345
PMT_API pmt_t init_s8vector(size_t k, const int8_t *data)
void description(std::string d)
Definition: rpcregisterhelpers.h:896
Virtual base class that produces messages.
Definition: msg_producer.h:35
T * _source
Definition: rpcregisterhelpers.h:63
pmt::pmt_t retrieve()
send msg to msg_producer
Definition: rpcregisterhelpers.h:541
rpcbasic_inserter(T *source, std::vector< uint8_t >(T::*func)())
Definition: rpcregisterhelpers.h:514
void(T::* _func)(Tto)
Definition: rpcregisterhelpers.h:64
std::string description() const
Definition: rpcregisterhelpers.h:754
priv_lvl_t
Definition: rpccallbackregister_base.h:46
void default_display(DisplayType d)
Definition: rpcregisterhelpers.h:764
void privilege_level(priv_lvl_t p)
Definition: rpcregisterhelpers.h:1146
void post(pmt::pmt_t which_port, pmt::pmt_t msg)
send msg to msg_accepter on port which_port
Definition: rpcregisterhelpers.h:197
unsigned char uint8_t
Definition: stdint.h:78
pmt::pmt_t max() const
Definition: rpcregisterhelpers.h:751
void units(std::string u)
Definition: rpcregisterhelpers.h:1144
Base class for registering a ControlPort Inserter. Produces a message.
Definition: rpcregisterhelpers.h:107
void post(pmt::pmt_t which_port, pmt::pmt_t msg)
send msg to msg_accepter on port which_port
Definition: rpcregisterhelpers.h:215
void post(pmt::pmt_t which_port, pmt::pmt_t msg)
send msg to msg_accepter on port which_port
Definition: rpcregisterhelpers.h:58
void post(pmt::pmt_t which_port, pmt::pmt_t msg)
send msg to msg_accepter on port which_port
Definition: rpcregisterhelpers.h:179
PMT_API pmt_t intern(const std::string &s)
Alias for pmt_string_to_symbol.
rpcbasic_extractor(T *source, void(T::*func)(std::string))
Definition: rpcregisterhelpers.h:341
virtual void unregisterConfigureCallback(const std::string &id)=0
pmt::pmt_t retrieve()
send msg to msg_producer
Definition: rpcregisterhelpers.h:395
rpcbasic_extractor(T *source, void(T::*func)(Tto))
Definition: rpcregisterhelpers.h:92
pmt::pmt_t retrieve()
send msg to msg_producer
Definition: rpcregisterhelpers.h:518
rpcbasic_extractor(T *source, void(T::*func)(char))
Definition: rpcregisterhelpers.h:175
PMT_API const std::string symbol_to_string(const pmt_t &sym)
static int count
Definition: rpcregisterhelpers.h:579
void set_max(pmt::pmt_t p)
Definition: rpcregisterhelpers.h:1142
PMT_API bool to_bool(pmt_t val)
Return true if val is pmt::True, return false when val is pmt::PMT_F,.
shared_ptr documentation stub
Definition: shared_ptr_docstub.h:15
rpcbasic_inserter(T *source, uint64_t(T::*func)())
Definition: rpcregisterhelpers.h:368
Definition: rpccallbackregister_base.h:48
Tfrom(T::* _func)()
Definition: rpcregisterhelpers.h:117
rpcbasic_extractor(T *source, void(T::*func)(long))
Definition: rpcregisterhelpers.h:247
pmt::pmt_t retrieve()
send msg to msg_producer
Definition: rpcregisterhelpers.h:138
Registers a 'get' function to get a parameter over ControlPort.
Definition: rpcregisterhelpers.h:944
virtual void registerQueryCallback(const std::string &id, const queryCallback_t callback)=0
void privilege_level(priv_lvl_t p)
Definition: rpcregisterhelpers.h:763
Templated parent class for registering a ControlPort Inserter.
Definition: rpcregisterhelpers.h:126
pmt::pmt_t retrieve()
send msg to msg_producer
Definition: rpcregisterhelpers.h:445
PMT_API pmt_t from_uint64(uint64_t x)
Return the pmt value that represents the uint64 x.
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:1338
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:711
virtual ~rpcbasic_base()
Definition: rpcregisterhelpers.h:589
void set_def(pmt::pmt_t p)
Definition: rpcregisterhelpers.h:1143
~rpcextractor_base()
Definition: rpcregisterhelpers.h:74
priv_lvl_t privilege_level() const
Definition: rpcregisterhelpers.h:1138
rpcbasic_extractor(T *source, void(T::*func)(std::complex< double >))
Definition: rpcregisterhelpers.h:322
void post(pmt::pmt_t which_port, pmt::pmt_t msg)
send msg to msg_accepter on port which_port
Definition: rpcregisterhelpers.h:233
std::string description() const
Definition: rpcregisterhelpers.h:893
virtual void unregisterQueryCallback(const std::string &id)=0
priv_lvl_t privilege_level() const
Definition: rpcregisterhelpers.h:894
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:1243
rpcinserter_base(T *source, Tfrom(T::*func)())
Definition: rpcregisterhelpers.h:110
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:1061
Base class for registering a ControlPort Extractor. Acts as a message acceptor.
Definition: rpcregisterhelpers.h:50
T * _source
Definition: rpcregisterhelpers.h:81
rpcbasic_extractor(T *source, void(T::*func)(short))
Definition: rpcregisterhelpers.h:193
unsigned __int64 uint64_t
Definition: stdint.h:90
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:974
Virtual base class that accepts messages.
Definition: messages/msg_accepter.h:35
rpcbasic_inserter(T *source, uint64_t(T::*func)() const)
Definition: rpcregisterhelpers.h:364
void set_max(pmt::pmt_t p)
Definition: rpcregisterhelpers.h:759
PMT_API long to_long(pmt_t x)
Convert pmt to long if possible.
~rpcextractor_base()
Definition: rpcregisterhelpers.h:56
virtual rpcserver_base * i()=0
rpcextractor_base(T *source, void(T::*func)(Tto))
Definition: rpcregisterhelpers.h:54
PMT_API double to_double(pmt_t x)
Convert pmt to double if possible.
void setptr(Tfrom *_variable)
Definition: rpcregisterhelpers.h:1208
static rpcserver_booter_base * get()
rpcbasic_extractor(T *source, void(T::*func)(std::complex< float >))
Definition: rpcregisterhelpers.h:302
pmt::pmt_t max() const
Definition: rpcregisterhelpers.h:1134
#define PMT_NIL
Definition: pmt.h:252
rpcbasic_inserter(T *source, std::vector< float >(T::*func)())
Definition: rpcregisterhelpers.h:491
~rpcbasic_register_get()
Definition: rpcregisterhelpers.h:1126
pmt::pmt_t min() const
Definition: rpcregisterhelpers.h:1133
rpcbasic_inserter(T *source, std::vector< int >(T::*func)() const)
Definition: rpcregisterhelpers.h:437
Registers a 'trigger' function to trigger an action over ControlPort.
Definition: rpcregisterhelpers.h:801
Registers a read-only function to get a parameter over ControlPort.
Definition: rpcregisterhelpers.h:1198
priv_lvl_t privilege_level() const
Definition: rpcregisterhelpers.h:755
const uint32_t DISPNULL
DisplayType Plotting types.
Definition: rpccallbackregister_base.h:32
rpcbasic_inserter(T *source, std::vector< float >(T::*func)() const)
Definition: rpcregisterhelpers.h:487
rpcextractor_base(T *source, void(T::*func)())
Definition: rpcregisterhelpers.h:72
void set_def(pmt::pmt_t p)
Definition: rpcregisterhelpers.h:760
PMT_API pmt_t init_f32vector(size_t k, const float *data)
VOLK_API void(kern.name) _manual($kern.arglist_full
Call into a specific implementation given by name.
DisplayType default_display() const
Definition: rpcregisterhelpers.h:756
pmt::pmt_t def() const
Definition: rpcregisterhelpers.h:1135
rpcbasic_inserter(T *source, std::vector< uint8_t >(T::*func)() const)
Definition: rpcregisterhelpers.h:510
pmt::pmt_t min() const
Definition: rpcregisterhelpers.h:750
void post(pmt::pmt_t which_port, pmt::pmt_t msg)
send msg to msg_accepter on port which_port
Definition: rpcregisterhelpers.h:269
void post(pmt::pmt_t which_port, pmt::pmt_t msg)
send msg to msg_accepter on port which_port
Definition: rpcregisterhelpers.h:76
Specialized extractor class to make calls to functions that do not take data (enable, reset, start, etc.).
Definition: rpcregisterhelpers.h:155
rpcinserter_base()
Definition: rpcregisterhelpers.h:111
pmt::pmt_t retrieve()
send msg to msg_producer
Definition: rpcregisterhelpers.h:564
PMT_API pmt_t init_c32vector(size_t k, const std::complex< float > *data)
std::string units() const
Definition: rpcregisterhelpers.h:1136
VOLK_API $kern pname $kern name
A function pointer to the dispatcher implementation.
GR_RUNTIME_API gr::block_registry global_block_registry
rpcbasic_inserter(T *source, std::complex< float >(T::*func)() const)
Definition: rpcregisterhelpers.h:533
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:1008
rpcbasic_inserter(T *source, Tfrom(T::*func)())
Definition: rpcregisterhelpers.h:134
void set_min(pmt::pmt_t p)
Definition: rpcregisterhelpers.h:758
rpcbasic_base()
Definition: rpcregisterhelpers.h:588
std::string description() const
Definition: rpcregisterhelpers.h:1137
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:863
void post(pmt::pmt_t which_port, pmt::pmt_t msg)
send msg to msg_accepter on port which_port
Definition: rpcregisterhelpers.h:251
void units(std::string u)
Definition: rpcregisterhelpers.h:761
~rpcbasic_register_set()
Definition: rpcregisterhelpers.h:742
void default_display(DisplayType d)
Definition: rpcregisterhelpers.h:1147
rpcbasic_inserter(T *source, std::complex< double >(T::*func)() const)
Definition: rpcregisterhelpers.h:556
void description(std::string d)
Definition: rpcregisterhelpers.h:762
boost::intrusive_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting). See http://www.boost.org/libs/smart_ptr/smart_ptr.htm
Definition: pmt.h:56
void set_min(pmt::pmt_t p)
Definition: rpcregisterhelpers.h:1141
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:824
rpc_register_base()
Definition: rpcregisterhelpers.h:578
rpcbasic_inserter(T *source, std::vector< std::complex< float > >(T::*func)() const)
Definition: rpcregisterhelpers.h:462
PMT_API pmt_t init_s16vector(size_t k, const int16_t *data)
rpcbasic_extractor(T *source, void(T::*func)(int))
Definition: rpcregisterhelpers.h:265
rpcbasic_inserter(T *source, Tfrom(T::*func)() const)
Definition: rpcregisterhelpers.h:130
void post(pmt::pmt_t which_port, pmt::pmt_t msg)
send msg to msg_accepter on port which_port
Definition: rpcregisterhelpers.h:306
basic_block_sptr block_lookup(pmt::pmt_t symbol)
void post(pmt::pmt_t which_port, pmt::pmt_t msg)
send msg to msg_accepter on port which_port
Definition: rpcregisterhelpers.h:162
rpcbasic_inserter(T *source, std::vector< signed char >(T::*func)() const)
Definition: rpcregisterhelpers.h:387
void description(std::string d)
Definition: rpcregisterhelpers.h:1145
pmt::pmt_t retrieve()
send msg to msg_producer
Definition: rpcregisterhelpers.h:420
static pmt_t mp(const std::string &s)
Make pmt symbol.
Definition: pmt_sugar.h:36
rpcbasic_extractor(T *source, void(T::*func)(bool))
Definition: rpcregisterhelpers.h:283
unsigned char bool
Definition: stdbool.h:30
void privilege_level(priv_lvl_t p)
Definition: rpcregisterhelpers.h:897
DisplayType default_display() const
Definition: rpcregisterhelpers.h:1139
void post(pmt::pmt_t which_port, pmt::pmt_t msg)
send msg to msg_accepter on port which_port
Definition: rpcregisterhelpers.h:326
rpcbasic_inserter(T *source, std::vector< std::complex< float > >(T::*func)())
Definition: rpcregisterhelpers.h:466
uint32_t DisplayType
Definition: rpccallbackregister_base.h:29
Registers a 'set' function to set a parameter over ControlPort.
Definition: rpcregisterhelpers.h:630