summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rondeau <tom@trondeau.com>2015-02-12 15:18:03 -0500
committerTom Rondeau <tom@trondeau.com>2015-04-02 15:38:56 -0700
commit7240a8bdbbaefb8d9bd4ff489393f1b703776f8f (patch)
tree03faa6e1477d550e07f458dcbdc6c513f47588f9
parentb1c1c6e0b2b9c1681ca2d528360aea9741d7a739 (diff)
controlport: working controlport server using thrift.
Still needs integration of running the thrift compiler for cpp and py in build system.
-rw-r--r--gnuradio-runtime/include/gnuradio/CMakeLists.txt3
-rw-r--r--gnuradio-runtime/include/gnuradio/rpcserver_selector.h3
-rw-r--r--gnuradio-runtime/include/gnuradio/rpcserver_thrift.h68
-rw-r--r--gnuradio-runtime/lib/controlport/CMakeLists.txt8
-rw-r--r--gnuradio-runtime/lib/controlport/rpcserver_booter_aggregator.cc3
-rw-r--r--gnuradio-runtime/lib/controlport/rpcserver_selector.cc5
-rw-r--r--gnuradio-runtime/lib/controlport/rpcserver_thrift.cc75
7 files changed, 95 insertions, 70 deletions
diff --git a/gnuradio-runtime/include/gnuradio/CMakeLists.txt b/gnuradio-runtime/include/gnuradio/CMakeLists.txt
index 3fc2fe7bd8..02b80ccb5c 100644
--- a/gnuradio-runtime/include/gnuradio/CMakeLists.txt
+++ b/gnuradio-runtime/include/gnuradio/CMakeLists.txt
@@ -80,7 +80,10 @@ install(FILES
rpcserver_base.h
rpcserver_booter_aggregator.h
rpcserver_booter_base.h
+ rpcserver_booter_thrift.h
rpcserver_selector.h
+ thrift_application_base.h
+ thrift_server_template.h
${CMAKE_CURRENT_BINARY_DIR}/logger.h
DESTINATION ${GR_INCLUDE_DIR}/gnuradio
COMPONENT "runtime_devel"
diff --git a/gnuradio-runtime/include/gnuradio/rpcserver_selector.h b/gnuradio-runtime/include/gnuradio/rpcserver_selector.h
index 8a14f78d99..1011911575 100644
--- a/gnuradio-runtime/include/gnuradio/rpcserver_selector.h
+++ b/gnuradio-runtime/include/gnuradio/rpcserver_selector.h
@@ -23,9 +23,10 @@
#ifndef RPCSERVER_SELECTOR
#define RPCSERVER_SELECTOR
-//#define RPCSERVER_ENABLED
+#define RPCSERVER_ENABLED
//#define RPCSERVER_ICE
+#define RPCSERVER_THRIFT
//#define RPCSERVER_ERLANG
//#define RPCSERVER_XMLRPC
diff --git a/gnuradio-runtime/include/gnuradio/rpcserver_thrift.h b/gnuradio-runtime/include/gnuradio/rpcserver_thrift.h
index 8bb7776928..d0dc069bd3 100644
--- a/gnuradio-runtime/include/gnuradio/rpcserver_thrift.h
+++ b/gnuradio-runtime/include/gnuradio/rpcserver_thrift.h
@@ -1,3 +1,4 @@
+/* -*- c++ -*- */
/*
* Copyright 2014 Free Software Foundation, Inc.
*
@@ -18,6 +19,7 @@
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
+
#ifndef RPCSERVER_THRIFT_H
#define RPCSERVER_THRIFT_H
@@ -47,17 +49,13 @@ public:
void registerQueryCallback(const std::string &id, const queryCallback_t callback);
void unregisterQueryCallback(const std::string &id);
- virtual void set(const GNURadio::KnobMap&);
-
- GNURadio::KnobMap get(const GNURadio::KnobIDList&);
-
- GNURadio::KnobMap getRe(const GNURadio::KnobIDList&);
-
- GNURadio::KnobPropMap properties(const GNURadio::KnobIDList&);
-
+ void setKnobs(const GNURadio::KnobMap&);
+ void getKnobs(GNURadio::KnobMap&, const GNURadio::KnobIDList&);
+ void getRe(GNURadio::KnobMap&, const GNURadio::KnobIDList&);
+ void properties(GNURadio::KnobPropMap&, const GNURadio::KnobIDList& knobs);
virtual void shutdown();
-private:
+ private:
typedef std::map<std::string, configureCallback_t> ConfigureCallbackMap_t;
ConfigureCallbackMap_t d_setcallbackmap;
@@ -65,9 +63,11 @@ private:
QueryCallbackMap_t d_getcallbackmap;
template<typename T, typename TMap> struct set_f
- : public std::unary_function<T,void> {
- set_f(TMap &_setcallbackmap, const priv_lvl_t &_cur_priv) :
- d_setcallbackmap(_setcallbackmap), cur_priv(_cur_priv) {
+ : public std::unary_function<T,void>
+ {
+ set_f(TMap &_setcallbackmap, const priv_lvl_t &_cur_priv)
+ : d_setcallbackmap(_setcallbackmap), cur_priv(_cur_priv)
+ {
;
}
@@ -80,8 +80,8 @@ private:
}
else {
std::cout << "Key " << p.first << " requires PRIVLVL <= "
- << iter->second.priv << " to set, currently at: "
- << cur_priv << std::endl;
+ << iter->second.priv << " to set, currently at: "
+ << cur_priv << std::endl;
}
}
else {
@@ -94,10 +94,10 @@ private:
};
template<typename T, typename TMap>
- struct get_f : public std::unary_function<T,void>
+ struct get_f : public std::unary_function<T,void>
{
get_f(TMap &_getcallbackmap, const priv_lvl_t &_cur_priv, GNURadio::KnobMap &_outknobs) :
- d_getcallbackmap(_getcallbackmap), cur_priv(_cur_priv), outknobs(_outknobs)
+ d_getcallbackmap(_getcallbackmap), cur_priv(_cur_priv), outknobs(_outknobs)
{}
void operator()(const T& p)
@@ -109,8 +109,8 @@ private:
}
else {
std::cout << "Key " << iter->first << " requires PRIVLVL: <= "
- << iter->second.priv << " to get, currently at: "
- << cur_priv << std::endl;
+ << iter->second.priv << " to get, currently at: "
+ << cur_priv << std::endl;
}
}
else {
@@ -127,10 +127,10 @@ private:
};
template<typename T, typename TMap, typename TKnobMap>
- struct get_all_f : public std::unary_function<T,void>
+ struct get_all_f : public std::unary_function<T,void>
{
- get_all_f(TMap &_getcallbackmap, const priv_lvl_t &_cur_priv, TKnobMap &_outknobs) :
- d_getcallbackmap(_getcallbackmap), cur_priv(_cur_priv), outknobs(_outknobs)
+ get_all_f(TMap &_getcallbackmap, const priv_lvl_t &_cur_priv, TKnobMap &_outknobs) :
+ d_getcallbackmap(_getcallbackmap), cur_priv(_cur_priv), outknobs(_outknobs)
{;}
void operator()(const T& p)
@@ -140,8 +140,8 @@ private:
}
else {
std::cout << "Key " << p.first << " requires PRIVLVL <= "
- << p.second.priv << " to get, currently at: "
- << cur_priv << std::endl;
+ << p.second.priv << " to get, currently at: "
+ << cur_priv << std::endl;
}
}
@@ -151,11 +151,11 @@ private:
};
template<typename T, typename TMap, typename TKnobMap>
- struct properties_all_f : public std::unary_function<T,void>
+ struct properties_all_f : public std::unary_function<T,void>
{
- properties_all_f(QueryCallbackMap_t &_getcallbackmap, const priv_lvl_t &_cur_priv, GNURadio::KnobPropMap &_outknobs)
- :
- d_getcallbackmap(_getcallbackmap), cur_priv(_cur_priv), outknobs(_outknobs)
+ properties_all_f(QueryCallbackMap_t &_getcallbackmap, const priv_lvl_t &_cur_priv, GNURadio::KnobPropMap &_outknobs)
+ :
+ d_getcallbackmap(_getcallbackmap), cur_priv(_cur_priv), outknobs(_outknobs)
{;}
void operator()(const T& p)
@@ -172,8 +172,8 @@ private:
}
else {
std::cout << "Key " << p.first << " requires PRIVLVL <= "
- << p.second.priv << " to get, currently at: "
- << cur_priv << std::endl;
+ << p.second.priv << " to get, currently at: "
+ << cur_priv << std::endl;
}
}
@@ -185,8 +185,8 @@ private:
template<class T, typename TMap, typename TKnobMap>
struct properties_f : public std::unary_function<T,void>
{
- properties_f(TMap &_getcallbackmap, const priv_lvl_t &_cur_priv, TKnobMap &_outknobs) :
- d_getcallbackmap(_getcallbackmap), cur_priv(_cur_priv), outknobs(_outknobs)
+ properties_f(TMap &_getcallbackmap, const priv_lvl_t &_cur_priv, TKnobMap &_outknobs) :
+ d_getcallbackmap(_getcallbackmap), cur_priv(_cur_priv), outknobs(_outknobs)
{;}
void operator()(const T& p)
@@ -204,8 +204,8 @@ private:
outknobs[p] = prop;
}
else {
- std::cout << "Key " << iter->first << " requires PRIVLVL: <= " <<
- iter->second.priv << " to get, currently at: " << cur_priv << std::endl;
+ std::cout << "Key " << iter->first << " requires PRIVLVL: <= "
+ << iter->second.priv << " to get, currently at: " << cur_priv << std::endl;
}
}
else {
@@ -219,4 +219,4 @@ private:
};
};
-#endif /* RPCSERVER_THRIFT_H */ \ No newline at end of file
+#endif /* RPCSERVER_THRIFT_H */
diff --git a/gnuradio-runtime/lib/controlport/CMakeLists.txt b/gnuradio-runtime/lib/controlport/CMakeLists.txt
index 8777009d86..9963362582 100644
--- a/gnuradio-runtime/lib/controlport/CMakeLists.txt
+++ b/gnuradio-runtime/lib/controlport/CMakeLists.txt
@@ -31,8 +31,11 @@ list(APPEND gnuradio_ctrlport_sources
${CMAKE_CURRENT_SOURCE_DIR}/rpcserver_selector.cc
${CMAKE_CURRENT_SOURCE_DIR}/rpcserver_thrift.cc
${CMAKE_CURRENT_SOURCE_DIR}/rpcpmtconverters_thrift.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/thrift_application_base.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/rpcserver_booter_thrift.cc
${CMAKE_CURRENT_SOURCE_DIR}/gnuradio_types.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gnuradio_constants.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/ControlPort.cpp
)
########################################################################
@@ -42,7 +45,8 @@ list(APPEND gnuradio_ctrlport_sources
include_directories(${CMAKE_CURRENT_BINARY_DIR})
# Add any required libraries here
-#list(APPEND gnuradio_runtime_libs
-#)
+list(APPEND gnuradio_runtime_libs
+ thrift
+)
endif(ENABLE_GR_CTRLPORT)
diff --git a/gnuradio-runtime/lib/controlport/rpcserver_booter_aggregator.cc b/gnuradio-runtime/lib/controlport/rpcserver_booter_aggregator.cc
index 201dfb3929..a1983b4ac5 100644
--- a/gnuradio-runtime/lib/controlport/rpcserver_booter_aggregator.cc
+++ b/gnuradio-runtime/lib/controlport/rpcserver_booter_aggregator.cc
@@ -23,7 +23,8 @@
#include <gnuradio/rpcserver_booter_aggregator.h>
rpcserver_booter_aggregator::rpcserver_booter_aggregator() :
- d_type(std::string("aggregator")), server(new rpcserver_aggregator())
+ d_type(std::string("aggregator")),
+ server(new rpcserver_aggregator())
{;}
rpcserver_booter_aggregator::~rpcserver_booter_aggregator()
diff --git a/gnuradio-runtime/lib/controlport/rpcserver_selector.cc b/gnuradio-runtime/lib/controlport/rpcserver_selector.cc
index 692f151958..199610169f 100644
--- a/gnuradio-runtime/lib/controlport/rpcserver_selector.cc
+++ b/gnuradio-runtime/lib/controlport/rpcserver_selector.cc
@@ -30,6 +30,11 @@ bool rpcmanager::make_aggregator(false);
#error TODO ICE
#endif
+#ifdef RPCSERVER_THRIFT
+#include <gnuradio/rpcserver_booter_thrift.h>
+rpcmanager::rpcserver_booter_register_helper<rpcserver_booter_thrift> boot_thrift;
+#endif
+
#ifdef RPCSERVER_ERLANG
#error TODO ERLANG
#endif
diff --git a/gnuradio-runtime/lib/controlport/rpcserver_thrift.cc b/gnuradio-runtime/lib/controlport/rpcserver_thrift.cc
index 6546dfe7d6..664305085f 100644
--- a/gnuradio-runtime/lib/controlport/rpcserver_thrift.cc
+++ b/gnuradio-runtime/lib/controlport/rpcserver_thrift.cc
@@ -1,3 +1,4 @@
+/* -*- c++ -*- */
/*
* Copyright 2014 Free Software Foundation, Inc.
*
@@ -18,6 +19,7 @@
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
+
#include <gnuradio/rpcserver_thrift.h>
#include <iostream>
#include <sstream>
@@ -34,15 +36,20 @@
using namespace rpcpmtconverter;
rpcserver_thrift::rpcserver_thrift()
-{}
+{
+ std::cout << "rpcserver_thrift::ctor" << std::endl;
+}
rpcserver_thrift::~rpcserver_thrift()
-{}
+{
+ std::cout << "rpcserver_thrift::dtor" << std::endl;
+}
void
rpcserver_thrift::registerConfigureCallback(const std::string &id, const configureCallback_t callback)
{
{
+ std::cout << "thrift::registerConfigureCallback: " << id << std::endl;
ConfigureCallbackMap_t::const_iterator iter(d_setcallbackmap.find(id));
if(iter != d_setcallbackmap.end()) {
std::stringstream s;
@@ -61,6 +68,7 @@ rpcserver_thrift::registerConfigureCallback(const std::string &id, const configu
void
rpcserver_thrift::unregisterConfigureCallback(const std::string &id)
{
+ std::cout << "thrift::unregisterConfigureCallback: " << id << std::endl;
ConfigureCallbackMap_t::iterator iter(d_setcallbackmap.find(id));
if(iter == d_setcallbackmap.end()) {
std::stringstream s;
@@ -77,9 +85,10 @@ rpcserver_thrift::unregisterConfigureCallback(const std::string &id)
void
rpcserver_thrift::registerQueryCallback(const std::string &id,
- const queryCallback_t callback)
+ const queryCallback_t callback)
{
{
+ std::cout << "thrift::registerQueryCallback: " << id << std::endl;
QueryCallbackMap_t::const_iterator iter(d_getcallbackmap.find(id));
if(iter != d_getcallbackmap.end()) {
std::stringstream s;
@@ -98,6 +107,7 @@ rpcserver_thrift::registerQueryCallback(const std::string &id,
void
rpcserver_thrift::unregisterQueryCallback(const std::string &id)
{
+ std::cout << "thrift::unregisterQueryCallback: " << id << std::endl;
QueryCallbackMap_t::iterator iter(d_getcallbackmap.find(id));
if(iter == d_getcallbackmap.end()) {
std::stringstream s;
@@ -114,15 +124,16 @@ rpcserver_thrift::unregisterQueryCallback(const std::string &id)
}
void
-rpcserver_thrift::set(const GNURadio::KnobMap& knobs)
+rpcserver_thrift::setKnobs(const GNURadio::KnobMap& knobs)
{
std::for_each(knobs.begin(), knobs.end(),
- set_f<GNURadio::KnobMap::value_type,ConfigureCallbackMap_t>
- (d_setcallbackmap, cur_priv));
+ set_f<GNURadio::KnobMap::value_type,ConfigureCallbackMap_t>
+ (d_setcallbackmap, cur_priv));
}
-GNURadio::KnobMap
-rpcserver_thrift::getRe(const GNURadio::KnobIDList& knobs)
+
+void
+rpcserver_thrift::getKnobs(GNURadio::KnobMap& _return, const GNURadio::KnobIDList& knobs)
{
GNURadio::KnobMap outknobs;
@@ -132,41 +143,41 @@ rpcserver_thrift::getRe(const GNURadio::KnobIDList& knobs)
(d_getcallbackmap, cur_priv, outknobs));
}
else {
- QueryCallbackMap_t::iterator it;
- for(it = d_getcallbackmap.begin(); it != d_getcallbackmap.end(); it++){
- for(size_t j=0; j<knobs.size(); j++){
- const boost::xpressive::sregex re(boost::xpressive::sregex::compile(knobs[j]));
- if(boost::xpressive::regex_match(it->first, re)){
- get_f<GNURadio::KnobIDList::value_type, QueryCallbackMap_t>
- (d_getcallbackmap, cur_priv, outknobs)(it->first);
- break;
- }
- }
- }
+ std::for_each(knobs.begin(), knobs.end(),
+ get_f<GNURadio::KnobIDList::value_type, QueryCallbackMap_t>
+ (d_getcallbackmap, cur_priv, outknobs));
}
- return outknobs;
+ _return = outknobs;
}
-GNURadio::KnobMap
-rpcserver_thrift::get(const GNURadio::KnobIDList& knobs)
+void
+rpcserver_thrift::getRe(GNURadio::KnobMap& _return, const GNURadio::KnobIDList& knobs)
{
GNURadio::KnobMap outknobs;
if(knobs.size() == 0) {
std::for_each(d_getcallbackmap.begin(), d_getcallbackmap.end(),
- get_all_f<QueryCallbackMap_t::value_type, QueryCallbackMap_t, GNURadio::KnobMap>
- (d_getcallbackmap, cur_priv, outknobs));
+ get_all_f<QueryCallbackMap_t::value_type, QueryCallbackMap_t, GNURadio::KnobMap>
+ (d_getcallbackmap, cur_priv, outknobs));
}
else {
- std::for_each(knobs.begin(), knobs.end(),
- get_f<GNURadio::KnobIDList::value_type, QueryCallbackMap_t>
- (d_getcallbackmap, cur_priv, outknobs));
+ QueryCallbackMap_t::iterator it;
+ for(it = d_getcallbackmap.begin(); it != d_getcallbackmap.end(); it++){
+ for(size_t j=0; j<knobs.size(); j++){
+ const boost::xpressive::sregex re(boost::xpressive::sregex::compile(knobs[j]));
+ if(boost::xpressive::regex_match(it->first, re)){
+ get_f<GNURadio::KnobIDList::value_type, QueryCallbackMap_t>
+ (d_getcallbackmap, cur_priv, outknobs)(it->first);
+ break;
+ }
+ }
+ }
}
- return outknobs;
+ _return = outknobs;
}
-GNURadio::KnobPropMap
-rpcserver_thrift::properties(const GNURadio::KnobIDList& knobs)
+void
+rpcserver_thrift::properties(GNURadio::KnobPropMap& _return, const GNURadio::KnobIDList& knobs)
{
GNURadio::KnobPropMap outknobs;
@@ -180,7 +191,7 @@ rpcserver_thrift::properties(const GNURadio::KnobIDList& knobs)
properties_f<GNURadio::KnobIDList::value_type,
QueryCallbackMap_t, GNURadio::KnobPropMap>(d_getcallbackmap, cur_priv, outknobs));
}
- return outknobs;
+ _return = outknobs;
}
void
@@ -188,4 +199,4 @@ rpcserver_thrift::shutdown() {
if (DEBUG) {
std::cout << "Shutting down..." << std::endl;
}
-} \ No newline at end of file
+}