A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
file-aggregator.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Bucknell University
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: L. Felipe Perrone (perrone@bucknell.edu)
18 *
19 * Modified by: Mitch Watrous (watrous@u.washington.edu)
20 *
21 */
22
23#ifndef FILE_AGGREGATOR_H
24#define FILE_AGGREGATOR_H
25
26#include "ns3/data-collection-object.h"
27
28#include <fstream>
29#include <map>
30#include <string>
31
32namespace ns3
33{
34
41{
42 public:
45 {
50 };
51
56 static TypeId GetTypeId();
57
66 FileAggregator(const std::string& outputFileName, FileType fileType = SPACE_SEPARATED);
67
68 ~FileAggregator() override;
69
77 void SetFileType(FileType fileType);
78
88 void SetHeading(const std::string& heading);
89
96 void Set1dFormat(const std::string& format);
97
104 void Set2dFormat(const std::string& format);
105
112 void Set3dFormat(const std::string& format);
113
120 void Set4dFormat(const std::string& format);
121
128 void Set5dFormat(const std::string& format);
129
136 void Set6dFormat(const std::string& format);
137
144 void Set7dFormat(const std::string& format);
145
152 void Set8dFormat(const std::string& format);
153
160 void Set9dFormat(const std::string& format);
161
168 void Set10dFormat(const std::string& format);
169
170 // Below are hooked to connectors exporting data
171 // They are not overloaded since it confuses the compiler when made
172 // into callbacks
173
180 void Write1d(std::string context, double v1);
181
189 void Write2d(std::string context, double v1, double v2);
190
199 void Write3d(std::string context, double v1, double v2, double v3);
200
210 void Write4d(std::string context, double v1, double v2, double v3, double v4);
211
222 void Write5d(std::string context, double v1, double v2, double v3, double v4, double v5);
223
235 void Write6d(std::string context,
236 double v1,
237 double v2,
238 double v3,
239 double v4,
240 double v5,
241 double v6);
242
255 void Write7d(std::string context,
256 double v1,
257 double v2,
258 double v3,
259 double v4,
260 double v5,
261 double v6,
262 double v7);
263
277 void Write8d(std::string context,
278 double v1,
279 double v2,
280 double v3,
281 double v4,
282 double v5,
283 double v6,
284 double v7,
285 double v8);
286
301 void Write9d(std::string context,
302 double v1,
303 double v2,
304 double v3,
305 double v4,
306 double v5,
307 double v6,
308 double v7,
309 double v8,
310 double v9);
311
327 void Write10d(std::string context,
328 double v1,
329 double v2,
330 double v3,
331 double v4,
332 double v5,
333 double v6,
334 double v7,
335 double v8,
336 double v9,
337 double v10);
338
339 private:
341 std::string m_outputFileName;
342
344 std::ofstream m_file;
345
348
350 std::string m_separator;
351
354
356 std::string m_heading;
357
358 std::string m_1dFormat;
359 std::string m_2dFormat;
360 std::string m_3dFormat;
361 std::string m_4dFormat;
362 std::string m_5dFormat;
363 std::string m_6dFormat;
364 std::string m_7dFormat;
365 std::string m_8dFormat;
366 std::string m_9dFormat;
367 std::string m_10dFormat;
368
369}; // class FileAggregator
370
371} // namespace ns3
372
373#endif // FILE_AGGREGATOR_H
Base class for data collection framework objects.
This aggregator sends values it receives to a file.
~FileAggregator() override
void Set4dFormat(const std::string &format)
Sets the 4D format string for the C-style sprintf() function.
void Write7d(std::string context, double v1, double v2, double v3, double v4, double v5, double v6, double v7)
Writes 7 values to the file.
void Write3d(std::string context, double v1, double v2, double v3)
Writes 3 values to the file.
std::string m_separator
Printed between values in the file.
void Set6dFormat(const std::string &format)
Sets the 6D format string for the C-style sprintf() function.
std::string m_5dFormat
Format string for 5D C-style sprintf() function.
FileType m_fileType
Determines the kind of file written by the aggregator.
std::string m_4dFormat
Format string for 4D C-style sprintf() function.
void Set8dFormat(const std::string &format)
Sets the 8D format string for the C-style sprintf() function.
void Write1d(std::string context, double v1)
Writes 1 value to the file.
void Set7dFormat(const std::string &format)
Sets the 7D format string for the C-style sprintf() function.
void Write9d(std::string context, double v1, double v2, double v3, double v4, double v5, double v6, double v7, double v8, double v9)
Writes 9 values to the file.
void Write4d(std::string context, double v1, double v2, double v3, double v4)
Writes 4 values to the file.
void Set2dFormat(const std::string &format)
Sets the 2D format string for the C-style sprintf() function.
void SetFileType(FileType fileType)
Set the file type to create, which determines the separator to use when printing values to the file.
void Set9dFormat(const std::string &format)
Sets the 9D format string for the C-style sprintf() function.
std::string m_10dFormat
Format string for 10D C-style sprintf() function.
std::ofstream m_file
Used to write values to the file.
void Write2d(std::string context, double v1, double v2)
Writes 2 values to the file.
std::string m_9dFormat
Format string for 9D C-style sprintf() function.
void Write5d(std::string context, double v1, double v2, double v3, double v4, double v5)
Writes 5 values to the file.
void Set3dFormat(const std::string &format)
Sets the 3D format string for the C-style sprintf() function.
void Set1dFormat(const std::string &format)
Sets the 1D format string for the C-style sprintf() function.
bool m_hasHeadingBeenSet
Indicates if the heading line for the file has been set.
std::string m_7dFormat
Format string for 7D C-style sprintf() function.
std::string m_heading
Heading line for the outputfile.
void Set10dFormat(const std::string &format)
Sets the 10D format string for the C-style sprintf() function.
void Write6d(std::string context, double v1, double v2, double v3, double v4, double v5, double v6)
Writes 6 values to the file.
void Set5dFormat(const std::string &format)
Sets the 5D format string for the C-style sprintf() function.
std::string m_3dFormat
Format string for 3D C-style sprintf() function.
void SetHeading(const std::string &heading)
Sets the heading string that will be printed on the first line of the file.
std::string m_1dFormat
Format string for 1D C-style sprintf() function.
std::string m_outputFileName
The file name.
std::string m_6dFormat
Format string for 6D C-style sprintf() function.
std::string m_8dFormat
Format string for 8D C-style sprintf() function.
void Write8d(std::string context, double v1, double v2, double v3, double v4, double v5, double v6, double v7, double v8)
Writes 8 values to the file.
FileType
The type of file written by the aggregator.
std::string m_2dFormat
Format string for 2D C-style sprintf() function.
void Write10d(std::string context, double v1, double v2, double v3, double v4, double v5, double v6, double v7, double v8, double v9, double v10)
Writes 10 values to the file.
static TypeId GetTypeId()
Get the type ID.
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.