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 TimeSource public header */
26 #ifndef HH_SENF_Utils_Logger_TimeSource_
27 #define HH_SENF_Utils_Logger_TimeSource_ 1
30 #include <boost/cstdint.hpp>
32 #include "../../config.hh"
34 //#include "TimeSource.mpp"
35 ///////////////////////////////hh.p////////////////////////////////////////
40 typedef config::time_type time_type;
42 /** \brief Log message time source abstract base class
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
48 A new TimeSource may be installed using \ref senf::log::timeSource().
54 virtual ~TimeSource();
55 virtual time_type operator()() const = 0;
57 static time_type now();
60 /** \brief Default %log message time source
62 This time source is installed by default and uses gettimeofday() (via the Boost.DateTime
63 library) to get the current universal time.
67 struct SystemTimeSource : public TimeSource
69 virtual time_type operator()() const;
72 /** \brief Change %log message time source
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.
77 Since the time source class will in almost all cases be default constructible, see the
78 template overload for a simpler interface.
82 void timeSource(std::auto_ptr<TimeSource> source);
84 /** \brief Change %log message time source
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.
91 template <class Source> void timeSource();
95 ///////////////////////////////hh.e////////////////////////////////////////
96 #include "TimeSource.cci"
97 //#include "TimeSource.ct"
98 #include "TimeSource.cti"
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"