# HG changeset patch # User Mathieu Lacage # Date 1184748833 -7200 # Node ID 990f0fd3bf87fe312926e46f8028c75a95f08580 # Parent 181db96ac3a4ddb20389f4161f011d7f8445e959 RandomRectangleTopology -> RandomTopology diff -r 181db96ac3a4 -r 990f0fd3bf87 SConstruct --- a/SConstruct Wed Jul 18 10:46:44 2007 +0200 +++ b/SConstruct Wed Jul 18 10:53:53 2007 +0200 @@ -253,7 +253,7 @@ 'static-mobility-model.cc', 'static-speed-mobility-model.cc', 'grid-topology.cc', - 'random-rectangle-topology.cc', + 'random-topology.cc', 'random-walk-mobility-model.cc', 'random-mobility-model.cc', 'random-direction-mobility-model.cc', @@ -284,7 +284,7 @@ 'static-mobility-model.h', 'static-speed-mobility-model.h', 'grid-topology.h', - 'random-rectangle-topology.h', + 'random-topology.h', 'random-walk-mobility-model.h', 'random-mobility-model.h', 'random-direction-mobility-model.h', diff -r 181db96ac3a4 -r 990f0fd3bf87 src/node/random-rectangle-topology.cc --- a/src/node/random-rectangle-topology.cc Wed Jul 18 10:46:44 2007 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2007 INRIA - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Mathieu Lacage - */ -#include "ns3/random-variable-default-value.h" -#include "random-rectangle-topology.h" -#include "random-2d-position.h" -#include "mobility-model.h" - -namespace ns3 { - -static ClassIdDefaultValue -g_position ("Random2dTopologyType", - "The type of initial random position in a 2d topology.", - Random2dPosition::iid, - "Rectangle"); - -static ClassIdDefaultValue -g_mobility ("Random2dTopologyMobilityModelType", - "The type of mobility model attached to an object in a 2d topology.", - MobilityModel::iid, - "StaticMobilityModel"); - -RandomRectangleTopology::RandomRectangleTopology () - : m_mobilityModel (g_mobility.GetValue ()) -{ - m_positionModel = ComponentManager::Create (g_position.GetValue (), - Random2dPosition::iid); -} -RandomRectangleTopology::RandomRectangleTopology (Ptr positionModel, ClassId mobilityModel) - : m_positionModel (positionModel), - m_mobilityModel (mobilityModel) -{} -RandomRectangleTopology::~RandomRectangleTopology () -{ - m_positionModel = 0; -} - -void -RandomRectangleTopology::SetMobilityModel (ClassId classId) -{ - m_mobilityModel = classId; -} - -void -RandomRectangleTopology::SetPositionModel (Ptr positionModel) -{ - m_positionModel = positionModel; -} - -void -RandomRectangleTopology::LayoutOne (Ptr object) -{ - Position2d position2d = m_positionModel->Get (); - Ptr mobility = ComponentManager::Create (m_mobilityModel, - MobilityModel::iid); - Position position = mobility->Get (); - position.x = position2d.x; - position.y = position2d.y; - mobility->Set (position); - object->AddInterface (mobility); -} - - -} // namespace ns3 diff -r 181db96ac3a4 -r 990f0fd3bf87 src/node/random-rectangle-topology.h --- a/src/node/random-rectangle-topology.h Wed Jul 18 10:46:44 2007 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2007 INRIA - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Mathieu Lacage - */ -#ifndef RANDOM_RECTANGLE_TOPOLOGY_H -#define RANDOM_RECTANGLE_TOPOLOGY_H - -#include "ns3/ptr.h" -#include "ns3/object.h" -#include "ns3/component-manager.h" - -namespace ns3 { - -class Random2dPosition; - -class RandomRectangleTopology -{ - public: - RandomRectangleTopology (); - RandomRectangleTopology (Ptr positionModel, - ClassId mobilityModel); - - ~RandomRectangleTopology (); - - void SetMobilityModel (ClassId classId); - void SetPositionModel (Ptr positionModel); - - void LayoutOne (Ptr object); - - template - void Layout (const T &begin, const T &end); - private: - Ptr m_positionModel; - ClassId m_mobilityModel; -}; - -} // namespace ns3 - -namespace ns3 { - -template -void -RandomRectangleTopology::Layout (const T &begin, const T &end) -{ - for (T i = begin; i != end; i++) - { - LayoutOne (*i); - } -} - - -} // namespace ns3 - -#endif /* RANDOM_RECTANGLE_TOPOLOGY_H */ diff -r 181db96ac3a4 -r 990f0fd3bf87 src/node/random-topology.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/node/random-topology.cc Wed Jul 18 10:53:53 2007 +0200 @@ -0,0 +1,81 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2007 INRIA + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Mathieu Lacage + */ +#include "ns3/random-variable-default-value.h" +#include "random-topology.h" +#include "random-2d-position.h" +#include "mobility-model.h" + +namespace ns3 { + +static ClassIdDefaultValue +g_position ("Random2dTopologyType", + "The type of initial random position in a 2d topology.", + Random2dPosition::iid, + "Rectangle"); + +static ClassIdDefaultValue +g_mobility ("Random2dTopologyMobilityModelType", + "The type of mobility model attached to an object in a 2d topology.", + MobilityModel::iid, + "StaticMobilityModel"); + +RandomTopology::RandomTopology () + : m_mobilityModel (g_mobility.GetValue ()) +{ + m_positionModel = ComponentManager::Create (g_position.GetValue (), + Random2dPosition::iid); +} +RandomTopology::RandomTopology (Ptr positionModel, ClassId mobilityModel) + : m_positionModel (positionModel), + m_mobilityModel (mobilityModel) +{} +RandomTopology::~RandomTopology () +{ + m_positionModel = 0; +} + +void +RandomTopology::SetMobilityModel (ClassId classId) +{ + m_mobilityModel = classId; +} + +void +RandomTopology::SetPositionModel (Ptr positionModel) +{ + m_positionModel = positionModel; +} + +void +RandomTopology::LayoutOne (Ptr object) +{ + Position2d position2d = m_positionModel->Get (); + Ptr mobility = ComponentManager::Create (m_mobilityModel, + MobilityModel::iid); + Position position = mobility->Get (); + position.x = position2d.x; + position.y = position2d.y; + mobility->Set (position); + object->AddInterface (mobility); +} + + +} // namespace ns3 diff -r 181db96ac3a4 -r 990f0fd3bf87 src/node/random-topology.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/node/random-topology.h Wed Jul 18 10:53:53 2007 +0200 @@ -0,0 +1,70 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2007 INRIA + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Mathieu Lacage + */ +#ifndef RANDOM_TOPOLOGY_H +#define RANDOM_TOPOLOGY_H + +#include "ns3/ptr.h" +#include "ns3/object.h" +#include "ns3/component-manager.h" + +namespace ns3 { + +class Random2dPosition; + +class RandomTopology +{ + public: + RandomTopology (); + RandomTopology (Ptr positionModel, + ClassId mobilityModel); + + ~RandomTopology (); + + void SetMobilityModel (ClassId classId); + void SetPositionModel (Ptr positionModel); + + void LayoutOne (Ptr object); + + template + void Layout (const T &begin, const T &end); + private: + Ptr m_positionModel; + ClassId m_mobilityModel; +}; + +} // namespace ns3 + +namespace ns3 { + +template +void +RandomTopology::Layout (const T &begin, const T &end) +{ + for (T i = begin; i != end; i++) + { + LayoutOne (*i); + } +} + + +} // namespace ns3 + +#endif /* RANDOM_TOPOLOGY_H */