LEFT | RIGHT |
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 28 matching lines...) Expand all Loading... |
39 *· | 39 *· |
40 * \brief Container for a set of ns3::Object pointers. | 40 * \brief Container for a set of ns3::Object pointers. |
41 * | 41 * |
42 * This class it used to get attribute access to an array of | 42 * This class it used to get attribute access to an array of |
43 * ns3::Object pointers. | 43 * ns3::Object pointers. |
44 */ | 44 */ |
45 class ObjectPtrContainerValue : public AttributeValue | 45 class ObjectPtrContainerValue : public AttributeValue |
46 { | 46 { |
47 public: | 47 public: |
48 /** Iterator type for traversing this container. */ | 48 /** Iterator type for traversing this container. */ |
49 typedef std::map<uint32_t, Ptr<Object> >::const_iterator Iterator; | 49 typedef std::map<std::size_t, Ptr<Object> >::const_iterator Iterator; |
50 | 50 |
51 /** Default constructor. */ | 51 /** Default constructor. */ |
52 ObjectPtrContainerValue (); | 52 ObjectPtrContainerValue (); |
53 | 53 |
54 /** | 54 /** |
55 * Get an iterator to the first Object. | 55 * Get an iterator to the first Object. |
56 * | 56 * |
57 * \returns An iterator to the first Object. | 57 * \returns An iterator to the first Object. |
58 */ | 58 */ |
59 Iterator Begin (void) const; | 59 Iterator Begin (void) const; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 * | 97 * |
98 * \param [in] value The serialized string form. | 98 * \param [in] value The serialized string form. |
99 * \param [in] checker The checker to use. | 99 * \param [in] checker The checker to use. |
100 * \returns \c true. | 100 * \returns \c true. |
101 */ | 101 */ |
102 virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChec
ker> checker); | 102 virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChec
ker> checker); |
103 | 103 |
104 private: | 104 private: |
105 friend class ObjectPtrContainerAccessor; | 105 friend class ObjectPtrContainerAccessor; |
106 /** The container implementation. */ | 106 /** The container implementation. */ |
107 std::map<uint32_t, Ptr<Object> > m_objects; | 107 std::map<std::size_t, Ptr<Object> > m_objects; |
108 }; | 108 }; |
109 | 109 |
110 /** | 110 /** |
111 * \ingroup attribute_ObjectPtrContainer | 111 * \ingroup attribute_ObjectPtrContainer |
112 * Create an AttributeAccessor using a container class indexed get method. | 112 * Create an AttributeAccessor using a container class indexed get method. |
113 * | 113 * |
114 * The two versions of this function differ only in argument order. | 114 * The two versions of this function differ only in argument order. |
115 * | 115 * |
116 * \tparam T \deduced The container class type. | 116 * \tparam T \deduced The container class type. |
117 * \tparam U \deduced The type of object the get method returns. | 117 * \tparam U \deduced The type of object the get method returns. |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 if (obj == 0) | 252 if (obj == 0) |
253 { | 253 { |
254 return false; | 254 return false; |
255 } | 255 } |
256 *n = (obj->*m_getN)(); | 256 *n = (obj->*m_getN)(); |
257 return true; | 257 return true; |
258 } | 258 } |
259 virtual Ptr<Object> DoGet(const ObjectBase *object, std::size_t i, std::size
_t *index) const { | 259 virtual Ptr<Object> DoGet(const ObjectBase *object, std::size_t i, std::size
_t *index) const { |
260 const T *obj = static_cast<const T *> (object); | 260 const T *obj = static_cast<const T *> (object); |
261 *index = i; | 261 *index = i; |
262 return (obj->*m_get)(i); | 262 return (obj->*m_get)(static_cast<uint32_t> (i)); |
263 } | 263 } |
264 Ptr<U> (T::*m_get)(INDEX) const; | 264 Ptr<U> (T::*m_get)(INDEX) const; |
265 INDEX (T::*m_getN)(void) const; | 265 INDEX (T::*m_getN)(void) const; |
266 } *spec = new MemberGetters (); | 266 } *spec = new MemberGetters (); |
267 spec->m_get = get; | 267 spec->m_get = get; |
268 spec->m_getN = getN; | 268 spec->m_getN = getN; |
269 return Ptr<const AttributeAccessor> (spec, false); | 269 return Ptr<const AttributeAccessor> (spec, false); |
270 } | 270 } |
271 | 271 |
272 template <typename T, typename U, typename INDEX> | 272 template <typename T, typename U, typename INDEX> |
273 Ptr<const AttributeAccessor> | 273 Ptr<const AttributeAccessor> |
274 MakeObjectPtrContainerAccessor (INDEX (T::*getN)(void) const, | 274 MakeObjectPtrContainerAccessor (INDEX (T::*getN)(void) const, |
275 Ptr<U> (T::*get)(INDEX) const) | 275 Ptr<U> (T::*get)(INDEX) const) |
276 { | 276 { |
277 return MakeObjectPtrContainerAccessor (get, getN); | 277 return MakeObjectPtrContainerAccessor (get, getN); |
278 } | 278 } |
279 | 279 |
280 template <typename T> | 280 template <typename T> |
281 Ptr<const AttributeChecker> MakeObjectPtrContainerChecker (void) | 281 Ptr<const AttributeChecker> MakeObjectPtrContainerChecker (void) |
282 { | 282 { |
283 return Create<internal::ObjectPtrContainerChecker<T> > (); | 283 return Create<internal::ObjectPtrContainerChecker<T> > (); |
284 } | 284 } |
285 | 285 |
286 | 286 |
287 } // namespace ns3 | 287 } // namespace ns3 |
288 | 288 |
289 #endif /* OBJECT_PTR_CONTAINER_H */ | 289 #endif /* OBJECT_PTR_CONTAINER_H */ |
LEFT | RIGHT |