author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Wed, 12 Mar 2008 09:31:50 -0700 | |
changeset 2595 | b504951bcca8 |
parent 2583 | c09faa6c90bf |
child 2599 | fcc1728eb669 |
permissions | -rw-r--r-- |
2581
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2550
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2550
diff
changeset
|
2 |
/* |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2550
diff
changeset
|
3 |
* Copyright (c) 2008 INRIA |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2550
diff
changeset
|
4 |
* |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2550
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2550
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2550
diff
changeset
|
7 |
* published by the Free Software Foundation; |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2550
diff
changeset
|
8 |
* |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2550
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2550
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2550
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2550
diff
changeset
|
12 |
* GNU General Public License for more details. |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2550
diff
changeset
|
13 |
* |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2550
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2550
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2550
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2550
diff
changeset
|
17 |
* |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2550
diff
changeset
|
18 |
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2550
diff
changeset
|
19 |
*/ |
2438
e2ac9f9aeeb9
value.h -> attribute.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2437
diff
changeset
|
20 |
#ifndef ATTRIBUTE_H |
e2ac9f9aeeb9
value.h -> attribute.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2437
diff
changeset
|
21 |
#define ATTRIBUTE_H |
2371
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
|
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
23 |
#include <string> |
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
#include <stdint.h> |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
25 |
#include "ptr.h" |
2371
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
26 |
#include "object-base.h" |
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
|
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
28 |
namespace ns3 { |
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
|
2436
23415bac7eaf
Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2435
diff
changeset
|
30 |
class AttributeAccessor; |
2427
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
31 |
class AttributeChecker; |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
32 |
class Attribute; |
2371
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
33 |
|
2583
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
34 |
/** |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
35 |
* \brief Hold a value for an Attribute. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
36 |
* |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
37 |
* Instances of this class are usually created by Attribute::Create<> and |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
38 |
* should always be wrapped into an Attribute object. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
39 |
* Most subclasses of this base class are implemented by the |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
40 |
* ATTRIBUTE_HELPER_* macros. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
41 |
*/ |
2437
44e34ffee8e3
Value -> AttributeValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
42 |
class AttributeValue |
2371
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
43 |
{ |
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
44 |
public: |
2437
44e34ffee8e3
Value -> AttributeValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
45 |
AttributeValue (); |
44e34ffee8e3
Value -> AttributeValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
46 |
AttributeValue (const AttributeValue &o); |
44e34ffee8e3
Value -> AttributeValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
47 |
AttributeValue &operator = (const AttributeValue &o); |
44e34ffee8e3
Value -> AttributeValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
48 |
virtual ~AttributeValue (); |
2371
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
49 |
|
2583
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
50 |
/** |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
51 |
* \returns a deep copy of this class, wrapped into an Attribute object. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
52 |
*/ |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
53 |
virtual Attribute Copy (void) const = 0; |
2583
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
54 |
/** |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
55 |
* \param checker the checker associated to the attribute |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
56 |
* \returns a string representation of this value. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
57 |
* |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
58 |
* In most cases, this method will not make any use of the checker argument. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
59 |
* However, in a very limited set of cases, the checker argument is needed to |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
60 |
* perform proper serialization. A nice example of code which needs it is |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
61 |
* the EnumValue::SerializeToString code. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
62 |
*/ |
2427
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
63 |
virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const = 0; |
2583
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
64 |
/** |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
65 |
* \param value a string representation of the value |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
66 |
* \param checker a pointer to the checker associated to the attribute. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
67 |
* \returns true if the input string was correctly-formatted and could be |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
68 |
* successfully deserialized, false otherwise. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
69 |
* |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
70 |
* Upon return of this function, this AttributeValue instance contains |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
71 |
* the deserialized value. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
72 |
* In most cases, this method will not make any use of the checker argument. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
73 |
* However, in a very limited set of cases, the checker argument is needed to |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
74 |
* perform proper serialization. A nice example of code which needs it is |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
75 |
* the EnumValue::SerializeToString code. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
76 |
*/ |
2427
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
77 |
virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker) = 0; |
2371
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
78 |
private: |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
79 |
friend class Attribute; |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
80 |
uint32_t m_count; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
81 |
}; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
82 |
|
2583
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
83 |
/** |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
84 |
* \brief an opaque wrapper around a value to set or retrieved |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
85 |
* from an attribute. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
86 |
* |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
87 |
* This class is really a smart pointer to an instance of AttributeValue. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
88 |
* Of course, the question is "why not use a Ptr<AttributeValue>" ?. The |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
89 |
* answer is long and complicated but the crux of the issue is that if we |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
90 |
* do not reproduce the smart pointer code in this class, we cannot provide |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
91 |
* transparent handling of Ptr<T> values through the attribute system. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
92 |
*/ |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
93 |
class Attribute |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
94 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
95 |
public: |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
96 |
Attribute (); |
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
97 |
Attribute (const Attribute &o); |
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
98 |
Attribute &operator = (const Attribute &o); |
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
99 |
~Attribute (); |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
100 |
|
2583
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
101 |
/** |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
102 |
* Forward to AttributeValue::Copy |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
103 |
*/ |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
104 |
Attribute Copy (void) const; |
2583
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
105 |
/** |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
106 |
* Forward to AttributeValue::SerializeToString |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
107 |
*/ |
2427
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
108 |
std::string SerializeToString (Ptr<const AttributeChecker> checker) const; |
2583
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
109 |
/** |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
110 |
* Forward to AttributeValue::DeserializeFromString |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
111 |
*/ |
2427
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
112 |
bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker); |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
113 |
|
2583
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
114 |
/** |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
115 |
* \returns a new Attribute object which wraps an instance of the requested |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
116 |
* subclass of AttributeValue. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
117 |
*/ |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
118 |
template <typename T> |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
119 |
static Attribute Create (void); |
2583
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
120 |
/** |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
121 |
* \param a1 a value to pass through to the constructor of the class T. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
122 |
* \returns a new Attribute object which wraps an instance of the requested |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
123 |
* subclass of AttributeValue. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
124 |
*/ |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
125 |
template <typename T, typename T1> |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
126 |
static Attribute Create (T1 a1); |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
127 |
|
2583
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
128 |
/** |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
129 |
* This method performs a dynamic_cast on the underlying AttributeValue. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
130 |
* This method is typically used to implement conversion operators |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
131 |
* from the type Attribute. In most cases, these conversion operators |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
132 |
* will be generated for you by the ATTRIBUTE_HELPER_* macros. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
133 |
* \returns the casted pointer. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
134 |
*/ |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
135 |
template <typename T> |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
136 |
T DynCast (void) const; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
137 |
|
2583
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
138 |
/** |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
139 |
* \param pointer a pointer to convert into an Attribute. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
140 |
*/ |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
141 |
template <typename T> |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
142 |
Attribute (Ptr<T> pointer); |
2583
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
143 |
/** |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
144 |
* \returns a pointer converted from this Attribute instance. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
145 |
*/ |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
146 |
template <typename T> |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
147 |
operator Ptr<T> (); |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
148 |
|
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
149 |
private: |
2437
44e34ffee8e3
Value -> AttributeValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
150 |
Attribute (AttributeValue *value); |
44e34ffee8e3
Value -> AttributeValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
151 |
AttributeValue *m_value; |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
152 |
}; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
153 |
|
2583
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
154 |
/** |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
155 |
* \brief allow setting and getting the value of an attribute. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
156 |
* |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
157 |
* The goal of this class is to hide from the user how an attribute |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
158 |
* is actually set or get to or from a class instance. Implementations |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
159 |
* of this base class are usually provided through the MakeAccessorHelper |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
160 |
* template functions, hidden behind an ATTRIBUTE_HELPER_* macro. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
161 |
*/ |
2436
23415bac7eaf
Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2435
diff
changeset
|
162 |
class AttributeAccessor : public ObjectBase |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
163 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
164 |
public: |
2436
23415bac7eaf
Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2435
diff
changeset
|
165 |
AttributeAccessor (); |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
166 |
void Ref (void) const; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
167 |
void Unref (void) const; |
2436
23415bac7eaf
Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2435
diff
changeset
|
168 |
virtual ~AttributeAccessor (); |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
169 |
|
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
170 |
/** |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
171 |
* \param object the object instance to set the value in |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
172 |
* \param value the value to set |
2583
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
173 |
* \returns true if the value could be set successfully, false otherwise. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
174 |
* |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
175 |
* This method expects that the caller has checked that the input value is |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
176 |
* valid with AttributeChecker::Check. |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
177 |
*/ |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
178 |
virtual bool Set (ObjectBase * object, Attribute value) const = 0; |
2583
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
179 |
/** |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
180 |
* \param object the object instance to get the value from |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
181 |
* \param attribute a pointer to where the value should be set. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
182 |
* \returns true if the value could be read successfully, and |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
183 |
* stored in the input value, false otherwise. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
184 |
* |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
185 |
* This method expects that the caller has checked that the input value is |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
186 |
* valid with AttributeChecker::Check. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
187 |
*/ |
2595
b504951bcca8
fix doxygen errors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2583
diff
changeset
|
188 |
virtual bool Get (const ObjectBase * object, Attribute attribute) const = 0; |
2427
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
189 |
private: |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
190 |
mutable uint32_t m_count; |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
191 |
}; |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
192 |
|
2583
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
193 |
/** |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
194 |
* \brief Represent the type of an attribute |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
195 |
* |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
196 |
* Each type of attribute has an associated unique AttributeChecker |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
197 |
* subclass. The type of the subclass can be safely used by users |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
198 |
* to infer the type of the associated attribute. i.e., we expect |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
199 |
* binding authors to use the checker associated to an attribute |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
200 |
* to detect the type of the associated attribute. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
201 |
* |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
202 |
* Most subclasses of this base class are implemented by the |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
203 |
* ATTRIBUTE_HELPER_* macros. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
204 |
*/ |
2427
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
205 |
class AttributeChecker : public ObjectBase |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
206 |
{ |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
207 |
public: |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
208 |
AttributeChecker (); |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
209 |
void Ref (void) const; |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
210 |
void Unref (void) const; |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
211 |
virtual ~AttributeChecker (); |
2583
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
212 |
/** |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
213 |
* \param value a pointer to the value to check |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
214 |
* \returns true if the input value is both of the right type |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
215 |
* and if its value is within the requested range. Returns |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
216 |
* false otherwise. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
217 |
*/ |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
218 |
virtual bool Check (Attribute value) const = 0; |
2583
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
219 |
/** |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
220 |
* \returns a new instance of an AttributeValue (wrapper in an Attribute |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
221 |
* instance) which matches the type of the underlying attribute. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
222 |
* |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
223 |
* This method is typically used to create a temporary variable prior |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
224 |
* to calling Attribute::DeserializeFromString. |
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2581
diff
changeset
|
225 |
*/ |
2520
a4896ebf6e1d
introduce AttributeChecker::Create and use it instead of AttributeValue::Copy.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2506
diff
changeset
|
226 |
virtual Attribute Create (void) const = 0; |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
227 |
private: |
2371
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
228 |
mutable uint32_t m_count; |
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
229 |
}; |
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
230 |
|
2473
24e929fe7d4c
add a base arg to MakeSimpleAttributeChecker
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2438
diff
changeset
|
231 |
template <typename T, typename BASE> |
2427
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
232 |
Ptr<AttributeChecker> |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
233 |
MakeSimpleAttributeChecker (void); |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
234 |
|
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
235 |
template <typename T, typename U> |
2436
23415bac7eaf
Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2435
diff
changeset
|
236 |
Ptr<const AttributeAccessor> |
2435
3128175f5866
ParamSpec -> Accessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2433
diff
changeset
|
237 |
MakePtrAccessor (Ptr<U> T::*memberVariable); |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
238 |
|
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
239 |
template <typename T, typename U> |
2436
23415bac7eaf
Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2435
diff
changeset
|
240 |
Ptr<const AttributeAccessor> |
2435
3128175f5866
ParamSpec -> Accessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2433
diff
changeset
|
241 |
MakePtrAccessor (void (T::*setter) (Ptr<U>)); |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
242 |
template <typename T, typename U> |
2436
23415bac7eaf
Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2435
diff
changeset
|
243 |
Ptr<const AttributeAccessor> |
2435
3128175f5866
ParamSpec -> Accessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2433
diff
changeset
|
244 |
MakePtrAccessor (Ptr<U> (T::*getter) (void) const); |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
245 |
|
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
246 |
|
2473
24e929fe7d4c
add a base arg to MakeSimpleAttributeChecker
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2438
diff
changeset
|
247 |
class PtrChecker : public AttributeChecker {}; |
24e929fe7d4c
add a base arg to MakeSimpleAttributeChecker
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2438
diff
changeset
|
248 |
|
24e929fe7d4c
add a base arg to MakeSimpleAttributeChecker
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2438
diff
changeset
|
249 |
template <typename T> |
24e929fe7d4c
add a base arg to MakeSimpleAttributeChecker
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2438
diff
changeset
|
250 |
Ptr<AttributeChecker> MakePtrChecker (void); |
24e929fe7d4c
add a base arg to MakeSimpleAttributeChecker
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2438
diff
changeset
|
251 |
|
24e929fe7d4c
add a base arg to MakeSimpleAttributeChecker
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2438
diff
changeset
|
252 |
|
24e929fe7d4c
add a base arg to MakeSimpleAttributeChecker
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2438
diff
changeset
|
253 |
|
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
254 |
} // namespace ns3 |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
255 |
|
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
256 |
namespace ns3 { |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
257 |
|
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
258 |
/******************************************************** |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
259 |
* The class used to access the pointer stored in a |
2437
44e34ffee8e3
Value -> AttributeValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
260 |
* PtrValue<T> AttributeValue instance. |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
261 |
********************************************************/ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
262 |
|
2437
44e34ffee8e3
Value -> AttributeValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
263 |
class PtrValueBase : public AttributeValue |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
264 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
265 |
public: |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
266 |
virtual ObjectBase *PeekObjectBase (void) const = 0; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
267 |
virtual bool SetObjectBase (ObjectBase *object) = 0; |
2427
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
268 |
virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const; |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
269 |
virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker); |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
270 |
}; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
271 |
|
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
272 |
/******************************************************** |
2437
44e34ffee8e3
Value -> AttributeValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
273 |
* Store the content of a Ptr<T> in a AttributeValue |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
274 |
********************************************************/ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
275 |
|
2505
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
276 |
namespace internal { |
2496
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
277 |
|
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
278 |
template <typename T> |
2505
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
279 |
class PtrValue : public PtrValueBase |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
280 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
281 |
public: |
2520
a4896ebf6e1d
introduce AttributeChecker::Create and use it instead of AttributeValue::Copy.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2506
diff
changeset
|
282 |
PtrValue () |
a4896ebf6e1d
introduce AttributeChecker::Create and use it instead of AttributeValue::Copy.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2506
diff
changeset
|
283 |
: m_pointer () {} |
2505
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
284 |
PtrValue (Ptr<T> pointer) |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
285 |
: m_pointer (pointer) {} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
286 |
|
2505
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
287 |
virtual ObjectBase *PeekObjectBase (void) const { |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
288 |
return PeekPointer (m_pointer); |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
289 |
} |
2505
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
290 |
virtual bool SetObjectBase (ObjectBase *object) { |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
291 |
T *ptr = dynamic_cast<T *> (object); |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
292 |
if (ptr == 0) |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
293 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
294 |
return false; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
295 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
296 |
m_pointer = ptr; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
297 |
return true; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
298 |
} |
2505
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
299 |
virtual Attribute Copy (void) const { |
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
300 |
return Attribute::Create<PtrValue<T> > (*this); |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
301 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
302 |
private: |
2505
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
303 |
Ptr<T> m_pointer; |
2496
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
304 |
}; |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
305 |
|
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
306 |
template <typename T> |
2505
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
307 |
class APtrChecker : public PtrChecker |
2496
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
308 |
{ |
2505
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
309 |
virtual bool Check (Attribute val) const { |
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
310 |
const PtrValueBase *value = val.DynCast<const PtrValueBase *> (); |
2496
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
311 |
if (value == 0) |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
312 |
{ |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
313 |
return false; |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
314 |
} |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
315 |
if (value->PeekObjectBase () == 0) |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
316 |
{ |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
317 |
return true; |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
318 |
} |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
319 |
T *ptr = dynamic_cast<T*> (value->PeekObjectBase ()); |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
320 |
if (ptr == 0) |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
321 |
{ |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
322 |
return false; |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
323 |
} |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
324 |
return true; |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
325 |
} |
2520
a4896ebf6e1d
introduce AttributeChecker::Create and use it instead of AttributeValue::Copy.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2506
diff
changeset
|
326 |
virtual Attribute Create (void) const { |
a4896ebf6e1d
introduce AttributeChecker::Create and use it instead of AttributeValue::Copy.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2506
diff
changeset
|
327 |
return Attribute::Create<PtrValue<T> > (); |
a4896ebf6e1d
introduce AttributeChecker::Create and use it instead of AttributeValue::Copy.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2506
diff
changeset
|
328 |
} |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
329 |
}; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
330 |
|
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
331 |
/******************************************************** |
2496
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
332 |
* The Accessor associated to |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
333 |
* PtrValue<T> |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
334 |
********************************************************/ |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
335 |
|
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
336 |
template <typename T, typename U> |
2505
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
337 |
class PtrAccessor : public AttributeAccessor |
2496
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
338 |
{ |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
339 |
public: |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
340 |
virtual ~PtrAccessor () {} |
2505
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
341 |
virtual bool Set (ObjectBase * object, Attribute val) const { |
2496
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
342 |
T *obj = dynamic_cast<T *> (object); |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
343 |
if (obj == 0) |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
344 |
{ |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
345 |
return false; |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
346 |
} |
2505
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
347 |
const PtrValueBase *value = val.DynCast<const PtrValueBase *> (); |
2496
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
348 |
if (value == 0) |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
349 |
{ |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
350 |
return false; |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
351 |
} |
2505
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
352 |
Ptr<U> ptr = dynamic_cast<U*> (value->PeekObjectBase ()); |
2496
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
353 |
if (ptr == 0) |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
354 |
{ |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
355 |
return false; |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
356 |
} |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
357 |
DoSet (obj, ptr); |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
358 |
return true; |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
359 |
} |
2505
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
360 |
virtual bool Get (const ObjectBase * object, Attribute val) const { |
2496
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
361 |
const T *obj = dynamic_cast<const T *> (object); |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
362 |
if (obj == 0) |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
363 |
{ |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
364 |
return false; |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
365 |
} |
2505
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
366 |
PtrValueBase *value = val.DynCast<PtrValueBase *> (); |
2496
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
367 |
if (value == 0) |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
368 |
{ |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
369 |
return false; |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
370 |
} |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
371 |
return value->SetObjectBase (PeekPointer (DoGet (obj))); |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
372 |
} |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
373 |
private: |
2505
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
374 |
virtual void DoSet (T *object, Ptr<U> value) const = 0; |
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
375 |
virtual Ptr<U> DoGet (const T *object) const = 0; |
2496
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
376 |
}; |
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
377 |
|
2505
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
378 |
} // namespace internal |
2496
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
379 |
|
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
380 |
/******************************************************** |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
381 |
* The implementation of the Attribute |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
382 |
* class template methods. |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
383 |
********************************************************/ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
384 |
|
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
385 |
template <typename T> |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
386 |
Attribute |
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
387 |
Attribute::Create (void) |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
388 |
{ |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
389 |
return Attribute (new T ()); |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
390 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
391 |
template <typename T, typename T1> |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
392 |
Attribute |
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
393 |
Attribute::Create (T1 a1) |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
394 |
{ |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
395 |
return Attribute (new T (a1)); |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
396 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
397 |
|
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
398 |
template <typename T> |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
399 |
T |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
400 |
Attribute::DynCast (void) const |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
401 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
402 |
return dynamic_cast<T> (m_value); |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
403 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
404 |
|
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
405 |
template <typename T> |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
406 |
Attribute::Attribute (Ptr<T> pointer) |
2505
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
407 |
: m_value (new internal::PtrValue<T> (pointer)) |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
408 |
{} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
409 |
template <typename T> |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
410 |
Attribute::operator Ptr<T> () |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
411 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
412 |
PtrValueBase *value = DynCast<PtrValueBase *> (); |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
413 |
if (value == 0) |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
414 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
415 |
return 0; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
416 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
417 |
ObjectBase *objectBase = value->PeekObjectBase (); |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
418 |
T *obj = dynamic_cast<T *> (objectBase); |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
419 |
if (obj == 0) |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
420 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
421 |
return 0; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
422 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
423 |
return obj; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
424 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
425 |
|
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
426 |
|
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
427 |
|
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
428 |
template <typename T, typename U> |
2436
23415bac7eaf
Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2435
diff
changeset
|
429 |
Ptr<const AttributeAccessor> |
2435
3128175f5866
ParamSpec -> Accessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2433
diff
changeset
|
430 |
MakePtrAccessor (Ptr<U> T::*memberVariable) |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
431 |
{ |
2505
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
432 |
struct MemberVariable : public internal::PtrAccessor<T,U> |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
433 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
434 |
Ptr<U> T::*m_memberVariable; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
435 |
virtual void DoSet (T *object, Ptr<U> value) const { |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
436 |
(object->*m_memberVariable) = value; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
437 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
438 |
virtual Ptr<U> DoGet (const T *object) const { |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
439 |
return object->*m_memberVariable; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
440 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
441 |
} *spec = new MemberVariable (); |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
442 |
spec->m_memberVariable = memberVariable; |
2436
23415bac7eaf
Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2435
diff
changeset
|
443 |
return Ptr<const AttributeAccessor> (spec, false); |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
444 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
445 |
|
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
446 |
template <typename T, typename U> |
2436
23415bac7eaf
Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2435
diff
changeset
|
447 |
Ptr<const AttributeAccessor> |
2435
3128175f5866
ParamSpec -> Accessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2433
diff
changeset
|
448 |
MakePtrAccessor (void (T::*setter) (Ptr<U>)) |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
449 |
{ |
2505
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
450 |
struct MemberMethod : public internal::PtrAccessor<T,U> |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
451 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
452 |
void (T::*m_setter) (Ptr<U>); |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
453 |
virtual void DoSet (T *object, Ptr<U> value) const { |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
454 |
(object->*m_setter) (value); |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
455 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
456 |
virtual Ptr<U> DoGet (const T *object) const { |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
457 |
return 0; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
458 |
//return (object->*m_getter) (); |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
459 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
460 |
} *spec = new MemberMethod (); |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
461 |
spec->m_setter = setter; |
2436
23415bac7eaf
Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2435
diff
changeset
|
462 |
return Ptr<const AttributeAccessor> (spec, false); |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
463 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
464 |
|
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
465 |
template <typename T, typename U> |
2436
23415bac7eaf
Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2435
diff
changeset
|
466 |
Ptr<const AttributeAccessor> |
2435
3128175f5866
ParamSpec -> Accessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2433
diff
changeset
|
467 |
MakePtrAccessor (Ptr<U> (T::*getter) (void) const) |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
468 |
{ |
2505
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
469 |
struct MemberMethod : public internal::PtrAccessor<T,U> |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
470 |
{ |
2550
ab5aaa022458
typo is code unused until then.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2520
diff
changeset
|
471 |
Ptr<U> (T::*m_getter) (void) const; |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
472 |
virtual void DoSet (T *object, Ptr<U> value) const { |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
473 |
//(object->*m_setter) (value); |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
474 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
475 |
virtual Ptr<U> DoGet (const T *object) const { |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
476 |
return (object->*m_getter) (); |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
477 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
478 |
} *spec = new MemberMethod (); |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
479 |
spec->m_getter = getter; |
2436
23415bac7eaf
Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2435
diff
changeset
|
480 |
return Ptr<const AttributeAccessor> (spec, false); |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
481 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
482 |
|
2496
e91c92db28c0
re-organize the code to avoid link-time errors due to duplicate symbols.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2473
diff
changeset
|
483 |
|
2427
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
484 |
template <typename T> |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
485 |
Ptr<AttributeChecker> |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
486 |
MakePtrChecker (void) |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
487 |
{ |
2505
984b364e3111
do not use anonymous namespace in header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
488 |
return Create<internal::APtrChecker<T> > (); |
2427
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
489 |
} |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
490 |
|
2473
24e929fe7d4c
add a base arg to MakeSimpleAttributeChecker
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2438
diff
changeset
|
491 |
template <typename T, typename BASE> |
2427
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
492 |
Ptr<AttributeChecker> |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
493 |
MakeSimpleAttributeChecker (void) |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
494 |
{ |
2473
24e929fe7d4c
add a base arg to MakeSimpleAttributeChecker
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2438
diff
changeset
|
495 |
struct SimpleAttributeChecker : public BASE |
2427
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
496 |
{ |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
497 |
virtual bool Check (Attribute value) const { |
2427
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
498 |
return value.DynCast<const T *> () != 0; |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
499 |
} |
2520
a4896ebf6e1d
introduce AttributeChecker::Create and use it instead of AttributeValue::Copy.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2506
diff
changeset
|
500 |
virtual Attribute Create (void) const { |
a4896ebf6e1d
introduce AttributeChecker::Create and use it instead of AttributeValue::Copy.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2506
diff
changeset
|
501 |
return Attribute::Create<T> (); |
a4896ebf6e1d
introduce AttributeChecker::Create and use it instead of AttributeValue::Copy.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2506
diff
changeset
|
502 |
} |
2427
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
503 |
} *checker = new SimpleAttributeChecker (); |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
504 |
return Ptr<AttributeChecker> (checker, false); |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
505 |
} |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
506 |
|
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2424
diff
changeset
|
507 |
|
2371
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
508 |
} // namespace ns3 |
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
509 |
|
2438
e2ac9f9aeeb9
value.h -> attribute.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2437
diff
changeset
|
510 |
#endif /* ATTRIBUTE_H */ |