16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * |
17 * |
18 * Authors: Mathieu Lacage <mathieu.lacage@gmail.com> |
18 * Authors: Mathieu Lacage <mathieu.lacage@gmail.com> |
19 */ |
19 */ |
20 #include "object-ptr-container.h" |
20 #include "object-ptr-container.h" |
|
21 #include "log.h" |
|
22 |
|
23 NS_LOG_COMPONENT_DEFINE ("ObjectPtrContainer"); |
21 |
24 |
22 namespace ns3 { |
25 namespace ns3 { |
23 |
26 |
24 ObjectPtrContainerValue::ObjectPtrContainerValue () |
27 ObjectPtrContainerValue::ObjectPtrContainerValue () |
25 { |
28 { |
|
29 NS_LOG_FUNCTION (this); |
26 } |
30 } |
27 |
31 |
28 ObjectPtrContainerValue::Iterator |
32 ObjectPtrContainerValue::Iterator |
29 ObjectPtrContainerValue::Begin (void) const |
33 ObjectPtrContainerValue::Begin (void) const |
30 { |
34 { |
|
35 NS_LOG_FUNCTION (this); |
31 return m_objects.begin (); |
36 return m_objects.begin (); |
32 } |
37 } |
33 ObjectPtrContainerValue::Iterator |
38 ObjectPtrContainerValue::Iterator |
34 ObjectPtrContainerValue::End (void) const |
39 ObjectPtrContainerValue::End (void) const |
35 { |
40 { |
|
41 NS_LOG_FUNCTION (this); |
36 return m_objects.end (); |
42 return m_objects.end (); |
37 } |
43 } |
38 uint32_t |
44 uint32_t |
39 ObjectPtrContainerValue::GetN (void) const |
45 ObjectPtrContainerValue::GetN (void) const |
40 { |
46 { |
|
47 NS_LOG_FUNCTION (this); |
41 return m_objects.size (); |
48 return m_objects.size (); |
42 } |
49 } |
43 Ptr<Object> |
50 Ptr<Object> |
44 ObjectPtrContainerValue::Get (uint32_t i) const |
51 ObjectPtrContainerValue::Get (uint32_t i) const |
45 { |
52 { |
|
53 NS_LOG_FUNCTION (this << i); |
46 Iterator it = m_objects.find (i); |
54 Iterator it = m_objects.find (i); |
47 Ptr<Object> value = 0; |
55 Ptr<Object> value = 0; |
48 if ( it != m_objects.end () ) |
56 if ( it != m_objects.end () ) |
49 { |
57 { |
50 value = m_objects.find (i)->second; |
58 value = m_objects.find (i)->second; |
53 } |
61 } |
54 |
62 |
55 Ptr<AttributeValue> |
63 Ptr<AttributeValue> |
56 ObjectPtrContainerValue::Copy (void) const |
64 ObjectPtrContainerValue::Copy (void) const |
57 { |
65 { |
|
66 NS_LOG_FUNCTION (this); |
58 return ns3::Create<ObjectPtrContainerValue> (*this); |
67 return ns3::Create<ObjectPtrContainerValue> (*this); |
59 } |
68 } |
60 std::string |
69 std::string |
61 ObjectPtrContainerValue::SerializeToString (Ptr<const AttributeChecker> checker) const |
70 ObjectPtrContainerValue::SerializeToString (Ptr<const AttributeChecker> checker) const |
62 { |
71 { |
|
72 NS_LOG_FUNCTION (this << checker); |
63 std::ostringstream oss; |
73 std::ostringstream oss; |
64 Iterator it; |
74 Iterator it; |
65 for (it = Begin (); it != End (); ++it) |
75 for (it = Begin (); it != End (); ++it) |
66 { |
76 { |
67 oss << (*it).second; |
77 oss << (*it).second; |
73 return oss.str (); |
83 return oss.str (); |
74 } |
84 } |
75 bool |
85 bool |
76 ObjectPtrContainerValue::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker) |
86 ObjectPtrContainerValue::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker) |
77 { |
87 { |
|
88 NS_LOG_FUNCTION (this << value << checker); |
78 NS_FATAL_ERROR ("cannot deserialize a set of object pointers."); |
89 NS_FATAL_ERROR ("cannot deserialize a set of object pointers."); |
79 return true; |
90 return true; |
80 } |
91 } |
81 |
92 |
82 bool |
93 bool |
83 ObjectPtrContainerAccessor::Set (ObjectBase * object, const AttributeValue & value) const |
94 ObjectPtrContainerAccessor::Set (ObjectBase * object, const AttributeValue & value) const |
84 { |
95 { |
85 // not allowed. |
96 // not allowed. |
|
97 NS_LOG_FUNCTION (this << object << &value); |
86 return false; |
98 return false; |
87 } |
99 } |
88 bool |
100 bool |
89 ObjectPtrContainerAccessor::Get (const ObjectBase * object, AttributeValue &value) const |
101 ObjectPtrContainerAccessor::Get (const ObjectBase * object, AttributeValue &value) const |
90 { |
102 { |
|
103 NS_LOG_FUNCTION (this << object << &value); |
91 ObjectPtrContainerValue *v = dynamic_cast<ObjectPtrContainerValue *> (&value); |
104 ObjectPtrContainerValue *v = dynamic_cast<ObjectPtrContainerValue *> (&value); |
92 if (v == 0) |
105 if (v == 0) |
93 { |
106 { |
94 return false; |
107 return false; |
95 } |
108 } |