TimeSource.cci
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 /** \file
15  \brief TimeSource inline non-template implementation */
16 
17 #include "TimeSource.ih"
18 
19 // Custom includes
20 
21 #define prefix_ inline
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 // senf::log::detail::TimeSourceManager
26 
27 prefix_ senf::log::detail::TimeSourceManager::TimeSourceManager()
28  : timeSource_ (new SystemTimeSource())
29 {}
30 
31 prefix_ senf::log::time_type senf::log::detail::TimeSourceManager::now()
32 {
33  return (*timeSource_)();
34 }
35 
36 prefix_ void senf::log::detail::TimeSourceManager::timeSource(std::unique_ptr<TimeSource> source)
37 {
38  timeSource_.reset(source.release());
39 }
40 
41 //-/////////////////////////////////////////////////////////////////////////////////////////////////
42 // senf::log::TimeSource
43 
44 prefix_ senf::log::time_type senf::log::TimeSource::now()
45 {
46  return detail::TimeSourceManager::instance().now();
47 }
48 
49 //-/////////////////////////////////////////////////////////////////////////////////////////////////
50 // namespace senf::log members
51 
52 prefix_ void senf::log::timeSource(std::unique_ptr<TimeSource> source)
53 {
54  detail::TimeSourceManager::instance().timeSource(std::move(source));
55 }
56 
57 //-/////////////////////////////////////////////////////////////////////////////////////////////////
58 #undef prefix_
59 
60 
61 // Local Variables:
62 // mode: c++
63 // fill-column: 100
64 // comment-column: 40
65 // c-file-style: "senf"
66 // indent-tabs-mode: nil
67 // ispell-local-dictionary: "american"
68 // compile-command: "scons -u test"
69 // End: