A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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
TypeId
36
MobilityBuildingInfo::GetTypeId
(
void
)
37
{
38
static
TypeId
tid =
TypeId
(
"ns3::MobilityBuildingInfo"
)
39
.
SetParent
<
Object
> ()
40
.SetGroupName (
"Building"
)
41
.AddConstructor<
MobilityBuildingInfo
> ();
42
43
return
tid;
44
}
45
46
47
MobilityBuildingInfo::MobilityBuildingInfo
()
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
57
MobilityBuildingInfo::MobilityBuildingInfo
(
Ptr<Building>
building)
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
68
MobilityBuildingInfo::IsIndoor
(
void
)
69
{
70
NS_LOG_FUNCTION
(
this
);
71
return
(
m_indoor
);
72
}
73
74
bool
75
MobilityBuildingInfo::IsOutdoor
(
void
)
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
123
MobilityBuildingInfo::SetOutdoor
(
void
)
124
{
125
NS_LOG_FUNCTION
(
this
);
126
m_indoor
=
false
;
127
}
128
129
uint8_t
130
MobilityBuildingInfo::GetFloorNumber
(
void
)
131
{
132
NS_LOG_FUNCTION
(
this
);
133
return
(
m_nFloor
);
134
}
135
136
uint8_t
137
MobilityBuildingInfo::GetRoomNumberX
(
void
)
138
{
139
NS_LOG_FUNCTION
(
this
);
140
return
(
m_roomX
);
141
}
142
143
uint8_t
144
MobilityBuildingInfo::GetRoomNumberY
(
void
)
145
{
146
NS_LOG_FUNCTION
(
this
);
147
return
(
m_roomY
);
148
}
149
150
151
Ptr<Building>
152
MobilityBuildingInfo::GetBuilding
()
153
{
154
NS_LOG_FUNCTION
(
this
);
155
return
(
m_myBuilding
);
156
}
157
158
159
}
// namespace
src
buildings
model
mobility-building-info.cc
Generated on Fri Aug 30 2013 01:42:45 for ns-3 by
1.8.1.2