UHD  003.001.002
msg.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2011 Ettus Research LLC
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
17 
18 #ifndef INCLUDED_UHD_UTILS_MSG_HPP
19 #define INCLUDED_UHD_UTILS_MSG_HPP
20 
21 #include <uhd/config.hpp>
22 #include <uhd/utils/pimpl.hpp>
23 #include <ostream>
24 #include <string>
25 
30 #define UHD_MSG(type) \
31  uhd::msg::_msg(uhd::msg::type)()
32 
33 
34 namespace uhd{ namespace msg{
35 
37  enum type_t{
38  status = 's',
39  warning = 'w',
40  error = 'e',
41  fastpath= 'f'
42  };
43 
45  typedef void (*handler_t)(type_t, const std::string &);
46 
53  UHD_API void register_handler(const handler_t &handler);
54 
56  class UHD_API _msg{
57  public:
58  _msg(const type_t type);
59  ~_msg(void);
60  std::ostream &operator()(void);
61  private:
62  UHD_PIMPL_DECL(impl) _impl;
63  };
64 
65 }} //namespace uhd::msg
66 
67 #endif /* INCLUDED_UHD_UTILS_MSG_HPP */
Definition: msg.hpp:39
void(* handler_t)(type_t, const std::string &)
Typedef for a user-registered message handler.
Definition: msg.hpp:45
UHD_API void register_handler(const handler_t &handler)
type_t
Possible message types.
Definition: msg.hpp:37
#define UHD_API
Definition: config.hpp:76
Definition: convert.hpp:28
Definition: msg.hpp:40
#define UHD_PIMPL_DECL(_name)
Definition: pimpl.hpp:42
Internal message object (called by UHD_MSG macro)
Definition: msg.hpp:56
Definition: msg.hpp:41
Definition: msg.hpp:38