A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
building-allocator.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007 INRIA
3 * Copyright (C) 2012 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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19 * Author: Nicola Baldo <nbaldo@cttc.es> (took position-allocator and turned it into
20 * building-allocator)
21 */
22#ifndef BUILDING_ALLOCATOR_H
23#define BUILDING_ALLOCATOR_H
24
25#include "building-container.h"
26
27#include "ns3/object-factory.h"
28#include "ns3/object.h"
29#include "ns3/position-allocator.h"
30#include "ns3/vector.h"
31
32namespace ns3
33{
34
35class Building;
36
37/**
38 * \ingroup buildings
39 * \brief Allocate buildings on a rectangular 2d grid.
40 *
41 * This class allows to create a set of buildings positioned on a
42 * rectangular 2D grid. Under the hood, this class uses two instances
43 * of GridPositionAllocator.
44 */
46{
47 public:
49 ~GridBuildingAllocator() override;
50
51 /**
52 * \brief Get the type ID.
53 * \return The object TypeId.
54 */
55 static TypeId GetTypeId();
56
57 /**
58 * Set an attribute to be used for each new building to be created
59 *
60 * \param n attribute name
61 * \param v attribute value
62 */
63 void SetBuildingAttribute(std::string n, const AttributeValue& v);
64
65 /**
66 * Create a set of buildings allocated on a grid
67 *
68 * \param n the number of buildings to create
69 *
70 * \return the BuildingContainer that contains the newly created buildings
71 */
73
74 private:
75 /**
76 * Pushes the attributes into the relevant position allocators
77 */
78 void PushAttributes() const;
79
80 mutable uint32_t m_current; //!< Current building number
82 double m_xMin; //!< The x coordinate where the grid starts
83 double m_yMin; //!< The y coordinate where the grid starts
84 uint32_t m_n; //!< The number of objects laid out on a line
85 double m_lengthX; //!< The length of the wall of each building along the X axis.
86 double m_lengthY; //!< The length of the wall of each building along the Y axis.
87 double m_deltaX; //!< The x space between buildings
88 double m_deltaY; //!< The y space between buildings
89 double m_height; //!< The height of the building (roof level)
90
91 mutable ObjectFactory m_buildingFactory; //!< The building factory
92 Ptr<GridPositionAllocator> m_lowerLeftPositionAllocator; //!< The upper left position allocator
94 m_upperRightPositionAllocator; //!< The upper right position allocator
95};
96
97} // namespace ns3
98
99#endif /* BUILDING_ALLOCATOR_H */
Hold a value for an Attribute.
Definition: attribute.h:70
keep track of a set of building pointers.
Allocate buildings on a rectangular 2d grid.
void SetBuildingAttribute(std::string n, const AttributeValue &v)
Set an attribute to be used for each new building to be created.
double m_yMin
The y coordinate where the grid starts.
ObjectFactory m_buildingFactory
The building factory.
GridPositionAllocator::LayoutType m_layoutType
Layout type.
static TypeId GetTypeId()
Get the type ID.
double m_xMin
The x coordinate where the grid starts.
uint32_t m_n
The number of objects laid out on a line.
BuildingContainer Create(uint32_t n) const
Create a set of buildings allocated on a grid.
double m_deltaX
The x space between buildings.
Ptr< GridPositionAllocator > m_lowerLeftPositionAllocator
The upper left position allocator.
double m_lengthX
The length of the wall of each building along the X axis.
void PushAttributes() const
Pushes the attributes into the relevant position allocators.
uint32_t m_current
Current building number.
double m_deltaY
The y space between buildings.
double m_height
The height of the building (roof level)
double m_lengthY
The length of the wall of each building along the Y axis.
Ptr< GridPositionAllocator > m_upperRightPositionAllocator
The upper right position allocator.
LayoutType
Determine whether positions are allocated row first or column first.
Instantiate subclasses of ns3::Object.
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.