Fix documentation build under maverick (doxygen 1.7.1)
[senf.git] / senf / Utils / Logger / TimeSource.hh
1 // $Id$
2 //
3 // Copyright (C) 2008
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
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.
12 //
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.
17 //
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.
22
23 /** \file
24     \brief TimeSource public header */
25
26 #ifndef HH_SENF_Utils_Logger_TimeSource_
27 #define HH_SENF_Utils_Logger_TimeSource_ 1
28
29 // Custom includes
30 #include <boost/cstdint.hpp>
31 #include <memory>
32 #include <senf/config.hh>
33
34 //#include "TimeSource.mpp"
35 //-/////////////////////////////////////////////////////////////////////////////////////////////////
36
37 namespace senf {
38 namespace log {
39
40     typedef config::time_type time_type;
41
42     /** \brief Log message time source abstract base class
43
44         Instances derived from TimeSource provide the Logging library with the current date/time
45         value. The \c operator() member must be implemented to return the current universal time
46         (UTC).
47
48         A new TimeSource may be installed using \ref senf::log::timeSource().
49
50         \ingroup config
51      */
52     struct TimeSource
53     {
54         virtual ~TimeSource();
55         virtual time_type operator()() const = 0;
56
57         static time_type now();
58     };
59
60     /** \brief Default %log message time source
61
62         This time source is installed by default and uses gettimeofday() (via the Boost.DateTime
63         library) to get the current universal time.
64
65         \ingroup config
66      */
67     struct SystemTimeSource : public TimeSource
68     {
69         virtual time_type operator()() const;
70     };
71
72     /** \brief Change %log message time source
73
74         Set the %log message time source to \a source. The logging library will take ownership of \e
75         source and will take care to free it, if necessary.
76
77         Since the time source class will in almost all cases be default constructible, see the
78         template overload for a simpler interface.
79
80         \ingroup config
81      */
82     void timeSource(std::auto_ptr<TimeSource> source);
83
84     /** \brief Change %log message time source
85
86         Set the %log message time source to (an instance of) \a Source.  \a Source must be default
87         constructible, otherwise use the non-template senf::log::timeSource() overload.
88
89         \ingroup config
90      */
91     template <class Source> void timeSource();
92
93 }}
94
95 //-/////////////////////////////////////////////////////////////////////////////////////////////////
96 #include "TimeSource.cci"
97 //#include "TimeSource.ct"
98 #include "TimeSource.cti"
99 #endif
100
101 \f
102 // Local Variables:
103 // mode: c++
104 // fill-column: 100
105 // comment-column: 40
106 // c-file-style: "senf"
107 // indent-tabs-mode: nil
108 // ispell-local-dictionary: "american"
109 // compile-command: "scons -u test"
110 // End: