A Discrete-Event Network Simulator
API
mobility-model.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2006,2007 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 #ifndef MOBILITY_MODEL_H
21 #define MOBILITY_MODEL_H
22 
23 #include "ns3/vector.h"
24 #include "ns3/object.h"
25 #include "ns3/traced-callback.h"
26 
27 namespace ns3 {
28 
39 class MobilityModel : public Object
40 {
41 public:
46  static TypeId GetTypeId (void);
47  MobilityModel ();
48  virtual ~MobilityModel () = 0;
49 
53  Vector GetPosition (void) const;
57  void SetPosition (const Vector &position);
61  Vector GetVelocity (void) const;
66  double GetDistanceFrom (Ptr<const MobilityModel> position) const;
71  double GetRelativeSpeed (Ptr<const MobilityModel> other) const;
80  int64_t AssignStreams (int64_t stream);
81 
87  typedef void (* TracedCallback)(Ptr<const MobilityModel> model);
88 
89 protected:
94  void NotifyCourseChange (void) const;
95 private:
102  virtual Vector DoGetPosition (void) const = 0;
109  virtual void DoSetPosition (const Vector &position) = 0;
116  virtual Vector DoGetVelocity (void) const = 0;
124  virtual int64_t DoAssignStreams (int64_t start);
125 
131 
132 };
133 
134 } // namespace ns3
135 
136 #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.
virtual ~MobilityModel()=0
static TypeId GetTypeId(void)
Register this type with the TypeId system.
double GetDistanceFrom(Ptr< const MobilityModel > position) const
Vector GetVelocity(void) const
virtual Vector DoGetPosition(void) const =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.
void NotifyCourseChange(void) const
Must be invoked by subclasses when the course of the position changes to notify course change listene...
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.
void SetPosition(const Vector &position)
virtual Vector DoGetVelocity(void) const =0
Vector GetPosition(void) const
A base class which provides memory management and object aggregation.
Definition: object.h:88
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
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.
def start()
Definition: core.py:1855