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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Peter D. Barnes, Jr. <pdbarnes@llnl.gov>
18 */
19
20#ifndef SYSTEM_WALL_CLOCK_TIMESTAMP_H
21#define SYSTEM_WALL_CLOCK_TIMESTAMP_H
22
23/**
24 * \file
25 * \ingroup system
26 * ns3::SystemWallClockTimestamp declaration.
27 */
28
29#include <ctime> // ctime, time_t
30#include <string>
31
32namespace ns3
33{
34
35/**
36 * Utility class to record the difference between two wall-clock times.
37 */
39{
40 public:
41 /** Constructor */
43
44 /** Record the current wall-clock time and delta since the last stamp(). */
45 void Stamp();
46
47 /**
48 * Get the last time stamp as a string.
49 * \return The last time stamp.
50 */
51 std::string ToString() const;
52
53 /**
54 * Get the last recorded raw value.
55 * \returns The last time stamp recorded.
56 */
57 std::time_t GetLast() const;
58
59 /**
60 * Get the last recorded interval.
61 * \returns The interval between the last two time stamps.
62 */
63 std::time_t GetInterval() const;
64
65 private:
66 /** The last time stamp. */
67 std::time_t m_last;
68
69 /** Difference between the two previous time stamps. */
70 std::time_t m_diff;
71
72}; // class SystemWallClockTimestamp
73
74} // namespace ns3
75
76#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.