Left: | ||
Right: |
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 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; |
60 /** | 60 /** |
61 * Get an iterator to the _past-the-end_ Object. | 61 * Get an iterator to the _past-the-end_ Object. |
62 * | 62 * |
63 * \returns An iterator to the _past-the-end_ Object. | 63 * \returns An iterator to the _past-the-end_ Object. |
64 */ | 64 */ |
65 Iterator End (void) const; | 65 Iterator End (void) const; |
66 /** | 66 /** |
67 * Get the number of Objects. | 67 * Get the number of Objects. |
68 * | 68 * |
69 * \returns The number of objects. | 69 * \returns The number of objects. |
70 */ | 70 */ |
71 uint32_t GetN (void) const; | 71 std::size_t GetN (void) const; |
72 /** | 72 /** |
73 * Get a specific Object. | 73 * Get a specific Object. |
74 * | 74 * |
75 * \param [in] i The index of the requested object. | 75 * \param [in] i The index of the requested object. |
76 * \returns The requested object | 76 * \returns The requested object |
77 */ | 77 */ |
78 Ptr<Object> Get (uint32_t i) const; | 78 Ptr<Object> Get (std::size_t i) const; |
79 | 79 |
80 /** | 80 /** |
81 * Get a copy of this container. | 81 * Get a copy of this container. |
82 * | 82 * |
83 * \returns A copy of this container. | 83 * \returns A copy of this container. |
84 */ | 84 */ |
85 virtual Ptr<AttributeValue> Copy (void) const; | 85 virtual Ptr<AttributeValue> Copy (void) const; |
86 /** | 86 /** |
87 * Serialize each of the Object pointers to a string. | 87 * Serialize each of the Object pointers to a string. |
88 * | 88 * |
89 * Note this serializes the Ptr values, not the Objects themselves. | 89 * Note this serializes the Ptr values, not the Objects themselves. |
90 * | 90 * |
91 * \param [in] checker The checker to use (currently not used.) | 91 * \param [in] checker The checker to use (currently not used.) |
92 * \returns The string form of the Objects. | 92 * \returns The string form of the Objects. |
93 */ | 93 */ |
94 virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) co nst; | 94 virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) co nst; |
95 /** | 95 /** |
96 * Deserialize from a string. (Not implemented; raises a fatal error.) | 96 * Deserialize from a string. (Not implemented; raises a fatal error.) |
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 virtual bool HasGetter (void) const; | 221 virtual bool HasGetter (void) const; |
222 virtual bool HasSetter (void) const; | 222 virtual bool HasSetter (void) const; |
223 private: | 223 private: |
224 /** | 224 /** |
225 * Get the number of instances in the container. | 225 * Get the number of instances in the container. |
226 * | 226 * |
227 * \param [in] object The container object. | 227 * \param [in] object The container object. |
228 * \param [out] n The number of instances in the container. | 228 * \param [out] n The number of instances in the container. |
229 * \returns true if the value could be obtained successfully. | 229 * \returns true if the value could be obtained successfully. |
230 */ | 230 */ |
231 virtual bool DoGetN (const ObjectBase *object, uint32_t *n) const = 0; | 231 virtual bool DoGetN(const ObjectBase *object, std::size_t *n) const = 0; |
232 /** | 232 /** |
233 * Get an instance from the container, identified by index. | 233 * Get an instance from the container, identified by index. |
234 * | 234 * |
235 * \param [in] object The container object. | 235 * \param [in] object The container object. |
236 * \param [in] i The desired instance index. | 236 * \param [in] i The desired instance index. |
237 * \param [out] index The index retrieved. | 237 * \param [out] index The index retrieved. |
238 * \returns The index requested. | 238 * \returns The index requested. |
239 */ | 239 */ |
240 virtual Ptr<Object> DoGet (const ObjectBase *object, uint32_t i, uint32_t *ind ex) const = 0; | 240 virtual Ptr<Object> DoGet(const ObjectBase *object, std::size_t i, std::size_t *index) const = 0; |
241 }; | 241 }; |
242 | 242 |
243 template <typename T, typename U, typename INDEX> | 243 template <typename T, typename U, typename INDEX> |
244 Ptr<const AttributeAccessor> | 244 Ptr<const AttributeAccessor> |
245 MakeObjectPtrContainerAccessor (Ptr<U> (T::*get)(INDEX) const, | 245 MakeObjectPtrContainerAccessor (Ptr<U> (T::*get)(INDEX) const, |
246 INDEX (T::*getN)(void) const) | 246 INDEX (T::*getN)(void) const) |
247 { | 247 { |
248 struct MemberGetters : public ObjectPtrContainerAccessor | 248 struct MemberGetters : public ObjectPtrContainerAccessor |
249 { | 249 { |
250 virtual bool DoGetN (const ObjectBase *object, uint32_t *n) const { | 250 virtual bool DoGetN(const ObjectBase *object, std::size_t *n) const { |
251 const T *obj = dynamic_cast<const T *> (object); | 251 const T *obj = dynamic_cast<const T *> (object); |
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, uint32_t i, uint32_t *i ndex) 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)); |
Peter Barnes
2018/05/11 21:58:12
Unnecessary in ns-3-dev. If it is necessary, the
ammo6818-vandals.uidaho.edu
2018/05/16 15:06:28
Removed.
| |
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 |