NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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 
30 
37 template<class BaseClock>
39 {
40 public:
41  static nanoseconds
43  {
44  return nanoseconds::zero();
45  };
46 };
47 
54 template<>
56 {
57 public:
58  static nanoseconds
60  {
61  return seconds(1415684132);
62  };
63 };
64 
73 template<class BaseClock>
74 class UnitTestClock : public CustomClock<BaseClock>
75 {
76 public:
77  explicit
78  UnitTestClock(const nanoseconds& startTime =
80 
84  void
85  advance(const nanoseconds& duration);
86 
90  void
91  setNow(const nanoseconds& timeSinceEpoch);
92 
93 public: // CustomClock<BaseClock>
94 
95  virtual std::string
96  getSince() const;
97 
98  virtual typename BaseClock::time_point
99  getNow() const;
100 
101  virtual boost::posix_time::time_duration
102  toPosixDuration(const typename BaseClock::duration& duration) const;
103 
104 private:
105  nanoseconds m_currentTime;
106 };
107 
110 
111 } // namespace time
112 } // namespace ndn
113 
114 #endif // NDN_TIME_UNIT_TEST_CLOCK_HPP
Copyright (c) 2011-2015 Regents of the University of California.
UnitTestClock< system_clock > UnitTestSystemClock
Class implementing custom system or steady clock behavior.
Clock that can be used in unit tests for time-dependent tests independent of wall clock...
System clock.
Definition: time.hpp:69
UnitTestClock< steady_clock > UnitTestSteadyClock
static nanoseconds getDefaultStartTime()
Traits for UnitTestClock, defining default behavior for different clocks.