summaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/config.hpp7
-rw-r--r--host/include/uhd/utils/CMakeLists.txt1
-rw-r--r--host/include/uhd/utils/log.hpp2
-rw-r--r--host/include/uhd/utils/msg.hpp67
-rw-r--r--host/include/uhd/utils/safe_call.hpp6
-rw-r--r--host/include/uhd/utils/warning.hpp12
6 files changed, 87 insertions, 8 deletions
diff --git a/host/include/uhd/config.hpp b/host/include/uhd/config.hpp
index 6fd2932cf..96dfe8ed0 100644
--- a/host/include/uhd/config.hpp
+++ b/host/include/uhd/config.hpp
@@ -76,6 +76,13 @@ typedef ptrdiff_t ssize_t;
#define UHD_API UHD_IMPORT
#endif // UHD_DLL_EXPORTS
+// The user can enable this with -DUHD_FUTURE
+#ifdef UHD_FUTURE
+ #define UHD_API_FUTURE UHD_API
+#else
+ #define UHD_API_FUTURE
+#endif
+
// Platform defines for conditional parts of headers:
// Taken from boost/config/select_platform_config.hpp,
// however, we define macros, not strings for platforms.
diff --git a/host/include/uhd/utils/CMakeLists.txt b/host/include/uhd/utils/CMakeLists.txt
index 6c507dcde..875c4731f 100644
--- a/host/include/uhd/utils/CMakeLists.txt
+++ b/host/include/uhd/utils/CMakeLists.txt
@@ -24,6 +24,7 @@ INSTALL(FILES
gain_group.hpp
images.hpp
log.hpp
+ msg.hpp
pimpl.hpp
props.hpp
safe_call.hpp
diff --git a/host/include/uhd/utils/log.hpp b/host/include/uhd/utils/log.hpp
index 9dceea982..503c468f1 100644
--- a/host/include/uhd/utils/log.hpp
+++ b/host/include/uhd/utils/log.hpp
@@ -76,7 +76,7 @@ namespace uhd{ namespace _log{
};
//! Internal logging object (called by UHD_LOG macros)
- struct /*UHD_API*/ log{
+ struct UHD_API_FUTURE log{
log(
const verbosity_t verbosity,
const std::string &file,
diff --git a/host/include/uhd/utils/msg.hpp b/host/include/uhd/utils/msg.hpp
new file mode 100644
index 000000000..a78e04ad3
--- /dev/null
+++ b/host/include/uhd/utils/msg.hpp
@@ -0,0 +1,67 @@
+//
+// Copyright 2011 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_UTILS_MSG_HPP
+#define INCLUDED_UHD_UTILS_MSG_HPP
+
+#include <uhd/config.hpp>
+#include <ostream>
+#include <string>
+
+/*!
+ * A UHD message macro with configurable type.
+ * Usage: UHD_MSG(warning) << "some warning message" << std::endl;
+ */
+#define UHD_MSG(type) \
+ uhd::msg::_msg(uhd::msg::type)
+
+
+namespace uhd{ namespace msg{
+
+ //! Possible message types
+ enum type_t{
+ status = 's',
+ warning = 'w',
+ error = 'e',
+ };
+
+ //! Typedef for a user-registered message handler
+ typedef void (*handler_t)(type_t, const std::string &);
+
+ /*!
+ * Register the handler for uhd system messages.
+ * Only one handler can be registered at once.
+ * This replaces the default std::cout/cerr handler.
+ * \param handler a new handler callback function
+ */
+ UHD_API_FUTURE void register_handler(const handler_t &handler);
+
+ //! Internal message object (called by UHD_MSG macro)
+ struct UHD_API_FUTURE _msg{
+ _msg(const type_t type);
+ ~_msg(void);
+
+ std::ostream &get(void);
+
+ template <typename T> std::ostream &operator<<(const T &x){
+ return get() << x;
+ }
+ };
+
+}} //namespace uhd::msg
+
+#endif /* INCLUDED_UHD_UTILS_MSG_HPP */
diff --git a/host/include/uhd/utils/safe_call.hpp b/host/include/uhd/utils/safe_call.hpp
index 6b2c210af..b9f545b23 100644
--- a/host/include/uhd/utils/safe_call.hpp
+++ b/host/include/uhd/utils/safe_call.hpp
@@ -20,12 +20,12 @@
#include <uhd/config.hpp>
#include <uhd/exception.hpp>
-#include <uhd/utils/warning.hpp>
+#include <uhd/utils/msg.hpp>
//! helper macro for safe call to produce warnings
-#define _UHD_SAFE_CALL_WARNING(code, what) uhd::warning::post( \
+#define _UHD_SAFE_CALL_WARNING(code, what) UHD_MSG(warning) << \
UHD_THROW_SITE_INFO("Exception caught in safe-call.") + #code + " -> " + what \
-);
+;
/*!
* A safe-call catches all exceptions thrown by code,
diff --git a/host/include/uhd/utils/warning.hpp b/host/include/uhd/utils/warning.hpp
index a1e3f0d1e..ae614d59e 100644
--- a/host/include/uhd/utils/warning.hpp
+++ b/host/include/uhd/utils/warning.hpp
@@ -23,6 +23,10 @@
#include <vector>
#include <string>
+/*! \file warning.hpp
+ * EVERYTHING IN THIS FILE IS TOTALLY DEPRECATED! DO NOT USE IT!
+ */
+
namespace uhd{ namespace warning{
//! Callback function type for a message handler
@@ -32,7 +36,7 @@ namespace uhd{ namespace warning{
* Post a warning message to all registered handlers.
* \param msg the multiline warning message
*/
- UHD_API void post(const std::string &msg);
+ UHD_API UHD_DEPRECATED void post(const std::string &msg);
/*!
* Register a new handler with this name.
@@ -41,7 +45,7 @@ namespace uhd{ namespace warning{
* \param name a unique name for this handler
* \param handler the callback handler function
*/
- UHD_API void register_handler(const std::string &name, const handler_t &handler);
+ UHD_API UHD_DEPRECATED void register_handler(const std::string &name, const handler_t &handler);
/*!
* Unregister a handler for this name.
@@ -49,13 +53,13 @@ namespace uhd{ namespace warning{
* \return the handler that was registered
* \throw error when the name was not found in the registry
*/
- UHD_API handler_t unregister_handler(const std::string &name);
+ UHD_API UHD_DEPRECATED handler_t unregister_handler(const std::string &name);
/*!
* Get a list of registered handler names.
* \return a vector of unique string names
*/
- UHD_API const std::vector<std::string> registry_names(void);
+ UHD_API UHD_DEPRECATED const std::vector<std::string> registry_names(void);
}} //namespace uhd::warning