26 #include "ns3/abort.h"
28 #include "ns3/config.h"
29 #include "ns3/get-wildcard-matches.h"
39 m_outputFileNameWithoutExtension (
"file-helper"),
40 m_hasHeadingBeenSet (false)
52 m_fileType (fileType),
53 m_outputFileNameWithoutExtension (outputFileNameWithoutExtension),
54 m_hasHeadingBeenSet (false)
77 " may be destroyed if no references remain.");
91 const std::string &path,
92 const std::string &probeTraceSource)
96 std::string pathWithoutLastToken;
97 std::string lastToken;
100 bool pathHasNoWildcards = path.find (
"*") == std::string::npos;
103 size_t lastSlash = path.find_last_of (
"/");
104 if (lastSlash == std::string::npos)
106 pathWithoutLastToken = path;
112 pathWithoutLastToken = path.substr (0, lastSlash);
115 lastToken = path.substr (lastSlash + 1, std::string::npos);
121 uint32_t matchCount = matches.
GetN ();
124 std::string matchIdentifier;
127 bool onlyOneAggregator;
130 if (matchCount == 1 && pathHasNoWildcards)
135 matchIdentifier =
"0";
136 onlyOneAggregator =
true;
144 else if (matchCount > 0)
147 for (uint32_t i = 0; i < matchCount; i++)
150 std::ostringstream matchIdentifierStream;
151 matchIdentifierStream << i;
152 matchIdentifier = matchIdentifierStream.str ();
153 onlyOneAggregator =
false;
157 std::string wildcardSeparator =
"-";
181 const std::string &probeName,
182 const std::string &path)
203 probe->SetName (probeName);
206 probe->ConnectByPath (path);
212 m_probeMap[probeName] = std::make_pair (probe, typeId);
223 NS_ABORT_MSG (
"That time series adaptor has already been added");
230 timeSeriesAdaptor->
Enable ();
238 const std::string &outputFileName,
239 bool onlyOneAggregator)
241 NS_LOG_FUNCTION (
this << aggregatorName << outputFileName << onlyOneAggregator);
246 NS_ABORT_MSG (
"That file aggregator has already been added");
251 if (onlyOneAggregator)
262 CreateObject<FileAggregator> (outputFileName,
m_fileType);
280 multipleAggregator->
Enable ();
292 std::map<std::string, std::pair <Ptr<Probe>, std::string> >::const_iterator mapIterator =
m_probeMap.find (probeName);
297 return mapIterator->second.first;
341 const std::string &outputFileName)
353 bool onlyOneAggregator =
false;
452 const std::string &matchIdentifier,
453 const std::string &path,
454 const std::string &probeTraceSource,
455 const std::string &outputFileNameWithoutExtension,
456 bool onlyOneAggregator)
458 NS_LOG_FUNCTION (
this << typeId << matchIdentifier << path << probeTraceSource
459 << outputFileNameWithoutExtension << onlyOneAggregator);
465 std::ostringstream probeNameStream;
467 std::string probeName = probeNameStream.str ();
470 std::string probeContext = probeName
471 +
"/" + matchIdentifier +
"/" + probeTraceSource;
483 if (
m_probeMap[probeName].second ==
"ns3::DoubleProbe")
485 m_probeMap[probeName].first->TraceConnectWithoutContext
490 else if (
m_probeMap[probeName].second ==
"ns3::BooleanProbe")
492 m_probeMap[probeName].first->TraceConnectWithoutContext
497 else if (
m_probeMap[probeName].second ==
"ns3::PacketProbe")
499 m_probeMap[probeName].first->TraceConnectWithoutContext
504 else if (
m_probeMap[probeName].second ==
"ns3::ApplicationPacketProbe")
506 m_probeMap[probeName].first->TraceConnectWithoutContext
511 else if (
m_probeMap[probeName].second ==
"ns3::Ipv4PacketProbe")
513 m_probeMap[probeName].first->TraceConnectWithoutContext
518 else if (
m_probeMap[probeName].second ==
"ns3::Ipv6PacketProbe")
520 m_probeMap[probeName].first->TraceConnectWithoutContext
525 else if (
m_probeMap[probeName].second ==
"ns3::Uinteger8Probe")
527 m_probeMap[probeName].first->TraceConnectWithoutContext
532 else if (
m_probeMap[probeName].second ==
"ns3::Uinteger16Probe")
534 m_probeMap[probeName].first->TraceConnectWithoutContext
539 else if (
m_probeMap[probeName].second ==
"ns3::Uinteger32Probe")
541 m_probeMap[probeName].first->TraceConnectWithoutContext
548 NS_FATAL_ERROR (
"Unknown probe type " <<
m_probeMap[probeName].second <<
"; need to add support in the helper for this");
553 std::string outputFileName = outputFileNameWithoutExtension +
".txt";
554 AddAggregator (probeContext, outputFileName, onlyOneAggregator);
557 std::string adaptorTraceSource =
"Output";