64 do { |
64 do { |
65 // loop over all attributes in object type |
65 // loop over all attributes in object type |
66 NS_LOG_DEBUG ("construct tid="<<tid.GetName ()<<", params="<<tid.GetAttributeN ()); |
66 NS_LOG_DEBUG ("construct tid="<<tid.GetName ()<<", params="<<tid.GetAttributeN ()); |
67 for (uint32_t i = 0; i < tid.GetAttributeN (); i++) |
67 for (uint32_t i = 0; i < tid.GetAttributeN (); i++) |
68 { |
68 { |
69 Ptr<const AttributeAccessor> accessor = tid.GetAttributeAccessor (i); |
69 struct TypeId::AttributeInformation info = tid.GetAttribute(i); |
70 Ptr<const AttributeValue> initial = tid.GetAttributeInitialValue (i); |
|
71 Ptr<const AttributeChecker> checker = tid.GetAttributeChecker (i); |
|
72 NS_LOG_DEBUG ("try to construct \""<< tid.GetName ()<<"::"<< |
70 NS_LOG_DEBUG ("try to construct \""<< tid.GetName ()<<"::"<< |
73 tid.GetAttributeName (i)<<"\""); |
71 info.name <<"\""); |
74 if (!(tid.GetAttributeFlags (i) & TypeId::ATTR_CONSTRUCT)) |
72 if (!(info.flags & TypeId::ATTR_CONSTRUCT)) |
75 { |
73 { |
76 continue; |
74 continue; |
77 } |
75 } |
78 bool found = false; |
76 bool found = false; |
79 // is this attribute stored in this AttributeList instance ? |
77 // is this attribute stored in this AttributeList instance ? |
80 for (AttributeList::Attrs::const_iterator j = attributes.m_attributes.begin (); |
78 for (AttributeList::Attrs::const_iterator j = attributes.m_attributes.begin (); |
81 j != attributes.m_attributes.end (); j++) |
79 j != attributes.m_attributes.end (); j++) |
82 { |
80 { |
83 if (j->checker == checker) |
81 if (j->checker == info.checker) |
84 { |
82 { |
85 // We have a matching attribute value. |
83 // We have a matching attribute value. |
86 if (DoSet (accessor, checker, *j->value)) |
84 if (DoSet (info.accessor, info.checker, *j->value)) |
87 { |
85 { |
88 NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<< |
86 NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<< |
89 tid.GetAttributeName (i)<<"\""); |
87 info.name<<"\""); |
90 found = true; |
88 found = true; |
91 break; |
89 break; |
92 } |
90 } |
93 } |
91 } |
94 } |
92 } |
96 { |
94 { |
97 // is this attribute stored in the global instance ? |
95 // is this attribute stored in the global instance ? |
98 for (AttributeList::Attrs::const_iterator j = AttributeList::GetGlobal ()->m_attributes.begin (); |
96 for (AttributeList::Attrs::const_iterator j = AttributeList::GetGlobal ()->m_attributes.begin (); |
99 j != AttributeList::GetGlobal ()->m_attributes.end (); j++) |
97 j != AttributeList::GetGlobal ()->m_attributes.end (); j++) |
100 { |
98 { |
101 if (j->checker == checker) |
99 if (j->checker == info.checker) |
102 { |
100 { |
103 // We have a matching attribute value. |
101 // We have a matching attribute value. |
104 if (DoSet (accessor, checker, *j->value)) |
102 if (DoSet (info.accessor, info.checker, *j->value)) |
105 { |
103 { |
106 NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<< |
104 NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<< |
107 tid.GetAttributeName (i)<<"\" from global"); |
105 info.name <<"\" from global"); |
108 found = true; |
106 found = true; |
109 break; |
107 break; |
110 } |
108 } |
111 } |
109 } |
112 } |
110 } |
130 { |
128 { |
131 std::string name = tmp.substr (0, equal); |
129 std::string name = tmp.substr (0, equal); |
132 std::string value = tmp.substr (equal+1, tmp.size () - equal - 1); |
130 std::string value = tmp.substr (equal+1, tmp.size () - equal - 1); |
133 if (name == tid.GetAttributeFullName (i)) |
131 if (name == tid.GetAttributeFullName (i)) |
134 { |
132 { |
135 if (DoSet (accessor, checker, StringValue (value))) |
133 if (DoSet (info.accessor, info.checker, StringValue (value))) |
136 { |
134 { |
137 NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<< |
135 NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<< |
138 tid.GetAttributeName (i)<<"\" from env var"); |
136 info.name <<"\" from env var"); |
139 found = true; |
137 found = true; |
140 break; |
138 break; |
141 } |
139 } |
142 } |
140 } |
143 } |
141 } |
147 #endif /* HAVE_GETENV */ |
145 #endif /* HAVE_GETENV */ |
148 } |
146 } |
149 if (!found) |
147 if (!found) |
150 { |
148 { |
151 // No matching attribute value so we try to set the default value. |
149 // No matching attribute value so we try to set the default value. |
152 DoSet (accessor, checker, *initial); |
150 DoSet (info.accessor, info.checker, *info.initialValue); |
153 NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<< |
151 NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<< |
154 tid.GetAttributeName (i)<<"\" from initial value."); |
152 info.name <<"\" from initial value."); |
155 } |
153 } |
156 } |
154 } |
157 tid = tid.GetParent (); |
155 tid = tid.GetParent (); |
158 } while (tid != ObjectBase::GetTypeId ()); |
156 } while (tid != ObjectBase::GetTypeId ()); |
159 NotifyConstructionCompleted (); |
157 NotifyConstructionCompleted (); |