GNU Radio Manual and C++ API Reference  3.10.9.1
The Free & Open Software Radio Ecosystem
rpcserver_aggregator.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2012 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * SPDX-License-Identifier: GPL-3.0-or-later
8  *
9  */
10 
11 #ifndef RPCSERVER_AGGREGATOR_H
12 #define RPCSERVER_AGGREGATOR_H
13 
16 #include <functional>
17 #include <string>
18 #include <vector>
19 
20 class rpcserver_aggregator : public virtual rpcserver_base
21 {
22 public:
25 
26  void registerConfigureCallback(const std::string& id,
27  const configureCallback_t callback) override;
28  void unregisterConfigureCallback(const std::string& id) override;
29 
30  void registerQueryCallback(const std::string& id,
31  const queryCallback_t callback) override;
32  void unregisterQueryCallback(const std::string& id) override;
33 
34  void registerHandlerCallback(const std::string& id,
35  const handlerCallback_t callback) override;
36  void unregisterHandlerCallback(const std::string& id) override;
37 
38  void registerServer(rpcmanager_base::rpcserver_booter_base_sptr server);
39 
40  const std::string& type();
41 
42  const std::vector<std::string>& registeredServers();
43 
44 private:
45  template <class T, typename Tcallback>
46  struct registerConfigureCallback_f : public std::function<void(T)> {
47  registerConfigureCallback_f(const std::string& _id, const Tcallback _callback)
48  : id(_id), callback(_callback)
49  {
50  ;
51  }
52 
53  void operator()(T& x) { x->i()->registerConfigureCallback(id, callback); }
54  const std::string id;
55  const Tcallback callback;
56  };
57 
58  template <class T, typename Tcallback>
59  struct unregisterConfigureCallback_f : public std::function<void(T)> {
60  unregisterConfigureCallback_f(const std::string& _id) : id(_id) { ; }
61 
62  void operator()(T& x) { x->i()->unregisterConfigureCallback(id); }
63  const std::string id;
64  };
65 
66  template <class T, typename Tcallback>
67  struct registerQueryCallback_f : public std::function<void(T)> {
68  registerQueryCallback_f(const std::string& _id, const Tcallback _callback)
69  : id(_id), callback(_callback)
70  {
71  ;
72  }
73 
74  void operator()(T& x) { x->i()->registerQueryCallback(id, callback); }
75  const std::string id;
76  const Tcallback callback;
77  };
78 
79  template <class T, typename Tcallback>
80  struct unregisterQueryCallback_f : public std::function<void(T)> {
81  unregisterQueryCallback_f(const std::string& _id) : id(_id) { ; }
82 
83  void operator()(T& x) { x->i()->unregisterQueryCallback(id); }
84  const std::string id;
85  };
86 
87 
88  template <class T, typename Tcallback>
89  struct registerHandlerCallback_f : public std::function<void(T)> {
90  registerHandlerCallback_f(const std::string& _id, const Tcallback _callback)
91  : id(_id), callback(_callback)
92  {
93  ;
94  }
95 
96  void operator()(T& x) { x->i()->registerHandlerCallback(id, callback); }
97  const std::string id;
98  const Tcallback callback;
99  };
100 
101  template <class T, typename Tcallback>
102  struct unregisterHandlerCallback_f : public std::function<void(T)> {
103  unregisterHandlerCallback_f(const std::string& _id) : id(_id) { ; }
104 
105  void operator()(T& x) { x->i()->unregisterHandlerCallback(id); }
106  const std::string id;
107  };
108 
109 
110  const std::string d_type;
111  typedef std::vector<rpcmanager_base::rpcserver_booter_base_sptr> rpcServerMap_t;
112  std::vector<std::string> d_registeredServers;
113  rpcServerMap_t d_serverlist;
114 };
115 
116 #endif /* RPCSERVER_AGGREGATOR_H */
Definition: rpccallbackregister_base.h:83
Definition: rpcserver_aggregator.h:21
void registerQueryCallback(const std::string &id, const queryCallback_t callback) override
void registerHandlerCallback(const std::string &id, const handlerCallback_t callback) override
void unregisterConfigureCallback(const std::string &id) override
void registerServer(rpcmanager_base::rpcserver_booter_base_sptr server)
void unregisterQueryCallback(const std::string &id) override
void unregisterHandlerCallback(const std::string &id) override
~rpcserver_aggregator() override
void registerConfigureCallback(const std::string &id, const configureCallback_t callback) override
const std::vector< std::string > & registeredServers()
const std::string & type()
Definition: rpcserver_base.h:17