author | Peter D. Barnes, Jr. <barnes26@llnl.gov> |
Sun, 07 Dec 2014 22:08:04 -0800 | |
changeset 11096 | e57bfdb4f12c |
parent 11036 | 1e03af4311bd |
child 11194 | 46b6e53e8dbc |
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 |
#ifndef OBJECT_BASE_H |
5f7ad186b798
introduce ObjectBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
#define OBJECT_BASE_H |
5f7ad186b798
introduce ObjectBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
|
2633
a0639de8cd8b
split code from object.h/object.cc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
23 |
#include "type-id.h" |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
24 |
#include "callback.h" |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
25 |
#include <string> |
7399
520706f801e8
introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7252
diff
changeset
|
26 |
#include <list> |
2633
a0639de8cd8b
split code from object.h/object.cc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
27 |
|
a0639de8cd8b
split code from object.h/object.cc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
28 |
/** |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
29 |
* \file |
10651
065b4871c3e4
[doxygen] Stop warnings from NS_LOG_COMPONENT_DEFINE and NS_OBJECT_ENSURE_REGISTERED
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10410
diff
changeset
|
30 |
* \ingroup object |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
31 |
* ns3::ObjectBase class declaration and NS_OBJECT_ENSURE_REGISTERED() definition. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
32 |
*/ |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
33 |
|
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
34 |
/** |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
35 |
* \ingroup object |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
36 |
* \brief Register an Object subclass with the TypeId system. |
10405
45c8fceae24e
Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9971
diff
changeset
|
37 |
* |
2633
a0639de8cd8b
split code from object.h/object.cc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
38 |
* This macro should be invoked once for every class which |
a0639de8cd8b
split code from object.h/object.cc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
39 |
* defines a new GetTypeId method. |
10410
4d4eb8097fa3
doxygen] Suppress "warning: Member NS_OBJECT_ENSURE_REGISTERED is not documented"
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10405
diff
changeset
|
40 |
* |
4d4eb8097fa3
doxygen] Suppress "warning: Member NS_OBJECT_ENSURE_REGISTERED is not documented"
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10405
diff
changeset
|
41 |
* If the class is in a namespace, then the macro call should also be |
4d4eb8097fa3
doxygen] Suppress "warning: Member NS_OBJECT_ENSURE_REGISTERED is not documented"
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10405
diff
changeset
|
42 |
* in the namespace. |
2633
a0639de8cd8b
split code from object.h/object.cc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
43 |
*/ |
10999
771294355b2e
[Doxygen] Include the size of registered types in the long description for the class.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10651
diff
changeset
|
44 |
#define NS_OBJECT_ENSURE_REGISTERED(type) \ |
771294355b2e
[Doxygen] Include the size of registered types in the long description for the class.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10651
diff
changeset
|
45 |
static struct Object ## type ## RegistrationClass \ |
771294355b2e
[Doxygen] Include the size of registered types in the long description for the class.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10651
diff
changeset
|
46 |
{ \ |
771294355b2e
[Doxygen] Include the size of registered types in the long description for the class.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10651
diff
changeset
|
47 |
Object ## type ## RegistrationClass () { \ |
771294355b2e
[Doxygen] Include the size of registered types in the long description for the class.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10651
diff
changeset
|
48 |
ns3::TypeId tid = type::GetTypeId (); \ |
771294355b2e
[Doxygen] Include the size of registered types in the long description for the class.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10651
diff
changeset
|
49 |
tid.SetSize (sizeof (type)); \ |
771294355b2e
[Doxygen] Include the size of registered types in the long description for the class.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10651
diff
changeset
|
50 |
tid.GetParent (); \ |
771294355b2e
[Doxygen] Include the size of registered types in the long description for the class.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10651
diff
changeset
|
51 |
} \ |
771294355b2e
[Doxygen] Include the size of registered types in the long description for the class.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10651
diff
changeset
|
52 |
} Object ## type ## RegistrationVariable |
2633
a0639de8cd8b
split code from object.h/object.cc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
53 |
|
2370
5f7ad186b798
introduce ObjectBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
54 |
namespace ns3 { |
5f7ad186b798
introduce ObjectBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
55 |
|
7399
520706f801e8
introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7252
diff
changeset
|
56 |
class AttributeConstructionList; |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2719
diff
changeset
|
57 |
|
2370
5f7ad186b798
introduce ObjectBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
58 |
/** |
3182 | 59 |
* \ingroup object |
60 |
* |
|
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
61 |
* \brief Anchor the ns-3 type and attribute system. |
2719
6688934b493a
improve doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
62 |
* |
6688934b493a
improve doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
63 |
* Every class which wants to integrate in the ns-3 type and attribute |
6688934b493a
improve doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2718
diff
changeset
|
64 |
* system should derive from this base class. This base class provides: |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
65 |
* - A way to associate an ns3::TypeId to each object instance. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
66 |
* - A way to set and get the attributes registered in the ns3::TypeId. |
2370
5f7ad186b798
introduce ObjectBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
67 |
*/ |
5f7ad186b798
introduce ObjectBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
68 |
class ObjectBase |
5f7ad186b798
introduce ObjectBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
69 |
{ |
5f7ad186b798
introduce ObjectBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
70 |
public: |
9971
d31b6210afc8
[Doxygen] src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7570
diff
changeset
|
71 |
/** |
d31b6210afc8
[Doxygen] src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7570
diff
changeset
|
72 |
* Get the type ID. |
d31b6210afc8
[Doxygen] src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7570
diff
changeset
|
73 |
*/ |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
74 |
static TypeId GetTypeId (void); |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
75 |
|
9971
d31b6210afc8
[Doxygen] src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7570
diff
changeset
|
76 |
/** |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
77 |
* Virtual destructor. |
9971
d31b6210afc8
[Doxygen] src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7570
diff
changeset
|
78 |
*/ |
2370
5f7ad186b798
introduce ObjectBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
79 |
virtual ~ObjectBase (); |
2716
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2637
diff
changeset
|
80 |
|
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2637
diff
changeset
|
81 |
/** |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
82 |
* Get the most derived TypeId for this Object. |
2716
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2637
diff
changeset
|
83 |
* |
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2637
diff
changeset
|
84 |
* This method is typically implemented by ns3::Object::GetInstanceTypeId |
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2637
diff
changeset
|
85 |
* but some classes which derive from ns3::ObjectBase directly |
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2637
diff
changeset
|
86 |
* have to implement it themselves. |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
87 |
* |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
88 |
* \return The TypeId associated to the most-derived type |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
89 |
* of this instance. |
2716
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2637
diff
changeset
|
90 |
*/ |
2634
44a92f1d3728
introduce ObjectBase::GetInstanceTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2633
diff
changeset
|
91 |
virtual TypeId GetInstanceTypeId (void) const = 0; |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
92 |
|
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
93 |
/** |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
94 |
* |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
95 |
* Set a single attribute, raising fatal errors if unsuccessful. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
96 |
* |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
97 |
* This will either succeed at setting the attribute |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
98 |
* or it will raise NS_FATAL_ERROR() on these conditions: |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
99 |
* |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
100 |
* - The attribute doesn't exist in this Object. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
101 |
* - The attribute can't be set (no Setter). |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
102 |
* - The attribute couldn't be deserialized from the AttributeValue. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
103 |
* |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
104 |
* \param [in] name The name of the attribute to set. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
105 |
* \param [in] value The name of the attribute to set. |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
106 |
*/ |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2719
diff
changeset
|
107 |
void SetAttribute (std::string name, const AttributeValue &value); |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
108 |
/** |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
109 |
* Set a single attribute without raising errors. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
110 |
* |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
111 |
* If the atttribute could not be set this will return \c false, |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
112 |
* but not raise any errors. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
113 |
* |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
114 |
* \param [in] name The name of the attribute to set. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
115 |
* \param [in] value The value to set it to. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
116 |
* \return \c true if the requested attribute exists and could be set, |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
117 |
* \c false otherwise. |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
118 |
*/ |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2719
diff
changeset
|
119 |
bool SetAttributeFailSafe (std::string name, const AttributeValue &value); |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
120 |
/** |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
121 |
* Get the value of an attribute, raising fatal errors if unsuccessful. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
122 |
* |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
123 |
* This will either succeed at setting the attribute |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
124 |
* or it will raise NS_FATAL_ERROR() on these conditions: |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
125 |
* |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
126 |
* - The attribute doesn't exist in this Object. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
127 |
* - The attribute can't be read (no Getter). |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
128 |
* - The attribute doesn't support string formatting. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
129 |
* - The attribute couldn't be serialized into the AttributeValue. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
130 |
* |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
131 |
* \param [in] name The name of the attribute to read. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
132 |
* \param [out] value Where the result should be stored. |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
133 |
*/ |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2719
diff
changeset
|
134 |
void GetAttribute (std::string name, AttributeValue &value) const; |
2716
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2637
diff
changeset
|
135 |
/** |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
136 |
* Get the value of an attribute without raising erros. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
137 |
* |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
138 |
* If the atttribute could not be read this will return \c false, |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
139 |
* but not raise any errors. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
140 |
* |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
141 |
* \param [in] name The name of the attribute to read. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
142 |
* \param [out] value Where the result value should be stored. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
143 |
* \return \c true if the requested attribute was found, \c false otherwise. |
2716
2319c4bde708
use FailSafe postfix in a more rigorous way.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2637
diff
changeset
|
144 |
*/ |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
145 |
bool 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:
2637
diff
changeset
|
146 |
|
2718 | 147 |
/** |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
148 |
* Connect a TraceSource to a Callback with a context. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
149 |
* |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
150 |
* The target trace source should be registered with TypeId::AddTraceSource. |
2718 | 151 |
* |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
152 |
* \param name The name of the target trace source. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
153 |
* \param context The trace context associated to the callback. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
154 |
* \param cb The callback to connect to the trace source. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
155 |
* \returns \c true. |
2718 | 156 |
*/ |
157 |
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb); |
|
158 |
/** |
|
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
159 |
* Connect a TraceSource to a Callback without a context. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
160 |
* |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
161 |
* The target trace source should be registered with TypeId::AddTraceSource. |
2718 | 162 |
* |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
163 |
* \param name The name of the target trace source. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
164 |
* \param cb The callback to connect to the trace source. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
165 |
* \returns \c true. |
2718 | 166 |
*/ |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
167 |
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb); |
2718 | 168 |
/** |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
169 |
* Disconnect from a TraceSource a Callback previously connected |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
170 |
* with a context. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
171 |
* |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
172 |
* The target trace source should be registered with TypeId::AddTraceSource. |
2718 | 173 |
* |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
174 |
* \param name The name of the target trace source. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
175 |
* \param context The trace context associated to the callback. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
176 |
* \param cb The callback to disconnect from the trace source. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
177 |
* \returns \c true. |
2718 | 178 |
*/ |
179 |
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb); |
|
180 |
/** |
|
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
181 |
* Disconnect from a TraceSource a Callback previously connected |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
182 |
* without a context. |
2718 | 183 |
* |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
184 |
* The target trace source should be registered with TypeId::AddTraceSource. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
185 |
* |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
186 |
* \param name The name of the target trace source. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
187 |
* \param cb The callback to disconnect from the trace source. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
188 |
* \returns \c true. |
2718 | 189 |
*/ |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
190 |
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb); |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
191 |
|
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
192 |
protected: |
2718 | 193 |
/** |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
194 |
* Notifier called once the ObjectBase is fully constructucted. |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
195 |
* |
2718 | 196 |
* This method is invoked once all member attributes have been |
197 |
* initialized. Subclasses can override this method to be notified |
|
198 |
* of this event but if they do this, they must chain up to their |
|
199 |
* parent's NotifyConstructionCompleted method. |
|
200 |
*/ |
|
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
201 |
virtual void NotifyConstructionCompleted (void); |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
202 |
/** |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
203 |
* Complete construction of ObjectBase; invoked by derived classes. |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
204 |
* |
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
205 |
* Invoked from subclasses to initialize all of their |
2718 | 206 |
* attribute members. This method will typically be invoked |
207 |
* automatically from ns3::CreateObject if your class derives |
|
208 |
* from ns3::Object. If you derive from ns3::ObjectBase directly, |
|
209 |
* you should make sure that you invoke this method from |
|
210 |
* your most-derived constructor. |
|
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
211 |
* |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
212 |
* \param attributes The attribute values used to initialize |
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
213 |
* the member variables of this object's instance. |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
214 |
*/ |
7399
520706f801e8
introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7252
diff
changeset
|
215 |
void ConstructSelf (const AttributeConstructionList &attributes); |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
216 |
|
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
217 |
private: |
11036
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10999
diff
changeset
|
218 |
/** |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10999
diff
changeset
|
219 |
* Attempt to set the value referenced by the accessor \p spec |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10999
diff
changeset
|
220 |
* to a valid value according to the \c checker, based on \p value. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10999
diff
changeset
|
221 |
* |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10999
diff
changeset
|
222 |
* \param [in] spec The accessor for the storage location. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10999
diff
changeset
|
223 |
* \param [in] checker The checker to use in validating the value. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10999
diff
changeset
|
224 |
* \param [in] value The value to attempt to store. |
11096
e57bfdb4f12c
[Doxygen] Objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11036
diff
changeset
|
225 |
* \returns \c true if the \c value could be validated by the \p checker |
11036
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10999
diff
changeset
|
226 |
* and written to the storage location. |
1e03af4311bd
[Doxygen] Attribute implementations.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10999
diff
changeset
|
227 |
*/ |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2719
diff
changeset
|
228 |
bool DoSet (Ptr<const AttributeAccessor> spec, |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2719
diff
changeset
|
229 |
Ptr<const AttributeChecker> checker, |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2719
diff
changeset
|
230 |
const AttributeValue &value); |
2637
ac94e4889027
move attribute code to ObjectBase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
231 |
|
2370
5f7ad186b798
introduce ObjectBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
232 |
}; |
5f7ad186b798
introduce ObjectBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
233 |
|
5f7ad186b798
introduce ObjectBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
234 |
} // namespace ns3 |
5f7ad186b798
introduce ObjectBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
235 |
|
5f7ad186b798
introduce ObjectBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
236 |
#endif /* OBJECT_BASE_H */ |