A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
topology-reader-helper.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2010 Universita' di Firenze, Italy
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Tommaso Pecorella (tommaso.pecorella@unifi.it)
18
* Author: Valerio Sartini (valesar@gmail.com)
19
*/
20
21
#include "
topology-reader-helper.h
"
22
23
#include "ns3/inet-topology-reader.h"
24
#include "ns3/log.h"
25
#include "ns3/object.h"
26
#include "ns3/orbis-topology-reader.h"
27
#include "ns3/rocketfuel-topology-reader.h"
28
35
namespace
ns3
36
{
37
38
NS_LOG_COMPONENT_DEFINE
(
"TopologyReaderHelper"
);
39
40
TopologyReaderHelper::TopologyReaderHelper
()
41
{
42
m_inputModel
=
nullptr
;
43
}
44
45
void
46
TopologyReaderHelper::SetFileName
(
const
std::string fileName)
47
{
48
m_fileName
= fileName;
49
}
50
51
void
52
TopologyReaderHelper::SetFileType
(
const
std::string fileType)
53
{
54
m_fileType
= fileType;
55
}
56
57
Ptr<TopologyReader>
58
TopologyReaderHelper::GetTopologyReader
()
59
{
60
if
(!
m_inputModel
)
61
{
62
NS_ASSERT_MSG
(!
m_fileType
.empty(),
"Missing File Type"
);
63
NS_ASSERT_MSG
(!
m_fileName
.empty(),
"Missing File Name"
);
64
65
if
(
m_fileType
==
"Orbis"
)
66
{
67
NS_LOG_INFO
(
"Creating Orbis formatted data input."
);
68
m_inputModel
= CreateObject<OrbisTopologyReader>();
69
}
70
else
if
(
m_fileType
==
"Inet"
)
71
{
72
NS_LOG_INFO
(
"Creating Inet formatted data input."
);
73
m_inputModel
= CreateObject<InetTopologyReader>();
74
}
75
else
if
(
m_fileType
==
"Rocketfuel"
)
76
{
77
NS_LOG_INFO
(
"Creating Rocketfuel formatted data input."
);
78
m_inputModel
= CreateObject<RocketfuelTopologyReader>();
79
}
80
else
81
{
82
NS_ASSERT_MSG
(
false
,
"Wrong (unknown) File Type"
);
83
}
84
85
m_inputModel
->SetFileName(
m_fileName
);
86
}
87
return
m_inputModel
;
88
}
89
90
}
// namespace ns3
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
ns3::TopologyReaderHelper::m_fileName
std::string m_fileName
Name of the input file.
Definition:
topology-reader-helper.h:67
ns3::TopologyReaderHelper::SetFileType
void SetFileType(const std::string fileType)
Sets the input file type.
Definition:
topology-reader-helper.cc:52
ns3::TopologyReaderHelper::TopologyReaderHelper
TopologyReaderHelper()
Definition:
topology-reader-helper.cc:40
ns3::TopologyReaderHelper::m_inputModel
Ptr< TopologyReader > m_inputModel
Smart pointer to the actual topology model.
Definition:
topology-reader-helper.h:66
ns3::TopologyReaderHelper::GetTopologyReader
Ptr< TopologyReader > GetTopologyReader()
Gets a Ptr<TopologyReader> to the actual TopologyReader.
Definition:
topology-reader-helper.cc:58
ns3::TopologyReaderHelper::SetFileName
void SetFileName(const std::string fileName)
Sets the input file name.
Definition:
topology-reader-helper.cc:46
ns3::TopologyReaderHelper::m_fileType
std::string m_fileType
Type of the input file (e.g., "Inet", "Orbis", etc.).
Definition:
topology-reader-helper.h:68
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:86
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition:
log.h:275
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 Sun Mar 3 2024 17:11:09 for ns-3 by
1.9.1