NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
ndn::time::UnitTestClock< BaseClock, ClockTraits > Class Template Reference

Clock that can be used in unit tests for time-dependent tests independent of wall clock. More...

#include <time-unit-test-clock.hpp>

Inheritance diagram for ndn::time::UnitTestClock< BaseClock, ClockTraits >:
Collaboration diagram for ndn::time::UnitTestClock< BaseClock, ClockTraits >:

Public Member Functions

 UnitTestClock (nanoseconds startTime=ClockTraits::getDefaultStartTime())
 
void advance (nanoseconds duration)
 Advance unit test clock by duration. More...
 
void setNow (nanoseconds timeSinceEpoch)
 Explicitly set clock to timeSinceEpoch. More...
 
std::string getSince () const override
 
BaseClock::time_point getNow () const override
 
BaseClock::duration toWaitDuration (typename BaseClock::duration d) const override
 
- Public Member Functions inherited from ndn::time::CustomClock< BaseClock >
virtual ~CustomClock ()=default
 

Detailed Description

template<class BaseClock, class ClockTraits = UnitTestClockTraits<BaseClock>>
class ndn::time::UnitTestClock< BaseClock, ClockTraits >

Clock that can be used in unit tests for time-dependent tests independent of wall clock.

This clock should be explicitly advanced with UnitTestClock<BaseClock>::advance() or set with UnitTestClock<BaseClock>::setNow() methods.

Note
Default start time is determined by UnitTestClockTraits

Definition at line 73 of file time-unit-test-clock.hpp.

Constructor & Destructor Documentation

◆ UnitTestClock()

template<class BaseClock , class ClockTraits >
ndn::time::UnitTestClock< BaseClock, ClockTraits >::UnitTestClock ( nanoseconds  startTime = ClockTraits::getDefaultStartTime())
explicit

Definition at line 32 of file time-unit-test-clock.cpp.

Member Function Documentation

◆ advance()

template<class BaseClock , class ClockTraits >
void ndn::time::UnitTestClock< BaseClock, ClockTraits >::advance ( nanoseconds  duration)

Advance unit test clock by duration.

Definition at line 60 of file time-unit-test-clock.cpp.

◆ setNow()

template<class BaseClock , class ClockTraits >
void ndn::time::UnitTestClock< BaseClock, ClockTraits >::setNow ( nanoseconds  timeSinceEpoch)

Explicitly set clock to timeSinceEpoch.

Definition at line 81 of file time-unit-test-clock.cpp.

◆ getSince()

template<class BaseClock , class ClockTraits >
std::string ndn::time::UnitTestClock< BaseClock, ClockTraits >::getSince ( ) const
overridevirtual

Implements ndn::time::CustomClock< BaseClock >.

Definition at line 39 of file time-unit-test-clock.cpp.

◆ getNow()

template<class BaseClock , class ClockTraits >
BaseClock::time_point ndn::time::UnitTestClock< BaseClock, ClockTraits >::getNow ( ) const
overridevirtual

Implements ndn::time::CustomClock< BaseClock >.

Definition at line 46 of file time-unit-test-clock.cpp.

◆ toWaitDuration()

template<class BaseClock , class ClockTraits >
BaseClock::duration ndn::time::UnitTestClock< BaseClock, ClockTraits >::toWaitDuration ( typename BaseClock::duration  d) const
overridevirtual

Implements ndn::time::CustomClock< BaseClock >.

Definition at line 53 of file time-unit-test-clock.cpp.


The documentation for this class was generated from the following files: