A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
file-helper.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013 University of Washington
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: Mitch Watrous (watrous@u.washington.edu)
19  */
20 
21 #ifndef FILE_HELPER_H
22 #define FILE_HELPER_H
23 
24 #include <map>
25 #include <string>
26 #include "ns3/object-factory.h"
27 #include "ns3/ptr.h"
28 #include "ns3/probe.h"
29 #include "ns3/file-aggregator.h"
30 #include "ns3/time-series-adaptor.h"
31 
32 namespace ns3 {
33 
39 {
40 public:
45  FileHelper ();
46 
57  FileHelper (const std::string &outputFileNameWithoutExtension,
59 
60  virtual ~FileHelper ();
61 
73  void ConfigureFile (const std::string &outputFileNameWithoutExtension,
75 
101  void WriteProbe (const std::string &typeId,
102  const std::string &path,
103  const std::string &probeTraceSource);
104 
112  void AddProbe (const std::string &typeId,
113  const std::string &probeName,
114  const std::string &path);
115 
121  void AddTimeSeriesAdaptor (const std::string &adaptorName);
122 
131  void AddAggregator (const std::string &aggregatorName,
132  const std::string &outputFileName,
133  bool onlyOneAggregator);
134 
140  Ptr<Probe> GetProbe (std::string probeName) const;
141 
150 
160  Ptr<FileAggregator> GetAggregatorMultiple (const std::string &aggregatorName,
161  const std::string &outputFileName);
162 
172  void SetHeading (const std::string &heading);
173 
180  void Set1dFormat (const std::string &format);
181 
188  void Set2dFormat (const std::string &format);
189 
196  void Set3dFormat (const std::string &format);
197 
204  void Set4dFormat (const std::string &format);
205 
212  void Set5dFormat (const std::string &format);
213 
220  void Set6dFormat (const std::string &format);
221 
228  void Set7dFormat (const std::string &format);
229 
236  void Set8dFormat (const std::string &format);
237 
244  void Set9dFormat (const std::string &format);
245 
252  void Set10dFormat (const std::string &format);
253 
254 private:
270  void ConnectProbeToAggregator (const std::string &typeId,
271  const std::string &matchIdentifier,
272  const std::string &path,
273  const std::string &probeTraceSource,
274  const std::string &outputFileNameWithoutExtension,
275  bool onlyOneAggregator);
276 
279 
282 
285  std::map<std::string, Ptr<FileAggregator> > m_aggregatorMap;
286 
288  std::map<std::string, std::pair <Ptr<Probe>, std::string> > m_probeMap;
289 
291  std::map<std::string, Ptr<TimeSeriesAdaptor> > m_timeSeriesAdaptorMap;
292 
295 
298 
301 
304 
306  std::string m_heading;
307 
308  std::string m_1dFormat;
309  std::string m_2dFormat;
310  std::string m_3dFormat;
311  std::string m_4dFormat;
312  std::string m_5dFormat;
313  std::string m_6dFormat;
314  std::string m_7dFormat;
315  std::string m_8dFormat;
316  std::string m_9dFormat;
317  std::string m_10dFormat;
318 
319 }; // class FileHelper
320 
321 
322 } // namespace ns3
323 
324 #endif // FILE_HELPER_H
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
std::string m_3dFormat
Format string for 3D format C-style sprintf() function.
Definition: file-helper.h:310
std::string m_6dFormat
Format string for 6D format C-style sprintf() function.
Definition: file-helper.h:313
std::string m_9dFormat
Format string for 9D format C-style sprintf() function.
Definition: file-helper.h:316
void Set4dFormat(const std::string &format)
Sets the 4D format string for the C-style sprintf() function.
Definition: file-helper.cc:395
std::string m_4dFormat
Format string for 4D format C-style sprintf() function.
Definition: file-helper.h:311
Ptr< FileAggregator > m_aggregator
The single aggregator that is always created in the constructor.
Definition: file-helper.h:281
void Set8dFormat(const std::string &format)
Sets the 8D format string for the C-style sprintf() function.
Definition: file-helper.cc:427
void Set6dFormat(const std::string &format)
Sets the 6D format string for the C-style sprintf() function.
Definition: file-helper.cc:411
void Set5dFormat(const std::string &format)
Sets the 5D format string for the C-style sprintf() function.
Definition: file-helper.cc:403
void Set10dFormat(const std::string &format)
Sets the 10D format string for the C-style sprintf() function.
Definition: file-helper.cc:443
std::string m_7dFormat
Format string for 7D format C-style sprintf() function.
Definition: file-helper.h:314
void AddProbe(const std::string &typeId, const std::string &probeName, const std::string &path)
Adds a probe to be used to write values to files.
Definition: file-helper.cc:180
void AddAggregator(const std::string &aggregatorName, const std::string &outputFileName, bool onlyOneAggregator)
Adds an aggregator to be used to write values to files.
Definition: file-helper.cc:237
Ptr< Probe > GetProbe(std::string probeName) const
Gets the specified probe.
Definition: file-helper.cc:287
void Set9dFormat(const std::string &format)
Sets the 9D format string for the C-style sprintf() function.
Definition: file-helper.cc:435
uint32_t m_fileProbeCount
Number of file probes that have been created.
Definition: file-helper.h:294
std::string m_10dFormat
Format string for 10D format C-style sprintf() function.
Definition: file-helper.h:317
std::string m_8dFormat
Format string for 8D format C-style sprintf() function.
Definition: file-helper.h:315
FileType
The type of file written by the aggregator.
FileHelper()
Constructs a file helper that will create a space separated file named "file-helper.txt" unless it is later configured otherwise.
Definition: file-helper.cc:35
std::string m_heading
Heading line for the outputfile.
Definition: file-helper.h:306
Ptr< FileAggregator > GetAggregatorSingle()
Gets the single aggregator that is always constructed.
Definition: file-helper.cc:306
Helper class used to put data values into a file.
Definition: file-helper.h:38
void AddTimeSeriesAdaptor(const std::string &adaptorName)
Adds a time series adaptor to be used to write the file.
Definition: file-helper.cc:216
ObjectFactory m_factory
Used to create the probes and collectors as they are added.
Definition: file-helper.h:278
void Set7dFormat(const std::string &format)
Sets the 7D format string for the C-style sprintf() function.
Definition: file-helper.cc:419
std::map< std::string, std::pair< Ptr< Probe >, std::string > > m_probeMap
Maps probe names to probes.
Definition: file-helper.h:288
virtual ~FileHelper()
Definition: file-helper.cc:62
std::map< std::string, Ptr< FileAggregator > > m_aggregatorMap
Maps aggregator names to aggregators when multiple aggregators are needed.
Definition: file-helper.h:285
enum FileAggregator::FileType m_fileType
Determines the kind of file written by the aggregator.
Definition: file-helper.h:297
Ptr< FileAggregator > GetAggregatorMultiple(const std::string &aggregatorName, const std::string &outputFileName)
Gets one of the multiple aggregators from the map.
Definition: file-helper.cc:340
void SetHeading(const std::string &heading)
Sets the heading string that will be printed on the first line of the file.
Definition: file-helper.cc:362
void ConfigureFile(const std::string &outputFileNameWithoutExtension, enum FileAggregator::FileType fileType=FileAggregator::SPACE_SEPARATED)
Definition: file-helper.cc:68
void Set1dFormat(const std::string &format)
Sets the 1D format string for the C-style sprintf() function.
Definition: file-helper.cc:371
std::string m_1dFormat
Format string for 1D format C-style sprintf() function.
Definition: file-helper.h:308
void ConnectProbeToAggregator(const std::string &typeId, const std::string &matchIdentifier, const std::string &path, const std::string &probeTraceSource, const std::string &outputFileNameWithoutExtension, bool onlyOneAggregator)
Connects the probe to the aggregator.
Definition: file-helper.cc:451
std::string m_2dFormat
Format string for 2D format C-style sprintf() function.
Definition: file-helper.h:309
instantiate subclasses of ns3::Object.
void Set3dFormat(const std::string &format)
Sets the 3D format string for the C-style sprintf() function.
Definition: file-helper.cc:387
bool m_hasHeadingBeenSet
Indicates if the heading line for the file has been set.
Definition: file-helper.h:303
std::string m_5dFormat
Format string for 5D format C-style sprintf() function.
Definition: file-helper.h:312
std::map< std::string, Ptr< TimeSeriesAdaptor > > m_timeSeriesAdaptorMap
Maps time series adaptor names to time series adaptors.
Definition: file-helper.h:291
void WriteProbe(const std::string &typeId, const std::string &path, const std::string &probeTraceSource)
Definition: file-helper.cc:90
std::string m_outputFileNameWithoutExtension
The name of the output file to created without its extension.
Definition: file-helper.h:300
void Set2dFormat(const std::string &format)
Sets the 2D format string for the C-style sprintf() function.
Definition: file-helper.cc:379