4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief Definitions internal header */
31 #ifndef IH_SENF_Utils_Logger_Definitions_
32 #define IH_SENF_Utils_Logger_Definitions_ 1
36 //-/////////////////////////////////////////////////////////////////////////////////////////////////
38 // Implementation details concerning SENF_LOG_CLASS_AREA
40 // The SENF_LOG_CLASS_AREA statement shall declare the containing class as it's own default area. Of
41 // course, we cannot make the containing class into an area. Therefore we need to trick around a bit:
43 // We begin by defining an area SENFLogArea with in the class. This area however is hacked, so that
44 // it's name() member will return the name of the containing class (which is simple: just cut of the
45 // last couple of characters of the name since the name will always end in '::SENFLogArea').
47 // This however does not allow the use of the containing class as an area. There are several places
48 // which need to be adjusted to allow using the containing class as an area: The logging statements
49 // (SENF_LOG), the compile time configuration via SENF_LOG_CONF and the runtime configuration via
52 // Lets begin with the compile time configuration. The compile time configuration is done using
53 // specialization of the senf::log::detail::Config template. This doesn't care, what the area
54 // template argument really is. Therefore, compile-time configuration just uses the containing class
55 // as is. So we need to make sure, that the logging statements use the containing class when
56 // checking the compile-time limit whereas they need to use the nested SENFLogArea when calling the
59 // So let's look at the logging statements. The central logic for parsing the logging parameters is
60 // in SENF_LOG_MERGE_PARAMETERS in Parameters.ih. Here we have a special case which detects classes
61 // with a SENFLogArea member and then set's things up correctly: It uses the containing class for
62 // compile time checking (this is, what 'area_base' typedef is for) while using the nested
63 // SENFLogArea for routing (this is, what the 'area' typedef is for).
65 // So the last thing which needs to be adjusted is the routing which is part of the Target
66 // class. Here for each template taking an area as an argument we really provide TWO templates, one
67 // taking the area directly, the other checking for a nested SENFLogArea member. We can
68 // differentiate these overloads using boost::enable_if and friends.
70 // This setup makes a class with SENF_LOG_CLASS_AREA() look like an ordinary area even though the
71 // implementation is somewhat different.
73 #define SENF_LOG_DEFINE_AREA_I(area, decls) \
75 : public senf::log::detail::AreaBase, public senf::singleton<area> \
77 static std::string name() { return instance().v_name(); } \
78 using senf::singleton<area>::instance; \
82 friend class senf::singleton<area>; \
89 /// Internal: Alias base class
94 //-/////////////////////////////////////////////////////////////////////////////////////////////////
101 // comment-column: 40
102 // c-file-style: "senf"
103 // indent-tabs-mode: nil
104 // ispell-local-dictionary: "american"
105 // compile-command: "scons -u test"