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
36
TypeId
37
MobilityBuildingInfo::GetTypeId
(
void
)
38
{
39
static
TypeId
tid =
TypeId
(
"ns3::MobilityBuildingInfo"
)
40
.
SetParent
<
Object
> ()
41
.SetGroupName (
"Building"
)
42
.AddConstructor<
MobilityBuildingInfo
> ();
43
44
return
tid;
45
}
46
47
48
MobilityBuildingInfo::MobilityBuildingInfo
()
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
58
MobilityBuildingInfo::MobilityBuildingInfo
(
Ptr<Building>
building)
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
69
MobilityBuildingInfo::IsIndoor
(
void
)
70
{
71
NS_LOG_FUNCTION
(
this
);
72
return
(
m_indoor
);
73
}
74
75
bool
76
MobilityBuildingInfo::IsOutdoor
(
void
)
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
124
MobilityBuildingInfo::SetOutdoor
(
void
)
125
{
126
NS_LOG_FUNCTION
(
this
);
127
m_indoor
=
false
;
128
}
129
130
uint8_t
131
MobilityBuildingInfo::GetFloorNumber
(
void
)
132
{
133
NS_LOG_FUNCTION
(
this
);
134
return
(
m_nFloor
);
135
}
136
137
uint8_t
138
MobilityBuildingInfo::GetRoomNumberX
(
void
)
139
{
140
NS_LOG_FUNCTION
(
this
);
141
return
(
m_roomX
);
142
}
143
144
uint8_t
145
MobilityBuildingInfo::GetRoomNumberY
(
void
)
146
{
147
NS_LOG_FUNCTION
(
this
);
148
return
(
m_roomY
);
149
}
150
151
152
Ptr<Building>
153
MobilityBuildingInfo::GetBuilding
()
154
{
155
NS_LOG_FUNCTION
(
this
);
156
return
(
m_myBuilding
);
157
}
158
159
160
}
// namespace
ns3::Ptr
smart pointer class similar to boost::intrusive_ptr
Definition:
ptr.h:59
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:345
NS_ASSERT
#define NS_ASSERT(condition)
Definition:
assert.h:64
ns3::NS_OBJECT_ENSURE_REGISTERED
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
ns3::MobilityBuildingInfo::SetOutdoor
void SetOutdoor()
Mark this MobilityBuildingInfo instance as outdoor.
Definition:
mobility-building-info.cc:124
ns3::MobilityBuildingInfo::m_nFloor
uint8_t m_nFloor
Definition:
mobility-building-info.h:116
ns3::MobilityBuildingInfo::m_roomY
uint8_t m_roomY
Definition:
mobility-building-info.h:118
ns3::MobilityBuildingInfo::m_roomX
uint8_t m_roomX
Definition:
mobility-building-info.h:117
ns3::MobilityBuildingInfo::GetFloorNumber
uint8_t GetFloorNumber(void)
Definition:
mobility-building-info.cc:131
ns3::MobilityBuildingInfo::GetRoomNumberX
uint8_t GetRoomNumberX(void)
Definition:
mobility-building-info.cc:138
ns3::MobilityBuildingInfo::IsIndoor
bool IsIndoor(void)
Definition:
mobility-building-info.cc:69
ns3::MobilityBuildingInfo::SetIndoor
void SetIndoor(Ptr< Building > building, uint8_t nfloor, uint8_t nroomx, uint8_t nroomy)
Mark this MobilityBuildingInfo instance as indoor.
Definition:
mobility-building-info.cc:83
ns3::MobilityBuildingInfo::m_myBuilding
Ptr< Building > m_myBuilding
Definition:
mobility-building-info.h:114
ns3::MobilityBuildingInfo::IsOutdoor
bool IsOutdoor(void)
Definition:
mobility-building-info.cc:76
ns3::MobilityBuildingInfo::MobilityBuildingInfo
MobilityBuildingInfo()
Definition:
mobility-building-info.cc:48
ns3::MobilityBuildingInfo::GetTypeId
static TypeId GetTypeId(void)
Definition:
mobility-building-info.cc:37
NS_ASSERT_MSG
#define NS_ASSERT_MSG(condition, message)
Definition:
assert.h:86
ns3::MobilityBuildingInfo::GetBuilding
Ptr< Building > GetBuilding()
Definition:
mobility-building-info.cc:153
ns3::MobilityBuildingInfo
mobility buildings information (to be used by mobility models)
Definition:
mobility-building-info.h:47
ns3::Object
a base class which provides memory management and object aggregation
Definition:
object.h:63
ns3::MobilityBuildingInfo::m_indoor
bool m_indoor
Definition:
mobility-building-info.h:115
NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("MobilityBuildingInfo")
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Definition:
type-id.cc:611
ns3::MobilityBuildingInfo::GetRoomNumberY
uint8_t GetRoomNumberY(void)
Definition:
mobility-building-info.cc:145
src
buildings
model
mobility-building-info.cc
Generated on Sat Apr 19 2014 14:06:50 for ns-3 by
1.8.6