NS-3 based Named Data Networking (NDN) simulator
ndnSIM: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
spring-mobility-model.h
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:
19  */
20 #ifndef SPRING_MOBILITY_MODEL_H
21 #define SPRING_MOBILITY_MODEL_H
22 
23 #include "ns3/mobility-model.h"
24 #include "ns3/nstime.h"
25 #include "ns3/event-id.h"
26 
27 namespace ns3 {
28 
34 class SpringMobilityModel : public MobilityModel
35 {
36 public:
37  static TypeId GetTypeId (void);
38 
43  virtual ~SpringMobilityModel ();
44 
49  void
50  AddSpring (Ptr<MobilityModel> node);
51 
52 private:
53  // from Object
54  virtual void
55  DoStart ();
56 
57  // from MobilityModel
58  virtual Vector
59  DoGetPosition (void) const;
60 
61  virtual void
62  DoSetPosition (const Vector &position);
63 
64  virtual Vector
65  DoGetVelocity (void) const;
66 
67  // Updating positions
68  void
69  Update (void) const;
70 
71  static void
72  UpdateAll ();
73 
74 private:
75  static double m_epsilon;
76 
77  double m_nodeMass;
78  double m_nodeCharge;
79  double m_springNormalLength;
80  double m_springConstant;
81  double m_dampingFactor;
82 
83  static double m_totalKineticEnergy;
84  static bool m_stable;
85  static EventId m_updateEvent;
86 
87  mutable Vector m_position;
88  mutable Vector m_velocity;
89  mutable Time m_lastTime;
90 
91  std::list<Ptr<MobilityModel> > m_springs;
92 };
93 
94 } // namespace ns3
95 
96 #endif // SPRING_MOBILITY_MODEL_H