A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
file-aggregator.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Bucknell University
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: L. Felipe Perrone (perrone@bucknell.edu)
19  *
20  * Modified by: Mitch Watrous (watrous@u.washington.edu)
21  *
22  */
23 
24 #ifndef FILE_AGGREGATOR_H
25 #define FILE_AGGREGATOR_H
26 
27 #include <fstream>
28 #include <map>
29 #include <string>
30 #include "ns3/data-collection-object.h"
31 
32 namespace ns3 {
33 
38 {
39 public:
41  enum FileType
42  {
47  };
48 
49  static TypeId GetTypeId ();
50 
59  FileAggregator (const std::string &outputFileName,
60  enum FileType fileType = SPACE_SEPARATED);
61 
62  virtual ~FileAggregator ();
63 
71  void SetFileType (enum FileType fileType);
72 
82  void SetHeading (const std::string &heading);
83 
90  void Set1dFormat (const std::string &format);
91 
98  void Set2dFormat (const std::string &format);
99 
106  void Set3dFormat (const std::string &format);
107 
114  void Set4dFormat (const std::string &format);
115 
122  void Set5dFormat (const std::string &format);
123 
130  void Set6dFormat (const std::string &format);
131 
138  void Set7dFormat (const std::string &format);
139 
146  void Set8dFormat (const std::string &format);
147 
154  void Set9dFormat (const std::string &format);
155 
162  void Set10dFormat (const std::string &format);
163 
164  // Below are hooked to connectors exporting data
165  // They are not overloaded since it confuses the compiler when made
166  // into callbacks
167 
174  void Write1d (std::string context,
175  double v1);
176 
184  void Write2d (std::string context,
185  double v1,
186  double v2);
187 
196  void Write3d (std::string context,
197  double v1,
198  double v2,
199  double v3);
200 
210  void Write4d (std::string context,
211  double v1,
212  double v2,
213  double v3,
214  double v4);
215 
226  void Write5d (std::string context,
227  double v1,
228  double v2,
229  double v3,
230  double v4,
231  double v5);
232 
244  void Write6d (std::string context,
245  double v1,
246  double v2,
247  double v3,
248  double v4,
249  double v5,
250  double v6);
251 
264  void Write7d (std::string context,
265  double v1,
266  double v2,
267  double v3,
268  double v4,
269  double v5,
270  double v6,
271  double v7);
272 
286  void Write8d (std::string context,
287  double v1,
288  double v2,
289  double v3,
290  double v4,
291  double v5,
292  double v6,
293  double v7,
294  double v8);
295 
310  void Write9d (std::string context,
311  double v1,
312  double v2,
313  double v3,
314  double v4,
315  double v5,
316  double v6,
317  double v7,
318  double v8,
319  double v9);
320 
336  void Write10d (std::string context,
337  double v1,
338  double v2,
339  double v3,
340  double v4,
341  double v5,
342  double v6,
343  double v7,
344  double v8,
345  double v9,
346  double v10);
347 
348 private:
350  std::string m_outputFileName;
351 
353  std::ofstream m_file;
354 
357 
359  std::string m_separator;
360 
363 
365  std::string m_heading;
366 
368  std::string m_1dFormat;
369  std::string m_2dFormat;
370  std::string m_3dFormat;
371  std::string m_4dFormat;
372  std::string m_5dFormat;
373  std::string m_6dFormat;
374  std::string m_7dFormat;
375  std::string m_8dFormat;
376  std::string m_9dFormat;
377  std::string m_10dFormat;
378 
379 }; // class FileAggregator
380 
381 
382 } // namespace ns3
383 
384 #endif // FILE_AGGREGATOR_H
std::string m_outputFileName
The file name.
void Set6dFormat(const std::string &format)
Sets the 6D format string for the C-style sprintf() function.
void Set2dFormat(const std::string &format)
Sets the 2D format string for the C-style sprintf() function.
bool m_hasHeadingBeenSet
Indicates if the heading line for the file has been set.
void Write1d(std::string context, double v1)
Writes 1 value to the file.
void Set5dFormat(const std::string &format)
Sets the 5D format string for the 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.
void Set8dFormat(const std::string &format)
Sets the 8D 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.
void Write2d(std::string context, double v1, double v2)
Writes 2 values to the file.
void Set10dFormat(const std::string &format)
Sets the 10D format string for the C-style sprintf() function.
void Set7dFormat(const std::string &format)
Sets the 7D format string for the C-style sprintf() function.
void Write3d(std::string context, double v1, double v2, double v3)
Writes 3 values to the file.
void Write4d(std::string context, double v1, double v2, double v3, double v4)
Writes 4 values to the file.
FileType
The type of file written by the aggregator.
void SetFileType(enum FileType fileType)
Set the file type to create, which determines the separator to use when printing values to the file...
std::string m_heading
Heading line for the outputfile.
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.
enum FileType m_fileType
Determines the kind of file written by the aggregator.
static TypeId GetTypeId()
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 Write5d(std::string context, double v1, double v2, double v3, double v4, double v5)
Writes 5 values to the file.
std::string m_1dFormat
Format strings for 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 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.
void Set9dFormat(const std::string &format)
Sets the 9D format string for the 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.
FileAggregator(const std::string &outputFileName, enum FileType fileType=SPACE_SEPARATED)
std::string m_separator
Printed between values in the file.
void Set3dFormat(const std::string &format)
Sets the 3D format string for the C-style sprintf() function.
std::ofstream m_file
Used to write values to the file.
a unique identifier for an interface.
Definition: type-id.h:49
void Set4dFormat(const std::string &format)
Sets the 4D format string for the C-style sprintf() function.