A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
10
#include "
topology-reader-helper.h
"
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
24
namespace
ns3
25
{
26
27
NS_LOG_COMPONENT_DEFINE
(
"TopologyReaderHelper"
);
28
29
TopologyReaderHelper::TopologyReaderHelper
()
30
{
31
m_inputModel
=
nullptr
;
32
}
33
34
void
35
TopologyReaderHelper::SetFileName
(
const
std::string fileName)
36
{
37
m_fileName
= fileName;
38
}
39
40
void
41
TopologyReaderHelper::SetFileType
(
const
std::string fileType)
42
{
43
m_fileType
= fileType;
44
}
45
46
Ptr<TopologyReader>
47
TopologyReaderHelper::GetTopologyReader
()
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."
);
57
m_inputModel
=
CreateObject<OrbisTopologyReader>
();
58
}
59
else
if
(
m_fileType
==
"Inet"
)
60
{
61
NS_LOG_INFO
(
"Creating Inet formatted data input."
);
62
m_inputModel
=
CreateObject<InetTopologyReader>
();
63
}
64
else
if
(
m_fileType
==
"Rocketfuel"
)
65
{
66
NS_LOG_INFO
(
"Creating Rocketfuel formatted data input."
);
67
m_inputModel
=
CreateObject<RocketfuelTopologyReader>
();
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
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::TopologyReaderHelper::m_fileName
std::string m_fileName
Name of the input file.
Definition
topology-reader-helper.h:56
ns3::TopologyReaderHelper::SetFileType
void SetFileType(const std::string fileType)
Sets the input file type.
Definition
topology-reader-helper.cc:41
ns3::TopologyReaderHelper::TopologyReaderHelper
TopologyReaderHelper()
Definition
topology-reader-helper.cc:29
ns3::TopologyReaderHelper::m_inputModel
Ptr< TopologyReader > m_inputModel
Smart pointer to the actual topology model.
Definition
topology-reader-helper.h:55
ns3::TopologyReaderHelper::GetTopologyReader
Ptr< TopologyReader > GetTopologyReader()
Gets a Ptr<TopologyReader> to the actual TopologyReader.
Definition
topology-reader-helper.cc:47
ns3::TopologyReaderHelper::SetFileName
void SetFileName(const std::string fileName)
Sets the input file name.
Definition
topology-reader-helper.cc:35
ns3::TopologyReaderHelper::m_fileType
std::string m_fileType
Type of the input file (e.g., "Inet", "Orbis", etc.).
Definition
topology-reader-helper.h:57
NS_ASSERT_MSG
#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
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition
log.h:264
ns3::CreateObject
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition
object.h:619
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
topology-reader-helper.h
ns3::TopologyHelper declaration.
src
topology-read
helper
topology-reader-helper.cc
Generated on Fri Nov 8 2024 13:59:06 for ns-3 by
1.11.0