Helper class used to put data values into a file. More...
#include <file-helper.h>
 Collaboration diagram for ns3::FileHelper:
 Collaboration diagram for ns3::FileHelper:| Public Member Functions | |
| FileHelper () | |
| Constructs a file helper that will create a space separated file named "file-helper.txt" unless it is later configured otherwise.  More... | |
| FileHelper (const std::string &outputFileNameWithoutExtension, enum FileAggregator::FileType fileType=FileAggregator::SPACE_SEPARATED) | |
| virtual | ~FileHelper () | 
| void | AddAggregator (const std::string &aggregatorName, const std::string &outputFileName, bool onlyOneAggregator) | 
| Adds an aggregator to be used to write values to files.  More... | |
| 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.  More... | |
| void | AddTimeSeriesAdaptor (const std::string &adaptorName) | 
| Adds a time series adaptor to be used to write the file.  More... | |
| void | ConfigureFile (const std::string &outputFileNameWithoutExtension, enum FileAggregator::FileType fileType=FileAggregator::SPACE_SEPARATED) | 
| Ptr< FileAggregator > | GetAggregatorMultiple (const std::string &aggregatorName, const std::string &outputFileName) | 
| Gets one of the multiple aggregators from the map.  More... | |
| Ptr< FileAggregator > | GetAggregatorSingle () | 
| Gets the single aggregator that is always constructed.  More... | |
| Ptr< Probe > | GetProbe (std::string probeName) const | 
| Gets the specified probe.  More... | |
| void | Set10dFormat (const std::string &format) | 
| Sets the 10D format string for the C-style sprintf() function.  More... | |
| void | Set1dFormat (const std::string &format) | 
| Sets the 1D format string for the C-style sprintf() function.  More... | |
| void | Set2dFormat (const std::string &format) | 
| Sets the 2D format string for the C-style sprintf() function.  More... | |
| void | Set3dFormat (const std::string &format) | 
| Sets the 3D format string for the C-style sprintf() function.  More... | |
| void | Set4dFormat (const std::string &format) | 
| Sets the 4D format string for the C-style sprintf() function.  More... | |
| void | Set5dFormat (const std::string &format) | 
| Sets the 5D format string for the C-style sprintf() function.  More... | |
| void | Set6dFormat (const std::string &format) | 
| Sets the 6D format string for the C-style sprintf() function.  More... | |
| void | Set7dFormat (const std::string &format) | 
| Sets the 7D format string for the C-style sprintf() function.  More... | |
| void | Set8dFormat (const std::string &format) | 
| Sets the 8D format string for the C-style sprintf() function.  More... | |
| void | Set9dFormat (const std::string &format) | 
| Sets the 9D format string for the C-style sprintf() function.  More... | |
| void | SetHeading (const std::string &heading) | 
| Sets the heading string that will be printed on the first line of the file.  More... | |
| void | WriteProbe (const std::string &typeId, const std::string &path, const std::string &probeTraceSource) | 
| Private Member Functions | |
| 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.  More... | |
| Private Attributes | |
| std::string | m_10dFormat | 
| Format string for 10D format C-style sprintf() function.  More... | |
| std::string | m_1dFormat | 
| Format string for 1D format C-style sprintf() function.  More... | |
| std::string | m_2dFormat | 
| Format string for 2D format C-style sprintf() function.  More... | |
| std::string | m_3dFormat | 
| Format string for 3D format C-style sprintf() function.  More... | |
| std::string | m_4dFormat | 
| Format string for 4D format C-style sprintf() function.  More... | |
| std::string | m_5dFormat | 
| Format string for 5D format C-style sprintf() function.  More... | |
| std::string | m_6dFormat | 
| Format string for 6D format C-style sprintf() function.  More... | |
| std::string | m_7dFormat | 
| Format string for 7D format C-style sprintf() function.  More... | |
| std::string | m_8dFormat | 
| Format string for 8D format C-style sprintf() function.  More... | |
| std::string | m_9dFormat | 
| Format string for 9D format C-style sprintf() function.  More... | |
| Ptr< FileAggregator > | m_aggregator | 
| The single aggregator that is always created in the constructor.  More... | |
| std::map< std::string, Ptr < FileAggregator > > | m_aggregatorMap | 
| Maps aggregator names to aggregators when multiple aggregators are needed.  More... | |
| ObjectFactory | m_factory | 
| Used to create the probes and collectors as they are added.  More... | |
| uint32_t | m_fileProbeCount | 
| Number of file probes that have been created.  More... | |
| enum FileAggregator::FileType | m_fileType | 
| Determines the kind of file written by the aggregator.  More... | |
| bool | m_hasHeadingBeenSet | 
| Indicates if the heading line for the file has been set.  More... | |
| std::string | m_heading | 
| Heading line for the outputfile.  More... | |
| std::string | m_outputFileNameWithoutExtension | 
| The name of the output file to created without its extension.  More... | |
| std::map< std::string, std::pair< Ptr< Probe > , std::string > > | m_probeMap | 
| Maps probe names to probes.  More... | |
| std::map< std::string, Ptr < TimeSeriesAdaptor > > | m_timeSeriesAdaptorMap | 
| Maps time series adaptor names to time series adaptors.  More... | |
Helper class used to put data values into a file.
Definition at line 38 of file file-helper.h.
| ns3::FileHelper::FileHelper | ( | ) | 
Constructs a file helper that will create a space separated file named "file-helper.txt" unless it is later configured otherwise.
Definition at line 36 of file file-helper.cc.
References NS_LOG_FUNCTION.
| ns3::FileHelper::FileHelper | ( | const std::string & | outputFileNameWithoutExtension, | 
| enum FileAggregator::FileType | fileType = FileAggregator::SPACE_SEPARATED | ||
| ) | 
| outputFileNameWithoutExtension | name of output file to write with no extension | 
| fileType | type of file to write. | 
Constructs a file helper that will create a file named outputFileNameWithoutExtension plus possible extra information from wildcard matches plus ".txt" with values printed as specified by fileType. The default file type is space-separated.
Definition at line 49 of file file-helper.cc.
References NS_LOG_FUNCTION.
| 
 | virtual | 
