A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
system-wall-clock-timestamp.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Lawrence Livermore National Laboratory
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Peter D. Barnes, Jr. <pdbarnes@llnl.gov>
7 */
8
9#ifndef SYSTEM_WALL_CLOCK_TIMESTAMP_H
10#define SYSTEM_WALL_CLOCK_TIMESTAMP_H
11
12/**
13 * \file
14 * \ingroup system
15 * ns3::SystemWallClockTimestamp declaration.
16 */
17
18#include <ctime> // ctime, time_t
19#include <string>
20
21namespace ns3
22{
23
24/**
25 * Utility class to record the difference between two wall-clock times.
26 */
28{
29 public:
30 /** Constructor */
32
33 /** Record the current wall-clock time and delta since the last stamp(). */
34 void Stamp();
35
36 /**
37 * Get the last time stamp as a string.
38 * \return The last time stamp.
39 */
40 std::string ToString() const;
41
42 /**
43 * Get the last recorded raw value.
44 * \returns The last time stamp recorded.
45 */
46 std::time_t GetLast() const;
47
48 /**
49 * Get the last recorded interval.
50 * \returns The interval between the last two time stamps.
51 */
52 std::time_t GetInterval() const;
53
54 private:
55 /** The last time stamp. */
56 std::time_t m_last;
57
58 /** Difference between the two previous time stamps. */
59 std::time_t m_diff;
60
61}; // class SystemWallClockTimestamp
62
63} // namespace ns3
64
65#endif /* SYSTEM_WALL_CLOCK_TIMESTAMP_H */
Utility class to record the difference between two wall-clock times.
std::time_t GetInterval() const
Get the last recorded interval.
std::time_t GetLast() const
Get the last recorded raw value.
std::string ToString() const
Get the last time stamp as a string.
std::time_t m_diff
Difference between the two previous time stamps.
void Stamp()
Record the current wall-clock time and delta since the last stamp().
std::time_t m_last
The last time stamp.
Every class exported by the ns3 library is enclosed in the ns3 namespace.