A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
topology-reader-helper.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2010 Universita' di Firenze, Italy
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Tommaso Pecorella (tommaso.pecorella@unifi.it)
19  * Author: Valerio Sartini (valesar@gmail.com)
20  */
21 
22 #include "ns3/object.h"
23 #include "ns3/topology-reader-helper.h"
24 #include "ns3/inet-topology-reader.h"
25 #include "ns3/orbis-topology-reader.h"
26 #include "ns3/rocketfuel-topology-reader.h"
27 #include "ns3/log.h"
28 
29 namespace ns3 {
30 
31 NS_LOG_COMPONENT_DEFINE ("TopologyReaderHelper")
32  ;
33 
35 {
36  m_inputModel = 0;
37 }
38 
39 void
40 TopologyReaderHelper::SetFileName (const std::string fileName)
41 {
42  m_fileName = fileName;
43 }
44 
45 void
46 TopologyReaderHelper::SetFileType (const std::string fileType)
47 {
48  m_fileType = fileType;
49 }
50 
51 
54 {
55  if (!m_inputModel)
56  {
57  NS_ASSERT_MSG (!m_fileType.empty (), "Missing File Type");
58  NS_ASSERT_MSG (!m_fileName.empty (), "Missing File Name");
59 
60  if (m_fileType == "Orbis")
61  {
62  NS_LOG_INFO ("Creating Orbis formatted data input.");
63  m_inputModel = CreateObject<OrbisTopologyReader> ();
64  }
65  else if (m_fileType == "Inet")
66  {
67  NS_LOG_INFO ("Creating Inet formatted data input.");
68  m_inputModel = CreateObject<InetTopologyReader> ();
69  }
70  else if (m_fileType == "Rocketfuel")
71  {
72  NS_LOG_INFO ("Creating Rocketfuel formatted data input.");
73  m_inputModel = CreateObject<RocketfuelTopologyReader> ();
74  }
75  else
76  {
77  NS_ASSERT_MSG (false, "Wrong (unknown) File Type");
78  }
79 
80  m_inputModel->SetFileName (m_fileName);
81  }
82  return m_inputModel;
83 }
84 
85 
86 
87 } // namespace ns3
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
NS_LOG_COMPONENT_DEFINE("GrantedTimeWindowMpiInterface")
#define NS_LOG_INFO(msg)
Definition: log.h:298
void SetFileName(const std::string fileName)
Sets the input file name.
std::string m_fileName
Name of the input file.
Ptr< TopologyReader > GetTopologyReader()
Gets a Ptr to the actual TopologyReader.
void SetFileType(const std::string fileType)
Sets the input file type.
Ptr< TopologyReader > m_inputModel
Smart pointer to the actual topology model.
#define NS_ASSERT_MSG(condition, message)
Definition: assert.h:86
std::string m_fileType
Type of the input file (e.g., "Inet", "Orbis", etc.).