LEFT | RIGHT |
(no file at all) | |
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) 2007 INRIA, Mathieu Lacage | 3 * Copyright (c) 2007 INRIA, Mathieu Lacage |
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 /*************************************************************** | 75 /*************************************************************** |
76 * Implementation of the templates declared above. | 76 * Implementation of the templates declared above. |
77 ***************************************************************/ | 77 ***************************************************************/ |
78 | 78 |
79 template <typename T, typename U> | 79 template <typename T, typename U> |
80 Ptr<const AttributeAccessor> | 80 Ptr<const AttributeAccessor> |
81 MakeObjectVectorAccessor (U T::*memberVector) | 81 MakeObjectVectorAccessor (U T::*memberVector) |
82 { | 82 { |
83 struct MemberStdContainer : public ObjectPtrContainerAccessor | 83 struct MemberStdContainer : public ObjectPtrContainerAccessor |
84 { | 84 { |
85 virtual bool DoGetN (const ObjectBase *object, uint32_t *n) const { | 85 virtual bool DoGetN(const ObjectBase *object, std::size_t *n) const { |
86 const T *obj = dynamic_cast<const T *> (object); | 86 const T *obj = dynamic_cast<const T *> (object); |
87 if (obj == 0) | 87 if (obj == 0) |
88 { | 88 { |
89 return false; | 89 return false; |
90 } | 90 } |
91 *n = (obj->*m_memberVector).size (); | 91 *n = (obj->*m_memberVector).size (); |
92 return true; | 92 return true; |
93 } | 93 } |
94 virtual Ptr<Object> DoGet (const ObjectBase *object, uint32_t i, uint32_t *i
ndex) const { | 94 virtual Ptr<Object> DoGet(const ObjectBase *object, std::size_t i, std::size
_t *index) const { |
95 const T *obj = static_cast<const T *> (object); | 95 const T *obj = static_cast<const T *> (object); |
96 typename U::const_iterator begin = (obj->*m_memberVector).begin (); | 96 typename U::const_iterator begin = (obj->*m_memberVector).begin (); |
97 typename U::const_iterator end = (obj->*m_memberVector).end (); | 97 typename U::const_iterator end = (obj->*m_memberVector).end (); |
98 uint32_t k = 0; | 98 std::size_t k = 0; |
99 for (typename U::const_iterator j = begin; j != end; j++, k++) | 99 for (typename U::const_iterator j = begin; j != end; j++, k++) |
100 { | 100 { |
101 if (k == i) | 101 if (k == i) |
102 { | 102 { |
103 *index = k; | 103 *index = k; |
104 return *j; | 104 return *j; |
105 break; | 105 break; |
106 } | 106 } |
107 } | 107 } |
108 NS_ASSERT (false); | 108 NS_ASSERT (false); |
(...skipping 26 matching lines...) Expand all Loading... |
135 Ptr<U> (T::*get)(INDEX) const) | 135 Ptr<U> (T::*get)(INDEX) const) |
136 { | 136 { |
137 return MakeObjectPtrContainerAccessor<T,U,INDEX>(get, getN); | 137 return MakeObjectPtrContainerAccessor<T,U,INDEX>(get, getN); |
138 } | 138 } |
139 | 139 |
140 | 140 |
141 | 141 |
142 } // namespace ns3 | 142 } // namespace ns3 |
143 | 143 |
144 #endif /* OBJECT_VECTOR_H */ | 144 #endif /* OBJECT_VECTOR_H */ |
LEFT | RIGHT |