22 #include "building-allocator.h"
23 #include "ns3/building.h"
24 #include "ns3/double.h"
25 #include "ns3/uinteger.h"
34 NS_OBJECT_ENSURE_REGISTERED (GridBuildingAllocator);
36 GridBuildingAllocator::GridBuildingAllocator ()
39 m_buildingFactory.SetTypeId (
"ns3::Building");
40 m_lowerLeftPositionAllocator = CreateObject<GridPositionAllocator> ();
41 m_upperRightPositionAllocator = CreateObject<GridPositionAllocator> ();
44 GridBuildingAllocator::~GridBuildingAllocator ()
49 GridBuildingAllocator::GetTypeId (
void)
51 static TypeId tid = TypeId (
"ns3::GridBuildingAllocator")
53 .AddConstructor<GridBuildingAllocator> ()
54 .AddAttribute (
"GridWidth",
"The number of objects layed out on a line.",
56 MakeUintegerAccessor (&GridBuildingAllocator::m_n),
57 MakeUintegerChecker<uint32_t> ())
58 .AddAttribute (
"MinX",
"The x coordinate where the grid starts.",
60 MakeDoubleAccessor (&GridBuildingAllocator::m_xMin),
61 MakeDoubleChecker<double> ())
62 .AddAttribute (
"MinY",
"The y coordinate where the grid starts.",
64 MakeDoubleAccessor (&GridBuildingAllocator::m_yMin),
65 MakeDoubleChecker<double> ())
66 .AddAttribute (
"LengthX",
" the length of the wall of each building along the X axis.",
68 MakeDoubleAccessor (&GridBuildingAllocator::m_lengthX),
69 MakeDoubleChecker<double> ())
70 .AddAttribute (
"LengthY",
" the length of the wall of each building along the X axis.",
72 MakeDoubleAccessor (&GridBuildingAllocator::m_lengthY),
73 MakeDoubleChecker<double> ())
74 .AddAttribute (
"DeltaX",
"The x space between buildings.",
76 MakeDoubleAccessor (&GridBuildingAllocator::m_deltaX),
77 MakeDoubleChecker<double> ())
78 .AddAttribute (
"DeltaY",
"The y space between buildings.",
80 MakeDoubleAccessor (&GridBuildingAllocator::m_deltaY),
81 MakeDoubleChecker<double> ())
82 .AddAttribute (
"Height",
"The height of the building (roof level)",
84 MakeDoubleAccessor (&GridBuildingAllocator::m_height),
85 MakeDoubleChecker<double> ())
86 .AddAttribute (
"LayoutType",
"The type of layout.",
88 MakeEnumAccessor (&GridBuildingAllocator::m_layoutType),
99 m_buildingFactory.
Set (n, v);
108 uint32_t limit = n + m_current;
109 for (; m_current < limit; ++m_current)
111 Vector lowerLeft = m_lowerLeftPositionAllocator->GetNext ();
112 Vector upperRight = m_upperRightPositionAllocator->GetNext ();
113 Box box (lowerLeft.
x, upperRight.
x, lowerLeft.
y, upperRight.
y, 0, m_height);
116 m_buildingFactory.
Set (
"Boundaries", boxValue);
124 GridBuildingAllocator::PushAttributes ()
const
127 m_lowerLeftPositionAllocator->SetMinX (m_xMin);
128 m_upperRightPositionAllocator->SetMinX (m_xMin + m_lengthX);
129 m_lowerLeftPositionAllocator->SetDeltaX (m_lengthX + m_deltaX);
130 m_upperRightPositionAllocator->SetDeltaX (m_lengthX + m_deltaX);
132 m_lowerLeftPositionAllocator->SetMinY (m_yMin);
133 m_upperRightPositionAllocator->SetMinY (m_yMin + m_lengthY);
134 m_lowerLeftPositionAllocator->SetDeltaY (m_lengthY + m_deltaY);
135 m_upperRightPositionAllocator->SetDeltaY (m_lengthY + m_deltaY);
137 m_lowerLeftPositionAllocator->SetLayoutType (m_layoutType);
138 m_upperRightPositionAllocator->SetLayoutType (m_layoutType);
140 m_lowerLeftPositionAllocator->SetN (m_n);
141 m_upperRightPositionAllocator->SetN (m_n);
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
Hold a value for an Attribute.
void Add(BuildingContainer other)
Append the contents of another BuildingContainer to the end of this container.
#define NS_LOG_COMPONENT_DEFINE(name)
Ptr< Object > Create(void) const
BuildingContainer Create(uint32_t n) const
keep track of a set of building pointers.
hold objects of type ns3::Box
#define NS_LOG_LOGIC(msg)
void Set(std::string name, const AttributeValue &value)
void SetBuildingAttribute(std::string n, const AttributeValue &v)