|
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/buildings-mobility-model.h> |
|
25 #include "ns3/pointer.h" |
|
26 |
|
27 |
|
28 namespace ns3 { |
|
29 |
|
30 NS_OBJECT_ENSURE_REGISTERED (BuildingsMobilityModel); |
|
31 |
|
32 TypeId |
|
33 BuildingsMobilityModel::GetTypeId (void) |
|
34 { |
|
35 static TypeId tid = TypeId ("ns3::BuildingsMobilityModel") |
|
36 .SetParent<MobilityModel> () |
|
37 .SetGroupName ("Mobility") |
|
38 .AddConstructor<BuildingsMobilityModel> () |
|
39 .AddAttribute ("Bounds", |
|
40 "Bounds of the area to cruise.", |
|
41 BoxValue (Box (-100.0, 100.0, -100.0, 100.0, 0.0, 100.0)), |
|
42 MakeBoxAccessor (&BuildingsMobilityModel::m_bounds), |
|
43 MakeBoxChecker ()); |
|
44 |
|
45 return tid; |
|
46 } |
|
47 |
|
48 |
|
49 BuildingsMobilityModel::BuildingsMobilityModel () |
|
50 { |
|
51 m_indoor = false; |
|
52 m_nFloor = 0; |
|
53 m_roomX = 1; |
|
54 m_roomY = 1; |
|
55 } |
|
56 |
|
57 void |
|
58 BuildingsMobilityModel::DoDispose (void) |
|
59 { |
|
60 // chain up |
|
61 m_surroudingBuildings.clear (); |
|
62 MobilityModel::DoDispose (); |
|
63 } |
|
64 |
|
65 Vector |
|
66 BuildingsMobilityModel::DoGetPosition (void) const |
|
67 { |
|
68 m_helper.Update (); |
|
69 return m_helper.GetCurrentPosition (); |
|
70 } |
|
71 void |
|
72 BuildingsMobilityModel::DoSetPosition (const Vector &position) |
|
73 { |
|
74 m_helper.SetPosition (position); |
|
75 } |
|
76 Vector |
|
77 BuildingsMobilityModel::DoGetVelocity (void) const |
|
78 { |
|
79 return m_helper.GetVelocity (); |
|
80 } |
|
81 |
|
82 bool |
|
83 BuildingsMobilityModel::IsIndoor (void) |
|
84 { |
|
85 return (m_indoor); |
|
86 } |
|
87 |
|
88 bool |
|
89 BuildingsMobilityModel::IsOutdoor (void) |
|
90 { |
|
91 return (!m_indoor); |
|
92 } |
|
93 |
|
94 void |
|
95 BuildingsMobilityModel::SetIndoor (Ptr<Building> building) |
|
96 { |
|
97 m_indoor = true; |
|
98 m_myBuilding = building; |
|
99 } |
|
100 |
|
101 void |
|
102 BuildingsMobilityModel::SetOutdoor (void) |
|
103 { |
|
104 m_indoor = false; |
|
105 } |
|
106 |
|
107 void |
|
108 BuildingsMobilityModel::SetFloorNumber (uint8_t nfloor) |
|
109 { |
|
110 m_nFloor = nfloor; |
|
111 } |
|
112 |
|
113 void |
|
114 BuildingsMobilityModel::SetRoomNumberX (uint8_t nroomx) |
|
115 { |
|
116 m_roomX = nroomx; |
|
117 } |
|
118 |
|
119 void |
|
120 BuildingsMobilityModel::SetRoomNumberY (uint8_t nroomy) |
|
121 { |
|
122 m_roomY = nroomy; |
|
123 } |
|
124 |
|
125 |
|
126 void |
|
127 BuildingsMobilityModel::SetSurroudingBuilding (Ptr<Building> building) |
|
128 { |
|
129 m_surroudingBuildings.push_back (building); |
|
130 } |
|
131 |
|
132 uint8_t |
|
133 BuildingsMobilityModel::GetFloorNumber (void) |
|
134 { |
|
135 return (m_nFloor); |
|
136 } |
|
137 |
|
138 uint8_t |
|
139 BuildingsMobilityModel::GetRoomNumberX (void) |
|
140 { |
|
141 return (m_roomX); |
|
142 } |
|
143 |
|
144 uint8_t |
|
145 BuildingsMobilityModel::GetRoomNumberY (void) |
|
146 { |
|
147 return (m_roomY); |
|
148 } |
|
149 |
|
150 |
|
151 Ptr<Building> |
|
152 BuildingsMobilityModel::GetBuilding () |
|
153 { |
|
154 return (m_myBuilding); |
|
155 } |
|
156 |
|
157 |
|
158 } // namespace |