OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2008 INRIA | 3 * Copyright (c) 2008 INRIA |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 { | 58 { |
59 NS_LOG_FUNCTION (this); | 59 NS_LOG_FUNCTION (this); |
60 return m_objects.begin (); | 60 return m_objects.begin (); |
61 } | 61 } |
62 MatchContainer::Iterator | 62 MatchContainer::Iterator |
63 MatchContainer::End (void) const | 63 MatchContainer::End (void) const |
64 { | 64 { |
65 NS_LOG_FUNCTION (this); | 65 NS_LOG_FUNCTION (this); |
66 return m_objects.end (); | 66 return m_objects.end (); |
67 } | 67 } |
68 uint32_t | 68 std::size_t |
69 MatchContainer::GetN (void) const | 69 MatchContainer::GetN (void) const |
70 { | 70 { |
71 NS_LOG_FUNCTION (this); | 71 NS_LOG_FUNCTION (this); |
72 return m_objects.size (); | 72 return m_objects.size (); |
73 } | 73 } |
74 Ptr<Object> | 74 Ptr<Object> |
75 MatchContainer::Get (uint32_t i) const | 75 MatchContainer::Get (std::size_t i) const |
76 { | 76 { |
77 NS_LOG_FUNCTION (this << i); | 77 NS_LOG_FUNCTION (this << i); |
78 return m_objects[i]; | 78 return m_objects[i]; |
79 } | 79 } |
80 std::string | 80 std::string |
81 MatchContainer::GetMatchedPath (uint32_t i) const | 81 MatchContainer::GetMatchedPath (uint32_t i) const |
82 { | 82 { |
83 NS_LOG_FUNCTION (this << i); | 83 NS_LOG_FUNCTION (this << i); |
84 return m_contexts[i]; | 84 return m_contexts[i]; |
85 } | 85 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 * | 159 * |
160 * \param [in] element The Config path specification. | 160 * \param [in] element The Config path specification. |
161 */ | 161 */ |
162 ArrayMatcher (std::string element); | 162 ArrayMatcher (std::string element); |
163 /** | 163 /** |
164 * Test if a specific index matches the Config Path. | 164 * Test if a specific index matches the Config Path. |
165 * | 165 * |
166 * \param [in] i The index. | 166 * \param [in] i The index. |
167 * \returns \c true if the index matches the Config Path. | 167 * \returns \c true if the index matches the Config Path. |
168 */ | 168 */ |
169 bool Matches (uint32_t i) const; | 169 bool Matches (std::size_t i) const; |
170 private: | 170 private: |
171 /** | 171 /** |
172 * Convert a string to an \c uint32_t. | 172 * Convert a string to an \c uint32_t. |
173 * | 173 * |
174 * \param [in] str The string. | 174 * \param [in] str The string. |
175 * \param [in] value The location to store the \c uint32_t. | 175 * \param [in] value The location to store the \c uint32_t. |
176 * \returns \c true if the string could be converted. | 176 * \returns \c true if the string could be converted. |
177 */ | 177 */ |
178 bool StringToUint32 (std::string str, uint32_t *value) const; | 178 bool StringToUint32 (std::string str, uint32_t *value) const; |
179 /** The Config path element. */ | 179 /** The Config path element. */ |
180 std::string m_element; | 180 std::string m_element; |
181 | 181 |
182 }; // class ArrayMatcher | 182 }; // class ArrayMatcher |
183 | 183 |
184 | 184 |
185 ArrayMatcher::ArrayMatcher (std::string element) | 185 ArrayMatcher::ArrayMatcher (std::string element) |
186 : m_element (element) | 186 : m_element (element) |
187 { | 187 { |
188 NS_LOG_FUNCTION (this << element); | 188 NS_LOG_FUNCTION (this << element); |
189 } | 189 } |
190 bool | 190 bool |
191 ArrayMatcher::Matches (uint32_t i) const | 191 ArrayMatcher::Matches (std::size_t i) const |
192 { | 192 { |
193 NS_LOG_FUNCTION (this << i); | 193 NS_LOG_FUNCTION (this << i); |
194 if (m_element == "*") | 194 if (m_element == "*") |
195 { | 195 { |
196 NS_LOG_DEBUG ("Array "<<i<<" matches *"); | 196 NS_LOG_DEBUG ("Array "<<i<<" matches *"); |
197 return true; | 197 return true; |
198 } | 198 } |
199 std::string::size_type tmp; | 199 std::string::size_type tmp; |
200 tmp = m_element.find ("|"); | 200 tmp = m_element.find ("|"); |
201 if (tmp != std::string::npos) | 201 if (tmp != std::string::npos) |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 ·········· | 493 ·········· |
494 for (uint32_t i = 0; i < tid.GetAttributeN(); i++) | 494 for (uint32_t i = 0; i < tid.GetAttributeN(); i++) |
495 { | 495 { |
496 struct TypeId::AttributeInformation info; | 496 struct TypeId::AttributeInformation info; |
497 info = tid.GetAttribute(i); | 497 info = tid.GetAttribute(i); |
498 if (info.name != item && item != "*") | 498 if (info.name != item && item != "*") |
499 { | 499 { |
500 continue; | 500 continue; |
501 } | 501 } |
502 // attempt to cast to a pointer checker. | 502 // attempt to cast to a pointer checker. |
503 const PointerChecker *ptr = dynamic_cast<const PointerChecker *> (
PeekPointer (info.checker)); | 503 const PointerChecker *pChecker = dynamic_cast<const PointerChecker
*> (PeekPointer(info.checker)); |
504 if (ptr != 0) | 504 if (pChecker != 0) |
505 { | 505 { |
506 NS_LOG_DEBUG ("GetAttribute(ptr)="<<info.name<<" on path="<<Ge
tResolvedPath ()); | 506 NS_LOG_DEBUG ("GetAttribute(ptr)="<<info.name<<" on path="<<Ge
tResolvedPath ()); |
507 PointerValue ptr; | 507 PointerValue pValue; |
508 root->GetAttribute (info.name, ptr); | 508 root->GetAttribute (info.name, pValue); |
509 Ptr<Object> object = ptr.Get<Object> (); | 509 Ptr<Object> object = pValue.Get<Object> (); |
510 if (object == 0) | 510 if (object == 0) |
511 { | 511 { |
512 NS_LOG_ERROR ("Requested object name=\""<<item<< | 512 NS_LOG_ERROR ("Requested object name=\""<<item<< |
513 "\" exists on path=\""<<GetResolvedPath ()<<
"\"" | 513 "\" exists on path=\""<<GetResolvedPath ()<<
"\"" |
514 " but is null."); | 514 " but is null."); |
515 continue; | 515 continue; |
516 } | 516 } |
517 foundMatch = true; | 517 foundMatch = true; |
518 m_workStack.push_back (info.name); | 518 m_workStack.push_back (info.name); |
519 DoResolve (pathLeft, object); | 519 DoResolve (pathLeft, object); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 void Disconnect (std::string path, const CallbackBase &cb); | 595 void Disconnect (std::string path, const CallbackBase &cb); |
596 /** \copydoc Config::LookupMatches() */ | 596 /** \copydoc Config::LookupMatches() */ |
597 MatchContainer LookupMatches (std::string path); | 597 MatchContainer LookupMatches (std::string path); |
598 | 598 |
599 /** \copydoc Config::RegisterRootNamespaceObject() */ | 599 /** \copydoc Config::RegisterRootNamespaceObject() */ |
600 void RegisterRootNamespaceObject (Ptr<Object> obj); | 600 void RegisterRootNamespaceObject (Ptr<Object> obj); |
601 /** \copydoc Config::UnregisterRootNamespaceObject() */ | 601 /** \copydoc Config::UnregisterRootNamespaceObject() */ |
602 void UnregisterRootNamespaceObject (Ptr<Object> obj); | 602 void UnregisterRootNamespaceObject (Ptr<Object> obj); |
603 | 603 |
604 /** \copydoc Config::GetRootNamespaceObjectN() */ | 604 /** \copydoc Config::GetRootNamespaceObjectN() */ |
605 uint32_t GetRootNamespaceObjectN (void) const; | 605 std::size_t GetRootNamespaceObjectN (void) const; |
606 /** \copydoc Config::GetRootNamespaceObject() */ | 606 /** \copydoc Config::GetRootNamespaceObject() */ |
607 Ptr<Object> GetRootNamespaceObject (uint32_t i) const; | 607 Ptr<Object> GetRootNamespaceObject (std::size_t i) const; |
608 | 608 |
609 private: | 609 private: |
610 /** | 610 /** |
611 * Break a Config path into the leading path and the last leaf token. | 611 * Break a Config path into the leading path and the last leaf token. |
612 * \param [in] path The Config path. | 612 * \param [in] path The Config path. |
613 * \param [in,out] root The leading part of the \p path, | 613 * \param [in,out] root The leading part of the \p path, |
614 * up to the final slash. | 614 * up to the final slash. |
615 * \param [in,out] leaf The trailing part of the \p path. | 615 * \param [in,out] leaf The trailing part of the \p path. |
616 */ | 616 */ |
617 void ParsePath (std::string path, std::string *root, std::string *leaf) const; | 617 void ParsePath (std::string path, std::string *root, std::string *leaf) const; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 for (std::vector<Ptr<Object> >::iterator i = m_roots.begin (); i != m_roots.en
d (); i++) | 733 for (std::vector<Ptr<Object> >::iterator i = m_roots.begin (); i != m_roots.en
d (); i++) |
734 { | 734 { |
735 if (*i == obj) | 735 if (*i == obj) |
736 { | 736 { |
737 m_roots.erase (i); | 737 m_roots.erase (i); |
738 return; | 738 return; |
739 } | 739 } |
740 } | 740 } |
741 } | 741 } |
742 | 742 |
743 uint32_t | 743 std::size_t |
744 ConfigImpl::GetRootNamespaceObjectN (void) const | 744 ConfigImpl::GetRootNamespaceObjectN (void) const |
745 { | 745 { |
746 NS_LOG_FUNCTION (this); | 746 NS_LOG_FUNCTION (this); |
747 return m_roots.size (); | 747 return m_roots.size (); |
748 } | 748 } |
749 Ptr<Object>· | 749 Ptr<Object>· |
750 ConfigImpl::GetRootNamespaceObject (uint32_t i) const | 750 ConfigImpl::GetRootNamespaceObject (std::size_t i) const |
751 { | 751 { |
752 NS_LOG_FUNCTION (this << i); | 752 NS_LOG_FUNCTION (this << i); |
753 return m_roots[i]; | 753 return m_roots[i]; |
754 } | 754 } |
755 | 755 |
756 | 756 |
757 void Reset (void) | 757 void Reset (void) |
758 { | 758 { |
759 NS_LOG_FUNCTION_NOARGS (); | 759 NS_LOG_FUNCTION_NOARGS (); |
760 // First, let's reset the initial value of every attribute | 760 // First, let's reset the initial value of every attribute |
761 for (uint32_t i = 0; i < TypeId::GetRegisteredN (); i++) | 761 for (uint16_t i = 0; i < TypeId::GetRegisteredN (); i++) |
762 { | 762 { |
763 TypeId tid = TypeId::GetRegistered (i); | 763 TypeId tid = TypeId::GetRegistered (i); |
764 for (uint32_t j = 0; j < tid.GetAttributeN (); j++) | 764 for (uint32_t j = 0; j < tid.GetAttributeN (); j++) |
765 { | 765 { |
766 struct TypeId::AttributeInformation info = tid.GetAttribute (j); | 766 struct TypeId::AttributeInformation info = tid.GetAttribute (j); |
767 tid.SetAttributeInitialValue (j, info.originalInitialValue); | 767 tid.SetAttributeInitialValue (j, info.originalInitialValue); |
768 } | 768 } |
769 } | 769 } |
770 // now, let's reset the initial value of every global value. | 770 // now, let's reset the initial value of every global value. |
771 for (GlobalValue::Iterator i = GlobalValue::Begin (); i != GlobalValue::End ()
; ++i) | 771 for (GlobalValue::Iterator i = GlobalValue::Begin (); i != GlobalValue::End ()
; ++i) |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 NS_LOG_FUNCTION (obj); | 862 NS_LOG_FUNCTION (obj); |
863 ConfigImpl::Get ()->RegisterRootNamespaceObject (obj); | 863 ConfigImpl::Get ()->RegisterRootNamespaceObject (obj); |
864 } | 864 } |
865 | 865 |
866 void UnregisterRootNamespaceObject (Ptr<Object> obj) | 866 void UnregisterRootNamespaceObject (Ptr<Object> obj) |
867 { | 867 { |
868 NS_LOG_FUNCTION (obj); | 868 NS_LOG_FUNCTION (obj); |
869 ConfigImpl::Get ()->UnregisterRootNamespaceObject (obj); | 869 ConfigImpl::Get ()->UnregisterRootNamespaceObject (obj); |
870 } | 870 } |
871 | 871 |
872 uint32_t GetRootNamespaceObjectN (void) | 872 std::size_t GetRootNamespaceObjectN (void) |
873 { | 873 { |
874 NS_LOG_FUNCTION_NOARGS (); | 874 NS_LOG_FUNCTION_NOARGS (); |
875 return ConfigImpl::Get ()->GetRootNamespaceObjectN (); | 875 return ConfigImpl::Get ()->GetRootNamespaceObjectN (); |
876 } | 876 } |
877 | 877 |
878 Ptr<Object> GetRootNamespaceObject (uint32_t i) | 878 Ptr<Object> GetRootNamespaceObject (uint32_t i) |
879 { | 879 { |
880 NS_LOG_FUNCTION (i); | 880 NS_LOG_FUNCTION (i); |
881 return ConfigImpl::Get ()->GetRootNamespaceObject (i); | 881 return ConfigImpl::Get ()->GetRootNamespaceObject (i); |
882 } | 882 } |
883 | 883 |
884 } // namespace Config | 884 } // namespace Config |
885 | 885 |
886 } // namespace ns3 | 886 } // namespace ns3 |
OLD | NEW |