mobility: Expose child mobility model to parent position
This commit is contained in:
@@ -117,7 +117,7 @@ HierarchicalMobilityModel::DoGetPosition (void) const
|
||||
return m_child->GetPosition ();
|
||||
}
|
||||
Vector parentPosition = m_parent->GetPosition ();
|
||||
Vector childPosition = m_child->GetPosition ();
|
||||
Vector childPosition = m_child->GetPositionWithReference (parentPosition);
|
||||
return Vector (parentPosition.x + childPosition.x,
|
||||
parentPosition.y + childPosition.y,
|
||||
parentPosition.z + childPosition.z);
|
||||
|
||||
@@ -65,6 +65,19 @@ MobilityModel::GetPosition (void) const
|
||||
{
|
||||
return DoGetPosition ();
|
||||
}
|
||||
Vector
|
||||
MobilityModel::GetPositionWithReference (const Vector& referencePosition) const
|
||||
{
|
||||
return DoGetPositionWithReference (referencePosition);
|
||||
}
|
||||
|
||||
// Default implementation ignores referencePosition
|
||||
Vector
|
||||
MobilityModel::DoGetPositionWithReference (const Vector& referencePosition) const
|
||||
{
|
||||
return DoGetPosition ();
|
||||
}
|
||||
|
||||
Vector
|
||||
MobilityModel::GetVelocity (void) const
|
||||
{
|
||||
|
||||
@@ -51,6 +51,18 @@ public:
|
||||
* \return the current position
|
||||
*/
|
||||
Vector GetPosition (void) const;
|
||||
/**
|
||||
* This method may be used if the position returned may depend on some
|
||||
* reference position provided. For example, in a hierarchical mobility
|
||||
* model that is buildings-aware, the child mobility model may not be able
|
||||
* to determine if it is inside or outside of a building unless it knows
|
||||
* the parent position.
|
||||
*
|
||||
* \param referencePosition reference position to consider
|
||||
* \return the current position based on the provided referencePosition
|
||||
* \sa ns3::MobilityModel::DoGetPositionWithReference
|
||||
*/
|
||||
Vector GetPositionWithReference (const Vector &referencePosition) const;
|
||||
/**
|
||||
* \param position the position to set.
|
||||
*/
|
||||
@@ -100,6 +112,14 @@ private:
|
||||
* implement this method.
|
||||
*/
|
||||
virtual Vector DoGetPosition (void) const = 0;
|
||||
/**
|
||||
* \param referencePosition the reference position to consider
|
||||
* \return the current position.
|
||||
*
|
||||
* Unless subclasses override, this method will disregard the reference
|
||||
* position and return "DoGetPosition (void)".
|
||||
*/
|
||||
virtual Vector DoGetPositionWithReference (const Vector& referencePosition) const;
|
||||
/**
|
||||
* \param position the position to set.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user