diff options
author | Josh Blum <josh@joshknows.com> | 2011-05-18 18:08:17 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-05-18 18:08:17 -0700 |
commit | df020c6923aae830a20a2405c9de086b22e7c5f0 (patch) | |
tree | 300fd92b5020c4b3a2a46eac7640dc6fcbfc2a93 | |
parent | 0aff497dacc9cc4eba5d800cc46343da083cfdf1 (diff) | |
download | uhd-df020c6923aae830a20a2405c9de086b22e7c5f0.tar.gz uhd-df020c6923aae830a20a2405c9de086b22e7c5f0.tar.bz2 uhd-df020c6923aae830a20a2405c9de086b22e7c5f0.zip |
uhd: removed deprecated warning API, log+msg now in API
-rw-r--r-- | host/include/uhd/config.hpp | 7 | ||||
-rw-r--r-- | host/include/uhd/utils/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/include/uhd/utils/log.hpp | 2 | ||||
-rw-r--r-- | host/include/uhd/utils/msg.hpp | 4 | ||||
-rw-r--r-- | host/include/uhd/utils/warning.hpp | 66 | ||||
-rw-r--r-- | host/lib/utils/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/lib/utils/warning.cpp | 87 | ||||
-rw-r--r-- | host/tests/msg_test.cpp | 2 |
8 files changed, 3 insertions, 167 deletions
diff --git a/host/include/uhd/config.hpp b/host/include/uhd/config.hpp index 96dfe8ed0..6fd2932cf 100644 --- a/host/include/uhd/config.hpp +++ b/host/include/uhd/config.hpp @@ -76,13 +76,6 @@ 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 875c4731f..88a0e612b 100644 --- a/host/include/uhd/utils/CMakeLists.txt +++ b/host/include/uhd/utils/CMakeLists.txt @@ -31,7 +31,6 @@ INSTALL(FILES safe_main.hpp static.hpp thread_priority.hpp - warning.hpp DESTINATION ${INCLUDE_DIR}/uhd/utils COMPONENT headers ) diff --git a/host/include/uhd/utils/log.hpp b/host/include/uhd/utils/log.hpp index 7f83fd2a9..bc8f41fb4 100644 --- a/host/include/uhd/utils/log.hpp +++ b/host/include/uhd/utils/log.hpp @@ -77,7 +77,7 @@ namespace uhd{ namespace _log{ }; //! Internal logging object (called by UHD_LOG macros) - struct UHD_API_FUTURE log{ + struct UHD_API 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 index 17179f551..050504e57 100644 --- a/host/include/uhd/utils/msg.hpp +++ b/host/include/uhd/utils/msg.hpp @@ -49,10 +49,10 @@ namespace uhd{ namespace msg{ * 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); + UHD_API void register_handler(const handler_t &handler); //! Internal message object (called by UHD_MSG macro) - struct UHD_API_FUTURE _msg{ + struct UHD_API _msg{ _msg(const type_t type); ~_msg(void); std::ostream &operator()(void); diff --git a/host/include/uhd/utils/warning.hpp b/host/include/uhd/utils/warning.hpp deleted file mode 100644 index ae614d59e..000000000 --- a/host/include/uhd/utils/warning.hpp +++ /dev/null @@ -1,66 +0,0 @@ -// -// Copyright 2010 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_WARNING_HPP -#define INCLUDED_UHD_UTILS_WARNING_HPP - -#include <uhd/config.hpp> -#include <boost/function.hpp> -#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 - typedef boost::function<void(std::string)> handler_t; - - /*! - * Post a warning message to all registered handlers. - * \param msg the multiline warning message - */ - UHD_API UHD_DEPRECATED void post(const std::string &msg); - - /*! - * Register a new handler with this name. - * If the name was already registered for this name, - * the old registered handler will be replaced. - * \param name a unique name for this handler - * \param handler the callback handler function - */ - UHD_API UHD_DEPRECATED void register_handler(const std::string &name, const handler_t &handler); - - /*! - * Unregister a handler for this name. - * \param name a unique name for a registered handler - * \return the handler that was registered - * \throw error when the name was not found in the registry - */ - 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 UHD_DEPRECATED const std::vector<std::string> registry_names(void); - -}} //namespace uhd::warning - -#endif /* INCLUDED_UHD_UTILS_WARNING_HPP */ diff --git a/host/lib/utils/CMakeLists.txt b/host/lib/utils/CMakeLists.txt index 0e0d51c78..c8268c7b0 100644 --- a/host/lib/utils/CMakeLists.txt +++ b/host/lib/utils/CMakeLists.txt @@ -137,5 +137,4 @@ LIBUHD_APPEND_SOURCES( ${CMAKE_CURRENT_SOURCE_DIR}/props.cpp ${CMAKE_CURRENT_SOURCE_DIR}/static.cpp ${CMAKE_CURRENT_SOURCE_DIR}/thread_priority.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/warning.cpp ) diff --git a/host/lib/utils/warning.cpp b/host/lib/utils/warning.cpp deleted file mode 100644 index 87b6b24f5..000000000 --- a/host/lib/utils/warning.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// -// Copyright 2010-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/>. -// - -#include <uhd/utils/warning.hpp> -#include <uhd/exception.hpp> -#include <boost/tokenizer.hpp> -#include <uhd/utils/static.hpp> -#include <uhd/types/dict.hpp> -#include <boost/foreach.hpp> -#include <sstream> -#include <iostream> -#include <vector> - -using namespace uhd; - -#define tokenizer(inp, sep) \ - boost::tokenizer<boost::char_separator<char> > \ - (inp, boost::char_separator<char>(sep)) - -/*********************************************************************** - * Registry implementation - **********************************************************************/ -//create the registry for the handlers -typedef uhd::dict<std::string, warning::handler_t> registry_t; -UHD_SINGLETON_FCN(registry_t, get_registry) - -//the default warning handler -//static void stderr_warning(const std::string &msg){ -// std::cerr << msg; -//} - -//register a default handler -UHD_STATIC_BLOCK(warning_register_default){ - //warning::register_handler("default", &stderr_warning); -} - -/*********************************************************************** - * Post + format - **********************************************************************/ -void warning::post(const std::string &msg){ - std::stringstream ss; - - //format the warning message - ss << std::endl << "Warning:" << std::endl; - BOOST_FOREACH(const std::string &line, tokenizer(msg, "\n")){ - ss << " " << line << std::endl; - } - - //post the formatted message - BOOST_FOREACH(const std::string &name, get_registry().keys()){ - get_registry()[name](ss.str()); - } -} - -/*********************************************************************** - * Registry accessor functions - **********************************************************************/ -void warning::register_handler( - const std::string &name, const handler_t &handler -){ - get_registry()[name] = handler; -} - -warning::handler_t warning::unregister_handler(const std::string &name){ - if (not get_registry().has_key(name)) throw uhd::key_error( - "The warning registry does not have a handler registered to " + name - ); - return get_registry().pop(name); -} - -const std::vector<std::string> warning::registry_names(void){ - return get_registry().keys(); -} diff --git a/host/tests/msg_test.cpp b/host/tests/msg_test.cpp index 495907504..c05139ea9 100644 --- a/host/tests/msg_test.cpp +++ b/host/tests/msg_test.cpp @@ -20,7 +20,6 @@ #include <iostream> BOOST_AUTO_TEST_CASE(test_messages){ - #ifdef UHD_FUTURE std::cerr << "---begin print test ---" << std::endl; UHD_MSG(status) << "This is a test print for a status message.\n" @@ -35,5 +34,4 @@ BOOST_AUTO_TEST_CASE(test_messages){ "And this is the second line of the test print.\n" ; std::cerr << "---end print test ---" << std::endl; - #endif } |