author | Peter D. Barnes, Jr. <barnes26@llnl.gov> |
Sun, 07 Dec 2014 22:08:04 -0800 | |
changeset 11096 | e57bfdb4f12c |
parent 11036 | 1e03af4311bd |
child 11136 | 03bf8fa63bda |
permissions | -rw-r--r-- |
7412
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
2 |
/* |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
3 |
* Copyright (c) 2007 INRIA, Mathieu Lacage |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
4 |
* |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
7 |
* published by the Free Software Foundation; |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
8 |
* |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
12 |
* GNU General Public License for more details. |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
13 |
* |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
17 |
* |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
18 |
* Authors: Mathieu Lacage <mathieu.lacage@gmail.com> |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
19 |
*/ |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
20 |
#ifndef OBJECT_PTR_CONTAINER_H |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
21 |
#define OBJECT_PTR_CONTAINER_H |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
|
7884
963d5bfe9c52
Fixed bug 1352 (Object attribute map / vector issue)
Jaume Nin <jnin@cttc.cat>
parents:
7412
diff
changeset
|
23 |
#include <map> |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
#include "object.h" |
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
25 |
#include "ptr.h" |
2438
e2ac9f9aeeb9
value.h -> attribute.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2437
diff
changeset
|
26 |
#include "attribute.h" |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
|
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
28 |
namespace ns3 { |
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
|
2930
bbe74014af44
add doxygen documentation to avoid doxygen warnings.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2599
diff
changeset
|
30 |
/** |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
31 |
* \ingroup attribute_ObjectPtrContainer |
3182 | 32 |
* |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
33 |
* \brief Container for a set of ns3::Object pointers. |
2930
bbe74014af44
add doxygen documentation to avoid doxygen warnings.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2599
diff
changeset
|
34 |
* |
bbe74014af44
add doxygen documentation to avoid doxygen warnings.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2599
diff
changeset
|
35 |
* This class it used to get attribute access to an array of |
bbe74014af44
add doxygen documentation to avoid doxygen warnings.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2599
diff
changeset
|
36 |
* ns3::Object pointers. |
bbe74014af44
add doxygen documentation to avoid doxygen warnings.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2599
diff
changeset
|
37 |
*/ |
7412
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
38 |
class ObjectPtrContainerValue : public AttributeValue |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
39 |
{ |
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
40 |
public: |
11036
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
41 |
/** Iterator type for traversing this container. */ |
7884
963d5bfe9c52
Fixed bug 1352 (Object attribute map / vector issue)
Jaume Nin <jnin@cttc.cat>
parents:
7412
diff
changeset
|
42 |
typedef std::map<uint32_t, Ptr<Object> >::const_iterator Iterator; |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
43 |
|
11036
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
44 |
/** Default constructor. */ |
7412
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
45 |
ObjectPtrContainerValue (); |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
46 |
|
2967
6fe0a5622af7
improve the doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2965
diff
changeset
|
47 |
/** |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
48 |
* Get an iterator to the first Object. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
49 |
* |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
50 |
* \returns An iterator to the first Object. |
2967
6fe0a5622af7
improve the doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2965
diff
changeset
|
51 |
*/ |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
52 |
Iterator Begin (void) const; |
2967
6fe0a5622af7
improve the doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2965
diff
changeset
|
53 |
/** |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
54 |
* Get an iterator to the _past-the-end_ Object. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
55 |
* |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
56 |
* \returns An iterator to the _past-the-end_ Object. |
2967
6fe0a5622af7
improve the doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2965
diff
changeset
|
57 |
*/ |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
58 |
Iterator End (void) const; |
2967
6fe0a5622af7
improve the doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2965
diff
changeset
|
59 |
/** |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
60 |
* Get the number of Objects. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
61 |
* |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
62 |
* \returns The number of objects. |
2967
6fe0a5622af7
improve the doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2965
diff
changeset
|
63 |
*/ |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
64 |
uint32_t GetN (void) const; |
2967
6fe0a5622af7
improve the doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2965
diff
changeset
|
65 |
/** |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
66 |
* Get a specific Object. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
67 |
* |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
68 |
* \param i The index of the requested object. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
69 |
* \returns The requested object |
2967
6fe0a5622af7
improve the doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2965
diff
changeset
|
70 |
*/ |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
71 |
Ptr<Object> Get (uint32_t i) const; |
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
72 |
|
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
73 |
/** |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
74 |
* Get a copy of this container. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
75 |
* |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
76 |
* \returns A copy of this container. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
77 |
*/ |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2950
diff
changeset
|
78 |
virtual Ptr<AttributeValue> Copy (void) const; |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
79 |
/** |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
80 |
* Serialize each of the Object pointers to a string. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
81 |
* |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
82 |
* Note this serializes the Ptr values, not the Objects themselves. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
83 |
* |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
84 |
* \param checker The checker to use (currently not used.) |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
85 |
* \returns The string form of the Objects. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
86 |
*/ |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2950
diff
changeset
|
87 |
virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const; |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
88 |
/** |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
89 |
* Deserialize from a string. (Not implemented; raises a fatal error.) |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
90 |
* |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
91 |
* \param value The serialized string form. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
92 |
* \param checker The checker to use. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
93 |
* \returns \c true. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
94 |
*/ |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2950
diff
changeset
|
95 |
virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker); |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2950
diff
changeset
|
96 |
|
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
97 |
private: |
7412
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
98 |
friend class ObjectPtrContainerAccessor; |
11036
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
99 |
/** The container implementation. */ |
7884
963d5bfe9c52
Fixed bug 1352 (Object attribute map / vector issue)
Jaume Nin <jnin@cttc.cat>
parents:
7412
diff
changeset
|
100 |
std::map<uint32_t, Ptr<Object> > m_objects; |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
101 |
}; |
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
102 |
|
11036
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
103 |
/** |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
104 |
* \ingroup attribute_ObjectPtrContainer |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
105 |
* Create an AttributeAccessor using a container class indexed get method. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
106 |
* |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
107 |
* The two versions of this function differ only in argument order. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
108 |
* |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
109 |
* \tparam T The container class type. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
110 |
* \tparam U The type of object the get method returns. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
111 |
* \tparam INDEX The type of the index variable. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
112 |
* \param [in] get The class method to get a specific instance |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
113 |
* from the container. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
114 |
* \param [in] getN The class method to return the number of objects |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
115 |
* in the container. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
116 |
* \return The AttributeAccessor. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
117 |
*/ |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
118 |
template <typename T, typename U, typename INDEX> |
2436
23415bac7eaf
Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2435
diff
changeset
|
119 |
Ptr<const AttributeAccessor> |
7412
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
120 |
MakeObjectPtrContainerAccessor (Ptr<U> (T::*get)(INDEX) const, |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
121 |
INDEX (T::*getN)(void) const); |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
122 |
|
11036
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
123 |
/** |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
124 |
* \ingroup attribute_ObjectPtrContainer |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
125 |
* Create an AttributeAccessor using a container class indexed get method. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
126 |
* |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
127 |
* The two versions of this function differ only in argument order. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
128 |
* |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
129 |
* \tparam T The container class type. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
130 |
* \tparam U The type of object the get method returns. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
131 |
* \tparam INDEX The type of the index variable. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
132 |
* \param [in] get The class method to get a specific instance |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
133 |
* from the container. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
134 |
* \param [in] getN The class method to return the number of objects |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
135 |
* in the container. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
136 |
* \return The AttributeAccessor. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
137 |
*/ |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
138 |
template <typename T, typename U, typename INDEX> |
2436
23415bac7eaf
Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2435
diff
changeset
|
139 |
Ptr<const AttributeAccessor> |
7412
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
140 |
MakeObjectPtrContainerAccessor (INDEX (T::*getN)(void) const, |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
141 |
Ptr<U> (T::*get)(INDEX) const); |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
142 |
|
7412
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
143 |
class ObjectPtrContainerChecker : public AttributeChecker |
2933
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
144 |
{ |
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
145 |
public: |
11036
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
146 |
/** |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
147 |
* Get the TypeId of the container class type. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
148 |
* \returns The class TypeId. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
149 |
*/ |
2933
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
150 |
virtual TypeId GetItemTypeId (void) const = 0; |
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
151 |
}; |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
152 |
|
2933
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
153 |
template <typename T> |
7412
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
154 |
Ptr<const AttributeChecker> MakeObjectPtrContainerChecker (void); |
2427
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
155 |
|
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
156 |
} // namespace ns3 |
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
157 |
|
11036
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
158 |
|
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
159 |
/*************************************************************** |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
160 |
* The implementation of the above functions. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
161 |
***************************************************************/ |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
162 |
|
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
163 |
namespace ns3 { |
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
164 |
|
2933
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
165 |
namespace internal { |
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
166 |
|
11036
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
167 |
/** ObjectPtrContainerChecker implementation class. */ |
2933
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
168 |
template <typename T> |
11036
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
169 |
class ObjectPtrContainerChecker : public ns3::ObjectPtrContainerChecker |
2933
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
170 |
{ |
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
171 |
public: |
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
172 |
virtual TypeId GetItemTypeId (void) const { |
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
173 |
return T::GetTypeId (); |
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
174 |
} |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2950
diff
changeset
|
175 |
virtual bool Check (const AttributeValue &value) const { |
7412
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
176 |
return dynamic_cast<const ObjectPtrContainerValue *> (&value) != 0; |
2933
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
177 |
} |
2969
9d05d2a95dfa
improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2967
diff
changeset
|
178 |
virtual std::string GetValueTypeName (void) const { |
7412
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
179 |
return "ns3::ObjectPtrContainerValue"; |
2933
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
180 |
} |
2969
9d05d2a95dfa
improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2967
diff
changeset
|
181 |
virtual bool HasUnderlyingTypeInformation (void) const { |
2933
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
182 |
return true; |
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
183 |
} |
2969
9d05d2a95dfa
improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2967
diff
changeset
|
184 |
virtual std::string GetUnderlyingTypeInformation (void) const { |
2970
0384d6f6cca1
small tweak to generated dox
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2969
diff
changeset
|
185 |
return "ns3::Ptr< " + T::GetTypeId ().GetName () + " >"; |
2933
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
186 |
} |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2950
diff
changeset
|
187 |
virtual Ptr<AttributeValue> Create (void) const { |
7412
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
188 |
return ns3::Create<ObjectPtrContainerValue> (); |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2950
diff
changeset
|
189 |
} |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2950
diff
changeset
|
190 |
virtual bool Copy (const AttributeValue &source, AttributeValue &destination) const { |
7412
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
191 |
const ObjectPtrContainerValue *src = dynamic_cast<const ObjectPtrContainerValue *> (&source); |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
192 |
ObjectPtrContainerValue *dst = dynamic_cast<ObjectPtrContainerValue *> (&destination); |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2950
diff
changeset
|
193 |
if (src == 0 || dst == 0) |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2950
diff
changeset
|
194 |
{ |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
195 |
return false; |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2950
diff
changeset
|
196 |
} |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2950
diff
changeset
|
197 |
*dst = *src; |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
198 |
return true; |
2933
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
199 |
} |
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
200 |
}; |
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
201 |
|
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
202 |
} // namespace internal |
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
203 |
|
11036
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
204 |
|
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
205 |
/** |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
206 |
* \ingroup attribute_ObjectPtrContainer |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
207 |
* AttributeAccessor implementation for ObjectPtrContainerValue. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
208 |
*/ |
7412
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
209 |
class ObjectPtrContainerAccessor : public AttributeAccessor |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
210 |
{ |
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
211 |
public: |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2950
diff
changeset
|
212 |
virtual bool Set (ObjectBase * object, const AttributeValue &value) const; |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2950
diff
changeset
|
213 |
virtual bool Get (const ObjectBase * object, AttributeValue &value) const; |
2950
9e20fb862cd8
add AttributeAccessor::HasGetter/HasSetter and implement it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2947
diff
changeset
|
214 |
virtual bool HasGetter (void) const; |
9e20fb862cd8
add AttributeAccessor::HasGetter/HasSetter and implement it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2947
diff
changeset
|
215 |
virtual bool HasSetter (void) const; |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
216 |
private: |
11036
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
217 |
/** |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
218 |
* Get the number of instances in the container. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
219 |
* |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
220 |
* \param [in] object The container object. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
221 |
* \param [out] n The number of instances in the container. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
222 |
* \returns true if the value could be obtained successfully. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
223 |
*/ |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
224 |
virtual bool DoGetN (const ObjectBase *object, uint32_t *n) const = 0; |
11036
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
225 |
/** |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
226 |
* Get an instance from the container, identified by index. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
227 |
* |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
228 |
* \param [in] object The container object. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
229 |
* \param [in] i The desired instance index. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
230 |
* \param [out] index The index retrieved. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
231 |
* \returns The index requested. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
232 |
*/ |
7884
963d5bfe9c52
Fixed bug 1352 (Object attribute map / vector issue)
Jaume Nin <jnin@cttc.cat>
parents:
7412
diff
changeset
|
233 |
virtual Ptr<Object> DoGet (const ObjectBase *object, uint32_t i, uint32_t *index) const = 0; |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
234 |
}; |
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
235 |
|
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
236 |
template <typename T, typename U, typename INDEX> |
2436
23415bac7eaf
Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2435
diff
changeset
|
237 |
Ptr<const AttributeAccessor> |
7412
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
238 |
MakeObjectPtrContainerAccessor (Ptr<U> (T::*get)(INDEX) const, |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
239 |
INDEX (T::*getN)(void) const) |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
240 |
{ |
7412
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
241 |
struct MemberGetters : public ObjectPtrContainerAccessor |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
242 |
{ |
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
243 |
virtual bool DoGetN (const ObjectBase *object, uint32_t *n) const { |
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
244 |
const T *obj = dynamic_cast<const T *> (object); |
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
245 |
if (obj == 0) |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
246 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
247 |
return false; |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
248 |
} |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
249 |
*n = (obj->*m_getN)(); |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
250 |
return true; |
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
251 |
} |
7884
963d5bfe9c52
Fixed bug 1352 (Object attribute map / vector issue)
Jaume Nin <jnin@cttc.cat>
parents:
7412
diff
changeset
|
252 |
virtual Ptr<Object> DoGet (const ObjectBase *object, uint32_t i, uint32_t *index) const { |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
253 |
const T *obj = static_cast<const T *> (object); |
7884
963d5bfe9c52
Fixed bug 1352 (Object attribute map / vector issue)
Jaume Nin <jnin@cttc.cat>
parents:
7412
diff
changeset
|
254 |
*index = i; |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
255 |
return (obj->*m_get)(i); |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
256 |
} |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
257 |
Ptr<U> (T::*m_get)(INDEX) const; |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
258 |
INDEX (T::*m_getN)(void) const; |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
259 |
} *spec = new MemberGetters (); |
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
260 |
spec->m_get = get; |
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
261 |
spec->m_getN = getN; |
2436
23415bac7eaf
Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2435
diff
changeset
|
262 |
return Ptr<const AttributeAccessor> (spec, false); |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
263 |
} |
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
264 |
|
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
265 |
template <typename T, typename U, typename INDEX> |
2436
23415bac7eaf
Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2435
diff
changeset
|
266 |
Ptr<const AttributeAccessor> |
7412
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
267 |
MakeObjectPtrContainerAccessor (INDEX (T::*getN)(void) const, |
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
268 |
Ptr<U> (T::*get)(INDEX) const) |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
269 |
{ |
7412
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
270 |
return MakeObjectPtrContainerAccessor (get, getN); |
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
271 |
} |
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
272 |
|
2933
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
273 |
template <typename T> |
7412
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
274 |
Ptr<const AttributeChecker> MakeObjectPtrContainerChecker (void) |
2933
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
275 |
{ |
11036
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7884
diff
changeset
|
276 |
return Create<internal::ObjectPtrContainerChecker<T> > (); |
2933
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
277 |
} |
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
278 |
|
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2930
diff
changeset
|
279 |
|
2405
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
280 |
} // namespace ns3 |
17f406c71505
add ObjectVector value support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
281 |
|
7412
d79278c6e51c
refactor ObjectVector generic code into a separate file and introduce ObjectMap.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
282 |
#endif /* OBJECT_PTR_CONTAINER_H */ |