Definition at line 63 of file file-helper.cc.
References NS_LOG_FUNCTION.
| void ns3::FileHelper::AddAggregator | ( | const std::string & | aggregatorName, | 
| const std::string & | outputFileName, | ||
| bool | onlyOneAggregator | ||
| ) | 
Adds an aggregator to be used to write values to files.
| aggregatorName | the aggregator's name. | 
| outputFileName | name of the file to write. | 
| onlyOneAggregator | indicates if more than one aggregator should be created or not. | 
Definition at line 238 of file file-helper.cc.
References GetAggregatorSingle(), m_10dFormat, m_1dFormat, m_2dFormat, m_3dFormat, m_4dFormat, m_5dFormat, m_6dFormat, m_7dFormat, m_8dFormat, m_9dFormat, m_aggregatorMap, m_fileType, m_heading, NS_ABORT_MSG, and NS_LOG_FUNCTION.
Referenced by ConnectProbeToAggregator(), and GetAggregatorMultiple().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| void ns3::FileHelper::AddProbe | ( | const std::string & | typeId, | 
| const std::string & | probeName, | ||
| const std::string & | path | ||
| ) | 
Adds a probe to be used to write values to files.
| typeId | the type ID for the probe used when it is created. | 
| probeName | the probe's name. | 
| path | Config path to access the probe | 
Definition at line 181 of file file-helper.cc.
References ns3::ObjectFactory::Create(), ns3::Object::GetObject(), m_factory, m_probeMap, NS_ABORT_MSG, NS_LOG_FUNCTION, and ns3::ObjectFactory::SetTypeId().
Referenced by ConnectProbeToAggregator().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| void ns3::FileHelper::AddTimeSeriesAdaptor | ( | const std::string & | adaptorName | ) | 
Adds a time series adaptor to be used to write the file.
| adaptorName | the timeSeriesAdaptor's name. | 
Definition at line 217 of file file-helper.cc.
References m_timeSeriesAdaptorMap, NS_ABORT_MSG, and NS_LOG_FUNCTION.
Referenced by ConnectProbeToAggregator().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| void ns3::FileHelper::ConfigureFile | ( | const std::string & | outputFileNameWithoutExtension, | 
| enum FileAggregator::FileType | fileType = FileAggregator::SPACE_SEPARATED | ||
| ) | 
| outputFileNameWithoutExtension | name of output file to write with no extension | 
| fileType | type of file to write. | 
Configures file related parameters for this file helper so that it will create a file named outputFileNameWithoutExtension plus possible extra information from wildcard matches plus ".txt" with values printed as specified by fileType. The default file type is space-separated.
Definition at line 69 of file file-helper.cc.
References m_aggregator, m_fileType, m_hasHeadingBeenSet, m_outputFileNameWithoutExtension, NS_LOG_FUNCTION, and NS_LOG_WARN.
Referenced by main().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | private | 
Connects the probe to the aggregator.
| typeId | the type ID for the probe used when it is created. | 
| matchIdentifier | this string is used to make the probe's context be unique. | 
| path | Config path to access the probe. | 
| probeTraceSource | the probe trace source to access. | 
| outputFileNameWithoutExtension | name of output file to write with no extension | 
| onlyOneAggregator | indicates if more than one aggregator should be created or not. | 
A fatal error will result if an unknown probe type is used.
Definition at line 452 of file file-helper.cc.
References AddAggregator(), AddProbe(), AddTimeSeriesAdaptor(), m_aggregatorMap, m_fileProbeCount, m_probeMap, m_timeSeriesAdaptorMap, ns3::MakeCallback(), NS_FATAL_ERROR, NS_LOG_FUNCTION, ns3::TimeSeriesAdaptor::TraceSinkBoolean(), ns3::TimeSeriesAdaptor::TraceSinkDouble(), ns3::TimeSeriesAdaptor::TraceSinkUinteger16(), ns3::TimeSeriesAdaptor::TraceSinkUinteger32(), ns3::TimeSeriesAdaptor::TraceSinkUinteger8(), and ns3::FileAggregator::Write2d().
Referenced by WriteProbe().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| Ptr< FileAggregator > ns3::FileHelper::GetAggregatorMultiple | ( | const std::string & | aggregatorName, | 
| const std::string & | outputFileName | ||
| ) | 
Gets one of the multiple aggregators from the map.
| aggregatorName | name for aggregator. | 
| outputFileName | name of output file to write. | 
Definition at line 341 of file file-helper.cc.
References AddAggregator(), m_aggregatorMap, and NS_LOG_FUNCTION.
 Here is the call graph for this function:
 Here is the call graph for this function:| Ptr< FileAggregator > ns3::FileHelper::GetAggregatorSingle | ( | ) | 
