A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
mobility-building-info.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
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: Marco Miozzo <marco.miozzo@cttc.es>
19  *
20  */
21 
22 #include <ns3/simulator.h>
23 #include <ns3/position-allocator.h>
24 #include <ns3/mobility-building-info.h>
25 #include <ns3/pointer.h>
26 #include <ns3/log.h>
27 #include <ns3/assert.h>
28 
29 NS_LOG_COMPONENT_DEFINE ("MobilityBuildingInfo");
30 
31 namespace ns3 {
32 
33 NS_OBJECT_ENSURE_REGISTERED (MobilityBuildingInfo)
34  ;
35 
36 TypeId
38 {
39  static TypeId tid = TypeId ("ns3::MobilityBuildingInfo")
40  .SetParent<Object> ()
41  .SetGroupName ("Building")
42  .AddConstructor<MobilityBuildingInfo> ();
43 
44  return tid;
45 }
46 
47 
49 {
50  NS_LOG_FUNCTION (this);
51  m_indoor = false;
52  m_nFloor = 1;
53  m_roomX = 1;
54  m_roomY = 1;
55 }
56 
57 
59  : m_myBuilding (building)
60 {
61  NS_LOG_FUNCTION (this);
62  m_indoor = false;
63  m_nFloor = 1;
64  m_roomX = 1;
65  m_roomY = 1;
66 }
67 
68 bool
70 {
71  NS_LOG_FUNCTION (this);
72  return (m_indoor);
73 }
74 
75 bool
77 {
78  NS_LOG_FUNCTION (this);
79  return (!m_indoor);
80 }
81 
82 void
83 MobilityBuildingInfo::SetIndoor (Ptr<Building> building, uint8_t nfloor, uint8_t nroomx, uint8_t nroomy)
84 {
85  NS_LOG_FUNCTION (this);
86  m_indoor = true;
87  m_myBuilding = building;
88  m_nFloor = nfloor;
89  m_roomX = nroomx;
90  m_roomY = nroomy;
91 
92 
93  NS_ASSERT (m_roomX > 0);
94  NS_ASSERT (m_roomX <= building->GetNRoomsX ());
95  NS_ASSERT (m_roomY > 0);
96  NS_ASSERT (m_roomY <= building->GetNRoomsY ());
97  NS_ASSERT (m_nFloor > 0);
98  NS_ASSERT (m_nFloor <= building->GetNFloors ());
99 
100 }
101 
102 
103 void
104 MobilityBuildingInfo::SetIndoor (uint8_t nfloor, uint8_t nroomx, uint8_t nroomy)
105 {
106  NS_LOG_FUNCTION (this);
107  m_indoor = true;
108  m_nFloor = nfloor;
109  m_roomX = nroomx;
110  m_roomY = nroomy;
111 
112  NS_ASSERT_MSG (m_myBuilding, "Node does not have any building defined");
113  NS_ASSERT (m_roomX > 0);
114  NS_ASSERT (m_roomX <= m_myBuilding->GetNRoomsX ());
115  NS_ASSERT (m_roomY > 0);
116  NS_ASSERT (m_roomY <= m_myBuilding->GetNRoomsY ());
117  NS_ASSERT (m_nFloor > 0);
118  NS_ASSERT (m_nFloor <= m_myBuilding->GetNFloors ());
119 
120 }
121 
122 
123 void
125 {
126  NS_LOG_FUNCTION (this);
127  m_indoor = false;
128 }
129 
130 uint8_t
132 {
133  NS_LOG_FUNCTION (this);
134  return (m_nFloor);
135 }
136 
137 uint8_t
139 {
140  NS_LOG_FUNCTION (this);
141  return (m_roomX);
142 }
143 
144 uint8_t
146 {
147  NS_LOG_FUNCTION (this);
148  return (m_roomY);
149 }
150 
151 
154 {
155  NS_LOG_FUNCTION (this);
156  return (m_myBuilding);
157 }
158 
159 
160 } // namespace
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
#define NS_ASSERT(condition)
Definition: assert.h:64
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
void SetOutdoor()
Mark this MobilityBuildingInfo instance as outdoor.
void SetIndoor(Ptr< Building > building, uint8_t nfloor, uint8_t nroomx, uint8_t nroomy)
Mark this MobilityBuildingInfo instance as indoor.
#define NS_ASSERT_MSG(condition, message)
Definition: assert.h:86
mobility buildings information (to be used by mobility models)
a base class which provides memory management and object aggregation
Definition: object.h:63
NS_LOG_COMPONENT_DEFINE("MobilityBuildingInfo")
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611