src/node/mobility-model.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 04 Jul 2007 10:24:45 +0200
changeset 1582 92a3e76ec1c5
parent 1581 95a193d3ac1d
child 1583 470803bf9961
permissions -rw-r--r--
add Position class and Get/Set methods on MobilityModel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1542
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2006,2007 INRIA
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
 * All rights reserved.
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 *
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * it under the terms of the GNU General Public License version 2 as
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 * published by the Free Software Foundation;
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 *
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 * GNU General Public License for more details.
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 *
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * along with this program; if not, write to the Free Software
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
 *
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
 */
1581
95a193d3ac1d POSITION_H -> MOBILITY_MODEL_H
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1580
diff changeset
    21
#ifndef MOBILITY_MODEL_H
95a193d3ac1d POSITION_H -> MOBILITY_MODEL_H
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1580
diff changeset
    22
#define MOBILITY_MODEL_H
1542
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
#include "ns3/object.h"
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
namespace ns3 {
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
1582
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    28
class Vector3D
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    29
{
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    30
public:
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    31
  double x;
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    32
  double y;
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    33
  double z;
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    34
};
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    35
class Position : public Vector3D
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    36
{};
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    37
class Speed : public Vector3D
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    38
{};
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    39
class Vector2D
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    40
{
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    41
public:
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    42
  double x;
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    43
  double y;
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    44
};
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    45
class Position2D : public Vector2D
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    46
{};
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    47
class Speed2D : public Vector2D
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    48
{};
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    49
1542
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    50
/**
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
 * \brief keep track of the current position of an object
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    52
 *
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    53
 * All space coordinates in this class and its subclasses are
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    54
 * understood to be meters or meters/s. i.e., they are all
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    55
 * metric international units.
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    56
 */
1579
a4187ed1e45e Position -> MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1556
diff changeset
    57
class MobilityModel : public Object
1542
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    58
{
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    59
public:
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    60
  static const InterfaceId iid;
1579
a4187ed1e45e Position -> MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1556
diff changeset
    61
  MobilityModel ();
a4187ed1e45e Position -> MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1556
diff changeset
    62
  virtual ~MobilityModel () = 0;
1542
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    63
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    64
  /**
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    65
   * \param x reference to floating-point variable for x coordinate.
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    66
   * \param y reference to floating-point variable for y coordinate.
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    67
   * \param z reference to floating-point variable for z coordinate.
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
   *
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    69
   * Store in the x, y, and z variables the current coordinates
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
   * managed by this position object.
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
   * Unit is meters
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    72
   */
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    73
  void Get (double &x, double &y, double &z) const;
1582
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    74
  Position Get (void) const;
1542
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    75
  /**
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    76
   * \returns the current x coordinate
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    77
   *
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    78
   * Unit is meters
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    79
   */
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    80
  double GetX (void) const;
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    81
  /**
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    82
   * \returns the current y coordinate
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    83
   *
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    84
   * Unit is meters
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    85
   */
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    86
  double GetY (void) const;
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    87
  /**
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    88
   * \returns the current z coordinate
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    89
   *
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    90
   * Unit is meters
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    91
   */
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    92
  double GetZ (void) const;
1544
55080c1f8a22 add Position::DoSet et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1542
diff changeset
    93
1554
76e781c120bb rework the notification mechanism to allow its optional use with every position model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1545
diff changeset
    94
  void Add (double dx, double dy, double dz);
76e781c120bb rework the notification mechanism to allow its optional use with every position model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1545
diff changeset
    95
1544
55080c1f8a22 add Position::DoSet et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1542
diff changeset
    96
  void Set (double x, double y, double z);
1582
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    97
  void Set (const Position &position);
1544
55080c1f8a22 add Position::DoSet et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1542
diff changeset
    98
  void SetXY (double x, double y);
55080c1f8a22 add Position::DoSet et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1542
diff changeset
    99
  void SetX (double x);
55080c1f8a22 add Position::DoSet et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1542
diff changeset
   100
  void SetY (double y);
55080c1f8a22 add Position::DoSet et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1542
diff changeset
   101
  void SetZ (double z);
1542
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   102
  /**
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   103
   * \param position a reference to another position object instance
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   104
   * \returns the distance between the two objects.
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   105
   *
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   106
   * Unit is meters
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   107
   */
1579
a4187ed1e45e Position -> MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1556
diff changeset
   108
  double GetDistanceFrom (const MobilityModel &position) const;
1554
76e781c120bb rework the notification mechanism to allow its optional use with every position model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1545
diff changeset
   109
protected:
76e781c120bb rework the notification mechanism to allow its optional use with every position model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1545
diff changeset
   110
  /**
76e781c120bb rework the notification mechanism to allow its optional use with every position model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1545
diff changeset
   111
   * Must be invoked by subclasses when the course of the
76e781c120bb rework the notification mechanism to allow its optional use with every position model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1545
diff changeset
   112
   * position changes to notify course change listeners.
76e781c120bb rework the notification mechanism to allow its optional use with every position model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1545
diff changeset
   113
   */
76e781c120bb rework the notification mechanism to allow its optional use with every position model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1545
diff changeset
   114
  void NotifyCourseChange (void) const;
1542
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   115
private:
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   116
  /**
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   117
   * \param x reference to floating-point variable for x coordinate.
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   118
   * \param y reference to floating-point variable for y coordinate.
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   119
   * \param z reference to floating-point variable for z coordinate.
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   120
   *
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   121
   * Store in the x, y, and z variables the current coordinates
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   122
   * managed by this position object. Concrete subclasses of this 
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   123
   * base class must implement this method.
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   124
   * Unit is meters
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   125
   */
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   126
  virtual void DoGet (double &x, double &y, double &z) const = 0;
1545
c9c758a80f58 DoSet should not be const
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1544
diff changeset
   127
  virtual void DoSet (double x, double y, double z) = 0;
1542
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   128
};
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   129
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   130
}; // namespace ns3
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   131
1581
95a193d3ac1d POSITION_H -> MOBILITY_MODEL_H
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1580
diff changeset
   132
#endif /* MOBILITY_MODEL_H */