A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
mobility-model.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2006,2007 INRIA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19#ifndef MOBILITY_MODEL_H
20#define MOBILITY_MODEL_H
21
22#include "ns3/object.h"
23#include "ns3/traced-callback.h"
24#include "ns3/vector.h"
25
26namespace ns3
27{
28
39class MobilityModel : public Object
40{
41 public:
46 static TypeId GetTypeId();
48 ~MobilityModel() override = 0;
49
53 Vector GetPosition() const;
65 Vector GetPositionWithReference(const Vector& referencePosition) const;
69 void SetPosition(const Vector& position);
73 Vector GetVelocity() const;
78 double GetDistanceFrom(Ptr<const MobilityModel> position) const;
92 int64_t AssignStreams(int64_t stream);
93
100
101 protected:
106 void NotifyCourseChange() const;
107
108 private:
115 virtual Vector DoGetPosition() const = 0;
123 virtual Vector DoGetPositionWithReference(const Vector& referencePosition) const;
130 virtual void DoSetPosition(const Vector& position) = 0;
137 virtual Vector DoGetVelocity() const = 0;
145 virtual int64_t DoAssignStreams(int64_t start);
146
152};
153
154} // namespace ns3
155
156#endif /* MOBILITY_MODEL_H */
Keep track of the current position and velocity of an object.
ns3::TracedCallback< Ptr< const MobilityModel > > m_courseChangeTrace
Used to alert subscribers that a change in direction, velocity, or position has occurred.
Vector GetPositionWithReference(const Vector &referencePosition) const
This method may be used if the position returned may depend on some reference position provided.
static TypeId GetTypeId()
Register this type with the TypeId system.
double GetDistanceFrom(Ptr< const MobilityModel > position) const
~MobilityModel() override=0
double GetRelativeSpeed(Ptr< const MobilityModel > other) const
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
virtual Vector DoGetPosition() const =0
virtual Vector DoGetPositionWithReference(const Vector &referencePosition) const
Vector GetVelocity() const
virtual void DoSetPosition(const Vector &position)=0
virtual int64_t DoAssignStreams(int64_t start)
The default implementation does nothing but return the passed-in parameter.
Vector GetPosition() const
void SetPosition(const Vector &position)
void NotifyCourseChange() const
Must be invoked by subclasses when the course of the position changes to notify course change listene...
virtual Vector DoGetVelocity() const =0
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.