A Discrete-Event Network Simulator
API
des-metrics.h
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2016 LLNL
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Peter D. Barnes, Jr. <pdbarnes@llnl.gov>
19 */
20
21#ifndef DESMETRICS_H
22#define DESMETRICS_H
23
30#include "nstime.h"
31#include "singleton.h"
32#include "system-mutex.h"
33
34#include <stdint.h> // uint32_t
35#include <fstream>
36#include <string>
37#include <vector>
38
39namespace ns3 {
40
108class DesMetrics : public Singleton<DesMetrics>
109{
110public:
111
121 void Initialize (std::vector<std::string> args, std::string outDir = "");
122
129 void Trace (const Time & now, const Time & delay);
130
138 void TraceWithContext (uint32_t context, const Time & now, const Time & delay);
139
143 ~DesMetrics (void);
144
145private:
146
148 void Close (void);
149
156 static std::string m_outputDir;
157
159 std::ofstream m_os;
161
164
165}; // class DesMetrics
166
167
168} // namespace ns3
169
170#endif /* DESMETRICS_H */
Event trace data collector for the DES Metrics project.
Definition: des-metrics.h:109
SystemMutex m_mutex
Mutex to control access to the output file.
Definition: des-metrics.h:163
void Close(void)
Close the output file.
Definition: des-metrics.cc:147
bool m_initialized
Have we been initialized.
Definition: des-metrics.h:158
void Initialize(std::vector< std::string > args, std::string outDir="")
Open the DesMetrics trace file and print the header.
Definition: des-metrics.cc:42
char m_separator
The separator between event records.
Definition: des-metrics.h:160
void Trace(const Time &now, const Time &delay)
Trace an event to self at the time it is scheduled.
Definition: des-metrics.cc:102
void TraceWithContext(uint32_t context, const Time &now, const Time &delay)
Trace an event (with context) at the time it is scheduled.
Definition: des-metrics.cc:108
std::ofstream m_os
The output JSON trace file stream.
Definition: des-metrics.h:159
~DesMetrics(void)
Destructor, closes the trace file.
Definition: des-metrics.cc:141
static std::string m_outputDir
Cache the last-used output directory.
Definition: des-metrics.h:156
A template singleton.
Definition: singleton.h:61
A class which provides a relatively platform-independent Mutual Exclusion thread synchronization prim...
Definition: system-mutex.h:59
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Declaration of classes ns3::Time and ns3::TimeWithUnit, and the TimeValue implementation classes.
ns3::Singleton declaration and template implementation.
System-independent mutex primitive, ns3::SystemMutex, and ns3::CriticalSection.