25 namespace ns3 { |
25 namespace ns3 { |
26 |
26 |
27 /** |
27 /** |
28 * \brief a hierachical mobility model. |
28 * \brief a hierachical mobility model. |
29 * |
29 * |
30 * This model allows you to specify the position of a |
30 * This model allows you to specify the position of a child object |
31 * child object relative to a parent object. |
31 * relative to a parent object. |
|
32 * |
|
33 * Basically this is a mobility model that combines two other mobility |
|
34 * models: a "parent" model and a "child" model. The position of the |
|
35 * hierarchical model is always the vector sum of the parent + child |
|
36 * positions, so that if the parent model "moves", then this model |
|
37 * will report an equal relative movement. Useful, for instance, if |
|
38 * you want to simulate a node inside another node that moves, such as |
|
39 * a vehicle. |
|
40 * |
|
41 * Setting the position on this model is always done using world |
|
42 * absolute coordinates, and it changes only the child mobility model |
|
43 * position, never the parent. The child mobility model always uses a |
|
44 * coordinate sytem relative to the parent model position. |
|
45 * |
|
46 * @note: as a special case, the parent model may be NULL, which is |
|
47 * semantically equivalent to having a ConstantPositionMobilityModel |
|
48 * as parent positioned at origin (0,0,0). In other words, setting |
|
49 * the parent model to NULL makes the child model and the hierarchical |
|
50 * model start using world absolute coordinates. |
|
51 * |
|
52 * @warning: changing the parent/child mobility models in the middle |
|
53 * of a simulation will probably not play very well with the |
|
54 * ConfigStore APIs, so do this only if you know what you are doing. |
32 */ |
55 */ |
33 class HierarchicalMobilityModel : public MobilityModel |
56 class HierarchicalMobilityModel : public MobilityModel |
34 { |
57 { |
35 public: |
58 public: |
36 static TypeId GetTypeId (void); |
59 static TypeId GetTypeId (void); |
50 * This allows you to get access to the position of the |
73 * This allows you to get access to the position of the |
51 * parent mobility model which is used as the reference |
74 * parent mobility model which is used as the reference |
52 * position by the child mobility model. |
75 * position by the child mobility model. |
53 */ |
76 */ |
54 Ptr<MobilityModel> GetParent (void) const; |
77 Ptr<MobilityModel> GetParent (void) const; |
|
78 /** |
|
79 * Sets the child mobility model to a new one. If before there |
|
80 * already existed a child model, then the child mobility model |
|
81 * current position is also modified to ensure that the composite |
|
82 * position is preserved. |
|
83 */ |
|
84 void SetChild (Ptr<MobilityModel> model); |
|
85 /** |
|
86 * Sets the parent mobility model to a new one. If before there |
|
87 * already existed a child model, then the child mobility model |
|
88 * current position is also modified to ensure that the composite |
|
89 * position is preserved. |
|
90 */ |
|
91 void SetParent (Ptr<MobilityModel> model); |
55 |
92 |
56 private: |
93 private: |
57 virtual Vector DoGetPosition (void) const; |
94 virtual Vector DoGetPosition (void) const; |
58 virtual void DoSetPosition (const Vector &position); |
95 virtual void DoSetPosition (const Vector &position); |
59 virtual Vector DoGetVelocity (void) const; |
96 virtual Vector DoGetVelocity (void) const; |
60 |
97 |
61 void SetChild (Ptr<MobilityModel> model); |
|
62 void SetParent (Ptr<MobilityModel> model); |
|
63 void ParentChanged (Ptr<const MobilityModel> model); |
98 void ParentChanged (Ptr<const MobilityModel> model); |
64 void ChildChanged (Ptr<const MobilityModel> model); |
99 void ChildChanged (Ptr<const MobilityModel> model); |
65 |
100 |
66 Ptr<MobilityModel> m_child; |
101 Ptr<MobilityModel> m_child; |
67 Ptr<MobilityModel> m_parent; |
102 Ptr<MobilityModel> m_parent; |