A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
topology-reader-helper.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 Universita' di Firenze, Italy
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Tommaso Pecorella (tommaso.pecorella@unifi.it)
7 * Author: Valerio Sartini (valesar@gmail.com)
8 */
9
11
12#include "ns3/inet-topology-reader.h"
13#include "ns3/log.h"
14#include "ns3/object.h"
15#include "ns3/orbis-topology-reader.h"
16#include "ns3/rocketfuel-topology-reader.h"
17
18/**
19 * \file
20 * \ingroup topology
21 * ns3::TopologyHelper implementation.
22 */
23
24namespace ns3
25{
26
27NS_LOG_COMPONENT_DEFINE("TopologyReaderHelper");
28
33
34void
35TopologyReaderHelper::SetFileName(const std::string fileName)
36{
37 m_fileName = fileName;
38}
39
40void
41TopologyReaderHelper::SetFileType(const std::string fileType)
42{
43 m_fileType = fileType;
44}
45
48{
49 if (!m_inputModel)
50 {
51 NS_ASSERT_MSG(!m_fileType.empty(), "Missing File Type");
52 NS_ASSERT_MSG(!m_fileName.empty(), "Missing File Name");
53
54 if (m_fileType == "Orbis")
55 {
56 NS_LOG_INFO("Creating Orbis formatted data input.");
58 }
59 else if (m_fileType == "Inet")
60 {
61 NS_LOG_INFO("Creating Inet formatted data input.");
63 }
64 else if (m_fileType == "Rocketfuel")
65 {
66 NS_LOG_INFO("Creating Rocketfuel formatted data input.");
68 }
69 else
70 {
71 NS_ASSERT_MSG(false, "Wrong (unknown) File Type");
72 }
73
74 m_inputModel->SetFileName(m_fileName);
75 }
76 return m_inputModel;
77}
78
79} // namespace ns3
Smart pointer class similar to boost::intrusive_ptr.
std::string m_fileName
Name of the input file.
void SetFileType(const std::string fileType)
Sets the input file type.
Ptr< TopologyReader > m_inputModel
Smart pointer to the actual topology model.
Ptr< TopologyReader > GetTopologyReader()
Gets a Ptr<TopologyReader> to the actual TopologyReader.
void SetFileName(const std::string fileName)
Sets the input file name.
std::string m_fileType
Type of the input file (e.g., "Inet", "Orbis", etc.).
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:75
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:264
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::TopologyHelper declaration.