author | Mitch Watrous <watrous@u.washington.edu> |
Tue, 29 Apr 2014 22:38:13 +0200 | |
changeset 10710 | 1c733dcc50b2 |
parent 10652 | dc18deba4502 |
child 10968 | 2d29fee2b7b8 |
permissions | -rw-r--r-- |
2718 | 1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2008 INRIA |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License version 2 as |
|
7 |
* published by the Free Software Foundation; |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 |
* |
|
18 |
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
|
19 |
*/ |
|
2370
5f7ad186b798
introduce ObjectBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
#include "object-base.h" |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
21 |
#include "log.h" |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
22 |
#include "trace-source-accessor.h" |
7399
520706f801e8
introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7393
diff
changeset
|
23 |
#include "attribute-construction-list.h" |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
24 |
#include "string.h" |
4216
621e2ef9e7b8
add support for NS_ATTRIBUTE_DEFAULT
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2965
diff
changeset
|
25 |
#include "ns3/core-config.h" |
621e2ef9e7b8
add support for NS_ATTRIBUTE_DEFAULT
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2965
diff
changeset
|
26 |
#ifdef HAVE_STDLIB_H |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7399
diff
changeset
|
27 |
#include <cstdlib> |
4216
621e2ef9e7b8
add support for NS_ATTRIBUTE_DEFAULT
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2965
diff
changeset
|
28 |
#endif |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
29 |
|
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
30 |
NS_LOG_COMPONENT_DEFINE ("ObjectBase"); |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
31 |
|
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
32 |
namespace ns3 { |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
33 |
|
10652
dc18deba4502
[doxygen] Revert r10410, r10411, r10412
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10410
diff
changeset
|
34 |
NS_OBJECT_ENSURE_REGISTERED (ObjectBase); |
6393
f7e1f9dfa08d
ensure objects are regsitered
Josh Pelkey <jpelkey@gatech.edu>
parents:
4216
diff
changeset
|
35 |
|
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
36 |
static TypeId |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
37 |
GetObjectIid (void) |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
38 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
39 |
NS_LOG_FUNCTION_NOARGS (); |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
40 |
TypeId tid = TypeId ("ns3::ObjectBase"); |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
41 |
tid.SetParent (tid); |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
42 |
return tid; |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
43 |
} |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
44 |
|
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
45 |
TypeId |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
46 |
ObjectBase::GetTypeId (void) |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
47 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
48 |
NS_LOG_FUNCTION_NOARGS (); |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
49 |
static TypeId tid = GetObjectIid (); |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
50 |
return tid; |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
51 |
} |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
52 |
|
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
53 |
ObjectBase::~ObjectBase () |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
54 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
55 |
NS_LOG_FUNCTION (this); |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
56 |
} |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
57 |
|
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
58 |
void |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
59 |
ObjectBase::NotifyConstructionCompleted (void) |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
60 |
{ |
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
61 |
NS_LOG_FUNCTION (this); |
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
62 |
} |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
63 |
|
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
64 |
void |
7399
520706f801e8
introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7393
diff
changeset
|
65 |
ObjectBase::ConstructSelf (const AttributeConstructionList &attributes) |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
66 |
{ |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
67 |
// loop over the inheritance tree back to the Object base class. |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
68 |
NS_LOG_FUNCTION (this << &attributes); |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
69 |
TypeId tid = GetInstanceTypeId (); |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
70 |
do { |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
71 |
// loop over all attributes in object type |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
72 |
NS_LOG_DEBUG ("construct tid="<<tid.GetName ()<<", params="<<tid.GetAttributeN ()); |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
73 |
for (uint32_t i = 0; i < tid.GetAttributeN (); i++) |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
74 |
{ |
7392 | 75 |
struct TypeId::AttributeInformation info = tid.GetAttribute(i); |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
76 |
NS_LOG_DEBUG ("try to construct \""<< tid.GetName ()<<"::"<< |
7392 | 77 |
info.name <<"\""); |
10710
1c733dcc50b2
Bug 1717 - Detect unsettable attributes
Mitch Watrous <watrous@u.washington.edu>
parents:
10652
diff
changeset
|
78 |
// is this attribute stored in this AttributeConstructionList instance ? |
1c733dcc50b2
Bug 1717 - Detect unsettable attributes
Mitch Watrous <watrous@u.washington.edu>
parents:
10652
diff
changeset
|
79 |
Ptr<AttributeValue> value = attributes.Find(info.checker); |
1c733dcc50b2
Bug 1717 - Detect unsettable attributes
Mitch Watrous <watrous@u.washington.edu>
parents:
10652
diff
changeset
|
80 |
// See if this attribute should not be set here in the |
1c733dcc50b2
Bug 1717 - Detect unsettable attributes
Mitch Watrous <watrous@u.washington.edu>
parents:
10652
diff
changeset
|
81 |
// constructor. |
7392 | 82 |
if (!(info.flags & TypeId::ATTR_CONSTRUCT)) |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
83 |
{ |
10710
1c733dcc50b2
Bug 1717 - Detect unsettable attributes
Mitch Watrous <watrous@u.washington.edu>
parents:
10652
diff
changeset
|
84 |
// Handle this attribute if it should not be |
1c733dcc50b2
Bug 1717 - Detect unsettable attributes
Mitch Watrous <watrous@u.washington.edu>
parents:
10652
diff
changeset
|
85 |
// set here. |
1c733dcc50b2
Bug 1717 - Detect unsettable attributes
Mitch Watrous <watrous@u.washington.edu>
parents:
10652
diff
changeset
|
86 |
if (value == 0) |
1c733dcc50b2
Bug 1717 - Detect unsettable attributes
Mitch Watrous <watrous@u.washington.edu>
parents:
10652
diff
changeset
|
87 |
{ |
1c733dcc50b2
Bug 1717 - Detect unsettable attributes
Mitch Watrous <watrous@u.washington.edu>
parents:
10652
diff
changeset
|
88 |
// Skip this attribute if it's not in the |
1c733dcc50b2
Bug 1717 - Detect unsettable attributes
Mitch Watrous <watrous@u.washington.edu>
parents:
10652
diff
changeset
|
89 |
// AttributeConstructionList. |
1c733dcc50b2
Bug 1717 - Detect unsettable attributes
Mitch Watrous <watrous@u.washington.edu>
parents:
10652
diff
changeset
|
90 |
continue; |
1c733dcc50b2
Bug 1717 - Detect unsettable attributes
Mitch Watrous <watrous@u.washington.edu>
parents:
10652
diff
changeset
|
91 |
} |
1c733dcc50b2
Bug 1717 - Detect unsettable attributes
Mitch Watrous <watrous@u.washington.edu>
parents:
10652
diff
changeset
|
92 |
else |
1c733dcc50b2
Bug 1717 - Detect unsettable attributes
Mitch Watrous <watrous@u.washington.edu>
parents:
10652
diff
changeset
|
93 |
{ |
1c733dcc50b2
Bug 1717 - Detect unsettable attributes
Mitch Watrous <watrous@u.washington.edu>
parents:
10652
diff
changeset
|
94 |
// This is an error because this attribute is not |
1c733dcc50b2
Bug 1717 - Detect unsettable attributes
Mitch Watrous <watrous@u.washington.edu>
parents:
10652
diff
changeset
|
95 |
// settable in its constructor but is present in |
1c733dcc50b2
Bug 1717 - Detect unsettable attributes
Mitch Watrous <watrous@u.washington.edu>
parents:
10652
diff
changeset
|
96 |
// the AttributeConstructionList. |
1c733dcc50b2
Bug 1717 - Detect unsettable attributes
Mitch Watrous <watrous@u.washington.edu>
parents:
10652
diff
changeset
|
97 |
NS_FATAL_ERROR ("Attribute name="<<info.name<<" tid="<<tid.GetName () << ": initial value cannot be set using attributes"); |
1c733dcc50b2
Bug 1717 - Detect unsettable attributes
Mitch Watrous <watrous@u.washington.edu>
parents:
10652
diff
changeset
|
98 |
} |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
99 |
} |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
100 |
bool found = false; |
7399
520706f801e8
introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7393
diff
changeset
|
101 |
if (value != 0) |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
102 |
{ |
7399
520706f801e8
introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7393
diff
changeset
|
103 |
// We have a matching attribute value. |
520706f801e8
introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7393
diff
changeset
|
104 |
if (DoSet (info.accessor, info.checker, *value)) |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
105 |
{ |
7399
520706f801e8
introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7393
diff
changeset
|
106 |
NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<< |
520706f801e8
introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7393
diff
changeset
|
107 |
info.name<<"\""); |
520706f801e8
introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7393
diff
changeset
|
108 |
found = true; |
520706f801e8
introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7393
diff
changeset
|
109 |
continue; |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
110 |
} |
7399
520706f801e8
introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7393
diff
changeset
|
111 |
} |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
112 |
if (!found) |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
113 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
114 |
// No matching attribute value so we try to look at the env var. |
4216
621e2ef9e7b8
add support for NS_ATTRIBUTE_DEFAULT
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2965
diff
changeset
|
115 |
#ifdef HAVE_GETENV |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
116 |
char *envVar = getenv ("NS_ATTRIBUTE_DEFAULT"); |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
117 |
if (envVar != 0) |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
118 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
119 |
std::string env = std::string (envVar); |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
120 |
std::string::size_type cur = 0; |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
121 |
std::string::size_type next = 0; |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
122 |
while (next != std::string::npos) |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
123 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
124 |
next = env.find (";", cur); |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
125 |
std::string tmp = std::string (env, cur, next-cur); |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
126 |
std::string::size_type equal = tmp.find ("="); |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
127 |
if (equal != std::string::npos) |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
128 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
129 |
std::string name = tmp.substr (0, equal); |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
130 |
std::string value = tmp.substr (equal+1, tmp.size () - equal - 1); |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
131 |
if (name == tid.GetAttributeFullName (i)) |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
132 |
{ |
7392 | 133 |
if (DoSet (info.accessor, info.checker, StringValue (value))) |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
134 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
135 |
NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<< |
7392 | 136 |
info.name <<"\" from env var"); |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
137 |
found = true; |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
138 |
break; |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
139 |
} |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
140 |
} |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
141 |
} |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
142 |
cur = next + 1; |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
143 |
} |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
144 |
} |
4216
621e2ef9e7b8
add support for NS_ATTRIBUTE_DEFAULT
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2965
diff
changeset
|
145 |
#endif /* HAVE_GETENV */ |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
146 |
} |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
147 |
if (!found) |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
148 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
149 |
// No matching attribute value so we try to set the default value. |
7392 | 150 |
DoSet (info.accessor, info.checker, *info.initialValue); |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
151 |
NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<< |
7392 | 152 |
info.name <<"\" from initial value."); |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
153 |
} |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
154 |
} |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
155 |
tid = tid.GetParent (); |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
156 |
} while (tid != ObjectBase::GetTypeId ()); |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
157 |
NotifyConstructionCompleted (); |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
158 |
} |
2370
5f7ad186b798
introduce ObjectBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
159 |
|
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
160 |
bool |
7393
8c3dfe0be54d
use new API. kill old one.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7392
diff
changeset
|
161 |
ObjectBase::DoSet (Ptr<const AttributeAccessor> accessor, |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
162 |
Ptr<const AttributeChecker> checker, |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
163 |
const AttributeValue &value) |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
164 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
165 |
NS_LOG_FUNCTION (this << accessor << checker << &value); |
7399
520706f801e8
introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7393
diff
changeset
|
166 |
Ptr<AttributeValue> v = checker->CreateValidValue (value); |
520706f801e8
introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7393
diff
changeset
|
167 |
if (v == 0) |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
168 |
{ |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
169 |
return false; |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
170 |
} |
7399
520706f801e8
introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7393
diff
changeset
|
171 |
bool ok = accessor->Set (this, *v); |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
172 |
return ok; |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
173 |
} |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
174 |
|
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
175 |
void |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
176 |
ObjectBase::SetAttribute (std::string name, const AttributeValue &value) |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
177 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
178 |
NS_LOG_FUNCTION (this << name << &value); |
7393
8c3dfe0be54d
use new API. kill old one.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7392
diff
changeset
|
179 |
struct TypeId::AttributeInformation info; |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
180 |
TypeId tid = GetInstanceTypeId (); |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
181 |
if (!tid.LookupAttributeByName (name, &info)) |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
182 |
{ |
2716
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
183 |
NS_FATAL_ERROR ("Attribute name="<<name<<" does not exist for this object: tid="<<tid.GetName ()); |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
184 |
} |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
185 |
if (!(info.flags & TypeId::ATTR_SET) || |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
186 |
!info.accessor->HasSetter ()) |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
187 |
{ |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
188 |
NS_FATAL_ERROR ("Attribute name="<<name<<" is not settable for this object: tid="<<tid.GetName ()); |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
189 |
} |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
190 |
if (!DoSet (info.accessor, info.checker, value)) |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
191 |
{ |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
192 |
NS_FATAL_ERROR ("Attribute name="<<name<<" could not be set for this object: tid="<<tid.GetName ()); |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
193 |
} |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
194 |
} |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
195 |
bool |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
196 |
ObjectBase::SetAttributeFailSafe (std::string name, const AttributeValue &value) |
2716
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
197 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
198 |
NS_LOG_FUNCTION (this << name << &value); |
7393
8c3dfe0be54d
use new API. kill old one.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7392
diff
changeset
|
199 |
struct TypeId::AttributeInformation info; |
2716
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
200 |
TypeId tid = GetInstanceTypeId (); |
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
201 |
if (!tid.LookupAttributeByName (name, &info)) |
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
202 |
{ |
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
203 |
return false; |
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
204 |
} |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
205 |
if (!(info.flags & TypeId::ATTR_SET) || |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
206 |
!info.accessor->HasSetter ()) |
2716
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
207 |
{ |
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
208 |
return false; |
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
209 |
} |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
210 |
return DoSet (info.accessor, info.checker, value); |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
211 |
} |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
212 |
|
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
213 |
void |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
214 |
ObjectBase::GetAttribute (std::string name, AttributeValue &value) const |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
215 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
216 |
NS_LOG_FUNCTION (this << name << &value); |
7393
8c3dfe0be54d
use new API. kill old one.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7392
diff
changeset
|
217 |
struct TypeId::AttributeInformation info; |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
218 |
TypeId tid = GetInstanceTypeId (); |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
219 |
if (!tid.LookupAttributeByName (name, &info)) |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
220 |
{ |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
221 |
NS_FATAL_ERROR ("Attribute name="<<name<<" does not exist for this object: tid="<<tid.GetName ()); |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
222 |
} |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
223 |
if (!(info.flags & TypeId::ATTR_GET) || |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
224 |
!info.accessor->HasGetter ()) |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
225 |
{ |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
226 |
NS_FATAL_ERROR ("Attribute name="<<name<<" is not gettable for this object: tid="<<tid.GetName ()); |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
227 |
} |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
228 |
bool ok = info.accessor->Get (this, value); |
2716
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
229 |
if (ok) |
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
230 |
{ |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
231 |
return; |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
232 |
} |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
233 |
StringValue *str = dynamic_cast<StringValue *> (&value); |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
234 |
if (str == 0) |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
235 |
{ |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
236 |
NS_FATAL_ERROR ("Attribute name="<<name<<" tid="<<tid.GetName () << ": input value is not a string"); |
2716
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
237 |
} |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
238 |
Ptr<AttributeValue> v = info.checker->Create (); |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
239 |
ok = info.accessor->Get (this, *PeekPointer (v)); |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
240 |
if (!ok) |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
241 |
{ |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
242 |
NS_FATAL_ERROR ("Attribute name="<<name<<" tid="<<tid.GetName () << ": could not get value"); |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
243 |
} |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
244 |
str->Set (v->SerializeToString (info.checker)); |
2716
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
245 |
} |
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
246 |
|
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
247 |
|
2716
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
248 |
bool |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
249 |
ObjectBase::GetAttributeFailSafe (std::string name, AttributeValue &value) const |
2716
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
250 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
251 |
NS_LOG_FUNCTION (this << name << &value); |
7393
8c3dfe0be54d
use new API. kill old one.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7392
diff
changeset
|
252 |
struct TypeId::AttributeInformation info; |
2716
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
253 |
TypeId tid = GetInstanceTypeId (); |
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
254 |
if (!tid.LookupAttributeByName (name, &info)) |
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
255 |
{ |
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
256 |
return false; |
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
257 |
} |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
258 |
if (!(info.flags & TypeId::ATTR_GET) || |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
259 |
!info.accessor->HasGetter ()) |
2716
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
260 |
{ |
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
261 |
return false; |
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
262 |
} |
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
263 |
bool ok = info.accessor->Get (this, value); |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
264 |
if (ok) |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
265 |
{ |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
266 |
return true; |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
267 |
} |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
268 |
StringValue *str = dynamic_cast<StringValue *> (&value); |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
269 |
if (str == 0) |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
270 |
{ |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
271 |
return false; |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
272 |
} |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
273 |
Ptr<AttributeValue> v = info.checker->Create (); |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
274 |
ok = info.accessor->Get (this, *PeekPointer (v)); |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
275 |
if (!ok) |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
276 |
{ |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
277 |
return false; |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
278 |
} |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
279 |
str->Set (v->SerializeToString (info.checker)); |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
280 |
return true; |
2716
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
281 |
} |
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
282 |
|
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
283 |
bool |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
284 |
ObjectBase::TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
285 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
286 |
NS_LOG_FUNCTION (this << name << &cb); |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
287 |
TypeId tid = GetInstanceTypeId (); |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
288 |
Ptr<const TraceSourceAccessor> accessor = tid.LookupTraceSourceByName (name); |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
289 |
if (accessor == 0) |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
290 |
{ |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
291 |
return false; |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
292 |
} |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
293 |
bool ok = accessor->ConnectWithoutContext (this, cb); |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
294 |
return ok; |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
295 |
} |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
296 |
bool |
2718 | 297 |
ObjectBase::TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
298 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
299 |
NS_LOG_FUNCTION (this << name << context << &cb); |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
300 |
TypeId tid = GetInstanceTypeId (); |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
301 |
Ptr<const TraceSourceAccessor> accessor = tid.LookupTraceSourceByName (name); |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
302 |
if (accessor == 0) |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
303 |
{ |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
304 |
return false; |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
305 |
} |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
306 |
bool ok = accessor->Connect (this, context, cb); |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
307 |
return ok; |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
308 |
} |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
309 |
bool |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
310 |
ObjectBase::TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
311 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
312 |
NS_LOG_FUNCTION (this << name << &cb); |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
313 |
TypeId tid = GetInstanceTypeId (); |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
314 |
Ptr<const TraceSourceAccessor> accessor = tid.LookupTraceSourceByName (name); |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
315 |
if (accessor == 0) |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
316 |
{ |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
317 |
return false; |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
318 |
} |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
319 |
bool ok = accessor->DisconnectWithoutContext (this, cb); |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
320 |
return ok; |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
321 |
} |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
322 |
bool |
2718 | 323 |
ObjectBase::TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
324 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
325 |
NS_LOG_FUNCTION (this << name << context << &cb); |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
326 |
TypeId tid = GetInstanceTypeId (); |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
327 |
Ptr<const TraceSourceAccessor> accessor = tid.LookupTraceSourceByName (name); |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
328 |
if (accessor == 0) |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
329 |
{ |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
330 |
return false; |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
331 |
} |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
332 |
bool ok = accessor->Disconnect (this, context, cb); |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
333 |
return ok; |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
334 |
} |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
335 |
|
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
336 |
|
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
337 |
|
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
338 |
} // namespace ns3 |