A Discrete-Event Network Simulator
API
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 namespace ns3 {
30 
31 NS_LOG_COMPONENT_DEFINE ("MobilityBuildingInfo");
32 
33 NS_OBJECT_ENSURE_REGISTERED (MobilityBuildingInfo);
34 
35 TypeId
37 {
38  static TypeId tid = TypeId ("ns3::MobilityBuildingInfo")
39  .SetParent<Object> ()
40  .SetGroupName ("Buildings")
41  .AddConstructor<MobilityBuildingInfo> ();
42 
43  return tid;
44 }
45 
46 
48 {
49  NS_LOG_FUNCTION (this);
50  m_indoor = false;
51  m_nFloor = 1;
52  m_roomX = 1;
53  m_roomY = 1;
54 }
55 
56 
58  : m_myBuilding (building)
59 {
60  NS_LOG_FUNCTION (this);
61  m_indoor = false;
62  m_nFloor = 1;
63  m_roomX = 1;
64  m_roomY = 1;
65 }
66 
67 bool
69 {
70  NS_LOG_FUNCTION (this);
71  return (m_indoor);
72 }
73 
74 bool
76 {
77  NS_LOG_FUNCTION (this);
78  return (!m_indoor);
79 }
80 
81 void
82 MobilityBuildingInfo::SetIndoor (Ptr<Building> building, uint8_t nfloor, uint8_t nroomx, uint8_t nroomy)
83 {
84  NS_LOG_FUNCTION (this);
85  m_indoor = true;
86  m_myBuilding = building;
87  m_nFloor = nfloor;
88  m_roomX = nroomx;
89  m_roomY = nroomy;
90 
91 
92  NS_ASSERT (m_roomX > 0);
93  NS_ASSERT (m_roomX <= building->GetNRoomsX ());
94  NS_ASSERT (m_roomY > 0);
95  NS_ASSERT (m_roomY <= building->GetNRoomsY ());
96  NS_ASSERT (m_nFloor > 0);
97  NS_ASSERT (m_nFloor <= building->GetNFloors ());
98 
99 }
100 
101 
102 void
103 MobilityBuildingInfo::SetIndoor (uint8_t nfloor, uint8_t nroomx, uint8_t nroomy)
104 {
105  NS_LOG_FUNCTION (this);
106  m_indoor = true;
107  m_nFloor = nfloor;
108  m_roomX = nroomx;
109  m_roomY = nroomy;
110 
111  NS_ASSERT_MSG (m_myBuilding, "Node does not have any building defined");
112  NS_ASSERT (m_roomX > 0);
113  NS_ASSERT (m_roomX <= m_myBuilding->GetNRoomsX ());
114  NS_ASSERT (m_roomY > 0);
115  NS_ASSERT (m_roomY <= m_myBuilding->GetNRoomsY ());
116  NS_ASSERT (m_nFloor > 0);
117  NS_ASSERT (m_nFloor <= m_myBuilding->GetNFloors ());
118 
119 }
120 
121 
122 void
124 {
125  NS_LOG_FUNCTION (this);
126  m_indoor = false;
127 }
128 
129 uint8_t
131 {
132  NS_LOG_FUNCTION (this);
133  return (m_nFloor);
134 }
135 
136 uint8_t
138 {
139  NS_LOG_FUNCTION (this);
140  return (m_roomX);
141 }
142 
143 uint8_t
145 {
146  NS_LOG_FUNCTION (this);
147  return (m_roomY);
148 }
149 
150 
153 {
154  NS_LOG_FUNCTION (this);
155  return (m_myBuilding);
156 }
157 
158 
159 } // namespace
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
mobility buildings information (to be used by mobility models)
A base class which provides memory management and object aggregation.
Definition: object.h:87
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915