src/node/mobility-model.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Tue, 17 Jul 2007 10:58:13 +0200
changeset 1588 51b44f1f4ae5
parent 1584 b612c5fe9e6b
child 1590 6c3a3ed42635
permissions -rw-r--r--
remove extraneous setters/getters
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:
1584
b612c5fe9e6b new version of DoGet and DoSet
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1583
diff changeset
    31
  Vector3D (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
    32
  double x;
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    33
  double y;
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    34
  double z;
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    35
};
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    36
class Position : public Vector3D
1584
b612c5fe9e6b new version of DoGet and DoSet
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1583
diff changeset
    37
{
b612c5fe9e6b new version of DoGet and DoSet
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1583
diff changeset
    38
public:
b612c5fe9e6b new version of DoGet and DoSet
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1583
diff changeset
    39
  Position (double x, double y, double z);
b612c5fe9e6b new version of DoGet and DoSet
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1583
diff changeset
    40
};
1582
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    41
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
    42
{};
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    43
class Vector2D
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
public:
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    46
  double x;
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    47
  double y;
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
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
    50
{};
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    51
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
    52
{};
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    53
1542
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    54
/**
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    55
 * \brief keep track of the current position of an object
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    56
 *
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    57
 * All space coordinates in this class and its subclasses are
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    58
 * 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
    59
 * metric international units.
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    60
 */
1579
a4187ed1e45e Position -> MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1556
diff changeset
    61
class MobilityModel : public Object
1542
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    62
{
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    63
public:
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    64
  static const InterfaceId iid;
1579
a4187ed1e45e Position -> MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1556
diff changeset
    65
  MobilityModel ();
a4187ed1e45e Position -> MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1556
diff changeset
    66
  virtual ~MobilityModel () = 0;
1542
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    67
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
  /**
1583
470803bf9961 use new MobilityModel::Get and remove old one.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1582
diff changeset
    69
   * \returns the current position
1542
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
   * Unit is meters
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
   */
1582
92a3e76ec1c5 add Position class and Get/Set methods on MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1581
diff changeset
    72
  Position Get (void) 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
    73
1544
55080c1f8a22 add Position::DoSet et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1542
diff changeset
    74
  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
    75
  void Set (const Position &position);
1542
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    76
  /**
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    77
   * \param position a reference to another position object instance
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    78
   * \returns the distance between the two objects.
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
   * Unit is meters
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    81
   */
1579
a4187ed1e45e Position -> MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1556
diff changeset
    82
  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
    83
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
    84
  /**
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
    85
   * 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
    86
   * 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
    87
   */
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
    88
  void NotifyCourseChange (void) const;
1542
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    89
private:
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    90
  /**
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    91
   * \param x reference to floating-point variable for x coordinate.
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    92
   * \param y reference to floating-point variable for y coordinate.
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    93
   * \param z reference to floating-point variable for z coordinate.
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    94
   *
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    95
   * Store in the x, y, and z variables the current coordinates
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    96
   * managed by this position object. Concrete subclasses of this 
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    97
   * base class must implement this method.
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    98
   * Unit is meters
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    99
   */
1584
b612c5fe9e6b new version of DoGet and DoSet
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1583
diff changeset
   100
  virtual Position DoGet (void) const = 0;
b612c5fe9e6b new version of DoGet and DoSet
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1583
diff changeset
   101
  virtual void DoSet (const Position &position) = 0;
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
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   104
}; // namespace ns3
7d62f83de7d3 position models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   105
1581
95a193d3ac1d POSITION_H -> MOBILITY_MODEL_H
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1580
diff changeset
   106
#endif /* MOBILITY_MODEL_H */