|
1 #include "object-vector.h" |
|
2 |
|
3 namespace ns3 { |
|
4 |
|
5 ObjectVector::ObjectVector () |
|
6 {} |
|
7 |
|
8 ObjectVector::Iterator |
|
9 ObjectVector::Begin (void) const |
|
10 { |
|
11 return m_objects.begin (); |
|
12 } |
|
13 ObjectVector::Iterator |
|
14 ObjectVector::End (void) const |
|
15 { |
|
16 return m_objects.end (); |
|
17 } |
|
18 uint32_t |
|
19 ObjectVector::GetN (void) const |
|
20 { |
|
21 return m_objects.size (); |
|
22 } |
|
23 Ptr<Object> |
|
24 ObjectVector::Get (uint32_t i) const |
|
25 { |
|
26 return m_objects[i]; |
|
27 } |
|
28 |
|
29 ObjectVector::ObjectVector (PValue value) |
|
30 { |
|
31 const ObjectVectorValue *v = value.DynCast<const ObjectVectorValue *> (); |
|
32 if (v == 0) |
|
33 { |
|
34 NS_FATAL_ERROR ("Expected value of type ObjectVectorValue."); |
|
35 } |
|
36 *this = v->Get (); |
|
37 } |
|
38 |
|
39 ObjectVectorValue::ObjectVectorValue () |
|
40 : m_vector () |
|
41 {} |
|
42 |
|
43 ObjectVectorValue::ObjectVectorValue (const ObjectVector &vector) |
|
44 : m_vector (vector) |
|
45 {} |
|
46 |
|
47 ObjectVector |
|
48 ObjectVectorValue::Get (void) const |
|
49 { |
|
50 return m_vector; |
|
51 } |
|
52 |
|
53 PValue |
|
54 ObjectVectorValue::Copy (void) const |
|
55 { |
|
56 return PValue::Create<ObjectVectorValue> (*this); |
|
57 } |
|
58 std::string |
|
59 ObjectVectorValue::SerializeToString (Ptr<const ParamSpec> spec) const |
|
60 { |
|
61 return ""; |
|
62 } |
|
63 bool |
|
64 ObjectVectorValue::DeserializeFromString (std::string value, Ptr<const ParamSpec> spec) |
|
65 { |
|
66 return true; |
|
67 } |
|
68 |
|
69 bool |
|
70 ObjectVectorParamSpec::Set (ObjectBase * object, PValue value) const |
|
71 { |
|
72 // not allowed. |
|
73 return false; |
|
74 } |
|
75 bool |
|
76 ObjectVectorParamSpec::Get (const ObjectBase * object, PValue value) const |
|
77 { |
|
78 ObjectVectorValue *v = value.DynCast<ObjectVectorValue *> (); |
|
79 if (v == 0) |
|
80 { |
|
81 return false; |
|
82 } |
|
83 v->m_vector.m_objects.clear (); |
|
84 uint32_t n; |
|
85 bool ok = DoGetN (object, &n); |
|
86 if (!ok) |
|
87 { |
|
88 return false; |
|
89 } |
|
90 for (uint32_t i = 0; i < n; i++) |
|
91 { |
|
92 Ptr<Object> o = DoGet (object, i); |
|
93 v->m_vector.m_objects.push_back (o); |
|
94 } |
|
95 return true; |
|
96 } |
|
97 bool |
|
98 ObjectVectorParamSpec::Check (PValue value) const |
|
99 { |
|
100 const ObjectVectorValue *v = value.DynCast<const ObjectVectorValue *> (); |
|
101 return v != 0; |
|
102 } |
|
103 PValue |
|
104 ObjectVectorParamSpec::GetInitialValue (void) const |
|
105 { |
|
106 return PValue::Create<ObjectVectorValue> (); |
|
107 } |
|
108 PValue |
|
109 ObjectVectorParamSpec::CreateValue (void) const |
|
110 { |
|
111 return PValue::Create<ObjectVectorValue> (); |
|
112 } |
|
113 |
|
114 |
|
115 } // name |