GNU Radio 3.7.1 C++ API
rpccallbackregister_base.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /* 
00003  * Copyright 2012 Free Software Foundation, Inc.
00004  *
00005  * This file is part of GNU Radio
00006  * 
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  *
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with GNU Radio; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street,
00020  * Boston, MA 02110-1301, USA.
00021  */
00022 
00023 #ifndef RPCCALLBACKREGISTER_BASE_H
00024 #define RPCCALLBACKREGISTER_BASE_H
00025 
00026 #include <gnuradio/messages/msg_accepter.h>
00027 #include <gnuradio/messages/msg_producer.h>
00028 
00029 typedef uint32_t DisplayType;
00030 
00031 // DisplayType Plotting types
00032 const uint32_t DISPNULL = 0x0000;
00033 const uint32_t DISPTIME = 0x0001;
00034 const uint32_t DISPXY   = 0x0002;
00035 const uint32_t DISPPSD  = 0x0004;
00036 const uint32_t DISPSPEC = 0x0008;
00037 const uint32_t DISPRAST = 0x0010;
00038 
00039 // DisplayType Options
00040 const uint32_t DISPOPTCPLX    = 0x0100;
00041 const uint32_t DISPOPTLOG     = 0x0200;
00042 const uint32_t DISPOPTSTEM    = 0x0400;
00043 const uint32_t DISPOPTSTRIP   = 0x0800;
00044 const uint32_t DISPOPTSCATTER = 0x1000;
00045 
00046 enum priv_lvl_t {
00047   RPC_PRIVLVL_ALL = 0,
00048   RPC_PRIVLVL_MIN = 9,
00049   RPC_PRIVLVL_NONE = 10
00050 };
00051 
00052 enum KnobType {
00053   KNOBBOOL,       KNOBCHAR,       KNOBINT,        KNOBFLOAT,
00054   KNOBDOUBLE,     KNOBSTRING,     KNOBLONG,       KNOBVECBOOL,
00055   KNOBCOMPLEX,    KNOBCOMPLEXD,
00056   KNOBVECCHAR,    KNOBVECINT,     KNOBVECFLOAT,   KNOBVECDOUBLE,
00057   KNOBVECSTRING,  KNOBVECLONG
00058 };
00059 
00060 struct callbackregister_base
00061 {
00062   struct callback_base_t
00063   {
00064   public:
00065     callback_base_t(const priv_lvl_t priv_, const std::string& units_,
00066                     const DisplayType display_, const std::string& desc_,
00067                     const pmt::pmt_t min_, const pmt::pmt_t max_, const pmt::pmt_t def)
00068       : priv(priv_), units(units_), description(desc_),
00069         min(min_), max(max_), defaultvalue(def), display(display_)
00070     {
00071     }
00072 
00073     priv_lvl_t  priv;
00074     std::string units, description;
00075     pmt::pmt_t  min, max, defaultvalue;
00076     DisplayType  display;
00077   };
00078 
00079   template<typename T, typename Tsptr>
00080   class callback_t : public callback_base_t
00081   {
00082   public:
00083     callback_t(T* callback_, priv_lvl_t priv_, 
00084                const std::string& units_, const DisplayType display_, const:: std::string& desc_,
00085                const pmt::pmt_t& min_, const pmt::pmt_t& max_, const pmt::pmt_t& def_) :
00086       callback_base_t(priv_, units_, display_, desc_, min_, max_, def_),
00087       callback(callback_)
00088     {
00089     }
00090 
00091     Tsptr callback;
00092   };
00093 
00094   typedef callback_t<gr::messages::msg_accepter, gr::messages::msg_accepter_sptr> configureCallback_t;
00095   typedef callback_t<gr::messages::msg_producer, gr::messages::msg_producer_sptr> queryCallback_t;
00096 
00097   callbackregister_base() {;}
00098   virtual ~callbackregister_base() {;}
00099 
00100   virtual void registerConfigureCallback(const std::string &id, const configureCallback_t callback) = 0;
00101   virtual void unregisterConfigureCallback(const std::string &id) = 0;
00102   virtual void registerQueryCallback(const std::string &id, const queryCallback_t callback) = 0;
00103   virtual void unregisterQueryCallback(const std::string &id) = 0;
00104 };
00105 
00106 #endif /* RPCCALLBACKREGISTER_BASE_H */