Gets the single aggregator that is always constructed.
Definition at line 307 of file file-helper.cc.
References m_10dFormat, m_1dFormat, m_2dFormat, m_3dFormat, m_4dFormat, m_5dFormat, m_6dFormat, m_7dFormat, m_8dFormat, m_9dFormat, m_aggregator, m_fileType, m_heading, m_outputFileNameWithoutExtension, and NS_LOG_FUNCTION.
Referenced by AddAggregator().
 Here is the caller graph for this function:
 Here is the caller graph for this function:Gets the specified probe.
| probeName | the probe's name. | 
Definition at line 288 of file file-helper.cc.
References m_probeMap, NS_ABORT_MSG, and NS_LOG_FUNCTION.
| void ns3::FileHelper::Set10dFormat | ( | const std::string & | format | ) | 
Sets the 10D format string for the C-style sprintf() function.
| format | the 10D format string. | 
Definition at line 444 of file file-helper.cc.
References m_10dFormat, and NS_LOG_FUNCTION.
| void ns3::FileHelper::Set1dFormat | ( | const std::string & | format | ) | 
Sets the 1D format string for the C-style sprintf() function.
| format | the 1D format string. | 
Definition at line 372 of file file-helper.cc.
References m_1dFormat, and NS_LOG_FUNCTION.
| void ns3::FileHelper::Set2dFormat | ( | const std::string & | format | ) | 
Sets the 2D format string for the C-style sprintf() function.
| format | the 2D format string. | 
Definition at line 380 of file file-helper.cc.
References m_2dFormat, and NS_LOG_FUNCTION.
Referenced by main().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| void ns3::FileHelper::Set3dFormat | ( | const std::string & | format | ) | 
Sets the 3D format string for the C-style sprintf() function.
| format | the 3D format string. | 
Definition at line 388 of file file-helper.cc.
References m_3dFormat, and NS_LOG_FUNCTION.
| void ns3::FileHelper::Set4dFormat | ( | const std::string & | format | ) | 
Sets the 4D format string for the C-style sprintf() function.
| format | the 4D format string. | 
Definition at line 396 of file file-helper.cc.
References m_4dFormat, and NS_LOG_FUNCTION.
| void ns3::FileHelper::Set5dFormat | ( | const std::string & | format | ) | 
Sets the 5D format string for the C-style sprintf() function.
| format | the 5D format string. | 
Definition at line 404 of file file-helper.cc.
References m_5dFormat, and NS_LOG_FUNCTION.
| void ns3::FileHelper::Set6dFormat | ( | const std::string & | format | ) | 
Sets the 6D format string for the C-style sprintf() function.
| format | the 6D format string. | 
Definition at line 412 of file file-helper.cc.
References m_6dFormat, and NS_LOG_FUNCTION.
| void ns3::FileHelper::Set7dFormat | ( | const std::string & | format | ) | 
Sets the 7D format string for the C-style sprintf() function.
| format | the 7D format string. | 
Definition at line 420 of file file-helper.cc.
References m_7dFormat, and NS_LOG_FUNCTION.
| void ns3::FileHelper::Set8dFormat | ( | const std::string & | format | ) | 
Sets the 8D format string for the C-style sprintf() function.
| format | the 8D format string. | 
Definition at line 428 of file file-helper.cc.
References m_8dFormat, and NS_LOG_FUNCTION.
| void ns3::FileHelper::Set9dFormat | ( | const std::string & | format | ) | 
Sets the 9D format string for the C-style sprintf() function.
| format | the 9D format string. | 
Definition at line 436 of file file-helper.cc.
References m_9dFormat, and NS_LOG_FUNCTION.
| void ns3::FileHelper::SetHeading | ( | const std::string & | heading | ) | 
Sets the heading string that will be printed on the first line of the file.
| heading | the heading string. | 
Note that the heading string will only be printed if it has been set by calling this function.
Definition at line 363 of file file-helper.cc.
References m_hasHeadingBeenSet, m_heading, and NS_LOG_FUNCTION.
| void ns3::FileHelper::WriteProbe | ( | const std::string & | typeId, | 
| const std::string & | path, | ||
| const std::string & | probeTraceSource | ||
| ) | 
| typeId | the type ID for the probe used when it is created. | 
| path | Config path to access the probe. | 
| probeTraceSource | the probe trace source to access. | 
Creates output files generated by hooking the ns-3 trace source with a probe, and then writing the values from the probeTraceSource. The output file names will have the text stored in m_outputFileNameWithoutExtension plus ".txt", and will consist of the 'newValue' at each timestamp.
If the config path has more than one match in the system (e.g. there is a wildcard), then one output file for each match will be created. The output file names will contain the text in m_outputFileNameWithoutExtension plus the matched characters for each of the wildcards in the config path, separated by dashes, plus ".txt". For example, if the value in m_outputFileNameWithoutExtension is the string "packet-byte-count", and there are two wildcards in the path, then output file names like "packet-byte-count-0-0.txt" or "packet-byte-count-12-9.txt" will be possible as names for the files that will be created.
A fatal error will result if an unknown probe type is used.
This is used to indicate if multiple aggregators are needed.
Definition at line 91 of file file-helper.cc.
References ConnectProbeToAggregator(), ns3::Config::MatchContainer::GetMatchedPath(), ns3::Config::MatchContainer::GetN(), ns3::GetWildcardMatches(), ns3::Config::LookupMatches(), m_outputFileNameWithoutExtension, NS_FATAL_ERROR, and NS_LOG_FUNCTION.
Referenced by main().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | private | 
Format string for 10D format C-style sprintf() function.
Definition at line 317 of file file-helper.h.
Referenced by AddAggregator(), GetAggregatorSingle(), and Set10dFormat().
| 
 | private | 
