4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief Definitions internal header */
26 #ifndef IH_Definitions_
27 #define IH_Definitions_ 1
31 ///////////////////////////////ih.p////////////////////////////////////////
33 // Implementation details concerning SENF_LOG_CLASS_AREA
35 // The SENF_LOG_CLASS_AREA statement shall declare the containing class as it's own default area. Of
36 // course, we cannot make the containing class into an area. Therefor we need to trick around a bit:
38 // We begin by defining an area SENFLogArea with in the class. This area however is hacked, so that
39 // it's name() member will return the name of the containing class (which is simple: just cut of the
40 // last couple of characters of the name since the name will always end in '::SENFLogArea').
42 // This however does not allow the use of the containing class as an area. There are several places
43 // which need to be adjusted to allow using the containing class as an area: The logging statements
44 // (SENF_LOG), the compile time configuration via SENF_LOG_CONF and the runtime configuration via
47 // Lets begin with the compile time configuration. The compile time configuration is done using
48 // specialization of the senf::log::detail::Config template. This doesn't care, what the area
49 // template argument really is. Therefore, compile-time configuration just uses the containing class
50 // as is. So we need to make sure, that the logging statements use the containing class when
51 // checking the compile-time limit whereas they need to use the nested SENFLogArea when calling the
54 // So let's look at the logging statements. The central logic for parsing the logging parameters is
55 // in SENF_LOG_MERGE_PARAMETERS in Parameters.ih. Here we have a special case which detects classes
56 // with a SENFLogArea member and then set's things up correctly: It uses the containing class for
57 // compile time checking (this is, what 'area_base' typedef is for) while using the nested
58 // SENFLogArea for routing (this is, what the 'area' typedef is for).
60 // So the last thing which needs to be adjusted is the routing which is part of the Target
61 // class. Here for each template taking an area as an argument we really provide TWO templates, one
62 // taking the area directly, the other checking for a nested SENFLogArea member. We can
63 // differentiate these overloads using boost::enable_if and friends.
65 // This setup makes a class with SENF_LOG_CLASS_AREA() look like an ordinary area even though the
66 // implementation is somewhat different.
68 #define SENF_LOG_DEFINE_AREA_I(area, decls) \
70 : public senf::log::detail::AreaBase, public senf::singleton<area> \
72 static std::string name() { return instance().v_name(); } \
73 using senf::singleton<area>::instance; \
77 friend class senf::singleton<area>; \
84 /// Internal: Alias base class
89 ///////////////////////////////ih.e////////////////////////////////////////
97 // c-file-style: "senf"
98 // indent-tabs-mode: nil
99 // ispell-local-dictionary: "american"
100 // compile-command: "scons -u test"