NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
time-unit-test-clock.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22
#ifndef NDN_TIME_UNIT_TEST_CLOCK_HPP
23
#define NDN_TIME_UNIT_TEST_CLOCK_HPP
24
25
#include "
time-custom-clock.hpp
"
26
27
namespace
ndn
{
28
namespace
time
{
29
36
template
<
class
BaseClock>
37
class
UnitTestClockTraits
38
{
39
public
:
40
static
nanoseconds
41
getDefaultStartTime
()
42
{
43
return
nanoseconds::zero();
44
}
45
};
46
53
template
<>
54
class
UnitTestClockTraits
<
system_clock
>
55
{
56
public
:
57
static
nanoseconds
58
getDefaultStartTime
()
59
{
60
return
seconds(1415684132);
61
}
62
};
63
72
template
<
class
BaseClock>
73
class
UnitTestClock
:
public
CustomClock
<BaseClock>
74
{
75
public
:
76
explicit
77
UnitTestClock
(
const
nanoseconds& startTime =
UnitTestClockTraits<BaseClock>::getDefaultStartTime
());
78
82
void
83
advance(
const
nanoseconds& duration);
84
88
void
89
setNow(
const
nanoseconds& timeSinceEpoch);
90
91
public
:
// CustomClock<BaseClock>
92
virtual
std::string
93
getSince()
const override
;
94
95
virtual
typename
BaseClock::time_point
96
getNow()
const override
;
97
98
virtual
boost::posix_time::time_duration
99
toPosixDuration(
const
typename
BaseClock::duration& duration)
const override
;
100
101
private
:
102
nanoseconds m_currentTime;
103
};
104
105
typedef
UnitTestClock<system_clock>
UnitTestSystemClock
;
106
typedef
UnitTestClock<steady_clock>
UnitTestSteadyClock
;
107
108
}
// namespace time
109
}
// namespace ndn
110
111
#endif // NDN_TIME_UNIT_TEST_CLOCK_HPP
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::time::UnitTestSystemClock
UnitTestClock< system_clock > UnitTestSystemClock
Definition:
time-unit-test-clock.hpp:105
ndn::time::CustomClock
Class implementing custom system or steady clock behavior.
Definition:
time-custom-clock.hpp:37
ndn::time
Definition:
time-custom-clock.hpp:28
ndn::time::UnitTestClock
Clock that can be used in unit tests for time-dependent tests independent of wall clock...
Definition:
time-unit-test-clock.hpp:73
ndn::time::system_clock
System clock.
Definition:
time.hpp:81
ndn::time::UnitTestSteadyClock
UnitTestClock< steady_clock > UnitTestSteadyClock
Definition:
time-unit-test-clock.hpp:106
time-custom-clock.hpp
ndn::time::UnitTestClockTraits::getDefaultStartTime
static nanoseconds getDefaultStartTime()
Definition:
time-unit-test-clock.hpp:41
ndn::time::UnitTestClockTraits< system_clock >::getDefaultStartTime
static nanoseconds getDefaultStartTime()
Definition:
time-unit-test-clock.hpp:58
ndn::time::UnitTestClockTraits
Traits for UnitTestClock, defining default behavior for different clocks.
Definition:
time-unit-test-clock.hpp:37
ndnSIM
ndn-cxx
src
util
time-unit-test-clock.hpp
Generated on Wed Jan 11 2017 18:17:15 for ndnSIM by
1.8.13