Format string for 1D format C-style sprintf() function.
Definition at line 308 of file file-helper.h.
Referenced by AddAggregator(), GetAggregatorSingle(), and Set1dFormat().
| 
 | private | 
Format string for 2D format C-style sprintf() function.
Definition at line 309 of file file-helper.h.
Referenced by AddAggregator(), GetAggregatorSingle(), and Set2dFormat().
| 
 | private | 
Format string for 3D format C-style sprintf() function.
Definition at line 310 of file file-helper.h.
Referenced by AddAggregator(), GetAggregatorSingle(), and Set3dFormat().
| 
 | private | 
Format string for 4D format C-style sprintf() function.
Definition at line 311 of file file-helper.h.
Referenced by AddAggregator(), GetAggregatorSingle(), and Set4dFormat().
| 
 | private | 
Format string for 5D format C-style sprintf() function.
Definition at line 312 of file file-helper.h.
Referenced by AddAggregator(), GetAggregatorSingle(), and Set5dFormat().
| 
 | private | 
Format string for 6D format C-style sprintf() function.
Definition at line 313 of file file-helper.h.
Referenced by AddAggregator(), GetAggregatorSingle(), and Set6dFormat().
| 
 | private | 
Format string for 7D format C-style sprintf() function.
Definition at line 314 of file file-helper.h.
Referenced by AddAggregator(), GetAggregatorSingle(), and Set7dFormat().
| 
 | private | 
