00001 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2006,2007 INRIA 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> 00019 */ 00020 #ifndef MOBILITY_MODEL_H 00021 #define MOBILITY_MODEL_H 00022 00023 #include "vector.h" 00024 00025 #include "ns3/object.h" 00026 #include "ns3/traced-callback.h" 00027 00028 namespace ns3 { 00029 00030 /** 00031 * \brief keep track of the current position of an object 00032 * 00033 * All space coordinates in this class and its subclasses are 00034 * understood to be meters or meters/s. i.e., they are all 00035 * metric international units. 00036 */ 00037 class MobilityModel : public Object 00038 { 00039 public: 00040 static TypeId GetTypeId (void); 00041 MobilityModel (); 00042 virtual ~MobilityModel () = 0; 00043 00044 /** 00045 * \returns the current position 00046 */ 00047 Vector GetPosition (void) const; 00048 /** 00049 * \param position the position to set. 00050 */ 00051 void SetPosition (const Vector &position); 00052 /** 00053 * \returns the current velocity. 00054 */ 00055 Vector GetVelocity (void) const; 00056 /** 00057 * \param position a reference to another mobility model 00058 * \returns the distance between the two objects. Unit is meters. 00059 */ 00060 double GetDistanceFrom (Ptr<const MobilityModel> position) const; 00061 protected: 00062 /** 00063 * Must be invoked by subclasses when the course of the 00064 * position changes to notify course change listeners. 00065 */ 00066 void NotifyCourseChange (void) const; 00067 private: 00068 /** 00069 * \returns the current position. 00070 * 00071 * Concrete subclasses of this base class must 00072 * implement this method. 00073 */ 00074 virtual Vector DoGetPosition (void) const = 0; 00075 /** 00076 * \param position the position to set. 00077 * 00078 * Concrete subclasses of this base class must 00079 * implement this method. 00080 */ 00081 virtual void DoSetPosition (const Vector &position) = 0; 00082 /** 00083 * \returns the current velocity. 00084 * 00085 * Concrete subclasses of this base class must 00086 * implement this method. 00087 */ 00088 virtual Vector DoGetVelocity (void) const = 0; 00089 00090 /** 00091 * Used to alert subscribers that a change in direction, velocity, 00092 * or position has occurred. 00093 */ 00094 TracedCallback<Ptr<const MobilityModel> > m_courseChangeTrace; 00095 00096 }; 00097 00098 }; // namespace ns3 00099 00100 #endif /* MOBILITY_MODEL_H */