OTest2
A C++ testing framework
timesource.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Ondrej Starek
3  *
4  * This file is part of OTest2.
5  *
6  * OTest2 is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License,
9  * or (at your option) any later version.
10  *
11  * OTest2 is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14  * License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with OTest2. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef OTest2__INCLUDE_OTEST2_TIMESOURCE_H_
21 #define OTest2__INCLUDE_OTEST2_TIMESOURCE_H_
22 
23 #include <chrono>
24 
25 namespace OTest2 {
26 
30 class TimeSource {
31  public:
32  typedef std::chrono::system_clock::time_point time_point;
33  typedef time_point::duration duration;
34 
38  TimeSource();
39 
43  virtual ~TimeSource();
44 
45  /* -- avoid copying */
46  TimeSource(
47  const TimeSource&) = delete;
49  const TimeSource&) = delete;
50 
54  virtual time_point now() = 0;
55 };
56 
57 } /* -- namespace OTest2 */
58 
59 #endif /* -- OTest2__INCLUDE_OTEST2_TIMESOURCE_H_ */
OTest2::TimeSource::~TimeSource
virtual ~TimeSource()
Dtor.
Definition: timesource.cpp:28
OTest2::TimeSource::duration
time_point::duration duration
Definition: timesource.h:33
OTest2::TimeSource
Generic interface for getting of current time.
Definition: timesource.h:30
OTest2::TimeSource::TimeSource
TimeSource()
Ctor.
Definition: timesource.cpp:24
OTest2
Definition: assertbean.h:25
OTest2::TimeSource::now
virtual time_point now()=0
Get current time.
OTest2::TimeSource::operator=
TimeSource & operator=(const TimeSource &)=delete
OTest2::TimeSource::time_point
std::chrono::system_clock::time_point time_point
Definition: timesource.h:32