author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Wed, 18 Jul 2007 17:45:53 +0200 | |
changeset 1609 | 17b427c34d6b |
parent 1599 | 3c682047593a |
permissions | -rw-r--r-- |
1567
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
/* |
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
* Copyright (c) 2007 INRIA |
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
* All rights reserved. |
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* |
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* This program is free software; you can redistribute it and/or modify |
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
* it under the terms of the GNU General Public License version 2 as |
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation; |
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* |
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* GNU General Public License for more details. |
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* |
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
* along with this program; if not, write to the Free Software |
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
* |
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
*/ |
1596
181db96ac3a4
use Random2dPosition from RandomRectangleTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
21 |
#include "ns3/random-variable-default-value.h" |
1597
990f0fd3bf87
RandomRectangleTopology -> RandomTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1596
diff
changeset
|
22 |
#include "random-topology.h" |
1599
3c682047593a
Random2dPosition -> RandomPosition
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1597
diff
changeset
|
23 |
#include "random-position.h" |
1596
181db96ac3a4
use Random2dPosition from RandomRectangleTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
24 |
#include "mobility-model.h" |
1567
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
25 |
|
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
26 |
namespace ns3 { |
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
|
1596
181db96ac3a4
use Random2dPosition from RandomRectangleTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
28 |
static ClassIdDefaultValue |
1609 | 29 |
g_position ("RandomTopologyPositionType", |
1599
3c682047593a
Random2dPosition -> RandomPosition
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1597
diff
changeset
|
30 |
"The type of initial random position in a 3d topology.", |
3c682047593a
Random2dPosition -> RandomPosition
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1597
diff
changeset
|
31 |
RandomPosition::iid, |
1609 | 32 |
"RandomRectanglePosition"); |
1596
181db96ac3a4
use Random2dPosition from RandomRectangleTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
33 |
|
181db96ac3a4
use Random2dPosition from RandomRectangleTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
34 |
static ClassIdDefaultValue |
1609 | 35 |
g_mobility ("RandomTopologyMobilityType", |
1599
3c682047593a
Random2dPosition -> RandomPosition
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1597
diff
changeset
|
36 |
"The type of mobility model attached to an object in a 3d topology.", |
1596
181db96ac3a4
use Random2dPosition from RandomRectangleTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
37 |
MobilityModel::iid, |
181db96ac3a4
use Random2dPosition from RandomRectangleTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
38 |
"StaticMobilityModel"); |
1574
cf1ff5bfac1e
add a few constructors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1567
diff
changeset
|
39 |
|
1597
990f0fd3bf87
RandomRectangleTopology -> RandomTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1596
diff
changeset
|
40 |
RandomTopology::RandomTopology () |
1596
181db96ac3a4
use Random2dPosition from RandomRectangleTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
41 |
: m_mobilityModel (g_mobility.GetValue ()) |
181db96ac3a4
use Random2dPosition from RandomRectangleTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
42 |
{ |
1599
3c682047593a
Random2dPosition -> RandomPosition
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1597
diff
changeset
|
43 |
m_positionModel = ComponentManager::Create<RandomPosition> (g_position.GetValue (), |
3c682047593a
Random2dPosition -> RandomPosition
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1597
diff
changeset
|
44 |
RandomPosition::iid); |
1596
181db96ac3a4
use Random2dPosition from RandomRectangleTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
45 |
} |
1599
3c682047593a
Random2dPosition -> RandomPosition
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1597
diff
changeset
|
46 |
RandomTopology::RandomTopology (Ptr<RandomPosition> positionModel, ClassId mobilityModel) |
1596
181db96ac3a4
use Random2dPosition from RandomRectangleTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
47 |
: m_positionModel (positionModel), |
181db96ac3a4
use Random2dPosition from RandomRectangleTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
48 |
m_mobilityModel (mobilityModel) |
1567
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
49 |
{} |
1597
990f0fd3bf87
RandomRectangleTopology -> RandomTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1596
diff
changeset
|
50 |
RandomTopology::~RandomTopology () |
1567
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
51 |
{ |
1596
181db96ac3a4
use Random2dPosition from RandomRectangleTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
52 |
m_positionModel = 0; |
1567
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
53 |
} |
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
54 |
|
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
55 |
void |
1597
990f0fd3bf87
RandomRectangleTopology -> RandomTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1596
diff
changeset
|
56 |
RandomTopology::SetMobilityModel (ClassId classId) |
1567
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
57 |
{ |
1596
181db96ac3a4
use Random2dPosition from RandomRectangleTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
58 |
m_mobilityModel = classId; |
181db96ac3a4
use Random2dPosition from RandomRectangleTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
59 |
} |
181db96ac3a4
use Random2dPosition from RandomRectangleTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
60 |
|
181db96ac3a4
use Random2dPosition from RandomRectangleTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
61 |
void |
1599
3c682047593a
Random2dPosition -> RandomPosition
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1597
diff
changeset
|
62 |
RandomTopology::SetPositionModel (Ptr<RandomPosition> positionModel) |
1596
181db96ac3a4
use Random2dPosition from RandomRectangleTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
63 |
{ |
181db96ac3a4
use Random2dPosition from RandomRectangleTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
64 |
m_positionModel = positionModel; |
1567
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
65 |
} |
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
66 |
|
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
67 |
void |
1597
990f0fd3bf87
RandomRectangleTopology -> RandomTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1596
diff
changeset
|
68 |
RandomTopology::LayoutOne (Ptr<Object> object) |
1567
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
69 |
{ |
1596
181db96ac3a4
use Random2dPosition from RandomRectangleTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
70 |
Ptr<MobilityModel> mobility = ComponentManager::Create<MobilityModel> (m_mobilityModel, |
181db96ac3a4
use Random2dPosition from RandomRectangleTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
71 |
MobilityModel::iid); |
1599
3c682047593a
Random2dPosition -> RandomPosition
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1597
diff
changeset
|
72 |
Position position = m_positionModel->Get (); |
1596
181db96ac3a4
use Random2dPosition from RandomRectangleTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
73 |
mobility->Set (position); |
181db96ac3a4
use Random2dPosition from RandomRectangleTopology
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
74 |
object->AddInterface (mobility); |
1567
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
75 |
} |
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
76 |
|
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
77 |
|
27556d4e3b51
change GridTopology API and add RandomRectangle topology with similar API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
78 |
} // namespace ns3 |