NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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...
 
virtual std::string getSince () const
 
virtual BaseClock::time_point getNow () const
 
virtual boost::posix_time::time_duration toPosixDuration (const typename BaseClock::duration &duration) const
 
- Public Member Functions inherited from ndn::time::CustomClock< BaseClock >
virtual ~CustomClock ()
 

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 74 of file time-unit-test-clock.hpp.

Constructor & Destructor Documentation

§ UnitTestClock()

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

§ advance()

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().

§ setNow()

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().

§ getSince()

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

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

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

§ getNow()

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

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

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

§ toPosixDuration()

template<class BaseClock >
boost::posix_time::time_duration ndn::time::UnitTestClock< BaseClock >::toPosixDuration ( const typename BaseClock::duration &  duration) const
virtual

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: