author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Sun, 09 Mar 2008 21:07:14 +0100 | |
changeset 2570 | 15d5421022a1 |
parent 2502 | 50d0da37f02f |
child 2581 | 31d4960dc31b |
permissions | -rw-r--r-- |
2438
e2ac9f9aeeb9
value.h -> attribute.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2437
diff
changeset
|
1 |
#include "attribute.h" |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
2 |
#include "log.h" |
2397
45cd59c6ddf8
add automatic conversion from string to PValue.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2374
diff
changeset
|
3 |
#include "fatal-error.h" |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
4 |
#include <sstream> |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
5 |
|
2437
44e34ffee8e3
Value -> AttributeValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
6 |
NS_LOG_COMPONENT_DEFINE ("AttributeValue"); |
2371
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
|
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
namespace ns3 { |
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
|
2437
44e34ffee8e3
Value -> AttributeValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
10 |
AttributeValue::AttributeValue () |
2371
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
: m_count (1) |
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
{} |
2437
44e34ffee8e3
Value -> AttributeValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
13 |
AttributeValue::AttributeValue (const AttributeValue &o) |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
14 |
: m_count (1) |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
15 |
{} |
2437
44e34ffee8e3
Value -> AttributeValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
16 |
AttributeValue & |
44e34ffee8e3
Value -> AttributeValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
17 |
AttributeValue::operator = (const AttributeValue &o) |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
18 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
19 |
return *this; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
20 |
} |
2437
44e34ffee8e3
Value -> AttributeValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
21 |
AttributeValue::~AttributeValue () |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
22 |
{} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
23 |
|
2406
c54440da3228
add big warning
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2397
diff
changeset
|
24 |
/*************************************************************** |
c54440da3228
add big warning
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2397
diff
changeset
|
25 |
* Big interesting warning. |
c54440da3228
add big warning
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2397
diff
changeset
|
26 |
* ------------------------ |
c54440da3228
add big warning
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2397
diff
changeset
|
27 |
* |
c54440da3228
add big warning
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2397
diff
changeset
|
28 |
* One might wonder why we re-implement a smart pointer below |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
29 |
* in the Attribute class. This is a very good question and the answer |
2406
c54440da3228
add big warning
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2397
diff
changeset
|
30 |
* is unfortunately pretty complicated. |
c54440da3228
add big warning
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2397
diff
changeset
|
31 |
* |
2437
44e34ffee8e3
Value -> AttributeValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
32 |
* 1) We could have requested the user to use Ptr<AttributeValue> and save us |
2406
c54440da3228
add big warning
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2397
diff
changeset
|
33 |
* a lot of pain. This, however, does not work because our smart |
c54440da3228
add big warning
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2397
diff
changeset
|
34 |
* pointer needs a special constructor which can be used to convert |
c54440da3228
add big warning
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2397
diff
changeset
|
35 |
* objects of type Ptr<T> into a PtrValue<T> to hold the pointer. |
c54440da3228
add big warning
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2397
diff
changeset
|
36 |
* |
2437
44e34ffee8e3
Value -> AttributeValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
37 |
* 2) We could have made the m_value member variable below a Ptr<AttributeValue> |
2406
c54440da3228
add big warning
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2397
diff
changeset
|
38 |
* rather than store a raw pointer. This, however, does not work |
2437
44e34ffee8e3
Value -> AttributeValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
39 |
* because this would mean that the constructor Attribute (AttributeValue *) |
44e34ffee8e3
Value -> AttributeValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
40 |
* should be morphed into Attribute (Ptr<AttributeValue>) which, unfortunately, |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
41 |
* would conflict with the template constructor Attribute (Ptr<T>)... |
2406
c54440da3228
add big warning
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2397
diff
changeset
|
42 |
* |
c54440da3228
add big warning
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2397
diff
changeset
|
43 |
* This is definitely not fun. |
c54440da3228
add big warning
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2397
diff
changeset
|
44 |
*/ |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
45 |
Attribute::Attribute () |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
46 |
: m_value (0) |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
47 |
{} |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
48 |
Attribute::Attribute (const Attribute &o) |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
49 |
: m_value (o.m_value) |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
50 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
51 |
if (m_value != 0) |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
52 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
53 |
m_value->m_count++; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
54 |
NS_LOG_DEBUG ("this="<<m_value<<" ++count="<<m_value->m_count); |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
55 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
56 |
} |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
57 |
Attribute & |
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
58 |
Attribute::operator = (const Attribute &o) |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
59 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
60 |
if (&o != this) |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
61 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
62 |
if (m_value != 0) |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
63 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
64 |
m_value->m_count--; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
65 |
NS_LOG_DEBUG ("this="<<m_value<<" --count="<<m_value->m_count); |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
66 |
if (m_value->m_count == 0) |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
67 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
68 |
delete m_value; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
69 |
m_value = 0; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
70 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
71 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
72 |
m_value = o.m_value; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
73 |
if (m_value != 0) |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
74 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
75 |
m_value->m_count++; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
76 |
NS_LOG_DEBUG ("this="<<m_value<<" ++count="<<m_value->m_count); |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
77 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
78 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
79 |
return *this; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
80 |
} |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
81 |
Attribute::~Attribute () |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
82 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
83 |
if (m_value != 0) |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
84 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
85 |
m_value->m_count--; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
86 |
NS_LOG_DEBUG ("this="<<m_value<<" --count="<<m_value->m_count); |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
87 |
if (m_value->m_count == 0) |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
88 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
89 |
delete m_value; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
90 |
m_value = 0; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
91 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
92 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
93 |
} |
2437
44e34ffee8e3
Value -> AttributeValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
94 |
Attribute::Attribute (AttributeValue *value) |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
95 |
: m_value (value) |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
96 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
97 |
NS_LOG_DEBUG ("this="<<m_value<<" count="<<((m_value!=0)?m_value->m_count:666)); |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
98 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
99 |
|
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
100 |
Attribute |
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
101 |
Attribute::Copy (void) const |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
102 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
103 |
return m_value->Copy (); |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
104 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
105 |
std::string |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
106 |
Attribute::SerializeToString (Ptr<const AttributeChecker> checker) const |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
107 |
{ |
2427
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2421
diff
changeset
|
108 |
return m_value->SerializeToString (checker); |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
109 |
} |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
110 |
bool |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
111 |
Attribute::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
|
112 |
{ |
2427
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2421
diff
changeset
|
113 |
return m_value->DeserializeFromString (value, checker); |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
114 |
} |
2397
45cd59c6ddf8
add automatic conversion from string to PValue.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2374
diff
changeset
|
115 |
|
2436
23415bac7eaf
Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2435
diff
changeset
|
116 |
AttributeAccessor::AttributeAccessor () |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
117 |
: m_count (1) |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
118 |
{} |
2371
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
119 |
void |
2436
23415bac7eaf
Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2435
diff
changeset
|
120 |
AttributeAccessor::Ref (void) const |
2371
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
121 |
{ |
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
122 |
m_count++; |
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
123 |
} |
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
124 |
void |
2436
23415bac7eaf
Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2435
diff
changeset
|
125 |
AttributeAccessor::Unref (void) const |
2371
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
126 |
{ |
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
127 |
m_count--; |
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
128 |
if (m_count == 0) |
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
129 |
{ |
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
130 |
delete this; |
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
131 |
} |
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
132 |
} |
2436
23415bac7eaf
Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2435
diff
changeset
|
133 |
AttributeAccessor::~AttributeAccessor () |
2371
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
134 |
{} |
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
135 |
|
2427
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2421
diff
changeset
|
136 |
AttributeChecker::AttributeChecker () |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2421
diff
changeset
|
137 |
: m_count (1) |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2421
diff
changeset
|
138 |
{} |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2421
diff
changeset
|
139 |
void |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2421
diff
changeset
|
140 |
AttributeChecker::Ref (void) const |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2421
diff
changeset
|
141 |
{ |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2421
diff
changeset
|
142 |
m_count++; |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2421
diff
changeset
|
143 |
} |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2421
diff
changeset
|
144 |
void |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2421
diff
changeset
|
145 |
AttributeChecker::Unref (void) const |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2421
diff
changeset
|
146 |
{ |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2421
diff
changeset
|
147 |
m_count--; |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2421
diff
changeset
|
148 |
if (m_count == 0) |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2421
diff
changeset
|
149 |
{ |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2421
diff
changeset
|
150 |
delete this; |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2421
diff
changeset
|
151 |
} |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2421
diff
changeset
|
152 |
} |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2421
diff
changeset
|
153 |
AttributeChecker::~AttributeChecker () |
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2421
diff
changeset
|
154 |
{} |
2397
45cd59c6ddf8
add automatic conversion from string to PValue.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2374
diff
changeset
|
155 |
|
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
156 |
std::string |
2427
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2421
diff
changeset
|
157 |
PtrValueBase::SerializeToString (Ptr<const AttributeChecker> checker) const |
2374
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
158 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
159 |
std::ostringstream oss; |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
160 |
oss << PeekObjectBase (); |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
161 |
return oss.str (); |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
162 |
} |
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 |
bool |
2427
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2421
diff
changeset
|
165 |
PtrValueBase::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
|
166 |
{ |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
167 |
// XXX |
570f3c6c6142
make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2371
diff
changeset
|
168 |
return false; |
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 |
|
2371
2118204a86e6
initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
171 |
} // namespace ns3 |