NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
ndn::time::UnitTestClock< BaseClock > 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 >:
Collaboration diagram for ndn::time::UnitTestClock< BaseClock >:

Public Member Functions

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

Detailed Description

template<class BaseClock>
class ndn::time::UnitTestClock< BaseClock >

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

template<class BaseClock >
ndn::time::UnitTestClock< BaseClock >::UnitTestClock ( const nanoseconds &  startTime = UnitTestClockTraits<BaseClock>::getDefaultStartTime())
explicit

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

Member Function Documentation

template<class BaseClock >
void ndn::time::UnitTestClock< BaseClock >::advance ( const nanoseconds &  duration)

Advance unit test clock by duration.

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

References ndn::time::SLEEP_AFTER_TIME_CHANGE().

template<class BaseClock >
void ndn::time::UnitTestClock< BaseClock >::setNow ( const nanoseconds &  timeSinceEpoch)

Explicitly set clock to timeSinceEpoch.

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

References ndn::time::SLEEP_AFTER_TIME_CHANGE().

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

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

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

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

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

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

template<class BaseClock >
boost::posix_time::time_duration ndn::time::UnitTestClock< BaseClock >::toPosixDuration ( const typename BaseClock::duration &  duration) 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: