USRP Hardware Driver and USRP Manual  Version: 003.010.002.HEAD-0-gbd6e21dc
UHD and USRP Manual
msg.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2011-2013 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 <iomanip>
25 #include <string>
26 
31 #define UHD_MSG(type) \
32  uhd::msg::_msg(uhd::msg::type)()
33 
35 #define UHD_HERE() \
36  UHD_MSG(status) << __FILE__ << ":" << __LINE__ << std::endl
37 
39 #define UHD_VAR(var) \
40  UHD_MSG(status) << #var << " = " << var << std::endl;
41 
43 #define UHD_HEX(var) \
44  UHD_MSG(status) << #var << " = 0x" << std::hex << std::setfill('0') << std::setw(8) << var << std::dec << std::endl;
45 
46 namespace uhd{ namespace msg{
47 
49  enum type_t{
50  status = 's',
51  warning = 'w',
52  error = 'e',
53  fastpath= 'f'
54  };
55 
57  typedef void (*handler_t)(type_t, const std::string &);
58 
65  UHD_API void register_handler(const handler_t &handler);
66 
68  class UHD_API _msg{
69  public:
70  _msg(const type_t type);
71  ~_msg(void);
72  std::ostream &operator()(void);
73  private:
74  UHD_PIMPL_DECL(impl) _impl;
75  };
76 
77 }} //namespace uhd::msg
78 
79 #endif /* INCLUDED_UHD_UTILS_MSG_HPP */
Definition: msg.hpp:51
void(* handler_t)(type_t, const std::string &)
Typedef for a user-registered message handler.
Definition: msg.hpp:57
UHD_API void register_handler(const handler_t &handler)
type_t
Possible message types.
Definition: msg.hpp:49
Definition: build_info.hpp:25
Definition: msg.hpp:52
#define UHD_PIMPL_DECL(_name)
Definition: pimpl.hpp:42
Internal message object (called by UHD_MSG macro)
Definition: msg.hpp:68
#define UHD_API
Definition: config.h:73
Definition: msg.hpp:53
Definition: msg.hpp:50