Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:39:26

0001 /*
0002  *          Copyright Andrey Semashev 2007 - 2015.
0003  * Distributed under the Boost Software License, Version 1.0.
0004  *    (See accompanying file LICENSE_1_0.txt or copy at
0005  *          http://www.boost.org/LICENSE_1_0.txt)
0006  */
0007 /*!
0008  * \file   channel_logger.hpp
0009  * \author Andrey Semashev
0010  * \date   28.02.2008
0011  *
0012  * The header contains implementation of a logger with channel support.
0013  */
0014 
0015 #ifndef BOOST_LOG_SOURCES_CHANNEL_LOGGER_HPP_INCLUDED_
0016 #define BOOST_LOG_SOURCES_CHANNEL_LOGGER_HPP_INCLUDED_
0017 
0018 #include <boost/log/detail/config.hpp>
0019 #if !defined(BOOST_LOG_NO_THREADS)
0020 #include <boost/log/detail/light_rw_mutex.hpp>
0021 #endif // !defined(BOOST_LOG_NO_THREADS)
0022 #include <boost/log/sources/features.hpp>
0023 #include <boost/log/sources/basic_logger.hpp>
0024 #include <boost/log/sources/threading_models.hpp>
0025 #include <boost/log/sources/channel_feature.hpp>
0026 #include <boost/log/keywords/channel.hpp>
0027 #include <boost/log/detail/header.hpp>
0028 
0029 #ifdef BOOST_HAS_PRAGMA_ONCE
0030 #pragma once
0031 #endif
0032 
0033 namespace boost {
0034 
0035 BOOST_LOG_OPEN_NAMESPACE
0036 
0037 namespace sources {
0038 
0039 #ifndef BOOST_LOG_DOXYGEN_PASS
0040 
0041 #ifdef BOOST_LOG_USE_CHAR
0042 
0043 //! Narrow-char logger with channel support
0044 template< typename ChannelT = std::string >
0045 class channel_logger :
0046     public basic_composite_logger<
0047         char,
0048         channel_logger< ChannelT >,
0049         single_thread_model,
0050         features< channel< ChannelT > >
0051     >
0052 {
0053     typedef typename channel_logger::logger_base base_type;
0054 
0055 public:
0056     BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(channel_logger)
0057 
0058     explicit channel_logger(ChannelT const& channel) : base_type(keywords::channel = channel)
0059     {
0060     }
0061 };
0062 
0063 #if !defined(BOOST_LOG_NO_THREADS)
0064 
0065 //! Narrow-char thread-safe logger with channel support
0066 template< typename ChannelT = std::string >
0067 class channel_logger_mt :
0068     public basic_composite_logger<
0069         char,
0070         channel_logger_mt< ChannelT >,
0071         multi_thread_model< boost::log::aux::light_rw_mutex >,
0072         features< channel< ChannelT > >
0073     >
0074 {
0075     typedef typename channel_logger_mt::logger_base base_type;
0076 
0077 public:
0078     BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(channel_logger_mt)
0079 
0080     explicit channel_logger_mt(ChannelT const& channel) : base_type(keywords::channel = channel)
0081     {
0082     }
0083 };
0084 
0085 #endif // !defined(BOOST_LOG_NO_THREADS)
0086 
0087 #endif // BOOST_LOG_USE_CHAR
0088 
0089 #ifdef BOOST_LOG_USE_WCHAR_T
0090 
0091 //! Wide-char logger with channel support
0092 template< typename ChannelT = std::wstring >
0093 class wchannel_logger :
0094     public basic_composite_logger<
0095         wchar_t,
0096         wchannel_logger< ChannelT >,
0097         single_thread_model,
0098         features< channel< ChannelT > >
0099     >
0100 {
0101     typedef typename wchannel_logger::logger_base base_type;
0102 
0103 public:
0104     BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(wchannel_logger)
0105 
0106     explicit wchannel_logger(ChannelT const& channel) : base_type(keywords::channel = channel)
0107     {
0108     }
0109 };
0110 
0111 #if !defined(BOOST_LOG_NO_THREADS)
0112 
0113 //! Wide-char thread-safe logger with channel support
0114 template< typename ChannelT = std::wstring >
0115 class wchannel_logger_mt :
0116     public basic_composite_logger<
0117         wchar_t,
0118         wchannel_logger< ChannelT >,
0119         multi_thread_model< boost::log::aux::light_rw_mutex >,
0120         features< channel< ChannelT > >
0121     >
0122 {
0123     typedef typename wchannel_logger_mt::logger_base base_type;
0124 
0125 public:
0126     BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(wchannel_logger_mt)
0127 
0128     explicit wchannel_logger_mt(ChannelT const& channel) : base_type(keywords::channel = channel)
0129     {
0130     }
0131 };
0132 
0133 #endif // !defined(BOOST_LOG_NO_THREADS)
0134 
0135 #endif // BOOST_LOG_USE_WCHAR_T
0136 
0137 #else // BOOST_LOG_DOXYGEN_PASS
0138 
0139 /*!
0140  * \brief Narrow-char logger. Functionally equivalent to \c basic_channel_logger.
0141  *
0142  * See \c channel class template for a more detailed description
0143  */
0144 template< typename ChannelT = std::string >
0145 class channel_logger :
0146     public basic_composite_logger<
0147         char,
0148         channel_logger< ChannelT >,
0149         single_thread_model,
0150         features< channel< ChannelT > >
0151     >
0152 {
0153 public:
0154     /*!
0155      * Default constructor
0156      */
0157     channel_logger();
0158     /*!
0159      * Copy constructor
0160      */
0161     channel_logger(channel_logger const& that);
0162     /*!
0163      * Constructor with named arguments
0164      */
0165     template< typename... ArgsT >
0166     explicit channel_logger(ArgsT... const& args);
0167     /*!
0168      * The constructor creates the logger with the specified channel name
0169      *
0170      * \param channel The channel name
0171      */
0172     explicit channel_logger(ChannelT const& channel);
0173     /*!
0174      * Assignment operator
0175      */
0176     channel_logger& operator= (channel_logger const& that)
0177     /*!
0178      * Swaps two loggers
0179      */
0180     void swap(channel_logger& that);
0181 };
0182 
0183 /*!
0184  * \brief Narrow-char thread-safe logger. Functionally equivalent to \c basic_channel_logger.
0185  *
0186  * See \c channel class template for a more detailed description
0187  */
0188 template< typename ChannelT = std::string >
0189 class channel_logger_mt :
0190     public basic_composite_logger<
0191         char,
0192         channel_logger_mt< ChannelT >,
0193         multi_thread_model< implementation_defined >,
0194         features< channel< ChannelT > >
0195     >
0196 {
0197 public:
0198     /*!
0199      * Default constructor
0200      */
0201     channel_logger_mt();
0202     /*!
0203      * Copy constructor
0204      */
0205     channel_logger_mt(channel_logger_mt const& that);
0206     /*!
0207      * Constructor with named arguments
0208      */
0209     template< typename... ArgsT >
0210     explicit channel_logger_mt(ArgsT... const& args);
0211     /*!
0212      * The constructor creates the logger with the specified channel name
0213      *
0214      * \param channel The channel name
0215      */
0216     explicit channel_logger_mt(ChannelT const& channel);
0217     /*!
0218      * Assignment operator
0219      */
0220     channel_logger_mt& operator= (channel_logger_mt const& that)
0221     /*!
0222      * Swaps two loggers
0223      */
0224     void swap(channel_logger_mt& that);
0225 };
0226 
0227 /*!
0228  * \brief Wide-char logger. Functionally equivalent to \c basic_channel_logger.
0229  *
0230  * See \c channel class template for a more detailed description
0231  */
0232 template< typename ChannelT = std::wstring >
0233 class wchannel_logger :
0234     public basic_composite_logger<
0235         wchar_t,
0236         wchannel_logger< ChannelT >,
0237         single_thread_model,
0238         features< channel< ChannelT > >
0239     >
0240 {
0241 public:
0242     /*!
0243      * Default constructor
0244      */
0245     wchannel_logger();
0246     /*!
0247      * Copy constructor
0248      */
0249     wchannel_logger(wchannel_logger const& that);
0250     /*!
0251      * Constructor with named arguments
0252      */
0253     template< typename... ArgsT >
0254     explicit wchannel_logger(ArgsT... const& args);
0255     /*!
0256      * The constructor creates the logger with the specified channel name
0257      *
0258      * \param channel The channel name
0259      */
0260     explicit wchannel_logger(ChannelT const& channel);
0261     /*!
0262      * Assignment operator
0263      */
0264     wchannel_logger& operator= (wchannel_logger const& that)
0265     /*!
0266      * Swaps two loggers
0267      */
0268     void swap(wchannel_logger& that);
0269 };
0270 
0271 /*!
0272  * \brief Wide-char thread-safe logger. Functionally equivalent to \c basic_channel_logger.
0273  *
0274  * See \c channel class template for a more detailed description
0275  */
0276 template< typename ChannelT = std::wstring >
0277 class wchannel_logger_mt :
0278     public basic_composite_logger<
0279         wchar_t,
0280         wchannel_logger< ChannelT >,
0281         multi_thread_model< implementation_defined >,
0282         features< channel< ChannelT > >
0283     >
0284 {
0285 public:
0286     /*!
0287      * Default constructor
0288      */
0289     wchannel_logger_mt();
0290     /*!
0291      * Copy constructor
0292      */
0293     wchannel_logger_mt(wchannel_logger_mt const& that);
0294     /*!
0295      * Constructor with named arguments
0296      */
0297     template< typename... ArgsT >
0298     explicit wchannel_logger_mt(ArgsT... const& args);
0299     /*!
0300      * The constructor creates the logger with the specified channel name
0301      *
0302      * \param channel The channel name
0303      */
0304     explicit wchannel_logger_mt(ChannelT const& channel);
0305     /*!
0306      * Assignment operator
0307      */
0308     wchannel_logger_mt& operator= (wchannel_logger_mt const& that)
0309     /*!
0310      * Swaps two loggers
0311      */
0312     void swap(wchannel_logger_mt& that);
0313 };
0314 
0315 #endif // BOOST_LOG_DOXYGEN_PASS
0316 
0317 } // namespace sources
0318 
0319 BOOST_LOG_CLOSE_NAMESPACE // namespace log
0320 
0321 } // namespace boost
0322 
0323 #include <boost/log/detail/footer.hpp>
0324 
0325 #endif // BOOST_LOG_SOURCES_CHANNEL_LOGGER_HPP_INCLUDED_