Format string for 8D format C-style sprintf() function.
Definition at line 315 of file file-helper.h.
Referenced by AddAggregator(), GetAggregatorSingle(), and Set8dFormat().
| 
 | private | 
Format string for 9D format C-style sprintf() function.
Definition at line 316 of file file-helper.h.
Referenced by AddAggregator(), GetAggregatorSingle(), and Set9dFormat().
| 
 | private | 
The single aggregator that is always created in the constructor.
Definition at line 281 of file file-helper.h.
Referenced by ConfigureFile(), and GetAggregatorSingle().
| 
 | private | 
Maps aggregator names to aggregators when multiple aggregators are needed.
Definition at line 285 of file file-helper.h.
Referenced by AddAggregator(), ConnectProbeToAggregator(), and GetAggregatorMultiple().
| 
 | private | 
Used to create the probes and collectors as they are added.
Definition at line 278 of file file-helper.h.
Referenced by AddProbe().
| 
 | private | 
Number of file probes that have been created.
Definition at line 294 of file file-helper.h.
Referenced by ConnectProbeToAggregator().
| 
 | private | 
Determines the kind of file written by the aggregator.
Definition at line 297 of file file-helper.h.
Referenced by AddAggregator(), ConfigureFile(), and GetAggregatorSingle().
| 
 | private | 
Indicates if the heading line for the file has been set.
Definition at line 303 of file file-helper.h.
Referenced by ConfigureFile(), and SetHeading().
| 
 | private | 
Heading line for the outputfile.
Definition at line 306 of file file-helper.h.
Referenced by AddAggregator(), GetAggregatorSingle(), and SetHeading().
| 
 | private | 
The name of the output file to created without its extension.
Definition at line 300 of file file-helper.h.
Referenced by ConfigureFile(), GetAggregatorSingle(), and WriteProbe().
Maps probe names to probes.
Definition at line 288 of file file-helper.h.
Referenced by AddProbe(), ConnectProbeToAggregator(), and GetProbe().
| 
 | private | 
Maps time series adaptor names to time series adaptors.
Definition at line 291 of file file-helper.h.
Referenced by AddTimeSeriesAdaptor(), and ConnectProbeToAggregator().