00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef NS2_MOBILITY_FILE_TOPOLOGY_H
00021 #define NS2_MOBILITY_FILE_TOPOLOGY_H
00022
00023 #include <string>
00024 #include <stdint.h>
00025 #include "ns3/ptr.h"
00026 #include "ns3/object.h"
00027
00028 namespace ns3 {
00029
00030 class StaticSpeedMobilityModel;
00031
00032
00033
00034
00035
00036 class Ns2MobilityHelper
00037 {
00038 public:
00039
00040
00041
00042
00043 Ns2MobilityHelper (std::string filename);
00044
00045
00046
00047
00048
00049
00050
00051 void Install (void) const;
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 template <typename T>
00065 void Install (T begin, T end) const;
00066 private:
00067 class ObjectStore
00068 {
00069 public:
00070 virtual ~ObjectStore () {}
00071 virtual Ptr<Object> Get (uint32_t i) const = 0;
00072 };
00073 void LayoutObjectStore (const ObjectStore &store) const;
00074 Ptr<StaticSpeedMobilityModel> GetMobilityModel (std::string idString, const ObjectStore &store) const;
00075 double ReadDouble (std::string valueString) const;
00076 std::string m_filename;
00077 };
00078
00079 }
00080
00081 namespace ns3 {
00082
00083 template <typename T>
00084 void
00085 Ns2MobilityHelper::Install (T begin, T end) const
00086 {
00087 class MyObjectStore : public ObjectStore
00088 {
00089 public:
00090 MyObjectStore (T begin, T end)
00091 : m_begin (begin),
00092 m_end (end)
00093 {}
00094 virtual Ptr<Object> Get (uint32_t i) const {
00095 T iterator = m_begin;
00096 iterator += i;
00097 if (iterator >= m_end)
00098 {
00099 return 0;
00100 }
00101 return *iterator;
00102 }
00103 private:
00104 T m_begin;
00105 T m_end;
00106 };
00107 LayoutObjectStore (MyObjectStore (begin, end));
00108 }
00109
00110
00111 }
00112
00113 #endif