merge with HEAD
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Mon, 21 Apr 2008 09:04:08 -0700
changeset 2989b7eb3929096c
parent 2988 8774a8c9526f
parent 2974 30ed185e0364
child 2990 69ddc1c42130
child 2991 9a3ed582d153
merge with HEAD
doc/tracing.h
src/applications/onoff/onoff-application.cc
src/applications/udp-echo/udp-echo-client.cc
src/applications/udp-echo/udp-echo-server.cc
src/common/error-model.cc
src/devices/csma/csma-channel.cc
src/devices/csma/csma-net-device.cc
src/devices/point-to-point/point-to-point-channel.cc
src/devices/point-to-point/point-to-point-net-device.cc
src/devices/wifi/dca-txop.cc
src/devices/wifi/ideal-wifi-manager.cc
src/devices/wifi/nqap-wifi-mac.cc
src/devices/wifi/nqsta-wifi-mac.cc
src/devices/wifi/wifi-phy.cc
src/internet-node/ipv4-interface.cc
src/internet-node/ipv4-l3-protocol.cc
src/internet-node/tcp-l4-protocol.cc
src/internet-node/tcp-socket.cc
src/mobility/random-direction-2d-mobility-model.cc
src/node/drop-tail-queue.cc
src/node/node-list.cc
src/node/queue.cc
src/simulator/simulator.cc
utils/print-introspected-doxygen.cc
     1.1 --- a/doc/doxygen.conf	Mon Apr 21 08:58:23 2008 -0700
     1.2 +++ b/doc/doxygen.conf	Mon Apr 21 09:04:08 2008 -0700
     1.3 @@ -496,7 +496,6 @@
     1.4  INPUT                  = doc/modules \
     1.5                           doc/main.h \
     1.6                           doc/introspected-doxygen.h \
     1.7 -                         doc/tracing.h \ 
     1.8                           doc/howtos/ \ 
     1.9                           src
    1.10  
    1.11 @@ -1047,13 +1046,13 @@
    1.12  # compilation will be performed. Macro expansion can be done in a controlled 
    1.13  # way by setting EXPAND_ONLY_PREDEF to YES.
    1.14  
    1.15 -MACRO_EXPANSION        = NO
    1.16 +MACRO_EXPANSION        = YES
    1.17  
    1.18  # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
    1.19  # then the macro expansion is limited to the macros specified with the 
    1.20  # PREDEFINED and EXPAND_AS_DEFINED tags.
    1.21  
    1.22 -EXPAND_ONLY_PREDEF     = NO
    1.23 +EXPAND_ONLY_PREDEF     = YES
    1.24  
    1.25  # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
    1.26  # in the INCLUDE_PATH (see below) will be search if a #include is found.
    1.27 @@ -1090,7 +1089,9 @@
    1.28  # The macro definition that is found in the sources will be used. 
    1.29  # Use the PREDEFINED tag if you want to use a different macro definition.
    1.30  
    1.31 -EXPAND_AS_DEFINED      = 
    1.32 +EXPAND_AS_DEFINED      = ATTRIBUTE_VALUE_DEFINE \
    1.33 +		       ATTRIBUTE_VALUE_DEFINE_WITH_NAME \
    1.34 +		       ATTRIBUTE_HELPER_HEADER_2
    1.35  
    1.36  # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
    1.37  # doxygen's preprocessor will remove all function-like macros that are alone 
     2.1 --- a/doc/modules	Mon Apr 21 08:58:23 2008 -0700
     2.2 +++ b/doc/modules	Mon Apr 21 09:04:08 2008 -0700
     2.3 @@ -15,12 +15,13 @@
     2.4   *    - a class to register regression tests with the test manager: ns3::Test and ns3::TestManager
     2.5   *    - debugging facilities: \ref logging, \ref assert, \ref error
     2.6   *    - \ref randomvariable
     2.7 + *    - a base class for objects which need to support per-instance "attributes" and
     2.8 + *      trace sources: ns3::ObjectBase
     2.9   *    - a base class for objects which need to support reference counting
    2.10 - *      and QueryInterface: ns3::Object and ns3::InterfaceId 
    2.11 - *    - a set of low-level trace facilities integrated in the ns3::Object system: \ref tracing
    2.12 - *    - a ns3::ComponentManager which can be used to manage the creation
    2.13 - *      of any object which derives from ns3::Object through an ns3::ClassId 
    2.14 + *      and dynamic object aggregation: ns3::Object
    2.15   *    - a smart-pointer class ns3::Ptr designed to work together with ns3::Object
    2.16 + *    - a configuration class used to set and control all attributes and trace sources
    2.17 + *      in a simulation: ns3::Config.
    2.18   *
    2.19   * @defgroup common Common
    2.20   * The "core" module contains: 
    2.21 @@ -61,5 +62,4 @@
    2.22   * @brief Constants you can change
    2.23   *
    2.24   * @defgroup contrib Contrib
    2.25 - */
    2.26 -
    2.27 + */
    2.28 \ No newline at end of file
     3.1 --- a/doc/tracing.h	Mon Apr 21 08:58:23 2008 -0700
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,584 +0,0 @@
     3.4 -/**
     3.5 - * \ingroup core
     3.6 - * \defgroup TraceSourceList List of trace sources
     3.7 - */
     3.8 -
     3.9 -/**
    3.10 - * \ingroup core
    3.11 - * \defgroup tracing Tracing
    3.12 - *
    3.13 - * The flexibility of the ns-3 tracing system comes at the cost of quite
    3.14 - * a bit of complexity so, before trying to use the low-level aspects
    3.15 - * of the tracing API, it is important to focus on some basic definitions:
    3.16 - *
    3.17 - * - A trace source is an object instance which can report trace events
    3.18 - *   to a set of listening trace sinks.
    3.19 - *
    3.20 - * - A trace sink is a user-provided callback (a function) which can
    3.21 - *   be connected to a set of trace sources to receive the events generated
    3.22 - *   by each trace source.
    3.23 - *
    3.24 - * - A trace resolver is an object which allows users to establish 
    3.25 - *   connections between a set of trace sources and a set of trace sinks.
    3.26 - *
    3.27 - * \section TraceSource Generating Trace Events
    3.28 - *
    3.29 - * So, what does it look like in practice ? First, let's look at trace
    3.30 - * sources. We have two types of trace sources: numeric, and, normal 
    3.31 - * trace sources. Numeric trace sources behave as normal c++ integers 
    3.32 - * or c++ floating point numbers except that they report as trace events 
    3.33 - * each change of their value. For example:
    3.34 - * \code
    3.35 - * class MyModel 
    3.36 - * {
    3.37 - * public:
    3.38 - *   void DoSomething (void) 
    3.39 - *   {
    3.40 - *     // use the "int" trace source just 
    3.41 - *     // like any other "int" variable.
    3.42 - *     m_cwnd *= 2;
    3.43 - *     m_cwnd += 4;
    3.44 - *     if (m_cwnd > 100)
    3.45 - *       {
    3.46 - *         // do something.
    3.47 - *       }
    3.48 - *   }
    3.49 - * private:
    3.50 - *   // declare an instance of a "int" trace source
    3.51 - *   SVTraceSource<int> m_cwnd;
    3.52 - * };
    3.53 - * \endcode
    3.54 - * Normal trace sources, on the other hand, allow you to trace the
    3.55 - * call of arbitrary functions and methods, as shown below. They are
    3.56 - * typically used to track "rx", "tx", or "drop" events but could
    3.57 - * also be used to track route change events, or position change
    3.58 - * events:
    3.59 - * \code
    3.60 - * class MyModel 
    3.61 - * {
    3.62 - * public:
    3.63 - *   void DoSomething (Ptr<Packet> packet) 
    3.64 - *   {
    3.65 - *     // report this event on packet
    3.66 - *     m_doSomething (packet);
    3.67 - *     // do something
    3.68 - *   }
    3.69 - * private:
    3.70 - *   // report every "something" function call.
    3.71 - *   CallbackTraceSource<Ptr<Packet> > m_doSomething;
    3.72 - * };
    3.73 - * \endcode
    3.74 - * Every type of trace source derives from the ns3::TraceSource base class.
    3.75 - * As of today, the set of concrete subclasses is relatively short:
    3.76 - * ns3::CallbackTraceSource, ns3::SvTraceSource, ns3::UvTraceSource, and,
    3.77 - * ns3::FvTraceSource.
    3.78 - *
    3.79 - * \section TraceSink Receiving Trace Events
    3.80 - *
    3.81 - * To receive these trace events, a user should specify a set of trace sinks.
    3.82 - * For example, to receive the "int" and the "something" events shown in the
    3.83 - * examples above, a user would declare the following functions:
    3.84 - * \code
    3.85 - * // oldValue and newValue contain the previous and new values of 
    3.86 - * // the connected SVTraceSource<int> trace source.
    3.87 - * void 
    3.88 - * CwndTraceSink (const TraceContext &context, int64_t oldValue, int64_t newValue)
    3.89 - * {
    3.90 - *   // for example, print the new value:
    3.91 - *   std::cout << "cwnd=" << newValue << std::endl;
    3.92 - * }
    3.93 - * void 
    3.94 - * DoSomethingTraceSink (const TraceContext &context, Ptr<Packet> packet)
    3.95 - * {
    3.96 - *   // for example, print the packet
    3.97 - *   std::cout << "packet " << packet->Print () << std::endl;
    3.98 - * }
    3.99 - * \endcode
   3.100 - * Each of these sink function takes, as a first argument, a reference to a 
   3.101 - * const TraceContext object. This context object contains information which
   3.102 - * describes the instance of the connected trace source: that information is
   3.103 - * setup during the connection process and does not change afterwards
   3.104 - * The type and the number of the other arguments to each trace sink depends
   3.105 - * on the type of the connected trace source: it conveys per-event information
   3.106 - * from the trace source to the trace sink. For example, UVTraceSource and 
   3.107 - * SVTraceSource trace sources require two extra arguments. The former requires
   3.108 - * two unsigned 64 bit integers while the latter requires two signed 64 bit 
   3.109 - * integers. More generally, users can consult the \ref TraceSourceList
   3.110 - * to figure out the arguments which a trace sink is required to receive
   3.111 - * for each trace source: a signature of the user trace sink must match 
   3.112 - * _exactly_ the signature documented in the \ref TraceSourceList.
   3.113 - *
   3.114 - *
   3.115 - * \section TraceSourceSimpleExport A simple way to connect Trace Sources with Trace Sinks
   3.116 - *
   3.117 - * The crux of the complexity of the ns-3 tracing system comes from its 
   3.118 - * flexible system used to connect trace sources to trace sinks but what is really
   3.119 - * nice about it is that it is not necessary to use it to setup simple traces.
   3.120 - * 
   3.121 - * The simplest way to export a set of trace sources to a user, for example, 
   3.122 - * during the early prototyping phases of a system, is to add a set of public methods
   3.123 - * to give to your users access to the trace source object instances you use to generate
   3.124 - * trace events:
   3.125 - * \code
   3.126 - * class MyModel 
   3.127 - * {
   3.128 - * public:
   3.129 - *   void DoSomething (Ptr<Packet> packet) 
   3.130 - *   {
   3.131 - *     // report this event on packet
   3.132 - *     m_doSomething (packet);
   3.133 - *     // do something
   3.134 - *   }
   3.135 - *   CallbackTraceSource<Ptr<Packet>> *PeekSomethingTraceSource (void) const 
   3.136 - *   {
   3.137 - *     return &m_doSomething
   3.138 - *   }
   3.139 - * private:
   3.140 - *   // report every "something" function call.
   3.141 - *   CallbackTraceSource<Ptr<Packet>> m_doSomething;
   3.142 - * };
   3.143 - * \endcode
   3.144 - * If your users hold a pointer to an instance of MyModel, and if they want to connect
   3.145 - * a MySomethingSink, they can simply do the following which invokes the 
   3.146 - * TraceSource::AddCallback method and creates a Callback object from the user's
   3.147 - * sink with the MakeCallback function.
   3.148 - * \code
   3.149 - * void 
   3.150 - * MySomethingSink (const TraceContext &context, Ptr<Packet> packet)
   3.151 - * {
   3.152 - *   // do whatever you want.
   3.153 - * }
   3.154 - * MyModel *model = ...;
   3.155 - * CallbackTraceSource<Ptr<Packet>> *source = model->PeekSomethingTraceSource ();
   3.156 - * source->AddCallback (MakeCallback (&MySomethingSink));
   3.157 - * \endcode
   3.158 - *
   3.159 - * The full power of the tracing system comes however from its ns3::NodeList::Connect
   3.160 - * method which is described in the following sections.
   3.161 - *
   3.162 - * \section TraceConnection Connecting Trace Sources to Trace Sinks
   3.163 - * 
   3.164 - * If a trace source is integrated in the ns-3 trace connection facility, a user 
   3.165 - * should call the ns3::NodeList::ConnectWithoutContext method to establish a connection between
   3.166 - * a trace sink and a set of matching trace sources. The second argument to that
   3.167 - * method is a callback to the user's trace sink.
   3.168 - * That callback is easy to construct: call ns3::MakeCallback and you are done. The
   3.169 - * first argument is a string whose format is similar to a unix path and which is 
   3.170 - * used to uniquely identify the set of trace sources you want to connect to.
   3.171 - * The set of acceptable path strings is also documented in the \ref TraceSourceList.
   3.172 - *
   3.173 - * So, what does this look like from the perspective of a user ? If we wanted to 
   3.174 - * connect to a trace source defined somewhere deep into the a set of NetDevice objects
   3.175 - * located in some nodes of the system, we could write the following:
   3.176 - * \code
   3.177 - * void 
   3.178 - * DoSomethingTraceSink (const TraceContext &context, Ptr<Packet> packet)
   3.179 - * {
   3.180 - *   // for example, print the packet
   3.181 - *   std::cout << "packet: " << packet->Print () << std::endl;
   3.182 - * }
   3.183 - * // connect the above sink to a matching trace source
   3.184 - * NodeList::ConnectWithoutContext ("/nodes/* /devices/* /rx", MakeCallback (&DoSomethingTraceSink));
   3.185 - * \endcode
   3.186 - *
   3.187 - * The connection path string "/nodes/* /devices/* /rx" matches the "rx" trace source
   3.188 - * located in every netdevice located in every node. The syntax of that path string
   3.189 - * is loosely based on regular expressions so, a user could conceivably connect
   3.190 - * to the trace sources present in only one node identified by node index:
   3.191 - * "/nodex/3/devices/* /rx".
   3.192 - *
   3.193 - * The matching algorithm used here is very useful since it allows you to connect
   3.194 - * at once a large set of trace sources to a single sink but it introduces another 
   3.195 - * problem: it becomes impossible when you receive an event in your trace sink to
   3.196 - * know from _which_ trace source the event is coming from. In our example, the
   3.197 - * trace source might be coming from the NetDevice number 2 of Node 10 or Netdevice
   3.198 - * number 0 of Node 5. In both cases, you might need to know which of these NetDevice
   3.199 - * is generating this event, if only to generate some ascii trace dump. Another 
   3.200 - * similar use-case is that you might have connected the same trace sink to
   3.201 - * multiple types of events which have the same signature: it is quite common
   3.202 - * to receive all tx, rx, and drop events in the same trace sink and that would be
   3.203 - * quite trivial to achieve with a string such as: "/nodes/* /devices/* /*"
   3.204 - *
   3.205 - * The source of a trace event can be retrieved from a trace sink using 
   3.206 - * different means: the simplest
   3.207 - * way to get this information is to use the builtin printing facility of
   3.208 - * the TraceContext object:
   3.209 - * \code
   3.210 - * void 
   3.211 - * DoSomethingTraceSink (const TraceContext &context, Ptr<Packet> packet)
   3.212 - * {
   3.213 - *   // for example, print the packet
   3.214 - *   std::cout << "context=\"" << context << "\" packet: " << packet->Print () << std::endl;
   3.215 - * }
   3.216 - * \endcode
   3.217 - * The above code is going to generate output which looks like the following:
   3.218 - * \code
   3.219 - * context="nodeid=2 device=0 dev-rx" packet: IPV4(tos 0x0 ttl 64 id 0 offset ...
   3.220 - * context="nodeid=1 device=0 dev-rx" packet: IPV4(tos 0x0 ttl 64 id 0 offset ...
   3.221 - * ...
   3.222 - * \endcode
   3.223 - *
   3.224 - * Another more advanced way to get information out of a TraceContext is to call its
   3.225 - * ns3::TraceContext::GetElement method. This method takes as its first and only
   3.226 - * argument an instance of the object we want to read and the list of available
   3.227 - * object instances we can read from a TraceContext is documented, once again,
   3.228 - * in the \ref TraceSourceList. For example, we could write the following to
   3.229 - * generate adhoc trace output:
   3.230 - * \code
   3.231 - * void DeviceRxSink (const TraceContext &context, Ptr<const Packet> packet)
   3.232 - * {
   3.233 - *   NodeListIndex nodeIndex;
   3.234 - *   NodeNetDeviceIndex deviceIndex;
   3.235 - *   context.GetElement (nodeIndex);
   3.236 - *   context.GetElement (deviceIndex);
   3.237 - *   std::cout << "node-index=" << nodeIndex.Get ();
   3.238 - *   std::cout << ", device-index=" << deviceIndex.Get ();
   3.239 - *   std::cout << ", packet: " << packet->Print ();
   3.240 - *   std::cout << std::endl;
   3.241 - * }
   3.242 - * \endcode
   3.243 - *
   3.244 - * \section ExportingTraceSources Exporting new Trace Sources
   3.245 - *
   3.246 - * Using existing trace sources to connect them to a set of adhoc trace sinks
   3.247 - * is not really complicated but, setting up new trace sources which can hook
   3.248 - * in this automatic connection system is a bit more complicated.
   3.249 - *
   3.250 - * So far, we know that a model author can generate trace events really easily:
   3.251 - * \code
   3.252 - * class MyModel 
   3.253 - * {
   3.254 - * public:
   3.255 - *   void DoSomething (Ptr<Packet> packet) 
   3.256 - *   {
   3.257 - *     // report this event on packet with value
   3.258 - *     m_doSomething (packet);
   3.259 - *     // do something
   3.260 - *   }
   3.261 - * private:
   3.262 - *   // report every "something" function call.
   3.263 - *   CallbackTraceSource<Ptr<Packet>> m_doSomething;
   3.264 - * };
   3.265 - * \endcode
   3.266 - *
   3.267 - * To make these new trace sources available to the rest of the connection system,
   3.268 - * the first step is to make sure that your model object derives from the ns3::Object
   3.269 - * base class either directly (as shown below) or indirectly through another base class:
   3.270 - * \code
   3.271 - * class MyModel : public Object {...};
   3.272 - * // or:
   3.273 - * class SomeOtherObject : public Object {...};
   3.274 - * class MyModel : public SomeOtherObject {...};
   3.275 - * \endcode
   3.276 - *
   3.277 - * This is pretty trivial and lays the ground for the second step: overriding the
   3.278 - * ns3::Object::GetTraceResolver method:
   3.279 - * \code
   3.280 - * class MyModel : public MyParent
   3.281 - * {
   3.282 - * public:
   3.283 - *   // declare overriden method
   3.284 - *   virtual Ptr<TraceResolver> GetTraceResolver (void) const;
   3.285 - * private:
   3.286 - *   // the new trace source to export.
   3.287 - *   CallbackTraceSource<Ptr<Packet>> m_rxSource;
   3.288 - * };
   3.289 - * \endcode
   3.290 - *
   3.291 - * To implement this method, you could attempt to implement a new subclass of
   3.292 - * the ns3::TraceResolver base class and return an instance from this method but
   3.293 - * this would be very hard. Instead, you should use the helper class
   3.294 - * ns3::CompositeTraceResolver to register your trace sources and chain up to
   3.295 - * your parent:
   3.296 - * \code
   3.297 - * Ptr<TraceResolver>
   3.298 - * MyModel::GetTraceResolver (void) const
   3.299 - * {
   3.300 - *   // create an empty trace resolver
   3.301 - *   Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
   3.302 - *   // register m_rxSource
   3.303 - *   resolver->AddSource ("rx", // the name of the trace source in the path string
   3.304 - *                        TraceDoc ("some help text to explain the purpose of this trace source",
   3.305 - *                                  "Packet", // the type of the first argument to the trace source
   3.306 - *                                  "the purpose of the first argument",
   3.307 - *                                  "type-of-second-argument", "purpose-of-second-argument"),
   3.308 - *                        m_rxSource // the trace source itself is registered
   3.309 - *                       );
   3.310 - *   // make sure we include the trace sources implemented in the parent.
   3.311 - *   resolver->SetParentResolver (MyParent::GetTraceResolver ());
   3.312 - *   return resolver;
   3.313 - * }
   3.314 - * \endcode
   3.315 - *
   3.316 - * Once you have written that code, you must make sure that this new method GetTraceResolver
   3.317 - * is going to be called at some point by the tracing system. If your model is located somewhere
   3.318 - * deep in MAC or PHY layer, that is, it is part of a NetDevice implementation, all you
   3.319 - * have to do is to make sure that your model is registered as a "composite" of your NetDevice
   3.320 - * subclass:
   3.321 - * \code
   3.322 - * class MyNetDevice : public NetDevice
   3.323 - * {
   3.324 - * public:
   3.325 - *   Ptr<TraceResolver> GetTraceResolver (void) const;
   3.326 - * private:
   3.327 - *   Ptr<MyModel> m_model;
   3.328 - * };
   3.329 - * 
   3.330 - * Ptr<TraceResolver>
   3.331 - * MyNetDevice::GetTraceResolver (void) const
   3.332 - * {
   3.333 - *   Ptr<CompositeTraceResolver> resolver = ...;
   3.334 - *   // register other trace source
   3.335 - *   ...
   3.336 - *   // register now your model as a "composite"
   3.337 - *   resolver->AddComposite ("my-model", m_model);
   3.338 - *   // chain up to parent.
   3.339 - *   resolver->SetParentResolver (NetDevice::GetTraceResolver ());
   3.340 - *   return resolver;
   3.341 - * }
   3.342 - * \endcode
   3.343 - * 
   3.344 - * The code above will make your "rx" trace source appear under the
   3.345 - * /nodes/xx/devices/xx/my-model/rx namespace path.
   3.346 - *
   3.347 - * If you have implemented a new layer 3 or 4 protocol object, the process to
   3.348 - * export your trace sources is quite similar. You need to subclass from
   3.349 - * ns3::Object, override the ns3::Object::GetTraceResolver method, make
   3.350 - * sure you chain up to your parent's GetTraceResolver method, and, finally,
   3.351 - * make sure that someone calls your new GetTraceResolver method. How to accomplish
   3.352 - * the latter should be documented in the node's API documentation which describes
   3.353 - * how to implement a new layer 3 or 4 protocol object.
   3.354 - *
   3.355 - * \section AdvancedTraceContext Creating new Trace Context Elements
   3.356 - *
   3.357 - * The last important feature which model developers need to understand
   3.358 - * is how to provide extra context information to trace sinks. For example,
   3.359 - * if your model exports both rx and tx trace sources which share the same 
   3.360 - * signature, it is quite natural for a user to connect to a single trace sink
   3.361 - * to both of them with a trace path string such as "/nodes/* /devices/* /(rx|tx)".
   3.362 - * In this case, it becomes necessary to be able, from the trace sink function,
   3.363 - * to tell which event triggered the call to the trace sink: a rx or a tx event.
   3.364 - *
   3.365 - * That example is detailed below with a TX, a RX, and a DROP source:
   3.366 - * \code
   3.367 - * class MyModel
   3.368 - * {
   3.369 - * private:
   3.370 - *   CallbackTraceSource<Ptr<Packet>> m_rxSource;
   3.371 - *   CallbackTraceSource<Ptr<Packet>> m_txSource;
   3.372 - *   CallbackTraceSource<Ptr<Packet>> m_dropSource;
   3.373 - * };
   3.374 - * \endcode
   3.375 - * When a single sink is connected to all 3 sources here, one might want
   3.376 - * to write code like the following:
   3.377 - * \code
   3.378 - * void DeviceRxSink (const TraceContext &context, Ptr<const Packet> &packet)
   3.379 - * {
   3.380 - *   switch (type) {
   3.381 - *     case RX:
   3.382 - *       std::cout << "rx" << std::endl;
   3.383 - *       break;
   3.384 - *     case TX:
   3.385 - *       std::cout << "tx" << std::endl;
   3.386 - *       break;
   3.387 - *     case DROP:
   3.388 - *       std::cout << "drop" << std::endl;
   3.389 - *       break;
   3.390 - *   }
   3.391 - * \endcode
   3.392 - *
   3.393 - * \subsection AdvancedTraceContextSimpleSolution The simple solution
   3.394 - *
   3.395 - * The simplest way to do achieve the result shown above is to include
   3.396 - * in the trace source an extra explicit argument which describes the source event:
   3.397 - *   - define a small enum with 3 values
   3.398 - *   - change the signature of m_rxSource, m_txSource, and m_dropSource to include
   3.399 - *     the enum
   3.400 - *   - pass the enum value in each event
   3.401 - *
   3.402 - * The resulting code is shown below:
   3.403 - * \code
   3.404 - * class MyModel
   3.405 - * {
   3.406 - * public:
   3.407 - *   // define the trace type enum.
   3.408 - *   enum TraceType {
   3.409 - *     RX,
   3.410 - *     TX,
   3.411 - *     DROP
   3.412 - *   };
   3.413 - * private:
   3.414 - *   // generate events
   3.415 - *   void NotifyRxPacket (Ptr<Packet> p) {
   3.416 - *     m_rxSource (p, MyModel::RX);
   3.417 - *   }
   3.418 - *   void NotifyTxPacket (Ptr<Packet> p) {
   3.419 - *     m_rxSource (p, MyModel::TX);
   3.420 - *   }
   3.421 - *   void NotifyDropPacket (Ptr<Packet> p) {
   3.422 - *     m_rxSource (p, MyModel::DROP);
   3.423 - *   }
   3.424 - *   CallbackTraceSource<Ptr<Packet>,enum TraceType> m_rxSource;
   3.425 - *   CallbackTraceSource<Ptr<Packet>,enum TraceType> m_txSource;
   3.426 - *   CallbackTraceSource<Ptr<Packet>,enum TraceType> m_dropSource;
   3.427 - * };
   3.428 - * \endcode
   3.429 - * These 3 new sources can be connected easily to a new trace sink:
   3.430 - * \code
   3.431 - * void ASimpleTraceSink (const TraceContext &context, Ptr<const Packet> packet, enum MyModel::TraceType type)
   3.432 - * {
   3.433 - *   // here, read the "type" argument
   3.434 - * }
   3.435 - * \endcode
   3.436 - *
   3.437 - * This solution works but it makes it impossible to connect a single trace sink to a set
   3.438 - * of trace sources which represent "rx" events in different NetDevice objects since
   3.439 - * each of them will define a different enum type with different values: since the
   3.440 - * trace sink signature must match exactly the trace source signature, it is impossible
   3.441 - * to connect at the same time to all "rx" events of different NetDevice.
   3.442 - *
   3.443 - * \subsection AdvancedTraceContextFancySolution The more complex and generic solution
   3.444 - *
   3.445 - * There is, hopefully, a way to get the best of both worlds, that is, to allow a
   3.446 - * user to connect to a lot of trace source events of the same kind but coming from different
   3.447 - * implementations and to allow the user to differentiate between these different
   3.448 - * implementations.
   3.449 - *
   3.450 - * Rather than define an adhoc enum type with a list of trace sources, you can also
   3.451 - * define a new ns3::TraceContextElement for your source sources. For example, if you
   3.452 - * define a new MyModelTraceType class which contains the type of trace, your users can
   3.453 - * then write trace sink code which looks like this:
   3.454 - * \code
   3.455 - * void AFancyTraceSink (const TraceContext &context, Ptr<const Packet> packet)
   3.456 - * {
   3.457 - *   MyModelTraceType type;
   3.458 - *   if (context.GetElement (type))
   3.459 - *     {
   3.460 - *       switch (type.Get ())
   3.461 - *         {
   3.462 - *         case MyModelTraceType::RX:
   3.463 - *           std::cout << "rx" << std::endl;
   3.464 - *           break;
   3.465 - *         case MyModelTraceType::TX:
   3.466 - *           std::cout << "tx" << std::endl;
   3.467 - *           break;
   3.468 - *         case MyModelTraceType::DROP:
   3.469 - *           std::cout << "drop" << std::endl;
   3.470 - *           break;
   3.471 - *         }
   3.472 - *     }
   3.473 - * }
   3.474 - * \endcode
   3.475 - *
   3.476 - * Of course, since the type of trace is stored in the TraceContext, your users can
   3.477 - * also take the shortcut which uses the printing functionality of the TraceContext:
   3.478 - * \code
   3.479 - * void ALessFancyTraceSink (const TraceContext &context, Ptr<const Packet> packet)
   3.480 - * {
   3.481 - *   std::cout << "context=\"" << context << "\" packet: " << packet->Print () << std::endl;
   3.482 - * }
   3.483 - * \endcode
   3.484 - * which will generate something like the following when the trace source comes
   3.485 - * from MyModel:
   3.486 - * \code
   3.487 - * context="my-model-rx" packet: ...
   3.488 - * \endcode
   3.489 - *
   3.490 - * The first step to achieve this is to define and implement a new
   3.491 - * subclass of the ns3::TraceContextElement base class. The exact list of
   3.492 - * public methods which must be implemented is described in the API
   3.493 - * documentation of the ns3::TraceContextElement class. 
   3.494 - * \code
   3.495 - * class MyModelTraceType : public TraceContextElement
   3.496 - * {
   3.497 - * public:
   3.498 - *   enum Type {
   3.499 - *     RX,
   3.500 - *     TX,
   3.501 - *     DROP
   3.502 - *   };
   3.503 - *   // called from MyModel::GetTraceResolver
   3.504 - *   MyModelTraceType (enum Type type);
   3.505 - *   // needed for by the tracing subsystem.
   3.506 - *   MyModelTraceType ();
   3.507 - *   // called from trace sink
   3.508 - *   enum Type Get (void) const;
   3.509 - *   // needed by the tracing subsystem
   3.510 - *   static uint16_t GetUid (void);
   3.511 - *   // needed by the tracing subsystem to
   3.512 - *   // print the content of a TraceContext
   3.513 - *   void Print (std::ostream &os) const;
   3.514 - *   // needed by the tracing subsystem to
   3.515 - *   // generate the doxygen documentation.
   3.516 - *   std::string GetTypeName (void) const;
   3.517 - * private:
   3.518 - *   enum Type m_type;
   3.519 - * };
   3.520 - * \endcode
   3.521 - * The implementation does not require much thinking:
   3.522 - * \code
   3.523 - * MyModelTraceType::MyModelTraceType ()
   3.524 - *  : m_type (RX)
   3.525 - * {// an arbitrary default value.
   3.526 - * }
   3.527 - * MyModelTraceType::MyModelTraceType (enum Type type)
   3.528 - *  : m_type (type)
   3.529 - * {}
   3.530 - * enum MyModelTraceType::Type 
   3.531 - * MyModelTraceType::Get (void) const
   3.532 - * {
   3.533 - *   return m_type;
   3.534 - * }
   3.535 - * uint16_t 
   3.536 - * MyModelTraceType::GetUid (void)
   3.537 - * {
   3.538 - *   // use protected TraceContextElement::AllocateUid method
   3.539 - *   // the input string is used to uniquely identify this new subclass
   3.540 - *   static uint16_t uid = AllocateUid<MyModelTraceType> ("ns3::MyModelTraceType");
   3.541 - *   return uid;
   3.542 - * }
   3.543 - * void 
   3.544 - * MyModelTraceType::Print (std::ostream &os) const
   3.545 - * {
   3.546 - *   // this method is invoked by the print function of a TraceContext
   3.547 - *   // if it contains an instance of this TraceContextElement.
   3.548 - *   switch (m_type) {
   3.549 - *     case RX: os << "rx"; break;
   3.550 - *     // ...
   3.551 - *   }
   3.552 - * }
   3.553 - * std::string 
   3.554 - * MyModelTraceType::GetTypeName (void) const
   3.555 - * {
   3.556 - *   // This method should return a fully-qualified c++ typename
   3.557 - *   // This method is used only for documentation purposes to
   3.558 - *   // generate the content of the Trace Source List.
   3.559 - *   return "ns3::MyModelTraceType";
   3.560 - * }
   3.561 - * \endcode
   3.562 - *
   3.563 - * Once this subclass is implemented, the work is almost completed: you
   3.564 - * just need to pass an instance of that class as the last argument of 
   3.565 - * the ns3::CompositeTraceResolver::AddSource method as shown below:
   3.566 - * \code
   3.567 - * Ptr<TraceResolver>
   3.568 - * MyModel::GetTraceResolver (void) const
   3.569 - * {
   3.570 - *   // create an empty trace resolver
   3.571 - *   Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
   3.572 - *   // register m_rxSource
   3.573 - *   resolver->AddSource ("rx", // the name of the trace source in the path string
   3.574 - *                        TraceDoc ("some help text to explain the purpose of this trace source",
   3.575 - *                                  "Packet", // the type of the first argument to the trace source
   3.576 - *                                  "the purpose of the first argument",
   3.577 - *                                  "type-of-second-argument", "purpose-of-second-argument"),
   3.578 - *                        m_rxSource, // the trace source itself is registered
   3.579 - *                        // the TraceContextElement associated to this trace source.
   3.580 - *                        MyModelTraceType (MyModelTraceType::RX) 
   3.581 - *                       );
   3.582 - *   // make sure we include the trace sources implemented in the parent.
   3.583 - *   resolver->SetParentResolver (MyParent::GetTraceResolver ());
   3.584 - *   return resolver;
   3.585 - * }
   3.586 - * \endcode
   3.587 - */
     4.1 --- a/examples/csma-broadcast.cc	Mon Apr 21 08:58:23 2008 -0700
     4.2 +++ b/examples/csma-broadcast.cc	Mon Apr 21 09:04:08 2008 -0700
     4.3 @@ -68,8 +68,8 @@
     4.4  
     4.5    NS_LOG_INFO ("Build Topology.");
     4.6    CsmaHelper csma;
     4.7 -  csma.SetChannelParameter ("BitRate", DataRate(5000000));
     4.8 -  csma.SetChannelParameter ("Delay", MilliSeconds(2));
     4.9 +  csma.SetChannelParameter ("BitRate", DataRateValue (DataRate(5000000)));
    4.10 +  csma.SetChannelParameter ("Delay", TimeValue (MilliSeconds(2)));
    4.11  
    4.12    NetDeviceContainer n0 = csma.Install (c0);
    4.13    NetDeviceContainer n1 = csma.Install (c1);
    4.14 @@ -95,8 +95,8 @@
    4.15    NS_LOG_INFO ("Create Applications.");
    4.16    OnOffHelper onoff ("ns3::Udp", 
    4.17      Address (InetSocketAddress (Ipv4Address ("255.255.255.255"), port)));
    4.18 -  onoff.SetAttribute ("OnTime", ConstantVariable (1));
    4.19 -  onoff.SetAttribute ("OffTime", ConstantVariable (0));
    4.20 +  onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
    4.21 +  onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
    4.22  
    4.23    ApplicationContainer app = onoff.Install (c0.Get (0));
    4.24    // Start the application
     5.1 --- a/examples/csma-multicast.cc	Mon Apr 21 08:58:23 2008 -0700
     5.2 +++ b/examples/csma-multicast.cc	Mon Apr 21 09:04:08 2008 -0700
     5.3 @@ -59,7 +59,7 @@
     5.4    // Set up default values for the simulation.  
     5.5    //
     5.6    // Select Ethernet II-style encapsulation (no LLC/Snap header)
     5.7 -  Config::SetDefault ("ns3::CsmaNetDevice::EncapsulationMode", String ("IpArp"));  
     5.8 +  Config::SetDefault ("ns3::CsmaNetDevice::EncapsulationMode", StringValue ("IpArp"));  
     5.9  
    5.10    // Allow the user to override any of the defaults at
    5.11    // run-time, via command-line arguments
    5.12 @@ -75,8 +75,8 @@
    5.13    
    5.14    NS_LOG_INFO ("Build Topology.");
    5.15    CsmaHelper csma;
    5.16 -  csma.SetChannelParameter ("BitRate", DataRate (5000000));
    5.17 -  csma.SetChannelParameter ("Delay", MilliSeconds (2));
    5.18 +  csma.SetChannelParameter ("BitRate", DataRateValue (DataRate (5000000)));
    5.19 +  csma.SetChannelParameter ("Delay", TimeValue (MilliSeconds (2)));
    5.20   
    5.21    // We will use these NetDevice containers later, for IP addressing
    5.22    NetDeviceContainer nd0 = csma.Install (c0);  // First LAN
    5.23 @@ -142,10 +142,10 @@
    5.24    // every few seconds
    5.25    OnOffHelper onoff ("ns3::Udp", 
    5.26      Address (InetSocketAddress (multicastGroup, multicastPort)));
    5.27 -  onoff.SetAttribute ("OnTime", ConstantVariable (1));
    5.28 -  onoff.SetAttribute ("OffTime", ConstantVariable (0));
    5.29 -  onoff.SetAttribute ("DataRate", DataRate ("255b/s"));
    5.30 -  onoff.SetAttribute ("PacketSize", Uinteger (128));
    5.31 +  onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
    5.32 +  onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
    5.33 +  onoff.SetAttribute ("DataRate", DataRateValue (DataRate ("255b/s")));
    5.34 +  onoff.SetAttribute ("PacketSize", UintegerValue (128));
    5.35  
    5.36    ApplicationContainer srcC = onoff.Install (c0.Get (0));
    5.37  
    5.38 @@ -157,7 +157,7 @@
    5.39  
    5.40    // Create an optional packet sink to receive these packets
    5.41    PacketSinkHelper sink ("ns3::Udp",
    5.42 -    Address (InetSocketAddress (Ipv4Address::GetAny(), multicastPort)));
    5.43 +                         InetSocketAddress (Ipv4Address::GetAny(), multicastPort));
    5.44  
    5.45    ApplicationContainer sinkC = sink.Install (c1.Get (2)); // Node n4 
    5.46    // Start the sink
     6.1 --- a/examples/csma-one-subnet.cc	Mon Apr 21 08:58:23 2008 -0700
     6.2 +++ b/examples/csma-one-subnet.cc	Mon Apr 21 09:04:08 2008 -0700
     6.3 @@ -66,8 +66,8 @@
     6.4  
     6.5    NS_LOG_INFO ("Build Topology");
     6.6    CsmaHelper csma;
     6.7 -  csma.SetChannelParameter ("BitRate", DataRate (5000000));
     6.8 -  csma.SetChannelParameter ("Delay", MilliSeconds (2));
     6.9 +  csma.SetChannelParameter ("BitRate", DataRateValue (5000000));
    6.10 +  csma.SetChannelParameter ("Delay", TimeValue (MilliSeconds (2)));
    6.11  //
    6.12  // Now fill out the topology by creating the net devices required to connect
    6.13  // the nodes to the channels and hooking them up.  AddIpv4CsmaNetDevice will
    6.14 @@ -97,8 +97,8 @@
    6.15  
    6.16    OnOffHelper onoff ("ns3::Udp", 
    6.17      Address (InetSocketAddress (Ipv4Address ("10.1.1.2"), port)));
    6.18 -  onoff.SetAttribute ("OnTime", ConstantVariable (1));
    6.19 -  onoff.SetAttribute ("OffTime", ConstantVariable (0));
    6.20 +  onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
    6.21 +  onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
    6.22  
    6.23    ApplicationContainer app = onoff.Install (c.Get (0));
    6.24    // Start the application
    6.25 @@ -114,7 +114,7 @@
    6.26  // Create a similar flow from n3 to n0, starting at time 1.1 seconds
    6.27  //
    6.28    onoff.SetAttribute ("Remote", 
    6.29 -    Address (InetSocketAddress (Ipv4Address ("10.1.1.1"), port)));
    6.30 +                      AddressValue (InetSocketAddress (Ipv4Address ("10.1.1.1"), port)));
    6.31    ApplicationContainer app2 = onoff.Install (c.Get (3));
    6.32  
    6.33    sink.Install (c.Get (0));
     7.1 --- a/examples/csma-packet-socket.cc	Mon Apr 21 08:58:23 2008 -0700
     7.2 +++ b/examples/csma-packet-socket.cc	Mon Apr 21 09:04:08 2008 -0700
     7.3 @@ -70,13 +70,13 @@
     7.4  
     7.5    // create the shared medium used by all csma devices.
     7.6    NS_LOG_INFO ("Create channels.");
     7.7 -  Ptr<CsmaChannel> channel = CreateObject<CsmaChannel> ("BitRate", DataRate(5000000), 
     7.8 -                                                        "Delay", MilliSeconds(2));
     7.9 +  Ptr<CsmaChannel> channel = CreateObject<CsmaChannel> ("BitRate", DataRateValue (DataRate(5000000)), 
    7.10 +                                                        "Delay", TimeValue (MilliSeconds(2)));
    7.11  
    7.12    // use a helper function to connect our nodes to the shared channel.
    7.13    NS_LOG_INFO ("Build Topology.");
    7.14    CsmaHelper csma;
    7.15 -  csma.SetDeviceParameter ("EncapsulationMode", String ("Llc"));
    7.16 +  csma.SetDeviceParameter ("EncapsulationMode", StringValue ("Llc"));
    7.17    NetDeviceContainer devs = csma.Install (c, channel);
    7.18  
    7.19    NS_LOG_INFO ("Create Applications.");
    7.20 @@ -86,8 +86,8 @@
    7.21    socket.SetPhysicalAddress (devs.Get (1)->GetAddress ());
    7.22    socket.SetProtocol (2);
    7.23    OnOffHelper onoff ("ns3::PacketSocketFactory", Address (socket));
    7.24 -  onoff.SetAttribute ("OnTime", ConstantVariable (1.0));
    7.25 -  onoff.SetAttribute ("OffTime", ConstantVariable (0.0));
    7.26 +  onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1.0)));
    7.27 +  onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0.0)));
    7.28  
    7.29    ApplicationContainer apps = onoff.Install (c.Get (0));
    7.30    apps.Start (Seconds (1.0));
    7.31 @@ -96,8 +96,8 @@
    7.32    socket.SetSingleDevice (devs.Get (3)->GetIfIndex ());
    7.33    socket.SetPhysicalAddress (devs.Get (0)->GetAddress ());
    7.34    socket.SetProtocol (3);
    7.35 -  onoff.SetAttribute ("Remote", Address (socket));
    7.36 -  onoff.SetAttribute ("OffTime", ConstantVariable (0.0));
    7.37 +  onoff.SetAttribute ("Remote", AddressValue (socket));
    7.38 +  onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0.0)));
    7.39    apps = onoff.Install (c.Get (3));
    7.40    apps.Start (Seconds (1.0));
    7.41    apps.Stop (Seconds (10.0));
     8.1 --- a/examples/mixed-global-routing.cc	Mon Apr 21 08:58:23 2008 -0700
     8.2 +++ b/examples/mixed-global-routing.cc	Mon Apr 21 09:04:08 2008 -0700
     8.3 @@ -51,8 +51,8 @@
     8.4  int 
     8.5  main (int argc, char *argv[])
     8.6  {
     8.7 -  Config::SetDefault ("ns3::OnOffApplication::PacketSize", Uinteger (210));
     8.8 -  Config::SetDefault ("ns3::OnOffApplication::DataRate", DataRate ("448kb/s"));
     8.9 +  Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210));
    8.10 +  Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("448kb/s"));
    8.11  
    8.12    // Allow the user to override any of the defaults and the above
    8.13    // Bind ()s at run-time, via command-line arguments
    8.14 @@ -73,20 +73,20 @@
    8.15    // We create the channels first without any IP addressing information
    8.16    NS_LOG_INFO ("Create channels.");
    8.17    PointToPointHelper p2p;
    8.18 -  p2p.SetChannelParameter ("BitRate", DataRate (5000000));
    8.19 -  p2p.SetChannelParameter ("Delay", MilliSeconds (2));
    8.20 +  p2p.SetChannelParameter ("BitRate", StringValue ("5Mbps"));
    8.21 +  p2p.SetChannelParameter ("Delay", StringValue ("2ms"));
    8.22    NetDeviceContainer d0d2 = p2p.Install (n0n2);
    8.23  
    8.24    NetDeviceContainer d1d2 = p2p.Install (n1n2);
    8.25  
    8.26 -  p2p.SetChannelParameter ("BitRate", DataRate (1500000));
    8.27 -  p2p.SetChannelParameter ("Delay", MilliSeconds (10));
    8.28 +  p2p.SetChannelParameter ("BitRate", StringValue ("1500kbps"));
    8.29 +  p2p.SetChannelParameter ("Delay", StringValue ("10ms"));
    8.30    NetDeviceContainer d5d6 = p2p.Install (n5n6);
    8.31  
    8.32    // We create the channels first without any IP addressing information
    8.33    CsmaHelper csma;
    8.34 -  csma.SetChannelParameter ("BitRate", DataRate (5000000));
    8.35 -  csma.SetChannelParameter ("Delay", MilliSeconds (2));
    8.36 +  csma.SetChannelParameter ("BitRate", StringValue ("5Mbps"));
    8.37 +  csma.SetChannelParameter ("Delay", StringValue ("2ms"));
    8.38    NetDeviceContainer d2345 = csma.Install (n2345);
    8.39    
    8.40    // Later, we add IP addresses.  
    8.41 @@ -113,11 +113,11 @@
    8.42    NS_LOG_INFO ("Create Applications.");
    8.43    uint16_t port = 9;   // Discard port (RFC 863)
    8.44    OnOffHelper onoff ("ns3::Udp",
    8.45 -    Address (InetSocketAddress (i5i6.GetAddress (1), port)));
    8.46 -  onoff.SetAttribute ("OnTime", ConstantVariable (1));
    8.47 -  onoff.SetAttribute ("OffTime", ConstantVariable (0));
    8.48 -  onoff.SetAttribute ("DataRate", DataRate("300bps"));
    8.49 -  onoff.SetAttribute ("PacketSize", Uinteger (50));
    8.50 +                     InetSocketAddress (i5i6.GetAddress (1), port));
    8.51 +  onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
    8.52 +  onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
    8.53 +  onoff.SetAttribute ("DataRate", StringValue ("300bps"));
    8.54 +  onoff.SetAttribute ("PacketSize", UintegerValue (50));
    8.55  
    8.56    ApplicationContainer apps = onoff.Install (c.Get (0));
    8.57    apps.Start (Seconds (1.0));
     9.1 --- a/examples/mixed-wireless.cc	Mon Apr 21 08:58:23 2008 -0700
     9.2 +++ b/examples/mixed-wireless.cc	Mon Apr 21 09:04:08 2008 -0700
     9.3 @@ -96,8 +96,8 @@
     9.4    // Simulation defaults are typically set next, before command line
     9.5    // arguments are parsed.
     9.6    //
     9.7 -  Config::SetDefault ("ns3::OnOffApplication::PacketSize", String ("210"));
     9.8 -  Config::SetDefault ("ns3::OnOffApplication::DataRate", String ("448kb/s"));
     9.9 +  Config::SetDefault ("ns3::OnOffApplication::PacketSize", StringValue ("210"));
    9.10 +  Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("448kb/s"));
    9.11  
    9.12    //
    9.13    // For convenience, we add the local variables to the command line argument
    9.14 @@ -163,9 +163,9 @@
    9.15    positionAlloc->Add (Vector (5.0, 0.0, 0.0));
    9.16    mobility.SetPositionAllocator (positionAlloc);
    9.17    mobility.SetMobilityModel ("ns3::RandomDirection2dMobilityModel",
    9.18 -                              "Bounds", Rectangle (0, 1000, 0, 1000),
    9.19 -                              "Speed", ConstantVariable (2000),
    9.20 -                              "Pause", ConstantVariable (0.2));
    9.21 +                             "Bounds", RectangleValue (Rectangle (0, 1000, 0, 1000)),
    9.22 +                             "Speed", RandomVariableValue (ConstantVariable (2000)),
    9.23 +                             "Pause", RandomVariableValue (ConstantVariable (0.2)));
    9.24    mobility.Layout (backbone);
    9.25  
    9.26    /////////////////////////////////////////////////////////////////////////// 
    9.27 @@ -194,8 +194,8 @@
    9.28        // collection.
    9.29        //
    9.30        CsmaHelper csma;
    9.31 -      csma.SetChannelParameter ("BitRate", DataRate (5000000));
    9.32 -      csma.SetChannelParameter ("Delay", MilliSeconds (2));
    9.33 +      csma.SetChannelParameter ("BitRate", DataRateValue (DataRate (5000000)));
    9.34 +      csma.SetChannelParameter ("Delay", TimeValue (MilliSeconds (2)));
    9.35        NetDeviceContainer lanDevices = csma.Install (lan);
    9.36        //
    9.37        // Add the IPv4 protocol stack to the nodes in our container
    9.38 @@ -269,9 +269,9 @@
    9.39        mobility.PushReferenceMobilityModel (backbone.Get (i));
    9.40        mobility.SetPositionAllocator (subnetAlloc);
    9.41        mobility.SetMobilityModel ("ns3::RandomDirection2dMobilityModel",
    9.42 -                                 "Bounds", Rectangle (-25, 25, -25, 25),
    9.43 -                                 "Speed", ConstantVariable (30),
    9.44 -                                 "Pause", ConstantVariable (0.4));
    9.45 +                                 "Bounds", RectangleValue (Rectangle (-25, 25, -25, 25)),
    9.46 +                                 "Speed", RandomVariableValue (ConstantVariable (30)),
    9.47 +                                 "Pause", RandomVariableValue (ConstantVariable (0.4)));
    9.48        mobility.Layout (infra);
    9.49      }
    9.50    /////////////////////////////////////////////////////////////////////////// 
    9.51 @@ -304,8 +304,8 @@
    9.52  
    9.53    OnOffHelper onoff ("ns3::Udp", 
    9.54                       Address (InetSocketAddress (remoteAddr, port)));
    9.55 -  onoff.SetAttribute ("OnTime", ConstantVariable (1));
    9.56 -  onoff.SetAttribute ("OffTime", ConstantVariable (0));
    9.57 +  onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
    9.58 +  onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
    9.59    ApplicationContainer apps = onoff.Install (appSource);
    9.60    apps.Start (Seconds (3.0));
    9.61    apps.Stop (Seconds (20.0));
    10.1 --- a/examples/simple-alternate-routing.cc	Mon Apr 21 08:58:23 2008 -0700
    10.2 +++ b/examples/simple-alternate-routing.cc	Mon Apr 21 09:04:08 2008 -0700
    10.3 @@ -62,8 +62,8 @@
    10.4    //
    10.5    RandomVariable::UseGlobalSeed (1, 1, 2, 3, 5, 8);
    10.6  
    10.7 -  Config::SetDefault ("ns3::OnOffApplication::PacketSize", Uinteger (210));
    10.8 -  Config::SetDefault ("ns3::OnOffApplication::DataRate", DataRate ("300b/s"));
    10.9 +  Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210));
   10.10 +  Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("300b/s"));
   10.11  
   10.12    // The below metric, if set to 3 or higher, will cause packets between
   10.13    // n1 and n3 to take the 2-hop route through n2
   10.14 @@ -97,17 +97,17 @@
   10.15    // We create the channels first without any IP addressing information
   10.16    NS_LOG_INFO ("Create channels.");
   10.17    PointToPointHelper p2p;
   10.18 -  p2p.SetChannelParameter ("BitRate", DataRate (5000000));
   10.19 -  p2p.SetChannelParameter ("Delay", MilliSeconds (2));
   10.20 +  p2p.SetChannelParameter ("BitRate", StringValue ("5Mbps"));
   10.21 +  p2p.SetChannelParameter ("Delay", StringValue ("2ms"));
   10.22    NetDeviceContainer d0d2 = p2p.Install (n0n2);
   10.23  
   10.24    NetDeviceContainer d1d2 = p2p.Install (n1n2);
   10.25  
   10.26 -  p2p.SetChannelParameter ("BitRate", DataRate(1500000));
   10.27 -  p2p.SetChannelParameter ("Delay", MilliSeconds (10));
   10.28 +  p2p.SetChannelParameter ("BitRate", StringValue ("1500kbps"));
   10.29 +  p2p.SetChannelParameter ("Delay", StringValue ("10ms"));
   10.30    NetDeviceContainer d3d2 = p2p.Install (n3n2);
   10.31  
   10.32 -  p2p.SetChannelParameter ("Delay", MilliSeconds (100));
   10.33 +  p2p.SetChannelParameter ("Delay", StringValue ("100ms"));
   10.34    NetDeviceContainer d1d3 = p2p.Install (n1n3);
   10.35  
   10.36    InternetStackHelper internet;
   10.37 @@ -143,8 +143,8 @@
   10.38    // Create a flow from n3 to n1, starting at time 1.1 seconds
   10.39    OnOffHelper onoff ("ns3::Udp",
   10.40      Address (InetSocketAddress (i1i2.GetAddress (0), port)));
   10.41 -  onoff.SetAttribute ("OnTime", ConstantVariable (1));
   10.42 -  onoff.SetAttribute ("OffTime", ConstantVariable (0));
   10.43 +  onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
   10.44 +  onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
   10.45  
   10.46    ApplicationContainer apps = onoff.Install (c.Get (3));
   10.47    apps.Start (Seconds (1.1));
    11.1 --- a/examples/simple-error-model.cc	Mon Apr 21 08:58:23 2008 -0700
    11.2 +++ b/examples/simple-error-model.cc	Mon Apr 21 09:04:08 2008 -0700
    11.3 @@ -65,11 +65,11 @@
    11.4    RandomVariable::UseGlobalSeed (1, 1, 2, 3, 5, 8);
    11.5  
    11.6    // Set a few parameters
    11.7 -  Config::SetDefault ("ns3::RateErrorModel::ErrorRate", Double (0.01));
    11.8 -  Config::SetDefault ("ns3::RateErrorModel::ErrorUnit", String ("EU_PKT"));
    11.9 +  Config::SetDefault ("ns3::RateErrorModel::ErrorRate", DoubleValue (0.01));
   11.10 +  Config::SetDefault ("ns3::RateErrorModel::ErrorUnit", StringValue ("EU_PKT"));
   11.11    
   11.12 -  Config::SetDefault ("ns3::OnOffApplication::PacketSize", Uinteger (210));
   11.13 -  Config::SetDefault ("ns3::OnOffApplication::DataRate", DataRate ("448kb/s"));
   11.14 +  Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210));
   11.15 +  Config::SetDefault ("ns3::OnOffApplication::DataRate", DataRateValue (DataRate ("448kb/s")));
   11.16  
   11.17  
   11.18    // Allow the user to override any of the defaults and the above
   11.19 @@ -92,14 +92,14 @@
   11.20    // We create the channels first without any IP addressing information
   11.21    NS_LOG_INFO ("Create channels.");
   11.22    PointToPointHelper p2p;
   11.23 -  p2p.SetChannelParameter ("BitRate", DataRate (5000000));
   11.24 -  p2p.SetChannelParameter ("Delay", MilliSeconds (2));
   11.25 +  p2p.SetChannelParameter ("BitRate", DataRateValue (DataRate (5000000)));
   11.26 +  p2p.SetChannelParameter ("Delay", TimeValue (MilliSeconds (2)));
   11.27    NetDeviceContainer d0d2 = p2p.Install (n0n2);
   11.28  
   11.29    NetDeviceContainer d1d2 = p2p.Install (n1n2);
   11.30  
   11.31 -  p2p.SetChannelParameter ("BitRate", DataRate (1500000));
   11.32 -  p2p.SetChannelParameter ("Delay", MilliSeconds (10));
   11.33 +  p2p.SetChannelParameter ("BitRate", DataRateValue (DataRate (1500000)));
   11.34 +  p2p.SetChannelParameter ("Delay", TimeValue (MilliSeconds (10)));
   11.35    NetDeviceContainer d3d2 = p2p.Install (n3n2);
   11.36    
   11.37    // Later, we add IP addresses.  
   11.38 @@ -124,8 +124,8 @@
   11.39  
   11.40    OnOffHelper onoff ("ns3::Udp",
   11.41      Address (InetSocketAddress (i3i2.GetAddress (1), port)));
   11.42 -  onoff.SetAttribute ("OnTime", ConstantVariable(1));
   11.43 -  onoff.SetAttribute ("OffTime", ConstantVariable(0));
   11.44 +  onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable(1)));
   11.45 +  onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable(0)));
   11.46  
   11.47    ApplicationContainer apps = onoff.Install (c.Get (0));
   11.48    apps.Start(Seconds(1.0));
   11.49 @@ -140,14 +140,14 @@
   11.50  
   11.51    // Create a similar flow from n3 to n1, starting at time 1.1 seconds
   11.52    onoff.SetAttribute ("Remote", 
   11.53 -    Address (InetSocketAddress (i1i2.GetAddress (0), port)));
   11.54 +                      AddressValue (InetSocketAddress (i1i2.GetAddress (0), port)));
   11.55    apps = onoff.Install (c.Get (3));
   11.56    apps.Start(Seconds(1.1));
   11.57    apps.Stop (Seconds(10.0));
   11.58  
   11.59    // Create a packet sink to receive these packets
   11.60    sink.SetAttribute ("Local", 
   11.61 -    Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
   11.62 +                     AddressValue (InetSocketAddress (Ipv4Address::GetAny (), port)));
   11.63    apps = sink.Install (c.Get (1));
   11.64    apps.Start (Seconds (1.1));
   11.65    apps.Stop (Seconds (10.0));
   11.66 @@ -157,9 +157,9 @@
   11.67    //
   11.68    // Create an ErrorModel based on the implementation (constructor)
   11.69    // specified by the default classId
   11.70 -  Ptr<RateErrorModel> em = CreateObject<RateErrorModel> ("RanVar", UniformVariable (0.0, 1.0),
   11.71 -                                                         "ErrorRate", Double (0.001));
   11.72 -  d3d2.Get (0)->SetAttribute ("ReceiveErrorModel", em);
   11.73 +  Ptr<RateErrorModel> em = CreateObject<RateErrorModel> ("RanVar", RandomVariableValue (UniformVariable (0.0, 1.0)),
   11.74 +                                                         "ErrorRate", DoubleValue (0.001));
   11.75 +  d3d2.Get (0)->SetAttribute ("ReceiveErrorModel", PointerValue (em));
   11.76  
   11.77    // Now, let's use the ListErrorModel and explicitly force a loss
   11.78    // of the packets with pkt-uids = 11 and 17 on node 2, device 0
   11.79 @@ -169,7 +169,7 @@
   11.80    // This time, we'll explicitly create the error model we want
   11.81    Ptr<ListErrorModel> pem = CreateObject<ListErrorModel> ();
   11.82    pem->SetList (sampleList);
   11.83 -  d0d2.Get (1)->SetAttribute ("ReceiveErrorModel", pem);
   11.84 +  d0d2.Get (1)->SetAttribute ("ReceiveErrorModel", PointerValue (pem));
   11.85  
   11.86    std::ofstream ascii;
   11.87    ascii.open ("simple-error-model.tr");
    12.1 --- a/examples/simple-global-routing.cc	Mon Apr 21 08:58:23 2008 -0700
    12.2 +++ b/examples/simple-global-routing.cc	Mon Apr 21 09:04:08 2008 -0700
    12.3 @@ -67,8 +67,8 @@
    12.4    RandomVariable::UseGlobalSeed (1, 1, 2, 3, 5, 8);
    12.5  
    12.6    // Set up some default values for the simulation.  Use the 
    12.7 -  Config::SetDefault ("ns3::OnOffApplication::PacketSize", Uinteger (210));
    12.8 -  Config::SetDefault ("ns3::OnOffApplication::DataRate", DataRate ("448kb/s"));
    12.9 +  Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210));
   12.10 +  Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("448kb/s"));
   12.11  
   12.12    //DefaultValue::Bind ("DropTailQueue::m_maxPackets", 30);   
   12.13  
   12.14 @@ -92,14 +92,14 @@
   12.15    // We create the channels first without any IP addressing information
   12.16    NS_LOG_INFO ("Create channels.");
   12.17    PointToPointHelper p2p;
   12.18 -  p2p.SetChannelParameter ("BitRate", DataRate (5000000));
   12.19 -  p2p.SetChannelParameter ("Delay", MilliSeconds (2));
   12.20 +  p2p.SetChannelParameter ("BitRate", StringValue ("5Mbps"));
   12.21 +  p2p.SetChannelParameter ("Delay", StringValue ("2ms"));
   12.22    NetDeviceContainer d0d2 = p2p.Install (n0n2);
   12.23  
   12.24    NetDeviceContainer d1d2 = p2p.Install (n1n2);
   12.25    
   12.26 -  p2p.SetChannelParameter ("BitRate", DataRate (1500000));
   12.27 -  p2p.SetChannelParameter ("Delay", MilliSeconds (10));
   12.28 +  p2p.SetChannelParameter ("BitRate", StringValue ("1500kbps"));
   12.29 +  p2p.SetChannelParameter ("Delay", StringValue ("10ms"));
   12.30    NetDeviceContainer d3d2 = p2p.Install (n3n2);
   12.31    
   12.32    // Later, we add IP addresses.  
   12.33 @@ -124,8 +124,8 @@
   12.34    uint16_t port = 9;   // Discard port (RFC 863)
   12.35    OnOffHelper onoff ("ns3::Udp", 
   12.36      Address (InetSocketAddress (i3i2.GetAddress (0), port)));
   12.37 -  onoff.SetAttribute ("OnTime", ConstantVariable (1));
   12.38 -  onoff.SetAttribute ("OffTime", ConstantVariable (0));
   12.39 +  onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
   12.40 +  onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
   12.41    ApplicationContainer apps = onoff.Install (c.Get (0));
   12.42    apps.Start (Seconds (1.0));
   12.43    apps.Stop (Seconds (10.0));
   12.44 @@ -139,7 +139,7 @@
   12.45  
   12.46    // Create a similar flow from n3 to n1, starting at time 1.1 seconds
   12.47    onoff.SetAttribute ("Remote", 
   12.48 -    Address (InetSocketAddress (i1i2.GetAddress (0), port)));
   12.49 +    AddressValue (InetSocketAddress (i1i2.GetAddress (0), port)));
   12.50    apps = onoff.Install (c.Get (3));
   12.51    apps.Start (Seconds (1.1));
   12.52    apps.Stop (Seconds (10.0));
    13.1 --- a/examples/simple-point-to-point-olsr.cc	Mon Apr 21 08:58:23 2008 -0700
    13.2 +++ b/examples/simple-point-to-point-olsr.cc	Mon Apr 21 09:04:08 2008 -0700
    13.3 @@ -67,8 +67,8 @@
    13.4  
    13.5    // Set up some default values for the simulation.  Use the 
    13.6  
    13.7 -  Config::SetDefault ("ns3::OnOffApplication::PacketSize", Uinteger (210));
    13.8 -  Config::SetDefault ("ns3::OnOffApplication::DataRate", DataRate ("448kb/s"));
    13.9 +  Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210));
   13.10 +  Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("448kb/s"));
   13.11  
   13.12    //DefaultValue::Bind ("DropTailQueue::m_maxPackets", 30);   
   13.13  
   13.14 @@ -93,12 +93,12 @@
   13.15    // We create the channels first without any IP addressing information
   13.16    NS_LOG_INFO ("Create channels.");
   13.17    PointToPointHelper p2p;
   13.18 -  p2p.SetChannelParameter ("BitRate", DataRate (5000000));
   13.19 -  p2p.SetChannelParameter ("Delay", MilliSeconds (2));
   13.20 +  p2p.SetChannelParameter ("BitRate", StringValue ("5Mbps"));
   13.21 +  p2p.SetChannelParameter ("Delay", StringValue ("2ms"));
   13.22    NetDeviceContainer nd02 = p2p.Install (n02);
   13.23    NetDeviceContainer nd12 = p2p.Install (n12);
   13.24 -  p2p.SetChannelParameter ("BitRate", DataRate (1500000));
   13.25 -  p2p.SetChannelParameter ("Delay", MilliSeconds (10));
   13.26 +  p2p.SetChannelParameter ("BitRate", StringValue ("1500kbps"));
   13.27 +  p2p.SetChannelParameter ("Delay", StringValue ("10ms"));
   13.28    NetDeviceContainer nd32 = p2p.Install (n32);
   13.29    NetDeviceContainer nd34 = p2p.Install (n34);
   13.30    
   13.31 @@ -128,9 +128,9 @@
   13.32    uint16_t port = 9;   // Discard port (RFC 863)
   13.33  
   13.34    OnOffHelper onoff ("ns3::Udp", 
   13.35 -    Address (InetSocketAddress (i34.GetAddress (1), port)));
   13.36 -  onoff.SetAttribute ("OnTime", ConstantVariable (1));
   13.37 -  onoff.SetAttribute ("OffTime", ConstantVariable (0));
   13.38 +                     InetSocketAddress (i34.GetAddress (1), port));
   13.39 +  onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
   13.40 +  onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
   13.41  
   13.42    ApplicationContainer apps = onoff.Install (c.Get (0));
   13.43    apps.Start (Seconds (1.0));
   13.44 @@ -138,7 +138,7 @@
   13.45  
   13.46    // Create a packet sink to receive these packets
   13.47    PacketSinkHelper sink ("ns3::Udp",
   13.48 -    Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
   13.49 +                         InetSocketAddress (Ipv4Address::GetAny (), port));
   13.50  
   13.51    apps = sink.Install (c.Get (3));
   13.52    apps.Start (Seconds (1.0));
   13.53 @@ -146,7 +146,7 @@
   13.54  
   13.55    // Create a similar flow from n3 to n1, starting at time 1.1 seconds
   13.56    onoff.SetAttribute ("Remote",
   13.57 -    Address (InetSocketAddress (i12.GetAddress (0), port)));
   13.58 +                      AddressValue (InetSocketAddress (i12.GetAddress (0), port)));
   13.59    apps = onoff.Install (c.Get (3));
   13.60    apps.Start (Seconds (1.1));
   13.61    apps.Stop (Seconds (10.0));
    14.1 --- a/examples/tcp-large-transfer.cc	Mon Apr 21 08:58:23 2008 -0700
    14.2 +++ b/examples/tcp-large-transfer.cc	Mon Apr 21 09:04:08 2008 -0700
    14.3 @@ -137,8 +137,8 @@
    14.4  
    14.5    // We create the channels first without any IP addressing information
    14.6    PointToPointHelper p2p;
    14.7 -  p2p.SetChannelParameter ("BitRate", DataRate(10000000));
    14.8 -  p2p.SetChannelParameter ("Delay", MilliSeconds(10));
    14.9 +  p2p.SetChannelParameter ("BitRate", DataRateValue (DataRate(10000000)));
   14.10 +  p2p.SetChannelParameter ("Delay", TimeValue (MilliSeconds(10)));
   14.11    NetDeviceContainer dev0 = p2p.Install (c0);
   14.12    NetDeviceContainer dev1 = p2p.Install (c1);
   14.13  
   14.14 @@ -170,7 +170,7 @@
   14.15  
   14.16    // Create a packet sink to receive these packets
   14.17    PacketSinkHelper sink ("ns3::Tcp",
   14.18 -    Address (InetSocketAddress (Ipv4Address::GetAny (), servPort)));
   14.19 +                         InetSocketAddress (Ipv4Address::GetAny (), servPort));
   14.20  
   14.21    ApplicationContainer apps = sink.Install (c1.Get (1));
   14.22    apps.Start (Seconds (0.0));
    15.1 --- a/examples/udp-echo.cc	Mon Apr 21 08:58:23 2008 -0700
    15.2 +++ b/examples/udp-echo.cc	Mon Apr 21 09:04:08 2008 -0700
    15.3 @@ -87,8 +87,8 @@
    15.4  // Explicitly create the channels required by the topology (shown above).
    15.5  //
    15.6    CsmaHelper csma;
    15.7 -  csma.SetChannelParameter ("BitRate", DataRate(5000000));
    15.8 -  csma.SetChannelParameter ("Delay", MilliSeconds (2));
    15.9 +  csma.SetChannelParameter ("BitRate", DataRateValue (DataRate(5000000)));
   15.10 +  csma.SetChannelParameter ("Delay", TimeValue (MilliSeconds (2)));
   15.11    NetDeviceContainer d = csma.Install (n);
   15.12  
   15.13    Ipv4AddressHelper ipv4;
   15.14 @@ -119,9 +119,9 @@
   15.15    Time interPacketInterval = Seconds (1.);
   15.16    UdpEchoClientHelper client;
   15.17    client.SetRemote (i.GetAddress (1), port);
   15.18 -  client.SetAppAttribute ("MaxPackets", Uinteger (maxPacketCount));
   15.19 -  client.SetAppAttribute ("Interval", interPacketInterval);
   15.20 -  client.SetAppAttribute ("PacketSize", Uinteger (packetSize));
   15.21 +  client.SetAppAttribute ("MaxPackets", UintegerValue (maxPacketCount));
   15.22 +  client.SetAppAttribute ("Interval", TimeValue (interPacketInterval));
   15.23 +  client.SetAppAttribute ("PacketSize", UintegerValue (packetSize));
   15.24    apps = client.Install (n.Get (0));
   15.25    apps.Start (Seconds (2.0));
   15.26    apps.Stop (Seconds (10.0));
    16.1 --- a/examples/wifi-adhoc.cc	Mon Apr 21 08:58:23 2008 -0700
    16.2 +++ b/examples/wifi-adhoc.cc	Mon Apr 21 09:04:08 2008 -0700
    16.3 @@ -134,10 +134,10 @@
    16.4    socket.SetProtocol (1);
    16.5  
    16.6    OnOffHelper onoff ("ns3::PacketSocketFactory", Address (socket));
    16.7 -  onoff.SetAttribute ("OnTime", ConstantVariable (250));
    16.8 -  onoff.SetAttribute ("OffTime", ConstantVariable (0));
    16.9 -  onoff.SetAttribute ("DataRate", DataRate (60000000));
   16.10 -  onoff.SetAttribute ("PacketSize", Uinteger (2000));
   16.11 +  onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (250)));
   16.12 +  onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
   16.13 +  onoff.SetAttribute ("DataRate", DataRateValue (DataRate (60000000)));
   16.14 +  onoff.SetAttribute ("PacketSize", UintegerValue (2000));
   16.15  
   16.16    ApplicationContainer apps = onoff.Install (c.Get (0));
   16.17    apps.Start (Seconds (0.5));
   16.18 @@ -156,8 +156,8 @@
   16.19  int main (int argc, char *argv[])
   16.20  {
   16.21    // disable fragmentation
   16.22 -  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", String ("2200"));
   16.23 -  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", String ("2200"));
   16.24 +  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
   16.25 +  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
   16.26  
   16.27    CommandLine cmd;
   16.28    cmd.Parse (argc, argv);
   16.29 @@ -174,56 +174,56 @@
   16.30    NS_LOG_DEBUG ("54");
   16.31    experiment = Experiment ("54mb");
   16.32    wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
   16.33 -                                "DataMode", String ("wifia-54mbs"));
   16.34 +                                "DataMode", StringValue ("wifia-54mbs"));
   16.35    dataset = experiment.Run (wifi);
   16.36    gnuplot.AddDataset (dataset);
   16.37  
   16.38    NS_LOG_DEBUG ("48");
   16.39    experiment = Experiment ("48mb");
   16.40    wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
   16.41 -                                "DataMode", String ("wifia-48mbs"));
   16.42 +                                "DataMode", StringValue ("wifia-48mbs"));
   16.43    dataset = experiment.Run (wifi);
   16.44    gnuplot.AddDataset (dataset);
   16.45  
   16.46    NS_LOG_DEBUG ("36");
   16.47    experiment = Experiment ("36mb");
   16.48    wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
   16.49 -                                "DataMode", String ("wifia-36mbs"));
   16.50 +                                "DataMode", StringValue ("wifia-36mbs"));
   16.51    dataset = experiment.Run (wifi);
   16.52    gnuplot.AddDataset (dataset);
   16.53  
   16.54    NS_LOG_DEBUG ("24");
   16.55    experiment = Experiment ("24mb");
   16.56    wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
   16.57 -                                "DataMode", String ("wifia-24mbs"));
   16.58 +                                "DataMode", StringValue ("wifia-24mbs"));
   16.59    dataset = experiment.Run (wifi);
   16.60    gnuplot.AddDataset (dataset);
   16.61  
   16.62    NS_LOG_DEBUG ("18");
   16.63    experiment = Experiment ("18mb");
   16.64    wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
   16.65 -                                "DataMode", String ("wifia-18mbs"));
   16.66 +                                "DataMode", StringValue ("wifia-18mbs"));
   16.67    dataset = experiment.Run (wifi);
   16.68    gnuplot.AddDataset (dataset);
   16.69  
   16.70    NS_LOG_DEBUG ("12");
   16.71    experiment = Experiment ("12mb");
   16.72    wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
   16.73 -                                "DataMode", String ("wifia-12mbs"));
   16.74 +                                "DataMode", StringValue ("wifia-12mbs"));
   16.75    dataset = experiment.Run (wifi);
   16.76    gnuplot.AddDataset (dataset);
   16.77  
   16.78    NS_LOG_DEBUG ("9");
   16.79    experiment = Experiment ("9mb");
   16.80    wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
   16.81 -                                "DataMode", String ("wifia-9mbs"));
   16.82 +                                "DataMode", StringValue ("wifia-9mbs"));
   16.83    dataset = experiment.Run (wifi);
   16.84    gnuplot.AddDataset (dataset);
   16.85  
   16.86    NS_LOG_DEBUG ("6");
   16.87    experiment = Experiment ("6mb");
   16.88    wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
   16.89 -                                "DataMode", String ("wifia-6mbs"));
   16.90 +                                "DataMode", StringValue ("wifia-6mbs"));
   16.91    dataset = experiment.Run (wifi);
   16.92    gnuplot.AddDataset (dataset);
   16.93  
   16.94 @@ -231,7 +231,7 @@
   16.95  
   16.96  
   16.97    gnuplot = Gnuplot ("rate-control.png");
   16.98 -  Config::SetDefault ("ns3::WifiPhy::Standard", String ("holland"));
   16.99 +  Config::SetDefault ("ns3::WifiPhy::Standard", StringValue ("holland"));
  16.100  
  16.101  
  16.102    NS_LOG_DEBUG ("arf");
    17.1 --- a/examples/wifi-ap.cc	Mon Apr 21 08:58:23 2008 -0700
    17.2 +++ b/examples/wifi-ap.cc	Mon Apr 21 09:04:08 2008 -0700
    17.3 @@ -113,9 +113,9 @@
    17.4    Packet::EnableMetadata ();
    17.5  
    17.6    // enable rts cts all the time.
    17.7 -  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", String ("0"));
    17.8 +  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("0"));
    17.9    // disable fragmentation
   17.10 -  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", String ("2200"));
   17.11 +  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
   17.12  
   17.13    WifiHelper wifi;
   17.14    MobilityHelper mobility;
   17.15 @@ -141,13 +141,14 @@
   17.16    wifi.SetPhy ("ns3::WifiPhy");
   17.17    wifi.SetRemoteStationManager ("ns3::ArfWifiManager");
   17.18    // setup stas.
   17.19 -  wifi.SetMac ("ns3::NqstaWifiMac", "Ssid", ssid,
   17.20 -               "ActiveProbing", Boolean (false));
   17.21 +  wifi.SetMac ("ns3::NqstaWifiMac", 
   17.22 +               "Ssid", SsidValue (ssid),
   17.23 +               "ActiveProbing", BooleanValue (false));
   17.24    staDevs = wifi.Install (stas, channel);
   17.25    // setup ap.
   17.26 -  wifi.SetMac ("ns3::NqapWifiMac", "Ssid", ssid,
   17.27 -               "BeaconGeneration", Boolean (true),
   17.28 -               "BeaconInterval", Seconds (2.5));
   17.29 +  wifi.SetMac ("ns3::NqapWifiMac", "Ssid", SsidValue (ssid),
   17.30 +               "BeaconGeneration", BooleanValue (true),
   17.31 +               "BeaconInterval", TimeValue (Seconds (2.5)));
   17.32    wifi.Install (ap, channel);
   17.33  
   17.34    // mobility.
   17.35 @@ -162,8 +163,8 @@
   17.36    socket.SetProtocol (1);
   17.37  
   17.38    OnOffHelper onoff ("ns3::PacketSocketFactory", Address (socket));
   17.39 -  onoff.SetAttribute ("OnTime", ConstantVariable (42));
   17.40 -  onoff.SetAttribute ("OffTime", ConstantVariable (0));
   17.41 +  onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (42)));
   17.42 +  onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
   17.43  
   17.44    ApplicationContainer apps = onoff.Install (stas.Get (0));
   17.45    apps.Start (Seconds (0.5));
    18.1 --- a/samples/main-attribute-value.cc	Mon Apr 21 08:58:23 2008 -0700
    18.2 +++ b/samples/main-attribute-value.cc	Mon Apr 21 09:04:08 2008 -0700
    18.3 @@ -24,6 +24,7 @@
    18.4  #include "ns3/config.h"
    18.5  #include "ns3/uinteger.h"
    18.6  #include "ns3/string.h"
    18.7 +#include "ns3/pointer.h"
    18.8  #include "ns3/simulator.h"
    18.9  
   18.10  #include "ns3/node.h"
   18.11 @@ -50,10 +51,10 @@
   18.12    // (this default can be observed in the function DropTailQueue::GetTypeId)
   18.13    // 
   18.14    // Here, we set it to 80 packets.  We could use one of two value types:
   18.15 -  // a string-based value or a Uinteger value
   18.16 -  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", String ("80"));
   18.17 +  // a string-based value or a UintegerValue value
   18.18 +  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("80"));
   18.19    // The below function call is redundant
   18.20 -  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", Uinteger(80));
   18.21 +  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", UintegerValue (80));
   18.22  
   18.23    // Allow the user to override any of the defaults and the above
   18.24    // SetDefaults() at run-time, via command-line arguments
   18.25 @@ -87,7 +88,9 @@
   18.26    // First, we observe that we can get a pointer to the (base class)
   18.27    // queue via the PointToPointNetDevice attributes, where it is called
   18.28    // TxQueue 
   18.29 -  Ptr<Queue> txQueue = net0->GetAttribute ("TxQueue");
   18.30 +  PointerValue ptr;
   18.31 +  net0->GetAttribute ("TxQueue", ptr);
   18.32 +  Ptr<Queue> txQueue = ptr.Get<Queue> ();
   18.33  
   18.34    // Using the GetObject function, we can perform a safe downcast
   18.35    // to a DropTailQueue, where MaxPackets is a member
   18.36 @@ -100,18 +103,19 @@
   18.37    // the attribute system stores values and not disparate types.
   18.38    // Here, the attribute value is assigned to a Uinteger, and
   18.39    // the Get() method on this value produces the (unwrapped) uint32_t.
   18.40 -  Uinteger limit = dtq->GetAttribute ("MaxPackets");
   18.41 +  UintegerValue limit;
   18.42 +  dtq->GetAttribute ("MaxPackets", limit);
   18.43    NS_LOG_INFO ("1.  dtq limit: " << limit.Get () << " packets");
   18.44    
   18.45    // Note that the above downcast is not really needed; we could have
   18.46    // done the same using the Ptr<Queue> even though the attribute
   18.47    // is a member of the subclass
   18.48 -  limit = txQueue->GetAttribute ("MaxPackets");
   18.49 +  txQueue->GetAttribute ("MaxPackets", limit);
   18.50    NS_LOG_INFO ("2.  txQueue limit: " << limit.Get () << " packets");
   18.51  
   18.52    // Now, let's set it to another value (60 packets)
   18.53 -  txQueue->SetAttribute("MaxPackets", Uinteger (60));
   18.54 -  limit = txQueue->GetAttribute ("MaxPackets");
   18.55 +  txQueue->SetAttribute("MaxPackets", UintegerValue (60));
   18.56 +  txQueue->GetAttribute ("MaxPackets", limit);
   18.57    NS_LOG_INFO ("3.  txQueue limit changed: " << limit.Get () << " packets");
   18.58  
   18.59    // 2.  Namespace-based access
   18.60 @@ -121,18 +125,18 @@
   18.61    // namespace; this approach is useful if one doesn't have access to
   18.62    // the underlying pointers and would like to configure a specific
   18.63    // attribute with a single statement.  
   18.64 -  Config::Set ("/NodeList/0/DeviceList/0/TxQueue/MaxPackets", Uinteger (25));
   18.65 -  limit = txQueue->GetAttribute ("MaxPackets"); 
   18.66 +  Config::Set ("/NodeList/0/DeviceList/0/TxQueue/MaxPackets", UintegerValue (25));
   18.67 +  txQueue->GetAttribute ("MaxPackets", limit); 
   18.68    NS_LOG_INFO ("4.  txQueue limit changed through namespace: " << 
   18.69 -    limit.Get () << " packets");
   18.70 +               limit.Get () << " packets");
   18.71  
   18.72    // we could have also used wildcards to set this value for all nodes
   18.73    // and all net devices (which in this simple example has the same
   18.74    // effect as the previous Set())
   18.75 -  Config::Set ("/NodeList/*/DeviceList/*/TxQueue/MaxPackets", Uinteger (15));
   18.76 -  limit = txQueue->GetAttribute ("MaxPackets"); 
   18.77 +  Config::Set ("/NodeList/*/DeviceList/*/TxQueue/MaxPackets", UintegerValue (15));
   18.78 +  txQueue->GetAttribute ("MaxPackets", limit); 
   18.79    NS_LOG_INFO ("5.  txQueue limit changed through wildcarded namespace: " << 
   18.80 -    limit.Get () << " packets");
   18.81 +               limit.Get () << " packets");
   18.82  
   18.83    Simulator::Destroy ();
   18.84  }
    19.1 --- a/samples/main-grid-topology.cc	Mon Apr 21 08:58:23 2008 -0700
    19.2 +++ b/samples/main-grid-topology.cc	Mon Apr 21 09:04:08 2008 -0700
    19.3 @@ -23,12 +23,12 @@
    19.4    // the x interval between each object is 5 meters
    19.5    // and the y interval between each object is 20 meters
    19.6    mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
    19.7 -                                 "MinX", Double (-100.0),
    19.8 -                                 "MinY", Double (-100.0),
    19.9 -                                 "DeltaX", Double (5.0),
   19.10 -                                 "DeltaY", Double (20.0),
   19.11 -                                 "GridWidth", Uinteger (20),
   19.12 -                                 "LayoutType", String ("RowFirst"));
   19.13 +                                 "MinX", DoubleValue (-100.0),
   19.14 +                                 "MinY", DoubleValue (-100.0),
   19.15 +                                 "DeltaX", DoubleValue (5.0),
   19.16 +                                 "DeltaY", DoubleValue (20.0),
   19.17 +                                 "GridWidth", UintegerValue (20),
   19.18 +                                 "LayoutType", StringValue ("RowFirst"));
   19.19    // each object will be attached a static position.
   19.20    // i.e., once set by the "position allocator", the
   19.21    // position will never change.
    20.1 --- a/samples/main-propagation-loss.cc	Mon Apr 21 08:58:23 2008 -0700
    20.2 +++ b/samples/main-propagation-loss.cc	Mon Apr 21 09:04:08 2008 -0700
    20.3 @@ -51,8 +51,8 @@
    20.4  int main (int argc, char *argv[])
    20.5  {
    20.6  
    20.7 -  Config::SetGlobal ("LogDistancePropagationLossModel::ReferenceDistance", String ("1.0"));
    20.8 -  Config::SetGlobal ("LogDistancePropagationLossModel::Exponent", String ("4"));
    20.9 +  Config::SetGlobal ("LogDistancePropagationLossModel::ReferenceDistance", StringValue ("1.0"));
   20.10 +  Config::SetGlobal ("LogDistancePropagationLossModel::Exponent", StringValue ("4"));
   20.11  
   20.12    PrintOne (-10, 20, 5, 0, 10000, 2);
   20.13  
    21.1 --- a/samples/main-random-topology.cc	Mon Apr 21 08:58:23 2008 -0700
    21.2 +++ b/samples/main-random-topology.cc	Mon Apr 21 09:04:08 2008 -0700
    21.3 @@ -27,9 +27,9 @@
    21.4    MobilityHelper mobility;
    21.5    mobility.EnableNotifier ();
    21.6    mobility.SetPositionAllocator ("ns3::RandomDiscPositionAllocator",
    21.7 -                                 "X", String ("100.0"),
    21.8 -                                 "Y", String ("100.0"),
    21.9 -                                 "Rho", String ("Uniform:0:30"));
   21.10 +                                 "X", StringValue ("100.0"),
   21.11 +                                 "Y", StringValue ("100.0"),
   21.12 +                                 "Rho", StringValue ("Uniform:0:30"));
   21.13    mobility.SetMobilityModel ("ns3::StaticMobilityModel");
   21.14    mobility.Layout (c);
   21.15  
    22.1 --- a/samples/main-random-walk.cc	Mon Apr 21 08:58:23 2008 -0700
    22.2 +++ b/samples/main-random-walk.cc	Mon Apr 21 09:04:08 2008 -0700
    22.3 @@ -19,10 +19,10 @@
    22.4  
    22.5  int main (int argc, char *argv[])
    22.6  {
    22.7 -  Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Mode", String ("Time"));
    22.8 -  Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Time", String ("2s"));
    22.9 -  Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Speed", String ("Constant:1.0"));
   22.10 -  Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Bounds", String ("0:200:0:100"));
   22.11 +  Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Mode", StringValue ("Time"));
   22.12 +  Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Time", StringValue ("2s"));
   22.13 +  Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Speed", StringValue ("Constant:1.0"));
   22.14 +  Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Bounds", StringValue ("0:200:0:100"));
   22.15  
   22.16    CommandLine cmd;
   22.17    cmd.Parse (argc, argv);
   22.18 @@ -33,17 +33,17 @@
   22.19    MobilityHelper mobility;
   22.20    mobility.EnableNotifier ();
   22.21    mobility.SetPositionAllocator ("ns3::RandomDiscPositionAllocator",
   22.22 -                                 "X", String ("100.0"),
   22.23 -                                 "Y", String ("100.0"),
   22.24 -                                 "Rho", String ("Uniform:0:30"));
   22.25 +                                 "X", StringValue ("100.0"),
   22.26 +                                 "Y", StringValue ("100.0"),
   22.27 +                                 "Rho", StringValue ("Uniform:0:30"));
   22.28    mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
   22.29 -                             "Mode", String ("Time"),
   22.30 -                             "Time", String ("2s"),
   22.31 -                             "Speed", String ("Constant:1.0"),
   22.32 -                             "Bounds", String ("0:200:0:100"));
   22.33 +                             "Mode", StringValue ("Time"),
   22.34 +                             "Time", StringValue ("2s"),
   22.35 +                             "Speed", StringValue ("Constant:1.0"),
   22.36 +                             "Bounds", StringValue ("0:200:0:100"));
   22.37    mobility.LayoutAll ();
   22.38    Config::Connect ("/NodeList/*/$ns3::MobilityModelNotifier/CourseChange",
   22.39 -                              MakeCallback (&CourseChange));
   22.40 +                   MakeCallback (&CourseChange));
   22.41  
   22.42    Simulator::StopAt (Seconds (100.0));
   22.43  
    23.1 --- a/src/applications/onoff/onoff-application.cc	Mon Apr 21 08:58:23 2008 -0700
    23.2 +++ b/src/applications/onoff/onoff-application.cc	Mon Apr 21 09:04:08 2008 -0700
    23.3 @@ -52,34 +52,34 @@
    23.4      .SetParent<Application> ()
    23.5      .AddConstructor<OnOffApplication> ()
    23.6      .AddAttribute ("DataRate", "The data rate in on state.",
    23.7 -                   DataRate ("500kb/s"),
    23.8 +                   DataRateValue (DataRate ("500kb/s")),
    23.9                     MakeDataRateAccessor (&OnOffApplication::m_cbrRate),
   23.10                     MakeDataRateChecker ())
   23.11      .AddAttribute ("PacketSize", "The size of packets sent in on state",
   23.12 -                   Uinteger (512),
   23.13 +                   UintegerValue (512),
   23.14                     MakeUintegerAccessor (&OnOffApplication::m_pktSize),
   23.15                     MakeUintegerChecker<uint32_t> (1))
   23.16      .AddAttribute ("Remote", "The address of the destination",
   23.17 -                   Address (),
   23.18 +                   AddressValue (),
   23.19                     MakeAddressAccessor (&OnOffApplication::m_peer),
   23.20                     MakeAddressChecker ())
   23.21      .AddAttribute ("OnTime", "A RandomVariable used to pick the duration of the 'On' state.",
   23.22 -                   ConstantVariable (1.0),
   23.23 +                   RandomVariableValue (ConstantVariable (1.0)),
   23.24                     MakeRandomVariableAccessor (&OnOffApplication::m_onTime),
   23.25                     MakeRandomVariableChecker ())
   23.26      .AddAttribute ("OffTime", "A RandomVariable used to pick the duration of the 'Off' state.",
   23.27 -                   ConstantVariable (1.0),
   23.28 +                   RandomVariableValue (ConstantVariable (1.0)),
   23.29                     MakeRandomVariableAccessor (&OnOffApplication::m_offTime),
   23.30                     MakeRandomVariableChecker ())
   23.31      .AddAttribute ("MaxBytes", 
   23.32                     "The total number of bytes to send. Once these bytes are sent, "
   23.33                     "no packet is sent again, even in on state. The value zero means "
   23.34                     "that there is no limit.",
   23.35 -                   Uinteger (0),
   23.36 +                   UintegerValue (0),
   23.37                     MakeUintegerAccessor (&OnOffApplication::m_maxBytes),
   23.38                     MakeUintegerChecker<uint32_t> ())
   23.39      .AddAttribute ("Protocol", "The type of protocol to use.",
   23.40 -                   Udp::GetTypeId (),
   23.41 +                   TypeIdValue (Udp::GetTypeId ()),
   23.42                     MakeTypeIdAccessor (&OnOffApplication::m_tid),
   23.43                     MakeTypeIdChecker ())
   23.44      .AddTraceSource ("Tx", "A new packet is created and is sent",
    24.1 --- a/src/applications/packet-sink/packet-sink.cc	Mon Apr 21 08:58:23 2008 -0700
    24.2 +++ b/src/applications/packet-sink/packet-sink.cc	Mon Apr 21 09:04:08 2008 -0700
    24.3 @@ -43,11 +43,11 @@
    24.4      .SetParent<Application> ()
    24.5      .AddConstructor<PacketSink> ()
    24.6      .AddAttribute ("Local", "The Address on which to Bind the rx socket.",
    24.7 -                   Address (),
    24.8 +                   AddressValue (),
    24.9                     MakeAddressAccessor (&PacketSink::m_local),
   24.10                     MakeAddressChecker ())
   24.11      .AddAttribute ("Protocol", "The type id of the protocol to use for the rx socket.",
   24.12 -                   Udp::GetTypeId (),
   24.13 +                   TypeIdValue (Udp::GetTypeId ()),
   24.14                     MakeTypeIdAccessor (&PacketSink::m_tid),
   24.15                     MakeTypeIdChecker ())
   24.16      .AddTraceSource ("Rx", "A packet has been received",
    25.1 --- a/src/applications/udp-echo/udp-echo-client.cc	Mon Apr 21 08:58:23 2008 -0700
    25.2 +++ b/src/applications/udp-echo/udp-echo-client.cc	Mon Apr 21 09:04:08 2008 -0700
    25.3 @@ -38,23 +38,23 @@
    25.4      .SetParent<Application> ()
    25.5      .AddConstructor<UdpEchoClient> ()
    25.6      .AddAttribute ("MaxPackets", "XXX",
    25.7 -                   Uinteger (100),
    25.8 +                   UintegerValue (100),
    25.9                     MakeUintegerAccessor (&UdpEchoClient::m_count),
   25.10                     MakeUintegerChecker<uint32_t> ())
   25.11      .AddAttribute ("Interval", "XXX",
   25.12 -                   Seconds (1.0),
   25.13 +                   TimeValue (Seconds (1.0)),
   25.14                     MakeTimeAccessor (&UdpEchoClient::m_interval),
   25.15                     MakeTimeChecker ())
   25.16      .AddAttribute ("RemoteIpv4", "XXX",
   25.17 -                   Ipv4Address (),
   25.18 +                   Ipv4AddressValue (),
   25.19                     MakeIpv4AddressAccessor (&UdpEchoClient::m_peerAddress),
   25.20                     MakeIpv4AddressChecker ())
   25.21      .AddAttribute ("RemotePort", "XXX",
   25.22 -                   Uinteger (0),
   25.23 +                   UintegerValue (0),
   25.24                     MakeUintegerAccessor (&UdpEchoClient::m_peerPort),
   25.25                     MakeUintegerChecker<uint16_t> ())
   25.26      .AddAttribute ("PacketSize", "Size of packets generated",
   25.27 -                   Uinteger (100),
   25.28 +                   UintegerValue (100),
   25.29                     MakeUintegerAccessor (&UdpEchoClient::m_size),
   25.30                     MakeUintegerChecker<uint32_t> ())
   25.31      ;
    26.1 --- a/src/applications/udp-echo/udp-echo-client.h	Mon Apr 21 08:58:23 2008 -0700
    26.2 +++ b/src/applications/udp-echo/udp-echo-client.h	Mon Apr 21 09:04:08 2008 -0700
    26.3 @@ -29,6 +29,11 @@
    26.4  class Socket;
    26.5  class Packet;
    26.6  
    26.7 +/**
    26.8 + * \brief A Udp Echo client
    26.9 + *
   26.10 + * Every packet sent should be returned by the server and received here.
   26.11 + */
   26.12  class UdpEchoClient : public Application 
   26.13  {
   26.14  public:
    27.1 --- a/src/applications/udp-echo/udp-echo-server.cc	Mon Apr 21 08:58:23 2008 -0700
    27.2 +++ b/src/applications/udp-echo/udp-echo-server.cc	Mon Apr 21 09:04:08 2008 -0700
    27.3 @@ -40,7 +40,7 @@
    27.4      .SetParent<Application> ()
    27.5      .AddConstructor<UdpEchoServer> ()
    27.6      .AddAttribute ("Port", "Port on which we listen for incoming packets.",
    27.7 -                   Uinteger (9),
    27.8 +                   UintegerValue (9),
    27.9                     MakeUintegerAccessor (&UdpEchoServer::m_port),
   27.10                     MakeUintegerChecker<uint16_t> ())
   27.11      ;
    28.1 --- a/src/applications/udp-echo/udp-echo-server.h	Mon Apr 21 08:58:23 2008 -0700
    28.2 +++ b/src/applications/udp-echo/udp-echo-server.h	Mon Apr 21 09:04:08 2008 -0700
    28.3 @@ -29,6 +29,11 @@
    28.4  class Socket;
    28.5  class Packet;
    28.6  
    28.7 +/**
    28.8 + * \brief A Udp Echo server
    28.9 + *
   28.10 + * Every packet received is sent back.
   28.11 + */
   28.12  class UdpEchoServer : public Application 
   28.13  {
   28.14  public:
    29.1 --- a/src/common/data-rate.h	Mon Apr 21 08:58:23 2008 -0700
    29.2 +++ b/src/common/data-rate.h	Mon Apr 21 09:04:08 2008 -0700
    29.3 @@ -89,6 +89,11 @@
    29.4  std::ostream &operator << (std::ostream &os, const DataRate &rate);
    29.5  std::istream &operator >> (std::istream &is, DataRate &rate);
    29.6  
    29.7 +/**
    29.8 + * \class ns3::DataRateValue
    29.9 + * \brief hold objects of type ns3::DataRate
   29.10 + */
   29.11 +
   29.12  ATTRIBUTE_HELPER_HEADER_2 (DataRate);
   29.13  
   29.14  /**
    30.1 --- a/src/common/error-model.cc	Mon Apr 21 08:58:23 2008 -0700
    30.2 +++ b/src/common/error-model.cc	Mon Apr 21 09:04:08 2008 -0700
    30.3 @@ -42,7 +42,7 @@
    30.4    static TypeId tid = TypeId ("ns3::ErrorModel")
    30.5      .SetParent<Object> ()
    30.6      .AddAttribute ("IsEnabled", "Whether this ErrorModel is enabled or not.",
    30.7 -                   Boolean (true),
    30.8 +                   BooleanValue (true),
    30.9                     MakeBooleanAccessor (&ErrorModel::m_enable),
   30.10                     MakeBooleanChecker ())
   30.11      ;
   30.12 @@ -111,17 +111,17 @@
   30.13      .SetParent<ErrorModel> ()
   30.14      .AddConstructor<RateErrorModel> ()
   30.15      .AddAttribute ("ErrorUnit", "The error unit",
   30.16 -                   Enum (EU_BYTE),
   30.17 +                   EnumValue (EU_BYTE),
   30.18                     MakeEnumAccessor (&RateErrorModel::m_unit),
   30.19                     MakeEnumChecker (EU_BYTE, "EU_BYTE",
   30.20                                      EU_PKT, "EU_PKT",
   30.21                                      EU_BIT, "EU_BIT"))
   30.22      .AddAttribute ("ErrorRate", "The error rate.",
   30.23 -                   Double (0.0),
   30.24 +                   DoubleValue (0.0),
   30.25                     MakeDoubleAccessor (&RateErrorModel::m_rate),
   30.26                     MakeDoubleChecker<double> ())
   30.27      .AddAttribute ("RanVar", "The decision variable attached to this error model.",
   30.28 -                   UniformVariable (0.0, 1.0),
   30.29 +                   RandomVariableValue (UniformVariable (0.0, 1.0)),
   30.30                     MakeRandomVariableAccessor (&RateErrorModel::m_ranvar),
   30.31                     MakeRandomVariableChecker ())
   30.32      ;
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/src/contrib/config-store.cc	Mon Apr 21 09:04:08 2008 -0700
    31.3 @@ -0,0 +1,205 @@
    31.4 +#include "config-store.h"
    31.5 +#include "ns3/string.h"
    31.6 +#include "ns3/config.h"
    31.7 +#include "ns3/object-vector.h"
    31.8 +#include "ns3/pointer.h"
    31.9 +#include "ns3/log.h"
   31.10 +#include <string>
   31.11 +#include <fstream>
   31.12 +#include <iostream>
   31.13 +#include <unistd.h>
   31.14 +
   31.15 +NS_LOG_COMPONENT_DEFINE ("ConfigStore");
   31.16 +
   31.17 +namespace ns3 {
   31.18 +
   31.19 +NS_OBJECT_ENSURE_REGISTERED (ConfigStore);
   31.20 +
   31.21 +TypeId 
   31.22 +ConfigStore::GetTypeId (void)
   31.23 +{
   31.24 +  static TypeId tid = TypeId ("ns3::ConfigStore")
   31.25 +    .SetParent<ObjectBase> ()
   31.26 +    .AddAttribute ("LoadFilename", 
   31.27 +		   "The file where the configuration should be loaded from.",
   31.28 +		   StringValue (""),
   31.29 +		   MakeStringAccessor (&ConfigStore::m_loadFilename),
   31.30 +		   MakeStringChecker ())
   31.31 +    .AddAttribute ("StoreFilename", 
   31.32 +		   "The file where the configuration should be stored to.",
   31.33 +		   StringValue (""),
   31.34 +		   MakeStringAccessor (&ConfigStore::m_storeFilename),
   31.35 +		   MakeStringChecker ())
   31.36 +    ;
   31.37 +  return tid;
   31.38 +}
   31.39 +TypeId 
   31.40 +ConfigStore::GetInstanceTypeId (void) const
   31.41 +{
   31.42 +  return GetTypeId ();
   31.43 +}
   31.44 +
   31.45 +
   31.46 +ConfigStore::ConfigStore ()
   31.47 +{
   31.48 +  ObjectBase::ConstructSelf (AttributeList ());
   31.49 +}
   31.50 +
   31.51 +void 
   31.52 +ConfigStore::LoadFrom (std::string filename)
   31.53 +{
   31.54 +  std::ifstream is;
   31.55 +  is.open (filename.c_str (), std::ios::in);
   31.56 +  std::string path, value;
   31.57 +  while (is.good())
   31.58 +    {
   31.59 +      is >> path >> value;
   31.60 +      NS_LOG_DEBUG (path << "=" << value);
   31.61 +      Config::Set (path, StringValue (value));
   31.62 +    }
   31.63 +}
   31.64 +void 
   31.65 +ConfigStore::StoreTo (std::string filename)
   31.66 +{
   31.67 +  std::ofstream os;
   31.68 +  os.open (filename.c_str (), std::ios::out);
   31.69 +  for (uint32_t i = 0; i < Config::GetRootNamespaceObjectN (); ++i)
   31.70 +    {
   31.71 +      Ptr<Object> object = Config::GetRootNamespaceObject (i);
   31.72 +      Store (os, object);
   31.73 +    }
   31.74 +  os.close ();
   31.75 +  NS_ASSERT (m_currentPath.empty ());
   31.76 +  NS_ASSERT (m_examined.empty ());
   31.77 +  exit (0);
   31.78 +}
   31.79 +
   31.80 +bool
   31.81 +ConfigStore::IsExamined (Ptr<const Object> object)
   31.82 +{
   31.83 +  for (uint32_t i = 0; i < m_examined.size (); ++i)
   31.84 +    {
   31.85 +      if (object == m_examined[i])
   31.86 +	{
   31.87 +	  return true;
   31.88 +	}
   31.89 +    }
   31.90 +  return false;
   31.91 +}
   31.92 +
   31.93 +std::string
   31.94 +ConfigStore::GetCurrentPath (std::string attr) const
   31.95 +{
   31.96 +  std::ostringstream oss;
   31.97 +  for (uint32_t i = 0; i < m_currentPath.size (); ++i)
   31.98 +    {
   31.99 +      oss << "/" << m_currentPath[i];
  31.100 +    }
  31.101 +  oss << "/" << attr;
  31.102 +  return oss.str ();
  31.103 +}
  31.104 +
  31.105 +void
  31.106 +ConfigStore::Store (std::ostream &os, Ptr<const Object> object)
  31.107 +{
  31.108 +  if (IsExamined (object))
  31.109 +    {
  31.110 +      return;
  31.111 +    }
  31.112 +  TypeId tid = object->GetInstanceTypeId ();
  31.113 +  m_currentPath.push_back ("$" + tid.GetName ());
  31.114 +  NS_LOG_DEBUG ("store " << tid.GetName ());
  31.115 +  for (uint32_t i = 0; i < tid.GetAttributeN (); ++i)
  31.116 +    {
  31.117 +      Ptr<const AttributeChecker> checker = tid.GetAttributeChecker (i);
  31.118 +      const PointerChecker *ptrChecker = dynamic_cast<const PointerChecker *> (PeekPointer (checker));
  31.119 +      if (ptrChecker != 0)
  31.120 +	{
  31.121 +	  NS_LOG_DEBUG ("pointer attribute " << tid.GetAttributeName (i));
  31.122 +	  PointerValue ptr;
  31.123 +	  object->GetAttribute (tid.GetAttributeName (i), ptr);
  31.124 +	  Ptr<const Object> tmp = ptr.Get<Object> ();
  31.125 +	  if (tmp != 0)
  31.126 +	    {
  31.127 +	      m_currentPath.push_back (tid.GetAttributeName (i));
  31.128 +	      m_examined.push_back (object);
  31.129 +	      Store (os, tmp);
  31.130 +	      m_examined.pop_back ();
  31.131 +	      m_currentPath.pop_back ();
  31.132 +	    }
  31.133 +	  continue;
  31.134 +	}
  31.135 +      // attempt to cast to an object vector.
  31.136 +      const ObjectVectorChecker *vectorChecker = dynamic_cast<const ObjectVectorChecker *> (PeekPointer (checker));
  31.137 +      if (vectorChecker != 0)
  31.138 +	{
  31.139 +	  NS_LOG_DEBUG ("vector attribute " << tid.GetAttributeName (i));
  31.140 +	  ObjectVectorValue vector;
  31.141 +	  object->GetAttribute (tid.GetAttributeName (i), vector);
  31.142 +	  for (uint32_t j = 0; j < vector.GetN (); ++j)
  31.143 +	    {
  31.144 +	      NS_LOG_DEBUG ("vector attribute item " << j);
  31.145 +	      Ptr<const Object> tmp = vector.Get (j);
  31.146 +	      std::ostringstream oss;
  31.147 +	      oss << tid.GetAttributeName (i) << "/" << j;
  31.148 +	      m_currentPath.push_back (oss.str ());
  31.149 +	      m_examined.push_back (object);
  31.150 +	      Store (os, tmp);
  31.151 +	      m_examined.pop_back ();
  31.152 +	      m_currentPath.pop_back ();
  31.153 +	    }
  31.154 +	  continue;
  31.155 +	}
  31.156 +      uint32_t flags = tid.GetAttributeFlags (i);
  31.157 +      Ptr<const AttributeAccessor> accessor = tid.GetAttributeAccessor (i);
  31.158 +      if ((flags & TypeId::ATTR_GET) && accessor->HasGetter () &&
  31.159 +	  (flags & TypeId::ATTR_SET) && accessor->HasSetter ())
  31.160 +	{
  31.161 +	  StringValue str;
  31.162 +	  object->GetAttribute (tid.GetAttributeName (i), str);
  31.163 +	  os << GetCurrentPath (tid.GetAttributeName (i)) << " " << str.Get () << std::endl;
  31.164 +	}
  31.165 +      else
  31.166 +	{
  31.167 +	  NS_LOG_DEBUG ("could not store " << tid.GetAttributeName (i));
  31.168 +	}
  31.169 +    }
  31.170 +  Object::AggregateIterator iter = object->GetAggregateIterator ();
  31.171 +  bool recursiveAggregate = false;
  31.172 +  while (iter.HasNext ())
  31.173 +    {
  31.174 +      Ptr<const Object> tmp = iter.Next ();
  31.175 +      if (IsExamined (tmp))
  31.176 +	{
  31.177 +	  recursiveAggregate = true;
  31.178 +	}
  31.179 +    }
  31.180 +  if (!recursiveAggregate)
  31.181 +    {
  31.182 +      iter = object->GetAggregateIterator ();
  31.183 +      while (iter.HasNext ())
  31.184 +	{
  31.185 +	  Ptr<const Object> tmp = iter.Next ();
  31.186 +	  m_examined.push_back (object);
  31.187 +	  Store (os, tmp);
  31.188 +	  m_examined.pop_back ();
  31.189 +	}
  31.190 +    }
  31.191 +  m_currentPath.pop_back ();
  31.192 +}
  31.193 +
  31.194 +
  31.195 +void 
  31.196 +ConfigStore::Configure (void)
  31.197 +{
  31.198 +  if (m_loadFilename != "")
  31.199 +    {
  31.200 +      LoadFrom (m_loadFilename);
  31.201 +    }
  31.202 +  if (m_storeFilename != "")
  31.203 +    {
  31.204 +      StoreTo (m_storeFilename);
  31.205 +    }
  31.206 +}
  31.207 +
  31.208 +} // namespace ns3
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/src/contrib/config-store.h	Mon Apr 21 09:04:08 2008 -0700
    32.3 @@ -0,0 +1,44 @@
    32.4 +#ifndef CONFIG_STORE_H
    32.5 +#define CONFIG_STORE_H
    32.6 +
    32.7 +#include "ns3/object-base.h"
    32.8 +#include "ns3/object.h"
    32.9 +#include <vector>
   32.10 +
   32.11 +namespace ns3 {
   32.12 +
   32.13 +/**
   32.14 + * \brief Store and load simulation attribute configuration
   32.15 + *
   32.16 + */
   32.17 +class ConfigStore : public ObjectBase
   32.18 +{
   32.19 +public:
   32.20 +  static TypeId GetTypeId (void);
   32.21 +  virtual TypeId GetInstanceTypeId (void) const;
   32.22 +
   32.23 +  ConfigStore ();
   32.24 +
   32.25 +  /**
   32.26 +   * Depending on which attribute was set:
   32.27 +   *  - Store simulation configuration in file and exit
   32.28 +   *  - Load simulation configuration from file and proceed.
   32.29 +   */
   32.30 +  void Configure (void);
   32.31 +
   32.32 +private:
   32.33 +  void LoadFrom (std::string filename);
   32.34 +  void StoreTo (std::string filename);
   32.35 +  void Store (std::ostream &os, Ptr<const Object> object);
   32.36 +  bool IsExamined (Ptr<const Object> object);
   32.37 +  std::string GetCurrentPath (std::string attr) const;
   32.38 +
   32.39 +  std::string m_loadFilename;
   32.40 +  std::string m_storeFilename;
   32.41 +  std::vector<Ptr<const Object> > m_examined;
   32.42 +  std::vector<std::string> m_currentPath;
   32.43 +};
   32.44 +
   32.45 +}  // namespace ns3
   32.46 +
   32.47 +#endif /* CONFIG_STORE_H */
    33.1 --- a/src/contrib/wscript	Mon Apr 21 08:58:23 2008 -0700
    33.2 +++ b/src/contrib/wscript	Mon Apr 21 09:04:08 2008 -0700
    33.3 @@ -6,6 +6,7 @@
    33.4          'event-garbage-collector.cc',
    33.5          'gnuplot.cc',
    33.6          'delay-jitter-estimation.cc',
    33.7 +        'config-store.cc',
    33.8          ]
    33.9  
   33.10      headers = bld.create_obj('ns3header')
   33.11 @@ -14,4 +15,5 @@
   33.12          'event-garbage-collector.h',
   33.13          'gnuplot.h',
   33.14          'delay-jitter-estimation.h',
   33.15 +        'config-store.h',
   33.16          ]
    34.1 --- a/src/core/attribute-accessor-helper.h	Mon Apr 21 08:58:23 2008 -0700
    34.2 +++ b/src/core/attribute-accessor-helper.h	Mon Apr 21 09:04:08 2008 -0700
    34.3 @@ -48,8 +48,8 @@
    34.4  public:
    34.5    AccessorHelper () {}
    34.6  
    34.7 -  virtual bool Set (ObjectBase * object, Attribute val) const {
    34.8 -    const U *value = val.DynCast<const U*> ();
    34.9 +  virtual bool Set (ObjectBase * object, const AttributeValue & val) const {
   34.10 +    const U *value = dynamic_cast<const U *> (&val);
   34.11      if (value == 0)
   34.12        {
   34.13  	return false;
   34.14 @@ -62,8 +62,8 @@
   34.15      return DoSet (obj, value);
   34.16    }
   34.17  
   34.18 -  virtual bool Get (const ObjectBase * object, Attribute val) const {
   34.19 -    U *value = val.DynCast<U*> ();
   34.20 +  virtual bool Get (const ObjectBase * object, AttributeValue &val) const {
   34.21 +    U *value = dynamic_cast<U *> (&val);
   34.22      if (value == 0)
   34.23        {
   34.24  	return false;
   34.25 @@ -76,7 +76,6 @@
   34.26      return DoGet (obj, value);
   34.27    }
   34.28  
   34.29 -
   34.30  private:
   34.31    virtual bool DoSet (T *object, const U *v) const = 0;
   34.32    virtual bool DoGet (const T *object, U *v) const = 0;
   34.33 @@ -102,6 +101,12 @@
   34.34  	v->Set (object->*m_memberVariable);
   34.35  	return true;
   34.36        }
   34.37 +      virtual bool HasGetter (void) const {
   34.38 +        return true;
   34.39 +      }
   34.40 +      virtual bool HasSetter (void) const {
   34.41 +        return true;
   34.42 +      }
   34.43        
   34.44        U T::*m_memberVariable;
   34.45      };
   34.46 @@ -127,6 +132,12 @@
   34.47  	v->Set ((object->*m_getter) ());
   34.48  	return true;
   34.49        }
   34.50 +      virtual bool HasGetter (void) const {
   34.51 +        return true;
   34.52 +      }
   34.53 +      virtual bool HasSetter (void) const {
   34.54 +        return false;
   34.55 +      }
   34.56        U (T::*m_getter) (void) const;
   34.57      };
   34.58    return Ptr<const AttributeAccessor> (new MemberMethod (getter), false);
   34.59 @@ -152,6 +163,12 @@
   34.60        virtual bool DoGet (const T *object, V *v) const {
   34.61  	return false;
   34.62        }
   34.63 +      virtual bool HasGetter (void) const {
   34.64 +        return false;
   34.65 +      }
   34.66 +      virtual bool HasSetter (void) const {
   34.67 +        return true;
   34.68 +      }
   34.69        void (T::*m_setter) (U);
   34.70      };
   34.71    return Ptr<const AttributeAccessor> (new MemberMethod (setter), false);
   34.72 @@ -180,6 +197,12 @@
   34.73  	v->Set ((object->*m_getter) ());
   34.74  	return true;
   34.75        }
   34.76 +      virtual bool HasGetter (void) const {
   34.77 +        return true;
   34.78 +      }
   34.79 +      virtual bool HasSetter (void) const {
   34.80 +        return true;
   34.81 +      }
   34.82        void (T::*m_setter) (U);
   34.83        V (T::*m_getter) (void) const;
   34.84      };
    35.1 --- a/src/core/attribute-helper.h	Mon Apr 21 08:58:23 2008 -0700
    35.2 +++ b/src/core/attribute-helper.h	Mon Apr 21 09:04:08 2008 -0700
    35.3 @@ -29,28 +29,40 @@
    35.4  
    35.5  template <typename T, typename BASE>
    35.6  Ptr<AttributeChecker>
    35.7 -MakeSimpleAttributeChecker (std::string name)
    35.8 +MakeSimpleAttributeChecker (std::string name, std::string underlying)
    35.9  {
   35.10    struct SimpleAttributeChecker : public BASE
   35.11    {
   35.12 -    virtual bool Check (Attribute value) const {
   35.13 -      return value.DynCast<const T *> () != 0;
   35.14 +    virtual bool Check (const AttributeValue &value) const {
   35.15 +      return dynamic_cast<const T *> (&value) != 0;
   35.16      }
   35.17 -    virtual std::string GetType (void) const {
   35.18 +    virtual std::string GetValueTypeName (void) const {
   35.19        return m_type;
   35.20      }
   35.21 -    virtual bool HasTypeConstraints (void) const {
   35.22 -      return false;
   35.23 +    virtual bool HasUnderlyingTypeInformation (void) const {
   35.24 +      return true;
   35.25      }
   35.26 -    virtual std::string GetTypeConstraints (void) const {
   35.27 -      return "";
   35.28 +    virtual std::string GetUnderlyingTypeInformation (void) const {
   35.29 +      return m_underlying;
   35.30      }
   35.31 -    virtual Attribute Create (void) const {
   35.32 -      return Attribute::Create<T> ();
   35.33 +    virtual Ptr<AttributeValue> Create (void) const {
   35.34 +      return ns3::Create<T> ();
   35.35 +    }
   35.36 +    virtual bool Copy (const AttributeValue &source, AttributeValue &destination) const {
   35.37 +      const T *src = dynamic_cast<const T *> (&source);
   35.38 +      T *dst = dynamic_cast<T *> (&destination);
   35.39 +      if (src == 0 || dst == 0)
   35.40 +        {
   35.41 +          return false;
   35.42 +        }
   35.43 +      *dst = *src;
   35.44 +      return true;
   35.45      }
   35.46      std::string m_type;
   35.47 +    std::string m_underlying;
   35.48    } *checker = new SimpleAttributeChecker ();
   35.49    checker->m_type = name;
   35.50 +  checker->m_underlying = underlying;
   35.51    return Ptr<AttributeChecker> (checker, false);
   35.52  }
   35.53  
   35.54 @@ -98,6 +110,22 @@
   35.55      return MakeAccessorHelper<type##Value> (a1, a2);			\
   35.56    }
   35.57  
   35.58 +#define ATTRIBUTE_VALUE_DEFINE_WITH_NAME(type,name)                     \
   35.59 +  class name##Value : public AttributeValue				\
   35.60 +  {									\
   35.61 +  public:								\
   35.62 +    name##Value ();							\
   35.63 +    name##Value (const type &value);					\
   35.64 +    void Set (const type &value);					\
   35.65 +    type Get (void) const;						\
   35.66 +    virtual Ptr<AttributeValue> Copy (void) const;                      \
   35.67 +    virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const; \
   35.68 +    virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker); \
   35.69 +  private:								\
   35.70 +    type m_value;							\
   35.71 +  };
   35.72 +
   35.73 +
   35.74  /**
   35.75   * \ingroup AttributeHelper
   35.76   * \param type the name of the class.
   35.77 @@ -106,21 +134,8 @@
   35.78   * This macro is typically invoked in a class header.
   35.79   */
   35.80  #define ATTRIBUTE_VALUE_DEFINE(type)					\
   35.81 -  class type##Value : public AttributeValue				\
   35.82 -  {									\
   35.83 -  public:								\
   35.84 -    type##Value ();							\
   35.85 -    type##Value (const type &value);					\
   35.86 -    void Set (const type &value);					\
   35.87 -    type Get (void) const;						\
   35.88 -    virtual Attribute Copy (void) const;				\
   35.89 -    virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const; \
   35.90 -    virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker); \
   35.91 -    type##Value (Attribute value);					\
   35.92 -    operator Attribute () const;					\
   35.93 -  private:								\
   35.94 -    type m_value;							\
   35.95 -  };
   35.96 +  ATTRIBUTE_VALUE_DEFINE_WITH_NAME (type,type)
   35.97 +
   35.98  
   35.99  /**
  35.100   * \ingroup AttributeHelper
  35.101 @@ -130,9 +145,7 @@
  35.102   * from instances of type Attribute.
  35.103   * Typically invoked from xxx.h.
  35.104   */
  35.105 -#define ATTRIBUTE_CONVERTER_DEFINE(type)	\
  35.106 -  type (Attribute value);			\
  35.107 -  operator Attribute () const;
  35.108 +#define ATTRIBUTE_CONVERTER_DEFINE(type)
  35.109  
  35.110  /**
  35.111   * \ingroup AttributeHelper
  35.112 @@ -146,42 +159,34 @@
  35.113    class type##Checker : public AttributeChecker {};		\
  35.114    Ptr<const AttributeChecker> Make##type##Checker (void);	\
  35.115  
  35.116 -/**
  35.117 - * \ingroup AttributeHelper
  35.118 - * \param type the name of the class
  35.119 - *
  35.120 - * This macro implements the XXXValue class (without the 
  35.121 - * XXXValue::SerializeToString and XXXValue::DeserializeFromString 
  35.122 - * methods).
  35.123 - * Typically invoked from xxx.cc.
  35.124 - */
  35.125 -#define ATTRIBUTE_VALUE_IMPLEMENT_NO_SERIALIZE(type)			\
  35.126 -  type##Value::type##Value ()						\
  35.127 +
  35.128 +#define ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME(type,name)                  \
  35.129 +  name##Value::name##Value ()						\
  35.130      : m_value () {}							\
  35.131 -  type##Value::type##Value (const type &value)				\
  35.132 +  name##Value::name##Value (const type &value)				\
  35.133    : m_value (value) {}							\
  35.134 -  void type##Value::Set (const type &v) {				\
  35.135 +  void name##Value::Set (const type &v) {				\
  35.136      m_value = v;							\
  35.137    }									\
  35.138 -  type type##Value::Get (void) const {					\
  35.139 +  type name##Value::Get (void) const {					\
  35.140      return m_value;							\
  35.141    }									\
  35.142 -  Attribute								\
  35.143 -  type##Value::Copy (void) const {					\
  35.144 -    return Attribute::Create<type##Value> (*this);			\
  35.145 +  Ptr<AttributeValue>                                                   \
  35.146 +  name##Value::Copy (void) const {					\
  35.147 +    return ns3::Create<name##Value> (*this);                            \
  35.148 +  }                                                                     \
  35.149 +  std::string								\
  35.150 +  name##Value::SerializeToString (Ptr<const AttributeChecker> checker) const { \
  35.151 +    std::ostringstream oss;						\
  35.152 +    oss << m_value;							\
  35.153 +    return oss.str ();							\
  35.154    }									\
  35.155 -  type##Value::type##Value (Attribute value)				\
  35.156 -  {									\
  35.157 -    type##Value *v = value.DynCast<type##Value *> ();			\
  35.158 -    if (v == 0)								\
  35.159 -      {									\
  35.160 -	NS_FATAL_ERROR ("Unexpected type of value. Expected \"" << #type << "Value\""); \
  35.161 -      }									\
  35.162 -    m_value = v->Get ();						\
  35.163 -  }									\
  35.164 -  type##Value::operator Attribute () const				\
  35.165 -  {									\
  35.166 -    return Attribute::Create<type##Value> (*this);			\
  35.167 +  bool									\
  35.168 +  name##Value::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker) { \
  35.169 +    std::istringstream iss;						\
  35.170 +    iss.str (value);							\
  35.171 +    iss >> m_value;							\
  35.172 +    return !iss.bad () && !iss.fail ();					\
  35.173    }
  35.174  
  35.175  /**
  35.176 @@ -194,20 +199,8 @@
  35.177   * Typically invoked from xxx.cc.
  35.178   */
  35.179  #define ATTRIBUTE_VALUE_IMPLEMENT(type)					\
  35.180 -  std::string								\
  35.181 -  type##Value::SerializeToString (Ptr<const AttributeChecker> checker) const { \
  35.182 -    std::ostringstream oss;						\
  35.183 -    oss << m_value;							\
  35.184 -    return oss.str ();							\
  35.185 -  }									\
  35.186 -  bool									\
  35.187 -  type##Value::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker) { \
  35.188 -    std::istringstream iss;						\
  35.189 -    iss.str (value);							\
  35.190 -    iss >> m_value;							\
  35.191 -    return !iss.bad () && !iss.fail ();					\
  35.192 -  }									\
  35.193 -  ATTRIBUTE_VALUE_IMPLEMENT_NO_SERIALIZE (type)
  35.194 +  ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME(type,type)
  35.195 +
  35.196  
  35.197  /**
  35.198   * \ingroup AttributeHelper
  35.199 @@ -219,9 +212,16 @@
  35.200  #define ATTRIBUTE_CHECKER_IMPLEMENT(type)				\
  35.201    Ptr<const AttributeChecker> Make##type##Checker (void)		\
  35.202    {									\
  35.203 -    return MakeSimpleAttributeChecker<type##Value,type##Checker> (#type);	\
  35.204 +    return MakeSimpleAttributeChecker<type##Value,type##Checker> (#type "Value", #type); \
  35.205    }									\
  35.206  
  35.207 +#define ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME(type,name)                    \
  35.208 +  Ptr<const AttributeChecker> Make##type##Checker (void)		\
  35.209 +  {									\
  35.210 +    return MakeSimpleAttributeChecker<type##Value,type##Checker> (#type "Value", name); \
  35.211 +  }									\
  35.212 +
  35.213 +
  35.214  /**
  35.215   * \ingroup AttributeHelper
  35.216   * \param type the name of the class
  35.217 @@ -229,20 +229,7 @@
  35.218   * This macro implements the conversion operators to and from
  35.219   * instances of type Attribute. Typically invoked from xxx.cc.
  35.220   */
  35.221 -#define ATTRIBUTE_CONVERTER_IMPLEMENT(type)				\
  35.222 -  type::type (Attribute value)						\
  35.223 -  {									\
  35.224 -    const type##Value *v = value.DynCast<const type##Value *> ();	\
  35.225 -    if (v == 0)								\
  35.226 -      {									\
  35.227 -      NS_FATAL_ERROR ("Unexpected type of value. Expected \"" << #type << "Value\""); \
  35.228 -      }									\
  35.229 -    *this = v->Get ();							\
  35.230 -  }									\
  35.231 -  type::operator Attribute () const					\
  35.232 -  {									\
  35.233 -    return Attribute::Create<type##Value> (*this);			\
  35.234 -  }
  35.235 +#define ATTRIBUTE_CONVERTER_IMPLEMENT(type)
  35.236  
  35.237  
  35.238  /**
  35.239 @@ -252,8 +239,7 @@
  35.240   * This macro should be invoked from a public section of the class
  35.241   * declaration.
  35.242   */
  35.243 -#define ATTRIBUTE_HELPER_HEADER_1(type) \
  35.244 -  ATTRIBUTE_CONVERTER_DEFINE (type)
  35.245 +#define ATTRIBUTE_HELPER_HEADER_1(type)
  35.246  
  35.247  /**
  35.248   * \ingroup AttributeHelper
    36.1 --- a/src/core/attribute-list.cc	Mon Apr 21 08:58:23 2008 -0700
    36.2 +++ b/src/core/attribute-list.cc	Mon Apr 21 09:04:08 2008 -0700
    36.3 @@ -36,7 +36,7 @@
    36.4      {
    36.5        struct Attr attr;
    36.6        attr.checker = i->checker;
    36.7 -      attr.value = i->value.Copy ();
    36.8 +      attr.value = i->value->Copy ();
    36.9        m_attributes.push_back (attr);
   36.10      }
   36.11  }
   36.12 @@ -48,7 +48,7 @@
   36.13      {
   36.14        struct Attr attr;
   36.15        attr.checker = i->checker;
   36.16 -      attr.value = i->value.Copy ();
   36.17 +      attr.value = i->value->Copy ();
   36.18        m_attributes.push_back (attr);
   36.19      }
   36.20    return *this;
   36.21 @@ -59,7 +59,7 @@
   36.22  }
   36.23  
   36.24  void
   36.25 -AttributeList::Set (std::string name, Attribute value)
   36.26 +AttributeList::Set (std::string name, const AttributeValue &value)
   36.27  {
   36.28    struct TypeId::AttributeInfo info;
   36.29    bool ok = TypeId::LookupAttributeByFullName (name, &info);
   36.30 @@ -74,7 +74,7 @@
   36.31      }
   36.32  }
   36.33  bool 
   36.34 -AttributeList::SetFailSafe (std::string name, Attribute value)
   36.35 +AttributeList::SetFailSafe (std::string name, const AttributeValue &value)
   36.36  {
   36.37    struct TypeId::AttributeInfo info;
   36.38    bool ok = TypeId::LookupAttributeByFullName (name, &info);
   36.39 @@ -86,7 +86,7 @@
   36.40    return ok;
   36.41  }
   36.42  void
   36.43 -AttributeList::SetWithTid (TypeId tid, std::string name, Attribute value)
   36.44 +AttributeList::SetWithTid (TypeId tid, std::string name, const AttributeValue & value)
   36.45  {
   36.46    struct TypeId::AttributeInfo info;
   36.47    bool ok = tid.LookupAttributeByName (name, &info);
   36.48 @@ -102,7 +102,7 @@
   36.49  }
   36.50  
   36.51  void
   36.52 -AttributeList::DoSetOne (Ptr<const AttributeChecker> checker, Attribute value)
   36.53 +AttributeList::DoSetOne (Ptr<const AttributeChecker> checker, const AttributeValue &value)
   36.54  {
   36.55    // get rid of any previous value stored in this
   36.56    // vector of values.
   36.57 @@ -121,36 +121,38 @@
   36.58    m_attributes.push_back (attr);
   36.59  }
   36.60  bool
   36.61 -AttributeList::DoSet (struct TypeId::AttributeInfo *info, Attribute value)
   36.62 +AttributeList::DoSet (struct TypeId::AttributeInfo *info, const AttributeValue &value)
   36.63  {
   36.64    if (info->checker == 0)
   36.65      {
   36.66        return false;
   36.67      }
   36.68    bool ok = info->checker->Check (value);
   36.69 +  if (ok)
   36.70 +    {
   36.71 +      DoSetOne (info->checker, value);
   36.72 +      return true;
   36.73 +    }
   36.74 +
   36.75 +  // attempt to convert to string.
   36.76 +  const StringValue *str = dynamic_cast<const StringValue *> (&value);
   36.77 +  if (str == 0)
   36.78 +    {
   36.79 +      return false;
   36.80 +    }
   36.81 +  // attempt to convert back to value.
   36.82 +  Ptr<AttributeValue> v = info->checker->Create ();
   36.83 +  ok = v->DeserializeFromString (str->Get (), info->checker);
   36.84    if (!ok)
   36.85      {
   36.86 -      // attempt to convert to string.
   36.87 -      const StringValue *str = value.DynCast<const StringValue *> ();
   36.88 -      if (str == 0)
   36.89 -        {
   36.90 -          return false;
   36.91 -        }
   36.92 -      // attempt to convert back to value.
   36.93 -      Attribute v = info->checker->Create ();
   36.94 -      ok = v.DeserializeFromString (str->Get ().Get (), info->checker);
   36.95 -      if (!ok)
   36.96 -        {
   36.97 -          return false;
   36.98 -        }
   36.99 -      ok = info->checker->Check (v);
  36.100 -      if (!ok)
  36.101 -        {
  36.102 -          return false;
  36.103 -        }
  36.104 -      value = v;
  36.105 +      return false;
  36.106      }
  36.107 -  DoSetOne (info->checker, value);
  36.108 +  ok = info->checker->Check (*v);
  36.109 +  if (!ok)
  36.110 +    {
  36.111 +      return false;
  36.112 +    }
  36.113 +  DoSetOne (info->checker, *v);
  36.114    return true;
  36.115  }
  36.116  void 
  36.117 @@ -187,10 +189,11 @@
  36.118  AttributeList::SerializeToString (void) const
  36.119  {
  36.120    std::ostringstream oss;
  36.121 -  for (Attrs::const_iterator i = m_attributes.begin (); i != m_attributes.end (); i++)
  36.122 +  for (Attrs::const_iterator i = m_attributes.begin (); i != m_attributes.end ();)
  36.123      {
  36.124        std::string name = LookupAttributeFullNameByChecker (i->checker);
  36.125 -      oss << name << "=" << i->value.SerializeToString (i->checker);
  36.126 +      oss << name << "=" << i->value->SerializeToString (i->checker);
  36.127 +      i++;
  36.128        if (i != m_attributes.end ())
  36.129          {
  36.130            oss << "|";
  36.131 @@ -235,8 +238,8 @@
  36.132                  value = str.substr (equal+1, next - (equal+1));
  36.133                  cur++;
  36.134                }
  36.135 -            Attribute val = info.checker->Create ();
  36.136 -            bool ok = val.DeserializeFromString (value, info.checker);
  36.137 +            Ptr<AttributeValue> val = info.checker->Create ();
  36.138 +            bool ok = val->DeserializeFromString (value, info.checker);
  36.139              if (!ok)
  36.140                {
  36.141                  // XXX invalid value
  36.142 @@ -244,7 +247,7 @@
  36.143                }
  36.144              else
  36.145                {
  36.146 -                DoSetOne (info.checker, val);
  36.147 +                DoSetOne (info.checker, *val);
  36.148                }
  36.149            }
  36.150        }
    37.1 --- a/src/core/attribute-list.h	Mon Apr 21 08:58:23 2008 -0700
    37.2 +++ b/src/core/attribute-list.h	Mon Apr 21 09:04:08 2008 -0700
    37.3 @@ -48,14 +48,14 @@
    37.4     * value of that attribute. If any of these checks fails,
    37.5     * the program terminates with a message.
    37.6     */
    37.7 -  void Set (std::string name, Attribute value);
    37.8 +  void Set (std::string name, const AttributeValue &value);
    37.9    /**
   37.10     * \param name the full name of the attribute to set
   37.11     * \param value the value to set
   37.12     * \returns true if the requested attribute exists and could be
   37.13     *          stored, false otherwise.
   37.14     */
   37.15 -  bool SetFailSafe (std::string name, Attribute value);
   37.16 +  bool SetFailSafe (std::string name, const AttributeValue &value);
   37.17    /**
   37.18     * \param tid the TypeId associated to this attribute
   37.19     * \param name the name (not full!) of the attribute
   37.20 @@ -66,7 +66,7 @@
   37.21     * value of that attribute. If any of these checks fails,
   37.22     * the program terminates with a message.
   37.23     */
   37.24 -  void SetWithTid (TypeId tid, std::string name, Attribute value);
   37.25 +  void SetWithTid (TypeId tid, std::string name, const AttributeValue &value);
   37.26  
   37.27    /**
   37.28     * Clear the content of this instance.
   37.29 @@ -92,7 +92,7 @@
   37.30    friend class ObjectBase;
   37.31    struct Attr {
   37.32      Ptr<const AttributeChecker> checker;
   37.33 -    Attribute value;
   37.34 +    Ptr<const AttributeValue> value;
   37.35    };
   37.36    typedef std::vector<struct Attr> Attrs;
   37.37    typedef Attrs::iterator Iterator;
   37.38 @@ -100,8 +100,8 @@
   37.39  
   37.40  
   37.41  
   37.42 -  bool DoSet (struct TypeId::AttributeInfo *info, Attribute param);
   37.43 -  void DoSetOne (Ptr<const AttributeChecker> checker, Attribute param);
   37.44 +  bool DoSet (struct TypeId::AttributeInfo *info, const AttributeValue &param);
   37.45 +  void DoSetOne (Ptr<const AttributeChecker> checker, const AttributeValue &param);
   37.46    std::string LookupAttributeFullNameByChecker (Ptr<const AttributeChecker> checker) const;
   37.47  
   37.48    Attrs m_attributes;
    38.1 --- a/src/core/attribute-test.cc	Mon Apr 21 08:58:23 2008 -0700
    38.2 +++ b/src/core/attribute-test.cc	Mon Apr 21 09:04:08 2008 -0700
    38.3 @@ -30,6 +30,7 @@
    38.4  #include "object-vector.h"
    38.5  #include "traced-value.h"
    38.6  #include "trace-source-accessor.h"
    38.7 +#include "pointer.h"
    38.8  
    38.9  namespace ns3 {
   38.10  
   38.11 @@ -37,7 +38,6 @@
   38.12  {
   38.13  public:
   38.14    ValueClassTest () {}
   38.15 -  ATTRIBUTE_HELPER_HEADER_1 (ValueClassTest);
   38.16  private:
   38.17    int m_v;
   38.18  };
   38.19 @@ -90,7 +90,7 @@
   38.20  class AttributeObjectTest : public Object
   38.21  {
   38.22  public:
   38.23 -  enum TestEnum {
   38.24 +  enum Test_e {
   38.25      TEST_A,
   38.26      TEST_B,
   38.27      TEST_C
   38.28 @@ -100,69 +100,65 @@
   38.29        .SetParent<Object> ()
   38.30        .HideFromDocumentation ()
   38.31        .AddAttribute ("TestBoolName", "help text",
   38.32 -		     Boolean (false),
   38.33 +		     BooleanValue (false),
   38.34  		     MakeBooleanAccessor (&AttributeObjectTest::m_boolTest),
   38.35  		     MakeBooleanChecker ())
   38.36        .AddAttribute ("TestBoolA", "help text",
   38.37 -		     Boolean (false),
   38.38 +		     BooleanValue (false),
   38.39  		     MakeBooleanAccessor (&AttributeObjectTest::DoSetTestB,
   38.40  					   &AttributeObjectTest::DoGetTestB),
   38.41  		     MakeBooleanChecker ())
   38.42 -      .AddAttribute ("TestPtr", "help text", 
   38.43 -		     Ptr<Derived> (0),
   38.44 -		     MakePtrAccessor (&AttributeObjectTest::m_derived),
   38.45 -		     MakePtrChecker<Derived> ())
   38.46        .AddAttribute ("TestInt16", "help text",
   38.47 -		     Integer (-2),
   38.48 +		     IntegerValue (-2),
   38.49  		     MakeIntegerAccessor (&AttributeObjectTest::m_int16),
   38.50  		     MakeIntegerChecker<int16_t> ())
   38.51        .AddAttribute ("TestInt16WithBounds", "help text",
   38.52 -		     Integer (-2),
   38.53 +		     IntegerValue (-2),
   38.54  		     MakeIntegerAccessor (&AttributeObjectTest::m_int16WithBounds),
   38.55  		     MakeIntegerChecker<int16_t> (-5, 10))
   38.56        .AddAttribute ("TestInt16SetGet", "help text",
   38.57 -		     Integer (6),
   38.58 +		     IntegerValue (6),
   38.59  		     MakeIntegerAccessor (&AttributeObjectTest::DoSetInt16,
   38.60  				       &AttributeObjectTest::DoGetInt16),
   38.61  		     MakeIntegerChecker<int16_t> ())
   38.62        .AddAttribute ("TestUint8", "help text",
   38.63 -		     Uinteger (1),
   38.64 +		     UintegerValue (1),
   38.65  		     MakeUintegerAccessor (&AttributeObjectTest::m_uint8),
   38.66  		     MakeUintegerChecker<uint8_t> ())
   38.67        .AddAttribute ("TestEnum", "help text",
   38.68 -		     Enum (TEST_A),
   38.69 +		     EnumValue (TEST_A),
   38.70  		     MakeEnumAccessor (&AttributeObjectTest::m_enum),
   38.71  		     MakeEnumChecker (TEST_A, "TestA",
   38.72  				      TEST_B, "TestB",
   38.73  				      TEST_C, "TestC"))
   38.74        .AddAttribute ("TestRandom", "help text",
   38.75 -		     ConstantVariable (1.0),
   38.76 +		     RandomVariableValue (ConstantVariable (1.0)),
   38.77  		     MakeRandomVariableAccessor (&AttributeObjectTest::m_random),
   38.78  		     MakeRandomVariableChecker ())
   38.79        .AddAttribute ("TestFloat", "help text",
   38.80 -		     Double (-1.1),
   38.81 +		     DoubleValue (-1.1),
   38.82  		     MakeDoubleAccessor (&AttributeObjectTest::m_float),
   38.83  		     MakeDoubleChecker<float> ())
   38.84        .AddAttribute ("TestVector1", "help text",
   38.85 -		     ObjectVector (),
   38.86 +		     ObjectVectorValue (),
   38.87  		     MakeObjectVectorAccessor (&AttributeObjectTest::m_vector1),
   38.88 -		     MakeObjectVectorChecker ())
   38.89 +		     MakeObjectVectorChecker<Derived> ())
   38.90        .AddAttribute ("TestVector2", "help text",
   38.91 -		     ObjectVector (),
   38.92 +		     ObjectVectorValue (),
   38.93  		     MakeObjectVectorAccessor (&AttributeObjectTest::DoGetVectorN,
   38.94  						&AttributeObjectTest::DoGetVector),
   38.95 -		     MakeObjectVectorChecker ())
   38.96 +		     MakeObjectVectorChecker<Derived> ())
   38.97        .AddAttribute ("IntegerTraceSource1", "help text",
   38.98 -		     Integer (-2),
   38.99 +		     IntegerValue (-2),
  38.100  		     MakeIntegerAccessor (&AttributeObjectTest::m_intSrc1),
  38.101  		     MakeIntegerChecker<int8_t> ())
  38.102        .AddAttribute ("IntegerTraceSource2", "help text",
  38.103 -		     Integer (-2),
  38.104 +		     IntegerValue (-2),
  38.105  		     MakeIntegerAccessor (&AttributeObjectTest::DoSetIntSrc,
  38.106  					  &AttributeObjectTest::DoGetIntSrc),
  38.107  		     MakeIntegerChecker<int8_t> ())
  38.108        .AddAttribute ("ValueClassSource", "help text",
  38.109 -		     ValueClassTest (),
  38.110 +		     ValueClassTestValue (ValueClassTest ()),
  38.111  		     MakeValueClassTestAccessor (&AttributeObjectTest::m_valueSrc),
  38.112  		     MakeValueClassTestChecker ())
  38.113        .AddTraceSource ("Source1", "help test",
  38.114 @@ -171,6 +167,10 @@
  38.115  		       MakeTraceSourceAccessor (&AttributeObjectTest::m_cb))
  38.116        .AddTraceSource ("ValueSource", "help text",
  38.117  		       MakeTraceSourceAccessor (&AttributeObjectTest::m_valueSrc))
  38.118 +      .AddAttribute ("Pointer", "XXX",
  38.119 +                     PointerValue (),
  38.120 +                     MakePointerAccessor (&AttributeObjectTest::m_ptr),
  38.121 +                     MakePointerChecker<Derived> ())
  38.122        ;
  38.123          
  38.124      return tid;
  38.125 @@ -214,13 +214,12 @@
  38.126    }
  38.127    bool m_boolTestA;
  38.128    bool m_boolTest;
  38.129 -  Ptr<Derived> m_derived;
  38.130    int16_t m_int16;
  38.131    int16_t m_int16WithBounds;
  38.132    int16_t m_int16SetGet;
  38.133    uint8_t m_uint8;
  38.134    float m_float;
  38.135 -  enum TestEnum m_enum;
  38.136 +  enum Test_e m_enum;
  38.137    RandomVariable m_random;
  38.138    std::vector<Ptr<Derived> > m_vector1;
  38.139    std::vector<Ptr<Derived> > m_vector2;
  38.140 @@ -228,25 +227,24 @@
  38.141    TracedValue<int8_t> m_intSrc2;
  38.142    TracedCallback<double, int, float> m_cb;
  38.143    TracedValue<ValueClassTest> m_valueSrc;
  38.144 +  Ptr<Derived> m_ptr;
  38.145  };
  38.146  
  38.147  
  38.148 -#define CHECK_GET_STR(p,name,value)                             \
  38.149 -  {                                                             \
  38.150 -    std::string expected = value;                               \
  38.151 -    std::string got;                                            \
  38.152 -    bool ok = p->GetAttributeAsStringFailSafe (name, got);	\
  38.153 -    NS_TEST_ASSERT (ok);                                        \
  38.154 -    NS_TEST_ASSERT_EQUAL (got, expected);                       \
  38.155 +#define CHECK_GET_STR(p,name,value)                               \
  38.156 +  {                                                               \
  38.157 +    std::string expected = value;                                 \
  38.158 +    StringValue got;                                              \
  38.159 +    bool ok = p->GetAttributeFailSafe (name, got);                \
  38.160 +    NS_TEST_ASSERT (ok);                                          \
  38.161 +    NS_TEST_ASSERT_EQUAL (got.Get (), expected);                  \
  38.162    }
  38.163  #define CHECK_GET_PARAM(p,name,type,value)		\
  38.164    {							\
  38.165      const type expected = value;			\
  38.166 -    type got = value;					\
  38.167 -    Attribute v;                                        \
  38.168 -    bool ok = p->GetAttributeFailSafe (name, v);        \
  38.169 +    type got;                                           \
  38.170 +    bool ok = p->GetAttributeFailSafe (name, got);      \
  38.171      NS_TEST_ASSERT (ok);                                \
  38.172 -    got = v;                                            \
  38.173      NS_TEST_ASSERT_EQUAL (got.Get (), expected.Get ());	\
  38.174    }
  38.175  
  38.176 @@ -262,211 +260,199 @@
  38.177  
  38.178    AttributeList params;
  38.179    Ptr<AttributeObjectTest> p;
  38.180 -  NS_TEST_ASSERT (params.SetFailSafe ("ns3::AttributeObjectTest::TestBoolName", String ("false")));
  38.181 +  NS_TEST_ASSERT (params.SetFailSafe ("ns3::AttributeObjectTest::TestBoolName", StringValue ("false")));
  38.182    p = CreateObject<AttributeObjectTest> (params);
  38.183    CHECK_GET_STR (p, "TestBoolName", "false");
  38.184 -  CHECK_GET_PARAM (p, "TestBoolName", Boolean, false);
  38.185 +  CHECK_GET_PARAM (p, "TestBoolName", BooleanValue, false);
  38.186  
  38.187 -  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestBoolName", String ("true")));
  38.188 +  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestBoolName", StringValue ("true")));
  38.189    CHECK_GET_STR (p, "TestBoolName", "true");
  38.190 -  CHECK_GET_PARAM (p, "TestBoolName", Boolean, true);
  38.191 +  CHECK_GET_PARAM (p, "TestBoolName", BooleanValue, true);
  38.192  
  38.193 -  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestBoolName", Boolean (false)));
  38.194 +  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestBoolName", BooleanValue (false)));
  38.195    CHECK_GET_STR (p, "TestBoolName", "false");
  38.196 -  CHECK_GET_PARAM (p, "TestBoolName", Boolean, false);
  38.197 +  CHECK_GET_PARAM (p, "TestBoolName", BooleanValue, false);
  38.198  
  38.199 -  p = CreateObject<AttributeObjectTest> ("TestBoolName", String ("true"));
  38.200 +  p = CreateObject<AttributeObjectTest> ("TestBoolName", StringValue ("true"));
  38.201    CHECK_GET_STR (p, "TestBoolName", "true");
  38.202 -  CHECK_GET_PARAM (p, "TestBoolName", Boolean, true);
  38.203 +  CHECK_GET_PARAM (p, "TestBoolName", BooleanValue, true);
  38.204  
  38.205 -  p = CreateObject<AttributeObjectTest> ("TestBoolName", Boolean (true));
  38.206 +  p = CreateObject<AttributeObjectTest> ("TestBoolName", BooleanValue (true));
  38.207    CHECK_GET_STR (p, "TestBoolName", "true");
  38.208 -  CHECK_GET_PARAM (p, "TestBoolName", Boolean, true);
  38.209 +  CHECK_GET_PARAM (p, "TestBoolName", BooleanValue, true);
  38.210  
  38.211 -  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestBoolA", String ("false")));
  38.212 +  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestBoolA", StringValue ("false")));
  38.213    CHECK_GET_STR (p, "TestBoolA", "false");
  38.214 -  CHECK_GET_PARAM (p, "TestBoolA", Boolean, false);
  38.215 +  CHECK_GET_PARAM (p, "TestBoolA", BooleanValue, false);
  38.216  
  38.217 -  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestBoolA", String ("true")));
  38.218 +  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestBoolA", StringValue ("true")));
  38.219    CHECK_GET_STR (p, "TestBoolA", "true");
  38.220 -  CHECK_GET_PARAM (p, "TestBoolA", Boolean, true);
  38.221 +  CHECK_GET_PARAM (p, "TestBoolA", BooleanValue, true);
  38.222  
  38.223  
  38.224 -  Ptr<Derived> derived = p->GetAttribute ("TestPtr");
  38.225 -  NS_TEST_ASSERT (derived == 0);
  38.226 -  derived = Create<Derived> ();
  38.227 -  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestPtr", derived));
  38.228 -  Ptr<Derived> stored = p->GetAttribute ("TestPtr");
  38.229 -  NS_TEST_ASSERT (stored == derived);
  38.230 -  Ptr<Object> storedBase = p->GetAttribute ("TestPtr");
  38.231 -  NS_TEST_ASSERT (stored == storedBase);
  38.232 -  Ptr<AttributeObjectTest> x = p->GetAttribute ("TestPtr");
  38.233 -  NS_TEST_ASSERT (x == 0);
  38.234 -
  38.235 -  p = CreateObject<AttributeObjectTest> ("TestPtr", Create<Derived> ());
  38.236 -  NS_TEST_ASSERT (p != 0);
  38.237 -  derived = 0;
  38.238 -  derived = p->GetAttribute ("TestPtr");
  38.239 -  NS_TEST_ASSERT (derived != 0);
  38.240 -
  38.241    CHECK_GET_STR (p, "TestInt16", "-2");
  38.242 -  CHECK_GET_PARAM (p, "TestInt16", Integer, -2);
  38.243 +  CHECK_GET_PARAM (p, "TestInt16", IntegerValue, -2);
  38.244  
  38.245 -  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestInt16", String ("-5")));
  38.246 +  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestInt16", StringValue ("-5")));
  38.247    CHECK_GET_STR (p, "TestInt16", "-5");
  38.248 -  CHECK_GET_PARAM (p, "TestInt16", Integer, -5);
  38.249 +  CHECK_GET_PARAM (p, "TestInt16", IntegerValue, -5);
  38.250  
  38.251 -  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestInt16", Integer (+2)));
  38.252 +  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestInt16", IntegerValue (+2)));
  38.253    CHECK_GET_STR (p, "TestInt16", "2");
  38.254 -  CHECK_GET_PARAM (p, "TestInt16", Integer, +2);
  38.255 +  CHECK_GET_PARAM (p, "TestInt16", IntegerValue, +2);
  38.256  
  38.257 -  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestInt16", Integer (-32768)));
  38.258 +  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestInt16", IntegerValue (-32768)));
  38.259    CHECK_GET_STR (p, "TestInt16", "-32768");
  38.260 -  CHECK_GET_PARAM (p, "TestInt16", Integer, -32768);
  38.261 +  CHECK_GET_PARAM (p, "TestInt16", IntegerValue, -32768);
  38.262  
  38.263 -  NS_TEST_ASSERT (!p->SetAttributeFailSafe("TestInt16", Integer (-32769)));
  38.264 +  NS_TEST_ASSERT (!p->SetAttributeFailSafe("TestInt16", IntegerValue (-32769)));
  38.265    CHECK_GET_STR (p, "TestInt16", "-32768");
  38.266 -  CHECK_GET_PARAM (p, "TestInt16", Integer, -32768);
  38.267 +  CHECK_GET_PARAM (p, "TestInt16", IntegerValue, -32768);
  38.268  
  38.269 -  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestInt16", Integer (32767)));
  38.270 +  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestInt16", IntegerValue (32767)));
  38.271    CHECK_GET_STR (p, "TestInt16", "32767");
  38.272 -  CHECK_GET_PARAM (p, "TestInt16", Integer, 32767);
  38.273 +  CHECK_GET_PARAM (p, "TestInt16", IntegerValue, 32767);
  38.274  
  38.275 -  NS_TEST_ASSERT (!p->SetAttributeFailSafe("TestInt16", Integer (32768)));
  38.276 +  NS_TEST_ASSERT (!p->SetAttributeFailSafe("TestInt16", IntegerValue (32768)));
  38.277    CHECK_GET_STR (p, "TestInt16", "32767");
  38.278 -  CHECK_GET_PARAM (p, "TestInt16", Integer, 32767);
  38.279 +  CHECK_GET_PARAM (p, "TestInt16", IntegerValue, 32767);
  38.280  
  38.281 -  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestInt16WithBounds", Integer (10)));
  38.282 +  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestInt16WithBounds", IntegerValue (10)));
  38.283    CHECK_GET_STR (p, "TestInt16WithBounds", "10");
  38.284 -  CHECK_GET_PARAM (p, "TestInt16WithBounds", Integer, 10);
  38.285 -  NS_TEST_ASSERT (!p->SetAttributeFailSafe("TestInt16WithBounds", Integer (11)));
  38.286 +  CHECK_GET_PARAM (p, "TestInt16WithBounds", IntegerValue, 10);
  38.287 +  NS_TEST_ASSERT (!p->SetAttributeFailSafe("TestInt16WithBounds", IntegerValue (11)));
  38.288    CHECK_GET_STR (p, "TestInt16WithBounds", "10");
  38.289 -  CHECK_GET_PARAM (p, "TestInt16WithBounds", Integer, 10);
  38.290 +  CHECK_GET_PARAM (p, "TestInt16WithBounds", IntegerValue, 10);
  38.291  
  38.292 -  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestInt16WithBounds", Integer (-5)));
  38.293 +  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestInt16WithBounds", IntegerValue (-5)));
  38.294    CHECK_GET_STR (p, "TestInt16WithBounds", "-5");
  38.295 -  CHECK_GET_PARAM (p, "TestInt16WithBounds", Integer, -5);
  38.296 -  NS_TEST_ASSERT (!p->SetAttributeFailSafe("TestInt16WithBounds", Integer (-6)));
  38.297 +  CHECK_GET_PARAM (p, "TestInt16WithBounds", IntegerValue, -5);
  38.298 +  NS_TEST_ASSERT (!p->SetAttributeFailSafe("TestInt16WithBounds", IntegerValue (-6)));
  38.299    CHECK_GET_STR (p, "TestInt16WithBounds", "-5");
  38.300 -  CHECK_GET_PARAM (p, "TestInt16WithBounds", Integer, -5);
  38.301 +  CHECK_GET_PARAM (p, "TestInt16WithBounds", IntegerValue, -5);
  38.302  
  38.303    CHECK_GET_STR (p, "TestInt16SetGet", "6");
  38.304 -  CHECK_GET_PARAM (p, "TestInt16SetGet", Integer, 6);
  38.305 -  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestInt16SetGet", Integer (0)));
  38.306 +  CHECK_GET_PARAM (p, "TestInt16SetGet", IntegerValue, 6);
  38.307 +  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestInt16SetGet", IntegerValue (0)));
  38.308    CHECK_GET_STR (p, "TestInt16SetGet", "0");
  38.309 -  CHECK_GET_PARAM (p, "TestInt16SetGet", Integer, 0);
  38.310 +  CHECK_GET_PARAM (p, "TestInt16SetGet", IntegerValue, 0);
  38.311  
  38.312    CHECK_GET_STR (p, "TestUint8", "1");
  38.313 -  CHECK_GET_PARAM (p, "TestUint8", Uinteger, 1);
  38.314 -  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestUint8", Uinteger (0)));
  38.315 +  CHECK_GET_PARAM (p, "TestUint8", UintegerValue, 1);
  38.316 +  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestUint8", UintegerValue (0)));
  38.317    CHECK_GET_STR (p, "TestUint8", "0");
  38.318 -  CHECK_GET_PARAM (p, "TestUint8", Uinteger, 0);
  38.319 -  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestUint8", Uinteger (255)));
  38.320 +  CHECK_GET_PARAM (p, "TestUint8", UintegerValue, 0);
  38.321 +  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestUint8", UintegerValue (255)));
  38.322    CHECK_GET_STR (p, "TestUint8", "255");
  38.323 -  CHECK_GET_PARAM (p, "TestUint8", Uinteger, 255);
  38.324 -  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestUint8", String ("255")));
  38.325 +  CHECK_GET_PARAM (p, "TestUint8", UintegerValue, 255);
  38.326 +  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestUint8", StringValue ("255")));
  38.327    CHECK_GET_STR (p, "TestUint8", "255");
  38.328 -  CHECK_GET_PARAM (p, "TestUint8", Uinteger, 255);
  38.329 -  NS_TEST_ASSERT (!p->SetAttributeFailSafe("TestUint8", String ("256")));
  38.330 +  CHECK_GET_PARAM (p, "TestUint8", UintegerValue, 255);
  38.331 +  NS_TEST_ASSERT (!p->SetAttributeFailSafe("TestUint8", StringValue ("256")));
  38.332    CHECK_GET_STR (p, "TestUint8", "255");
  38.333 -  CHECK_GET_PARAM (p, "TestUint8", Uinteger, 255);
  38.334 -  NS_TEST_ASSERT (!p->SetAttributeFailSafe("TestUint8", String ("-1")));
  38.335 +  CHECK_GET_PARAM (p, "TestUint8", UintegerValue, 255);
  38.336 +  NS_TEST_ASSERT (!p->SetAttributeFailSafe("TestUint8", StringValue ("-1")));
  38.337    CHECK_GET_STR (p, "TestUint8", "255");
  38.338 -  CHECK_GET_PARAM (p, "TestUint8", Uinteger, 255);
  38.339 -  NS_TEST_ASSERT (!p->SetAttributeFailSafe("TestUint8", Uinteger ((uint64_t)-1)));
  38.340 +  CHECK_GET_PARAM (p, "TestUint8", UintegerValue, 255);
  38.341 +  NS_TEST_ASSERT (!p->SetAttributeFailSafe("TestUint8", UintegerValue ((uint64_t)-1)));
  38.342    CHECK_GET_STR (p, "TestUint8", "255");
  38.343 -  CHECK_GET_PARAM (p, "TestUint8", Uinteger, 255);
  38.344 +  CHECK_GET_PARAM (p, "TestUint8", UintegerValue, 255);
  38.345  
  38.346    CHECK_GET_STR (p, "TestFloat", "-1.1");
  38.347 -  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestFloat", Double ((float)+2.3)));
  38.348 -  CHECK_GET_PARAM (p, "TestFloat", Double, (float)+2.3);
  38.349 +  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestFloat", DoubleValue ((float)+2.3)));
  38.350 +  CHECK_GET_PARAM (p, "TestFloat", DoubleValue, (float)+2.3);
  38.351  
  38.352    CHECK_GET_STR (p, "TestEnum", "TestA");
  38.353 -  CHECK_GET_PARAM (p, "TestEnum", Enum, AttributeObjectTest::TEST_A);
  38.354 -  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestEnum", Enum (AttributeObjectTest::TEST_C)));
  38.355 +  CHECK_GET_PARAM (p, "TestEnum", EnumValue, AttributeObjectTest::TEST_A);
  38.356 +  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestEnum", EnumValue (AttributeObjectTest::TEST_C)));
  38.357    CHECK_GET_STR (p, "TestEnum", "TestC");
  38.358 -  CHECK_GET_PARAM (p, "TestEnum", Enum, AttributeObjectTest::TEST_C);
  38.359 -  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestEnum", String ("TestB")));
  38.360 +  CHECK_GET_PARAM (p, "TestEnum", EnumValue, AttributeObjectTest::TEST_C);
  38.361 +  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestEnum", StringValue ("TestB")));
  38.362    CHECK_GET_STR (p, "TestEnum", "TestB");
  38.363 -  CHECK_GET_PARAM (p, "TestEnum", Enum, AttributeObjectTest::TEST_B);
  38.364 -  NS_TEST_ASSERT (!p->SetAttributeFailSafe("TestEnum", String ("TestD")));
  38.365 +  CHECK_GET_PARAM (p, "TestEnum", EnumValue, AttributeObjectTest::TEST_B);
  38.366 +  NS_TEST_ASSERT (!p->SetAttributeFailSafe("TestEnum", StringValue ("TestD")));
  38.367    CHECK_GET_STR (p, "TestEnum", "TestB");
  38.368 -  CHECK_GET_PARAM (p, "TestEnum", Enum, AttributeObjectTest::TEST_B);
  38.369 -  NS_TEST_ASSERT (!p->SetAttributeFailSafe("TestEnum", Enum (5)));
  38.370 +  CHECK_GET_PARAM (p, "TestEnum", EnumValue, AttributeObjectTest::TEST_B);
  38.371 +  NS_TEST_ASSERT (!p->SetAttributeFailSafe("TestEnum", EnumValue (5)));
  38.372    CHECK_GET_STR (p, "TestEnum", "TestB");
  38.373 -  CHECK_GET_PARAM (p, "TestEnum", Enum, AttributeObjectTest::TEST_B);
  38.374 +  CHECK_GET_PARAM (p, "TestEnum", EnumValue, AttributeObjectTest::TEST_B);
  38.375  
  38.376 -  RandomVariable ran = p->GetAttribute ("TestRandom");
  38.377 -  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestRandom", UniformVariable (0.0, 1.0)));
  38.378 -  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestRandom", ConstantVariable (10.0)));
  38.379 +  RandomVariableValue ran;
  38.380 +  p->GetAttribute ("TestRandom", ran);
  38.381 +  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestRandom", RandomVariableValue (UniformVariable (0.0, 1.0))));
  38.382 +  NS_TEST_ASSERT (p->SetAttributeFailSafe("TestRandom", RandomVariableValue (ConstantVariable (10.0))));
  38.383  
  38.384    {
  38.385 -    ObjectVector vector = p->GetAttribute ("TestVector1");
  38.386 +    ObjectVectorValue vector;
  38.387 +    p->GetAttribute ("TestVector1", vector);
  38.388      NS_TEST_ASSERT_EQUAL (vector.GetN (), 0);
  38.389      p->AddToVector1 ();
  38.390      NS_TEST_ASSERT_EQUAL (vector.GetN (), 0);
  38.391 -    vector = p->GetAttribute ("TestVector1");
  38.392 +    p->GetAttribute ("TestVector1", vector);
  38.393      NS_TEST_ASSERT_EQUAL (vector.GetN (), 1);
  38.394      Ptr<Object> a = vector.Get (0);
  38.395      NS_TEST_ASSERT_UNEQUAL (a, 0);
  38.396      p->AddToVector1 ();
  38.397      NS_TEST_ASSERT_EQUAL (vector.GetN (), 1);
  38.398 -    vector = p->GetAttribute ("TestVector1");
  38.399 +    p->GetAttribute ("TestVector1", vector);
  38.400      NS_TEST_ASSERT_EQUAL (vector.GetN (), 2);
  38.401    }
  38.402  
  38.403    {
  38.404 -    ObjectVector vector = p->GetAttribute ("TestVector2");
  38.405 +    ObjectVectorValue vector;
  38.406 +    p->GetAttribute ("TestVector2", vector);
  38.407      NS_TEST_ASSERT_EQUAL (vector.GetN (), 0);
  38.408      p->AddToVector2 ();
  38.409      NS_TEST_ASSERT_EQUAL (vector.GetN (), 0);
  38.410 -    vector = p->GetAttribute ("TestVector2");
  38.411 +    p->GetAttribute ("TestVector2", vector);
  38.412      NS_TEST_ASSERT_EQUAL (vector.GetN (), 1);
  38.413      Ptr<Object> a = vector.Get (0);
  38.414      NS_TEST_ASSERT_UNEQUAL (a, 0);
  38.415      p->AddToVector2 ();
  38.416      NS_TEST_ASSERT_EQUAL (vector.GetN (), 1);
  38.417 -    vector = p->GetAttribute ("TestVector2");
  38.418 +    p->GetAttribute ("TestVector2", vector);
  38.419      NS_TEST_ASSERT_EQUAL (vector.GetN (), 2);
  38.420    }
  38.421  
  38.422 -  NS_TEST_ASSERT (AttributeList::GetGlobal ()->SetFailSafe ("ns3::AttributeObjectTest::TestBoolName", String ("true")));
  38.423 +  NS_TEST_ASSERT (AttributeList::GetGlobal ()->SetFailSafe ("ns3::AttributeObjectTest::TestBoolName", StringValue ("true")));
  38.424    p = CreateObject<AttributeObjectTest> ();
  38.425 -  Boolean boolV = p->GetAttribute ("TestBoolName");
  38.426 -  NS_TEST_ASSERT_EQUAL (boolV, Boolean (true));
  38.427 +  BooleanValue boolV;
  38.428 +  p->GetAttribute ("TestBoolName", boolV);
  38.429 +  NS_TEST_ASSERT_EQUAL (boolV.Get (), true);
  38.430  
  38.431 -  NS_TEST_ASSERT (AttributeList::GetGlobal ()->SetFailSafe ("ns3::AttributeObjectTest::TestBoolName", String ("false")));
  38.432 +  NS_TEST_ASSERT (AttributeList::GetGlobal ()->SetFailSafe ("ns3::AttributeObjectTest::TestBoolName", StringValue ("false")));
  38.433    p = CreateObject<AttributeObjectTest> ();
  38.434 -  boolV = p->GetAttribute ("TestBoolName");
  38.435 -  NS_TEST_ASSERT_EQUAL (boolV, Boolean (false));
  38.436 +  p->GetAttribute ("TestBoolName", boolV);
  38.437 +  NS_TEST_ASSERT_EQUAL (boolV.Get (), false);
  38.438  
  38.439 -  Integer i = p->GetAttribute ("IntegerTraceSource1");
  38.440 +  IntegerValue i;
  38.441 +  p->GetAttribute ("IntegerTraceSource1", i);
  38.442    NS_TEST_ASSERT_EQUAL (i.Get (), -2);
  38.443 -  NS_TEST_ASSERT (p->SetAttributeFailSafe ("IntegerTraceSource1", Integer (+5)));
  38.444 -  i = p->GetAttribute ("IntegerTraceSource1");
  38.445 +  NS_TEST_ASSERT (p->SetAttributeFailSafe ("IntegerTraceSource1", IntegerValue (+5)));
  38.446 +  p->GetAttribute ("IntegerTraceSource1", i);
  38.447    NS_TEST_ASSERT_EQUAL (i.Get (), +5);
  38.448 -  NS_TEST_ASSERT (p->SetAttributeFailSafe ("IntegerTraceSource1", Integer (127)));
  38.449 -  NS_TEST_ASSERT (!p->SetAttributeFailSafe ("IntegerTraceSource1", Integer (128)));
  38.450 -  NS_TEST_ASSERT (p->SetAttributeFailSafe ("IntegerTraceSource1", Integer (-128)));
  38.451 -  NS_TEST_ASSERT (!p->SetAttributeFailSafe ("IntegerTraceSource1", Integer (-129)));
  38.452 +  NS_TEST_ASSERT (p->SetAttributeFailSafe ("IntegerTraceSource1", IntegerValue (127)));
  38.453 +  NS_TEST_ASSERT (!p->SetAttributeFailSafe ("IntegerTraceSource1", IntegerValue (128)));
  38.454 +  NS_TEST_ASSERT (p->SetAttributeFailSafe ("IntegerTraceSource1", IntegerValue (-128)));
  38.455 +  NS_TEST_ASSERT (!p->SetAttributeFailSafe ("IntegerTraceSource1", IntegerValue (-129)));
  38.456  
  38.457 -  i = p->GetAttribute ("IntegerTraceSource2");
  38.458 +  p->GetAttribute ("IntegerTraceSource2", i);
  38.459    NS_TEST_ASSERT_EQUAL (i.Get (), -2);
  38.460 -  NS_TEST_ASSERT (p->SetAttributeFailSafe ("IntegerTraceSource2", Integer (+5)));
  38.461 -  i = p->GetAttribute ("IntegerTraceSource2");
  38.462 +  NS_TEST_ASSERT (p->SetAttributeFailSafe ("IntegerTraceSource2", IntegerValue (+5)));
  38.463 +  p->GetAttribute ("IntegerTraceSource2", i);
  38.464    NS_TEST_ASSERT_EQUAL (i.Get (), +5);
  38.465 -  NS_TEST_ASSERT (p->SetAttributeFailSafe ("IntegerTraceSource2", Integer (127)));
  38.466 -  NS_TEST_ASSERT (!p->SetAttributeFailSafe ("IntegerTraceSource2", Integer (128)));
  38.467 -  NS_TEST_ASSERT (p->SetAttributeFailSafe ("IntegerTraceSource2", Integer (-128)));
  38.468 -  NS_TEST_ASSERT (!p->SetAttributeFailSafe ("IntegerTraceSource2", Integer (-129)));
  38.469 +  NS_TEST_ASSERT (p->SetAttributeFailSafe ("IntegerTraceSource2", IntegerValue (127)));
  38.470 +  NS_TEST_ASSERT (!p->SetAttributeFailSafe ("IntegerTraceSource2", IntegerValue (128)));
  38.471 +  NS_TEST_ASSERT (p->SetAttributeFailSafe ("IntegerTraceSource2", IntegerValue (-128)));
  38.472 +  NS_TEST_ASSERT (!p->SetAttributeFailSafe ("IntegerTraceSource2", IntegerValue (-129)));
  38.473  
  38.474    m_got1 = -2;
  38.475 -  NS_TEST_ASSERT (p->SetAttributeFailSafe ("IntegerTraceSource1", Integer (-1)));
  38.476 +  NS_TEST_ASSERT (p->SetAttributeFailSafe ("IntegerTraceSource1", IntegerValue (-1)));
  38.477    NS_TEST_ASSERT (p->TraceConnectWithoutContext ("Source1", MakeCallback (&AttributeTest::NotifySource1, this)));
  38.478 -  NS_TEST_ASSERT (p->SetAttributeFailSafe ("IntegerTraceSource1", Integer (0)));
  38.479 +  NS_TEST_ASSERT (p->SetAttributeFailSafe ("IntegerTraceSource1", IntegerValue (0)));
  38.480    NS_TEST_ASSERT_EQUAL (m_got1, 0);
  38.481    NS_TEST_ASSERT (p->TraceDisconnectWithoutContext ("Source1", MakeCallback (&AttributeTest::NotifySource1, this)));
  38.482 -  NS_TEST_ASSERT (p->SetAttributeFailSafe ("IntegerTraceSource1", Integer (1)));
  38.483 +  NS_TEST_ASSERT (p->SetAttributeFailSafe ("IntegerTraceSource1", IntegerValue (1)));
  38.484    NS_TEST_ASSERT_EQUAL (m_got1, 0);
  38.485  
  38.486    m_got2 = 4.3;
  38.487 @@ -481,8 +467,29 @@
  38.488    NS_TEST_ASSERT_EQUAL (m_got2, 1.0);
  38.489  
  38.490    NS_TEST_ASSERT (p->TraceConnectWithoutContext ("ValueSource", MakeCallback (&AttributeTest::NotifySourceValue, this)));
  38.491 -  
  38.492  
  38.493 +  PointerValue ptr;
  38.494 +  p->GetAttribute ("Pointer", ptr);
  38.495 +  Ptr<Derived> derived = ptr.Get<Derived> ();
  38.496 +  NS_TEST_ASSERT (derived == 0);
  38.497 +  derived = Create<Derived> ();
  38.498 +  NS_TEST_ASSERT (p->SetAttributeFailSafe("Pointer", PointerValue (derived)));
  38.499 +  p->GetAttribute ("Pointer", ptr);
  38.500 +  Ptr<Derived> stored = ptr.Get<Derived> ();
  38.501 +  NS_TEST_ASSERT (stored == derived);
  38.502 +  p->GetAttribute ("Pointer", ptr);
  38.503 +  Ptr<Object> storedBase = ptr.Get<Object> ();
  38.504 +  NS_TEST_ASSERT (stored == storedBase);
  38.505 +  p->GetAttribute ("Pointer", ptr);
  38.506 +  Ptr<AttributeObjectTest> x = ptr.Get<AttributeObjectTest> ();
  38.507 +  NS_TEST_ASSERT (x == 0);
  38.508 +
  38.509 +  p = CreateObject<AttributeObjectTest> ("Pointer", PointerValue (Create<Derived> ()));
  38.510 +  NS_TEST_ASSERT (p != 0);
  38.511 +  derived = 0;
  38.512 +  p->GetAttribute ("Pointer", ptr);
  38.513 +  derived = ptr.Get<Derived> ();
  38.514 +  NS_TEST_ASSERT (derived != 0);
  38.515  
  38.516    return result;
  38.517  }
    39.1 --- a/src/core/attribute.cc	Mon Apr 21 08:58:23 2008 -0700
    39.2 +++ b/src/core/attribute.cc	Mon Apr 21 09:04:08 2008 -0700
    39.3 @@ -27,164 +27,38 @@
    39.4  namespace ns3 {
    39.5  
    39.6  AttributeValue::AttributeValue ()
    39.7 -  : m_count (1)
    39.8  {}
    39.9 -AttributeValue::AttributeValue (const AttributeValue &o)
   39.10 -  : m_count (1)
   39.11 -{}
   39.12 -AttributeValue &
   39.13 -AttributeValue::operator = (const AttributeValue &o)
   39.14 -{
   39.15 -  return *this;
   39.16 -}
   39.17  AttributeValue::~AttributeValue ()
   39.18  {}
   39.19  
   39.20 -/***************************************************************
   39.21 - *   Big interesting warning.
   39.22 - *   ------------------------
   39.23 - *
   39.24 - * One might wonder why we re-implement a smart pointer below 
   39.25 - * in the Attribute class. This is a very good question and the answer
   39.26 - * is unfortunately pretty complicated.
   39.27 - *
   39.28 - * 1) We could have requested the user to use Ptr<AttributeValue> and save us
   39.29 - *    a lot of pain. This, however, does not work because our smart 
   39.30 - *    pointer needs a special constructor which can be used to convert
   39.31 - *    objects of type Ptr<T> into a PtrValue<T> to hold the pointer.
   39.32 - *
   39.33 - * 2) We could have made the m_value member variable below a Ptr<AttributeValue>
   39.34 - *    rather than store a raw pointer. This, however, does not work
   39.35 - *    because this would mean that the constructor Attribute (AttributeValue *)
   39.36 - *    should be morphed into Attribute (Ptr<AttributeValue>) which, unfortunately,
   39.37 - *    would conflict with the template constructor Attribute (Ptr<T>)...
   39.38 - *
   39.39 - * This is definitely not fun.   
   39.40 - */
   39.41 -Attribute::Attribute ()
   39.42 -  : m_value (0)
   39.43 -{}
   39.44 -Attribute::Attribute (const Attribute &o)
   39.45 -  : m_value (o.m_value)
   39.46 -{
   39.47 -  if (m_value != 0)
   39.48 -    {
   39.49 -      m_value->m_count++;
   39.50 -      NS_LOG_DEBUG ("this="<<m_value<<" ++count="<<m_value->m_count);
   39.51 -    }
   39.52 -}
   39.53 -Attribute &
   39.54 -Attribute::operator = (const Attribute &o)
   39.55 -{
   39.56 -  if (&o != this)
   39.57 -    {
   39.58 -      if (m_value != 0)
   39.59 -	{
   39.60 -	  m_value->m_count--;
   39.61 -	  NS_LOG_DEBUG ("this="<<m_value<<" --count="<<m_value->m_count);
   39.62 -	  if (m_value->m_count == 0)
   39.63 -	    {
   39.64 -	      delete m_value;
   39.65 -	      m_value = 0;
   39.66 -	    }
   39.67 -	}
   39.68 -      m_value = o.m_value;
   39.69 -      if (m_value != 0)
   39.70 -	{
   39.71 -	  m_value->m_count++;
   39.72 -	  NS_LOG_DEBUG ("this="<<m_value<<" ++count="<<m_value->m_count);
   39.73 -	}
   39.74 -    }
   39.75 -  return *this;
   39.76 -}
   39.77 -Attribute::~Attribute ()
   39.78 -{
   39.79 -  if (m_value != 0) 
   39.80 -    {
   39.81 -      m_value->m_count--;
   39.82 -      NS_LOG_DEBUG ("this="<<m_value<<" --count="<<m_value->m_count);
   39.83 -      if (m_value->m_count == 0)
   39.84 -	{
   39.85 -	  delete m_value;
   39.86 -	  m_value = 0;
   39.87 -	}
   39.88 -    }
   39.89 -}
   39.90 -Attribute::Attribute (AttributeValue *value)
   39.91 -  : m_value (value)
   39.92 -{
   39.93 -  NS_LOG_DEBUG ("this="<<m_value<<" count="<<((m_value!=0)?m_value->m_count:666));
   39.94 -}
   39.95 -
   39.96 -Attribute 
   39.97 -Attribute::Copy (void) const
   39.98 -{
   39.99 -  return m_value->Copy ();
  39.100 -}
  39.101 -std::string 
  39.102 -Attribute::SerializeToString (Ptr<const AttributeChecker> checker) const
  39.103 -{
  39.104 -  return m_value->SerializeToString (checker);
  39.105 -}
  39.106 -bool 
  39.107 -Attribute::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
  39.108 -{
  39.109 -  return m_value->DeserializeFromString (value, checker);
  39.110 -}
  39.111  
  39.112  AttributeAccessor::AttributeAccessor ()
  39.113 -  : m_count (1)
  39.114  {}
  39.115 -void 
  39.116 -AttributeAccessor::Ref (void) const
  39.117 -{
  39.118 -  m_count++;
  39.119 -}
  39.120 -void 
  39.121 -AttributeAccessor::Unref (void) const
  39.122 -{
  39.123 -  m_count--;
  39.124 -  if (m_count == 0)
  39.125 -    {
  39.126 -      delete this;
  39.127 -    }
  39.128 -}
  39.129  AttributeAccessor::~AttributeAccessor ()
  39.130  {}
  39.131  
  39.132  AttributeChecker::AttributeChecker ()
  39.133 -  : m_count (1)
  39.134  {}
  39.135 -void 
  39.136 -AttributeChecker::Ref (void) const
  39.137 -{
  39.138 -  m_count++;
  39.139 -}
  39.140 -void 
  39.141 -AttributeChecker::Unref (void) const
  39.142 -{
  39.143 -  m_count--;
  39.144 -  if (m_count == 0)
  39.145 -    {
  39.146 -      delete this;
  39.147 -    }
  39.148 -}
  39.149  AttributeChecker::~AttributeChecker ()
  39.150  {}
  39.151  
  39.152 +EmptyAttributeValue::EmptyAttributeValue ()
  39.153 +{}
  39.154 +Ptr<AttributeValue> 
  39.155 +EmptyAttributeValue::Copy (void) const
  39.156 +{
  39.157 +  return Create<EmptyAttributeValue> ();
  39.158 +}
  39.159  std::string 
  39.160 -PtrValueBase::SerializeToString (Ptr<const AttributeChecker> checker) const
  39.161 +EmptyAttributeValue::SerializeToString (Ptr<const AttributeChecker> checker) const
  39.162  {
  39.163 -  std::ostringstream oss;
  39.164 -  oss << PeekObjectBase ();
  39.165 -  return oss.str ();
  39.166 +  return "";
  39.167 +}
  39.168 +bool 
  39.169 +EmptyAttributeValue::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
  39.170 +{
  39.171 +  return true;
  39.172  }
  39.173  
  39.174 -bool 
  39.175 -PtrValueBase::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
  39.176 -{
  39.177 -  // XXX
  39.178 -  return false;
  39.179 -}
  39.180  
  39.181  } // namespace ns3
    40.1 --- a/src/core/attribute.h	Mon Apr 21 08:58:23 2008 -0700
    40.2 +++ b/src/core/attribute.h	Mon Apr 21 09:04:08 2008 -0700
    40.3 @@ -23,6 +23,7 @@
    40.4  #include <string>
    40.5  #include <stdint.h>
    40.6  #include "ptr.h"
    40.7 +#include "ref-count-base.h"
    40.8  
    40.9  namespace ns3 {
   40.10  
   40.11 @@ -34,23 +35,20 @@
   40.12  /**
   40.13   * \brief Hold a value for an Attribute.
   40.14   *
   40.15 - * Instances of this class are usually created by Attribute::Create<> and
   40.16 - * should always be wrapped into an Attribute object.
   40.17 + * Instances of this class should always be wrapped into an Attribute object.
   40.18   * Most subclasses of this base class are implemented by the 
   40.19   * ATTRIBUTE_HELPER_* macros.
   40.20   */
   40.21 -class AttributeValue
   40.22 +class AttributeValue : public RefCountBase
   40.23  {
   40.24  public:
   40.25    AttributeValue ();
   40.26 -  AttributeValue (const AttributeValue &o);
   40.27 -  AttributeValue &operator = (const AttributeValue &o);
   40.28    virtual ~AttributeValue ();
   40.29  
   40.30    /**
   40.31     * \returns a deep copy of this class, wrapped into an Attribute object.
   40.32     */
   40.33 -  virtual Attribute Copy (void) const = 0;
   40.34 +  virtual Ptr<AttributeValue> Copy (void) const = 0;
   40.35    /**
   40.36     * \param checker the checker associated to the attribute
   40.37     * \returns a string representation of this value.
   40.38 @@ -75,80 +73,6 @@
   40.39     * the EnumValue::SerializeToString code.
   40.40     */
   40.41    virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker) = 0;
   40.42 -private:
   40.43 -  friend class Attribute;
   40.44 -  uint32_t m_count;
   40.45 -};
   40.46 -
   40.47 -/**
   40.48 - * \brief an opaque wrapper around a value to set or retrieved
   40.49 - *        from an attribute.
   40.50 - *
   40.51 - * This class is really a smart pointer to an instance of AttributeValue.
   40.52 - * Of course, the question is "why not use a Ptr<AttributeValue>" ?. The 
   40.53 - * answer is long and complicated but the crux of the issue is that if we
   40.54 - * do not reproduce the smart pointer code in this class, we cannot provide
   40.55 - * transparent handling of Ptr<T> values through the attribute system.
   40.56 - */
   40.57 -class Attribute
   40.58 -{
   40.59 -public:
   40.60 -  Attribute ();
   40.61 -  Attribute (const Attribute &o);
   40.62 -  Attribute &operator = (const Attribute &o);
   40.63 -  ~Attribute ();
   40.64 -
   40.65 -  /**
   40.66 -   * Forward to AttributeValue::Copy
   40.67 -   */
   40.68 -  Attribute Copy (void) const;
   40.69 -  /**
   40.70 -   * Forward to AttributeValue::SerializeToString
   40.71 -   */
   40.72 -  std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
   40.73 -  /**
   40.74 -   * Forward to AttributeValue::DeserializeFromString
   40.75 -   */
   40.76 -  bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
   40.77 -
   40.78 -  /**
   40.79 -   * \returns a new Attribute object which wraps an instance of the requested
   40.80 -   * subclass of AttributeValue.
   40.81 -   */
   40.82 -  template <typename T>
   40.83 -  static Attribute Create (void);
   40.84 -  /**
   40.85 -   * \param a1 a value to pass through to the constructor of the class T.
   40.86 -   * \returns a new Attribute object which wraps an instance of the requested
   40.87 -   * subclass of AttributeValue.
   40.88 -   */
   40.89 -  template <typename T, typename T1>
   40.90 -  static Attribute Create (T1 a1);
   40.91 -
   40.92 -  /**
   40.93 -   * This method performs a dynamic_cast on the underlying AttributeValue.
   40.94 -   * This method is typically used to implement conversion operators
   40.95 -   * from the type Attribute. In most cases, these conversion operators
   40.96 -   * will be generated for you by the ATTRIBUTE_HELPER_* macros.
   40.97 -   * \returns the casted pointer.
   40.98 -   */
   40.99 -  template <typename T>
  40.100 -  T DynCast (void) const;
  40.101 -
  40.102 -  /**
  40.103 -   * \param pointer a pointer to convert into an Attribute.
  40.104 -   */
  40.105 -  template <typename T>
  40.106 -  Attribute (Ptr<T> pointer);
  40.107 -  /**
  40.108 -   * \returns a pointer converted from this Attribute instance.
  40.109 -   */
  40.110 -  template <typename T>
  40.111 -  operator Ptr<T> ();
  40.112 -
  40.113 -private:
  40.114 -  Attribute (AttributeValue *value);
  40.115 -  AttributeValue *m_value;
  40.116  };
  40.117  
  40.118  /**
  40.119 @@ -159,12 +83,10 @@
  40.120   * of this base class are usually provided through the MakeAccessorHelper
  40.121   * template functions, hidden behind an ATTRIBUTE_HELPER_* macro.
  40.122   */
  40.123 -class AttributeAccessor
  40.124 +class AttributeAccessor : public RefCountBase
  40.125  {
  40.126  public:
  40.127    AttributeAccessor ();
  40.128 -  void Ref (void) const;
  40.129 -  void Unref (void) const;
  40.130    virtual ~AttributeAccessor ();
  40.131  
  40.132    /**
  40.133 @@ -175,7 +97,7 @@
  40.134     * This method expects that the caller has checked that the input value is
  40.135     * valid with AttributeChecker::Check.
  40.136     */
  40.137 -  virtual bool Set (ObjectBase * object, Attribute value) const = 0;
  40.138 +  virtual bool Set (ObjectBase * object, const AttributeValue &value) const = 0;
  40.139    /**
  40.140     * \param object the object instance to get the value from
  40.141     * \param attribute a pointer to where the value should be set.
  40.142 @@ -185,9 +107,18 @@
  40.143     * This method expects that the caller has checked that the input value is
  40.144     * valid with AttributeChecker::Check.
  40.145     */
  40.146 -  virtual bool Get (const ObjectBase * object, Attribute attribute) const = 0;
  40.147 -private:
  40.148 -  mutable uint32_t m_count;
  40.149 +  virtual bool Get (const ObjectBase * object, AttributeValue &attribute) const = 0;
  40.150 +
  40.151 +  /**
  40.152 +   * \return true if this accessor supports the Get operation, false
  40.153 +   *         otherwise.
  40.154 +   */
  40.155 +  virtual bool HasGetter (void) const = 0;
  40.156 +  /**
  40.157 +   * \return true if this accessor supports the Set operation, false
  40.158 +   *         otherwise.
  40.159 +   */
  40.160 +  virtual bool HasSetter (void) const = 0;
  40.161  };
  40.162  
  40.163  /**
  40.164 @@ -202,12 +133,10 @@
  40.165   * Most subclasses of this base class are implemented by the 
  40.166   * ATTRIBUTE_HELPER_* macros.
  40.167   */
  40.168 -class AttributeChecker
  40.169 +class AttributeChecker : public RefCountBase
  40.170  {
  40.171  public:
  40.172    AttributeChecker ();
  40.173 -  void Ref (void) const;
  40.174 -  void Unref (void) const;
  40.175    virtual ~AttributeChecker ();
  40.176    /**
  40.177     * \param value a pointer to the value to check
  40.178 @@ -215,10 +144,29 @@
  40.179     *          and if its value is within the requested range. Returns
  40.180     *          false otherwise.
  40.181     */
  40.182 -  virtual bool Check (Attribute value) const = 0;
  40.183 -  virtual std::string GetType (void) const = 0;
  40.184 -  virtual bool HasTypeConstraints (void) const = 0;
  40.185 -  virtual std::string GetTypeConstraints (void) const = 0;
  40.186 +  virtual bool Check (const AttributeValue &value) const = 0;
  40.187 +  /**
  40.188 +   * \returns the c++ fully-qualified typename of the subclass
  40.189 +   *          of the ns3::AttributeValue base class which is associated
  40.190 +   *          to this checker.
  40.191 +   *
  40.192 +   * A typical return value here is FooValue where Foo is the name of the
  40.193 +   * type being wrapped.
  40.194 +   */
  40.195 +  virtual std::string GetValueTypeName (void) const = 0;
  40.196 +  /**
  40.197 +   * \returns true if this checker has information about the underlying
  40.198 +   *          C++ type, false otherwise.
  40.199 +   *
  40.200 +   * If this method returns false, the return value of the GetUnderlyingTypeInformation
  40.201 +   * method cannot be relied upon.
  40.202 +   */
  40.203 +  virtual bool HasUnderlyingTypeInformation (void) const = 0;
  40.204 +  /**
  40.205 +   * \returns a human-readable representation of information about
  40.206 +   *          the underlying C++ type.
  40.207 +   */
  40.208 +  virtual std::string GetUnderlyingTypeInformation (void) const = 0;
  40.209    /**
  40.210     * \returns a new instance of an AttributeValue (wrapper in an Attribute 
  40.211     *          instance) which matches the type of the underlying attribute.
  40.212 @@ -226,314 +174,22 @@
  40.213     * This method is typically used to create a temporary variable prior
  40.214     * to calling Attribute::DeserializeFromString.
  40.215     */
  40.216 -  virtual Attribute Create (void) const = 0;
  40.217 -private:
  40.218 -  mutable uint32_t m_count;
  40.219 +  virtual Ptr<AttributeValue> Create (void) const = 0;
  40.220 +
  40.221 +  virtual bool Copy (const AttributeValue &source, AttributeValue &destination) const = 0;
  40.222 +
  40.223  };
  40.224  
  40.225 -template <typename T, typename U>
  40.226 -Ptr<const AttributeAccessor>
  40.227 -MakePtrAccessor (Ptr<U> T::*memberVariable);
  40.228 -
  40.229 -template <typename T, typename U>
  40.230 -Ptr<const AttributeAccessor>
  40.231 -MakePtrAccessor (void (T::*setter) (Ptr<U>));
  40.232 -template <typename T, typename U>
  40.233 -Ptr<const AttributeAccessor>
  40.234 -MakePtrAccessor (Ptr<U> (T::*getter) (void) const);
  40.235 -template <typename T, typename U>
  40.236 -Ptr<const AttributeAccessor>
  40.237 -MakePtrAccessor (void (T::*setter) (Ptr<U>),
  40.238 -                 Ptr<U> (T::*getter) (void) const);
  40.239 -template <typename T, typename U>
  40.240 -Ptr<const AttributeAccessor>
  40.241 -MakePtrAccessor (Ptr<U> (T::*getter) (void) const,
  40.242 -                 void (T::*setter) (Ptr<U>));
  40.243 -
  40.244 -
  40.245 -
  40.246 -class PtrChecker : public AttributeChecker {};
  40.247 -
  40.248 -template <typename T>
  40.249 -Ptr<AttributeChecker> MakePtrChecker (void);
  40.250 -
  40.251 -
  40.252 -
  40.253 -} // namespace ns3
  40.254 -
  40.255 -namespace ns3 {
  40.256 -
  40.257 -/********************************************************
  40.258 - *   The class used to access the pointer stored in a
  40.259 - *   PtrValue<T> AttributeValue instance.
  40.260 - ********************************************************/
  40.261 -
  40.262 -class PtrValueBase : public AttributeValue
  40.263 +class EmptyAttributeValue : public AttributeValue
  40.264  {
  40.265  public:
  40.266 -  virtual ObjectBase *PeekObjectBase (void) const = 0;
  40.267 -  virtual bool SetObjectBase (ObjectBase *object) = 0;
  40.268 +  EmptyAttributeValue ();
  40.269 +private:
  40.270 +  virtual Ptr<AttributeValue> Copy (void) const;
  40.271    virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
  40.272    virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
  40.273  };
  40.274  
  40.275 -/********************************************************
  40.276 - *        Store the content of a Ptr<T> in a AttributeValue
  40.277 - ********************************************************/
  40.278 -
  40.279 -namespace internal {
  40.280 -
  40.281 -template <typename T>
  40.282 -class PtrValue : public PtrValueBase
  40.283 -{
  40.284 -public:
  40.285 -  PtrValue () 
  40.286 -    : m_pointer () {}
  40.287 -  PtrValue (Ptr<T> pointer) 
  40.288 -    : m_pointer (pointer) {}
  40.289 -
  40.290 -  virtual ObjectBase *PeekObjectBase (void) const {
  40.291 -    return PeekPointer (m_pointer);
  40.292 -  }
  40.293 -  virtual bool SetObjectBase (ObjectBase *object) {
  40.294 -    T *ptr = dynamic_cast<T *> (object);
  40.295 -    if (ptr == 0)
  40.296 -      {
  40.297 -	return false;
  40.298 -      }
  40.299 -    m_pointer = ptr;
  40.300 -    return true;
  40.301 -  }
  40.302 -  virtual Attribute Copy (void) const {
  40.303 -    return Attribute::Create<PtrValue<T> > (*this);
  40.304 -  }
  40.305 -private:
  40.306 -  Ptr<T> m_pointer;
  40.307 -};
  40.308 -
  40.309 -template <typename T>
  40.310 -class APtrChecker : public PtrChecker
  40.311 -{
  40.312 -  virtual bool Check (Attribute val) const {
  40.313 -    const PtrValueBase *value = val.DynCast<const PtrValueBase *> ();
  40.314 -    if (value == 0)
  40.315 -      {
  40.316 -	return false;
  40.317 -      }
  40.318 -    if (value->PeekObjectBase () == 0)
  40.319 -      {
  40.320 -	return true;
  40.321 -      }
  40.322 -    T *ptr = dynamic_cast<T*> (value->PeekObjectBase ());
  40.323 -    if (ptr == 0)
  40.324 -      {
  40.325 -	return false;
  40.326 -      }
  40.327 -    return true;
  40.328 -  }
  40.329 -  virtual std::string GetType (void) const {
  40.330 -    // XXX: we should be able to return better information
  40.331 -    return "Ptr<>";
  40.332 -  }
  40.333 -  virtual bool HasTypeConstraints (void) const {
  40.334 -    return false;
  40.335 -  }
  40.336 -  virtual std::string GetTypeConstraints (void) const {
  40.337 -    return "";
  40.338 -  }
  40.339 -  virtual Attribute Create (void) const {
  40.340 -    return Attribute::Create<PtrValue<T> > ();
  40.341 -  }
  40.342 -};
  40.343 -
  40.344 -/********************************************************
  40.345 - *              The Accessor associated to 
  40.346 - *               PtrValue<T>
  40.347 - ********************************************************/
  40.348 -
  40.349 -template <typename T, typename U>
  40.350 -class PtrAccessor : public AttributeAccessor
  40.351 -{
  40.352 -public:
  40.353 -  virtual ~PtrAccessor () {}
  40.354 -  virtual bool Set (ObjectBase * object, Attribute val) const {
  40.355 -      T *obj = dynamic_cast<T *> (object);
  40.356 -      if (obj == 0)
  40.357 -        {
  40.358 -          return false;
  40.359 -        }
  40.360 -      const PtrValueBase *value = val.DynCast<const PtrValueBase *> ();
  40.361 -      if (value == 0)
  40.362 -        {
  40.363 -          return false;
  40.364 -        }
  40.365 -      Ptr<U> ptr = dynamic_cast<U*> (value->PeekObjectBase ());
  40.366 -      if (ptr == 0)
  40.367 -        {
  40.368 -          return false;
  40.369 -        }
  40.370 -      DoSet (obj, ptr);
  40.371 -      return true;
  40.372 -    }
  40.373 -  virtual bool Get (const ObjectBase * object, Attribute val) const {
  40.374 -      const T *obj = dynamic_cast<const T *> (object);
  40.375 -      if (obj == 0)
  40.376 -        {
  40.377 -          return false;
  40.378 -        }
  40.379 -      PtrValueBase *value = val.DynCast<PtrValueBase *> ();
  40.380 -      if (value == 0)
  40.381 -        {
  40.382 -          return false;
  40.383 -        }
  40.384 -      return value->SetObjectBase (PeekPointer (DoGet (obj)));
  40.385 -    }
  40.386 -private:
  40.387 -  virtual void DoSet (T *object, Ptr<U> value) const = 0;
  40.388 -  virtual Ptr<U> DoGet (const T *object) const = 0;
  40.389 -};
  40.390 -
  40.391 -} // namespace internal
  40.392 -
  40.393 -/********************************************************
  40.394 - *        The implementation of the Attribute 
  40.395 - *          class template methods.
  40.396 - ********************************************************/
  40.397 -
  40.398 -template <typename T>
  40.399 -Attribute 
  40.400 -Attribute::Create (void)
  40.401 -{
  40.402 -  return Attribute (new T ());
  40.403 -}
  40.404 -template <typename T, typename T1>
  40.405 -Attribute 
  40.406 -Attribute::Create (T1 a1)
  40.407 -{
  40.408 -  return Attribute (new T (a1));
  40.409 -}
  40.410 -
  40.411 -template <typename T>
  40.412 -T
  40.413 -Attribute::DynCast (void) const
  40.414 -{
  40.415 -  return dynamic_cast<T> (m_value);
  40.416 -}
  40.417 -
  40.418 -template <typename T>
  40.419 -Attribute::Attribute (Ptr<T> pointer)
  40.420 -  : m_value (new internal::PtrValue<T> (pointer))
  40.421 -{}
  40.422 -template <typename T>
  40.423 -Attribute::operator Ptr<T> ()
  40.424 -{
  40.425 -  PtrValueBase *value = DynCast<PtrValueBase *> ();
  40.426 -  if (value == 0)
  40.427 -    {
  40.428 -      return 0;
  40.429 -    }
  40.430 -  ObjectBase *objectBase = value->PeekObjectBase ();
  40.431 -  T *obj = dynamic_cast<T *> (objectBase);
  40.432 -  if (obj == 0)
  40.433 -    {
  40.434 -      return 0;
  40.435 -    }
  40.436 -  return obj;
  40.437 -}
  40.438 -
  40.439 -
  40.440 -
  40.441 -template <typename T, typename U>
  40.442 -Ptr<const AttributeAccessor>
  40.443 -MakePtrAccessor (Ptr<U> T::*memberVariable)
  40.444 -{
  40.445 -  struct MemberVariable : public internal::PtrAccessor<T,U>
  40.446 -  {
  40.447 -    Ptr<U> T::*m_memberVariable;
  40.448 -    virtual void DoSet (T *object, Ptr<U> value) const {
  40.449 -      (object->*m_memberVariable) = value;
  40.450 -    }
  40.451 -    virtual Ptr<U> DoGet (const T *object) const {
  40.452 -      return object->*m_memberVariable;
  40.453 -    }
  40.454 -  } *spec = new MemberVariable ();
  40.455 -  spec->m_memberVariable = memberVariable;
  40.456 -  return Ptr<const AttributeAccessor> (spec, false);
  40.457 -}
  40.458 -
  40.459 -template <typename T, typename U>
  40.460 -Ptr<const AttributeAccessor>
  40.461 -MakePtrAccessor (void (T::*setter) (Ptr<U>))
  40.462 -{
  40.463 -  struct MemberMethod : public internal::PtrAccessor<T,U>
  40.464 -  {
  40.465 -    void (T::*m_setter) (Ptr<U>);
  40.466 -    virtual void DoSet (T *object, Ptr<U> value) const {
  40.467 -      (object->*m_setter) (value);
  40.468 -    }
  40.469 -    virtual Ptr<U> DoGet (const T *object) const {
  40.470 -      return 0;
  40.471 -      //return (object->*m_getter) ();
  40.472 -    }
  40.473 -  } *spec = new MemberMethod ();
  40.474 -  spec->m_setter = setter;
  40.475 -  return Ptr<const AttributeAccessor> (spec, false);
  40.476 -}
  40.477 -
  40.478 -template <typename T, typename U>
  40.479 -Ptr<const AttributeAccessor>
  40.480 -MakePtrAccessor (Ptr<U> (T::*getter) (void) const)
  40.481 -{
  40.482 -  struct MemberMethod : public internal::PtrAccessor<T,U>
  40.483 -  {
  40.484 -    Ptr<U> (T::*m_getter) (void) const;
  40.485 -    virtual void DoSet (T *object, Ptr<U> value) const {
  40.486 -      //(object->*m_setter) (value);
  40.487 -    }
  40.488 -    virtual Ptr<U> DoGet (const T *object) const {
  40.489 -      return (object->*m_getter) ();
  40.490 -    }
  40.491 -  } *spec = new MemberMethod ();
  40.492 -  spec->m_getter = getter;
  40.493 -  return Ptr<const AttributeAccessor> (spec, false);
  40.494 -}
  40.495 -template <typename T, typename U>
  40.496 -Ptr<const AttributeAccessor>
  40.497 -MakePtrAccessor (void (T::*setter) (Ptr<U>),
  40.498 -                 Ptr<U> (T::*getter) (void) const)
  40.499 -{
  40.500 -  return MakePtrAccessor (getter, setter);
  40.501 -}
  40.502 -template <typename T, typename U>
  40.503 -Ptr<const AttributeAccessor>
  40.504 -MakePtrAccessor (Ptr<U> (T::*getter) (void) const,
  40.505 -                 void (T::*setter) (Ptr<U>))
  40.506 -{
  40.507 -  struct MemberMethod : public internal::PtrAccessor<T,U>
  40.508 -  {
  40.509 -    void (T::*m_setter) (Ptr<U>);
  40.510 -    Ptr<U> (T::*m_getter) (void) const;
  40.511 -    virtual void DoSet (T *object, Ptr<U> value) const {
  40.512 -      (object->*m_setter) (value);
  40.513 -    }
  40.514 -    virtual Ptr<U> DoGet (const T *object) const {
  40.515 -      return (object->*m_getter) ();
  40.516 -    }
  40.517 -  } *spec = new MemberMethod ();
  40.518 -  spec->m_setter = setter;
  40.519 -  spec->m_getter = getter;
  40.520 -  return Ptr<const AttributeAccessor> (spec, false);
  40.521 -}
  40.522 -
  40.523 -
  40.524 -
  40.525 -template <typename T>
  40.526 -Ptr<AttributeChecker>
  40.527 -MakePtrChecker (void)
  40.528 -{
  40.529 -  return Create<internal::APtrChecker<T> > ();
  40.530 -}
  40.531 -
  40.532  } // namespace ns3
  40.533  
  40.534  #endif /* ATTRIBUTE_H */
    41.1 --- a/src/core/boolean.cc	Mon Apr 21 08:58:23 2008 -0700
    41.2 +++ b/src/core/boolean.cc	Mon Apr 21 09:04:08 2008 -0700
    41.3 @@ -22,28 +22,28 @@
    41.4  
    41.5  namespace ns3 {
    41.6  
    41.7 -Boolean::Boolean ()
    41.8 +BooleanValue::BooleanValue ()
    41.9    : m_value (false)
   41.10  {}
   41.11 -Boolean::Boolean (bool value)
   41.12 +BooleanValue::BooleanValue (bool value)
   41.13    : m_value (value)
   41.14  {}
   41.15  void 
   41.16 -Boolean::Set (bool value)
   41.17 +BooleanValue::Set (bool value)
   41.18  {
   41.19    m_value = value;
   41.20  }
   41.21  bool 
   41.22 -Boolean::Get (void) const
   41.23 +BooleanValue::Get (void) const
   41.24  {
   41.25    return m_value;
   41.26  }
   41.27 -Boolean::operator bool () const
   41.28 +BooleanValue::operator bool () const
   41.29  {
   41.30    return m_value;
   41.31  }
   41.32  
   41.33 -std::ostream & operator << (std::ostream &os, const Boolean &value)
   41.34 +std::ostream & operator << (std::ostream &os, const BooleanValue &value)
   41.35  {
   41.36    if (value.Get ())
   41.37      {
   41.38 @@ -55,31 +55,48 @@
   41.39      }
   41.40    return os;
   41.41  }
   41.42 -std::istream & operator >> (std::istream &is, Boolean &value)
   41.43 +
   41.44 +Ptr<AttributeValue> 
   41.45 +BooleanValue::Copy (void) const
   41.46  {
   41.47 -  std::string v;
   41.48 -  is >> v;
   41.49 -  if (v == "true" ||
   41.50 -      v == "1" ||
   41.51 -      v == "t")
   41.52 +  return Create<BooleanValue> (*this);
   41.53 +}
   41.54 +std::string 
   41.55 +BooleanValue::SerializeToString (Ptr<const AttributeChecker> checker) const
   41.56 +{
   41.57 +  if (m_value)
   41.58      {
   41.59 -      value.Set (true);
   41.60 +      return "true";
   41.61 +    } 
   41.62 +  else
   41.63 +    {
   41.64 +      return "false";
   41.65      }
   41.66 -  else if (v == "false" ||
   41.67 -	   v == "0" ||
   41.68 -	   v == "f")
   41.69 +}
   41.70 +bool 
   41.71 +BooleanValue::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
   41.72 +{
   41.73 +  if (value == "true" ||
   41.74 +      value == "1" ||
   41.75 +      value == "t")
   41.76      {
   41.77 -      value.Set (false);
   41.78 +      m_value = true;
   41.79 +      return true;
   41.80 +    }
   41.81 +  else if (value == "false" ||
   41.82 +           value == "0" ||
   41.83 +           value == "f")
   41.84 +    {
   41.85 +      m_value = false;
   41.86 +      return true;
   41.87      }
   41.88    else
   41.89      {
   41.90 -      is.setstate (std::ios_base::badbit);
   41.91 +      return false;
   41.92      }  
   41.93 -  return is;
   41.94  }
   41.95  
   41.96 -ATTRIBUTE_CONVERTER_IMPLEMENT (Boolean);
   41.97 -ATTRIBUTE_VALUE_IMPLEMENT (Boolean);
   41.98 -ATTRIBUTE_CHECKER_IMPLEMENT (Boolean);
   41.99 +
  41.100 +ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME (Boolean,"bool");
  41.101  
  41.102  } // namespace ns3
    42.1 --- a/src/core/boolean.h	Mon Apr 21 08:58:23 2008 -0700
    42.2 +++ b/src/core/boolean.h	Mon Apr 21 09:04:08 2008 -0700
    42.3 @@ -28,28 +28,30 @@
    42.4  /**
    42.5   * \brief Hold a bool native type
    42.6   *
    42.7 + * \anchor bool
    42.8 + *
    42.9   * This class can be used to hold bool variables
   42.10   * which must go through the Attribute system.
   42.11   */
   42.12 -class Boolean
   42.13 +class BooleanValue : public AttributeValue
   42.14  {
   42.15  public:
   42.16 -  Boolean ();
   42.17 -  Boolean (bool value);
   42.18 +  BooleanValue ();
   42.19 +  BooleanValue (bool value);
   42.20    void Set (bool value);
   42.21    bool Get (void) const;
   42.22 -
   42.23 +  
   42.24    operator bool () const;
   42.25  
   42.26 -  ATTRIBUTE_CONVERTER_DEFINE (Boolean);
   42.27 +  virtual Ptr<AttributeValue> Copy (void) const;
   42.28 +  virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
   42.29 +  virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
   42.30  private:
   42.31    bool m_value;
   42.32  };
   42.33  
   42.34 -std::ostream & operator << (std::ostream &os, const Boolean &value);
   42.35 -std::istream & operator >> (std::istream &is, Boolean &value);
   42.36 +std::ostream & operator << (std::ostream &os, const BooleanValue &value);
   42.37  
   42.38 -ATTRIBUTE_VALUE_DEFINE (Boolean);
   42.39  ATTRIBUTE_CHECKER_DEFINE (Boolean);
   42.40  ATTRIBUTE_ACCESSOR_DEFINE (Boolean);
   42.41  
    43.1 --- a/src/core/command-line.cc	Mon Apr 21 08:58:23 2008 -0700
    43.2 +++ b/src/core/command-line.cc	Mon Apr 21 09:04:08 2008 -0700
    43.3 @@ -21,6 +21,7 @@
    43.4  #include "log.h"
    43.5  #include "config.h"
    43.6  #include "global-value.h"
    43.7 +#include "type-id.h"
    43.8  #include "string.h"
    43.9  #include <stdlib.h>
   43.10  
   43.11 @@ -109,8 +110,9 @@
   43.12      {
   43.13        std::cout << "    --" << (*i)->GetName () << "=[";
   43.14        Ptr<const AttributeChecker> checker = (*i)->GetChecker ();
   43.15 -      Attribute value = (*i)->GetValue ();
   43.16 -      std::cout << value.SerializeToString (checker) << "]:  "
   43.17 +      StringValue v;
   43.18 +      (*i)->GetValue (v);
   43.19 +      std::cout << v.Get () << "]:  "
   43.20  		<< (*i)->GetHelp () << std::endl;      
   43.21      }
   43.22    exit (0);
   43.23 @@ -128,8 +130,8 @@
   43.24      {
   43.25        std::cout << "    --"<<tid.GetAttributeFullName (i)<<"=[";
   43.26        Ptr<const AttributeChecker> checker = tid.GetAttributeChecker (i);
   43.27 -      Attribute initial = tid.GetAttributeInitialValue (i);
   43.28 -      std::cout << initial.SerializeToString (checker) << "]:  "
   43.29 +      Ptr<const AttributeValue> initial = tid.GetAttributeInitialValue (i);
   43.30 +      std::cout << initial->SerializeToString (checker) << "]:  "
   43.31  		<< tid.GetAttributeHelp (i) << std::endl;
   43.32      }
   43.33    exit (0);
   43.34 @@ -243,8 +245,8 @@
   43.35  	    }
   43.36  	}
   43.37      }
   43.38 -  if (!Config::SetGlobalFailSafe (name, String (value))
   43.39 -      && !Config::SetDefaultFailSafe (name, String (value)))
   43.40 +  if (!Config::SetGlobalFailSafe (name, StringValue (value))
   43.41 +      && !Config::SetDefaultFailSafe (name, StringValue (value)))
   43.42      {
   43.43        std::cerr << "Invalid command-line arguments: --"<<name<<"="<<value<<std::endl;
   43.44        PrintHelp ();
    44.1 --- a/src/core/config.cc	Mon Apr 21 08:58:23 2008 -0700
    44.2 +++ b/src/core/config.cc	Mon Apr 21 09:04:08 2008 -0700
    44.3 @@ -22,6 +22,7 @@
    44.4  #include "object.h"
    44.5  #include "global-value.h"
    44.6  #include "object-vector.h"
    44.7 +#include "pointer.h"
    44.8  #include "log.h"
    44.9  #include <sstream>
   44.10  
   44.11 @@ -125,7 +126,7 @@
   44.12    void Resolve (Ptr<Object> root);
   44.13  private:
   44.14    void DoResolve (std::string path, Ptr<Object> root);
   44.15 -  void DoArrayResolve (std::string path, const ObjectVector &vector);
   44.16 +  void DoArrayResolve (std::string path, const ObjectVectorValue &vector);
   44.17    void DoResolveOne (Ptr<Object> object, std::string name);
   44.18    std::string GetResolvedPath (std::string name) const;
   44.19    virtual void DoOne (Ptr<Object> object, std::string path, std::string name) = 0;
   44.20 @@ -213,14 +214,13 @@
   44.21  	  return;
   44.22  	}
   44.23        // attempt to cast to a pointer checker.
   44.24 -      const PtrChecker *ptr = dynamic_cast<const PtrChecker *> (PeekPointer (info.checker));
   44.25 +      const PointerChecker *ptr = dynamic_cast<const PointerChecker *> (PeekPointer (info.checker));
   44.26        if (ptr != 0)
   44.27  	{
   44.28  	  NS_LOG_DEBUG ("GetAttribute(ptr)="<<item<<" on path="<<GetResolvedPath (""));
   44.29 -	  // XXX: This is not completely right because anything could be stored in a
   44.30 -	  // Ptr<>. We really need to fix this by thinking seriously about our
   44.31 -	  // object hierarchy.
   44.32 -	  Ptr<Object> object = root->GetAttribute (item);
   44.33 +          PointerValue ptr;
   44.34 +          root->GetAttribute (item, ptr);
   44.35 +	  Ptr<Object> object = ptr.Get<Object> ();
   44.36  	  if (object == 0)
   44.37  	    {
   44.38  	      NS_LOG_ERROR ("Requested object name=\""<<item<<
   44.39 @@ -237,7 +237,8 @@
   44.40        if (vectorChecker != 0)
   44.41  	{
   44.42  	  NS_LOG_DEBUG ("GetAttribute(vector)="<<item<<" on path="<<GetResolvedPath (""));
   44.43 -	  ObjectVector vector = root->GetAttribute (item);
   44.44 +	  ObjectVectorValue vector;
   44.45 +          root->GetAttribute (item, vector);
   44.46  	  m_workStack.push_back (item);
   44.47  	  DoArrayResolve (pathLeft, vector);
   44.48  	  m_workStack.pop_back ();
   44.49 @@ -248,7 +249,7 @@
   44.50  }
   44.51  
   44.52  void 
   44.53 -Resolver::DoArrayResolve (std::string path, const ObjectVector &vector)
   44.54 +Resolver::DoArrayResolve (std::string path, const ObjectVectorValue &vector)
   44.55  {
   44.56    NS_ASSERT (path != "");
   44.57    std::string::size_type pos = path.find ("/");
   44.58 @@ -284,7 +285,7 @@
   44.59  class ConfigImpl 
   44.60  {
   44.61  public:
   44.62 -  void Set (std::string path, Attribute value);
   44.63 +  void Set (std::string path, const AttributeValue &value);
   44.64    void ConnectWithoutContext (std::string path, const CallbackBase &cb);
   44.65    void Connect (std::string path, const CallbackBase &cb);
   44.66    void DisconnectWithoutContext (std::string path, const CallbackBase &cb);
   44.67 @@ -292,6 +293,9 @@
   44.68  
   44.69    void RegisterRootNamespaceObject (Ptr<Object> obj);
   44.70    void UnregisterRootNamespaceObject (Ptr<Object> obj);
   44.71 +
   44.72 +  uint32_t GetRootNamespaceObjectN (void) const;
   44.73 +  Ptr<Object> GetRootNamespaceObject (uint32_t i) const;
   44.74    
   44.75  private:
   44.76    typedef std::vector<Ptr<Object> > Roots;
   44.77 @@ -299,19 +303,19 @@
   44.78  };
   44.79  
   44.80  void 
   44.81 -ConfigImpl::Set (std::string path, Attribute value)
   44.82 +ConfigImpl::Set (std::string path, const AttributeValue &value)
   44.83  {
   44.84    class SetResolver : public Resolver 
   44.85    {
   44.86    public:
   44.87 -    SetResolver (std::string path, Attribute value)
   44.88 +    SetResolver (std::string path, const AttributeValue &value)
   44.89        : Resolver (path),
   44.90 -	m_value (value) {}
   44.91 +	m_value (value.Copy ()) {}
   44.92    private:
   44.93      virtual void DoOne (Ptr<Object> object, std::string path, std::string name) {
   44.94 -      object->SetAttribute (name, m_value);
   44.95 +      object->SetAttribute (name, *m_value);
   44.96      }
   44.97 -    Attribute m_value;
   44.98 +    Ptr<const AttributeValue> m_value;
   44.99    } resolver = SetResolver (path, value);
  44.100    for (Roots::const_iterator i = m_roots.begin (); i != m_roots.end (); i++)
  44.101      {
  44.102 @@ -417,26 +421,36 @@
  44.103      }
  44.104  }
  44.105  
  44.106 +uint32_t 
  44.107 +ConfigImpl::GetRootNamespaceObjectN (void) const
  44.108 +{
  44.109 +  return m_roots.size ();
  44.110 +}
  44.111 +Ptr<Object> 
  44.112 +ConfigImpl::GetRootNamespaceObject (uint32_t i) const
  44.113 +{
  44.114 +  return m_roots[i];
  44.115 +}
  44.116  
  44.117  namespace Config {
  44.118  
  44.119 -void Set (std::string path, Attribute value)
  44.120 +void Set (std::string path, const AttributeValue &value)
  44.121  {
  44.122    Singleton<ConfigImpl>::Get ()->Set (path, value);
  44.123  }
  44.124 -void SetDefault (std::string name, Attribute value)
  44.125 +void SetDefault (std::string name, const AttributeValue &value)
  44.126  {
  44.127    AttributeList::GetGlobal ()->Set (name, value);
  44.128  }
  44.129 -bool SetDefaultFailSafe (std::string name, Attribute value)
  44.130 +bool SetDefaultFailSafe (std::string name, const AttributeValue &value)
  44.131  {
  44.132    return AttributeList::GetGlobal ()->SetFailSafe (name, value);
  44.133  }
  44.134 -void SetGlobal (std::string name, Attribute value)
  44.135 +void SetGlobal (std::string name, const AttributeValue &value)
  44.136  {
  44.137    GlobalValue::Bind (name, value);
  44.138  }
  44.139 -bool SetGlobalFailSafe (std::string name, Attribute value)
  44.140 +bool SetGlobalFailSafe (std::string name, const AttributeValue &value)
  44.141  {
  44.142    return GlobalValue::BindFailSafe (name, value);
  44.143  }
  44.144 @@ -469,6 +483,17 @@
  44.145    Singleton<ConfigImpl>::Get ()->UnregisterRootNamespaceObject (obj);
  44.146  }
  44.147  
  44.148 +uint32_t GetRootNamespaceObjectN (void)
  44.149 +{
  44.150 +  return Singleton<ConfigImpl>::Get ()->GetRootNamespaceObjectN ();
  44.151 +}
  44.152 +
  44.153 +Ptr<Object> GetRootNamespaceObject (uint32_t i)
  44.154 +{
  44.155 +  return Singleton<ConfigImpl>::Get ()->GetRootNamespaceObject (i);
  44.156 +}
  44.157 +
  44.158 +
  44.159  } // namespace Config
  44.160  
  44.161  } // namespace ns3
  44.162 @@ -512,31 +537,31 @@
  44.163    static TypeId tid = TypeId ("MyNode")
  44.164      .SetParent<Object> ()
  44.165      .AddAttribute ("NodesA", "",
  44.166 -		   ObjectVector (),
  44.167 +		   ObjectVectorValue (),
  44.168  		   MakeObjectVectorAccessor (&MyNode::m_nodesA),
  44.169 -		   MakeObjectVectorChecker ())
  44.170 +		   MakeObjectVectorChecker<MyNode> ())
  44.171      .AddAttribute ("NodesB", "",
  44.172 -		   ObjectVector (),
  44.173 +		   ObjectVectorValue (),
  44.174  		   MakeObjectVectorAccessor (&MyNode::m_nodesB),
  44.175 -		   MakeObjectVectorChecker ())
  44.176 +		   MakeObjectVectorChecker<MyNode> ())
  44.177      .AddAttribute ("NodeA", "",
  44.178 -		   Ptr<MyNode> (0),
  44.179 -		   MakePtrAccessor (&MyNode::m_nodeA),
  44.180 -		   MakePtrChecker<MyNode> ())
  44.181 +                   PointerValue (),
  44.182 +		   MakePointerAccessor (&MyNode::m_nodeA),
  44.183 +		   MakePointerChecker<MyNode> ())
  44.184      .AddAttribute ("NodeB", "",
  44.185 -		   Ptr<MyNode> (0),
  44.186 -		   MakePtrAccessor (&MyNode::m_nodeB),
  44.187 -		   MakePtrChecker<MyNode> ())
  44.188 +                   PointerValue (),
  44.189 +		   MakePointerAccessor (&MyNode::m_nodeB),
  44.190 +		   MakePointerChecker<MyNode> ())
  44.191      .AddAttribute ("A", "",
  44.192 -		   Integer (10),
  44.193 +		   IntegerValue (10),
  44.194  		   MakeIntegerAccessor (&MyNode::m_a),
  44.195  		   MakeIntegerChecker<int8_t> ())
  44.196      .AddAttribute ("B", "",
  44.197 -		   Integer (9),
  44.198 +		   IntegerValue (9),
  44.199  		   MakeIntegerAccessor (&MyNode::m_b),
  44.200  		   MakeIntegerChecker<int8_t> ())
  44.201      .AddAttribute ("Source", "XX",
  44.202 -		   Integer (-1),
  44.203 +		   IntegerValue (-1),
  44.204  		   MakeIntegerAccessor (&MyNode::m_trace),
  44.205  		   MakeIntegerChecker<int16_t> ())
  44.206      .AddTraceSource ("Source", "XX",
  44.207 @@ -615,44 +640,45 @@
  44.208  
  44.209    Ptr<MyNode> root = CreateObject<MyNode> ();
  44.210    Config::RegisterRootNamespaceObject (root);
  44.211 -  Config::Set ("/A", Integer (1));
  44.212 -  Config::Set ("/B", Integer (-1));
  44.213 -  Integer v = root->GetAttribute ("A");
  44.214 +  Config::Set ("/A", IntegerValue (1));
  44.215 +  Config::Set ("/B", IntegerValue (-1));
  44.216 +  IntegerValue v;
  44.217 +  root->GetAttribute ("A", v);
  44.218    NS_TEST_ASSERT_EQUAL (v.Get (), 1);
  44.219 -  v = root->GetAttribute ("B");
  44.220 +  root->GetAttribute ("B", v);
  44.221    NS_TEST_ASSERT_EQUAL (v.Get (), -1);
  44.222  
  44.223    Ptr<MyNode> a = CreateObject<MyNode> ();
  44.224    root->SetNodeA (a);
  44.225 -  Config::Set ("/NodeA/A", Integer (2));
  44.226 -  Config::Set ("/NodeA/B", Integer (-2));
  44.227 -  v = a->GetAttribute ("A");
  44.228 +  Config::Set ("/NodeA/A", IntegerValue (2));
  44.229 +  Config::Set ("/NodeA/B", IntegerValue (-2));
  44.230 +  a->GetAttribute ("A", v);
  44.231    NS_TEST_ASSERT_EQUAL (v.Get (), 2);
  44.232 -  v = a->GetAttribute ("B");
  44.233 +  a->GetAttribute ("B", v);
  44.234    NS_TEST_ASSERT_EQUAL (v.Get (), -2);
  44.235 -  Config::Set ("/NodeB/A", Integer (3));
  44.236 -  Config::Set ("/NodeB/B", Integer (-3));
  44.237 -  v = a->GetAttribute ("A");
  44.238 +  Config::Set ("/NodeB/A", IntegerValue (3));
  44.239 +  Config::Set ("/NodeB/B", IntegerValue (-3));
  44.240 +  a->GetAttribute ("A", v);
  44.241    NS_TEST_ASSERT_EQUAL (v.Get (), 2);
  44.242 -  v = a->GetAttribute ("B");
  44.243 +  a->GetAttribute ("B", v);
  44.244    NS_TEST_ASSERT_EQUAL (v.Get (), -2);
  44.245  
  44.246    Ptr<MyNode> b = CreateObject<MyNode> ();
  44.247    a->SetNodeB (b);
  44.248 -  Config::Set ("/NodeA/NodeB/A", Integer (4));
  44.249 -  Config::Set ("/NodeA/NodeB/B", Integer (-4));
  44.250 -  v = b->GetAttribute ("A");
  44.251 +  Config::Set ("/NodeA/NodeB/A", IntegerValue (4));
  44.252 +  Config::Set ("/NodeA/NodeB/B", IntegerValue (-4));
  44.253 +  b->GetAttribute ("A", v);
  44.254    NS_TEST_ASSERT_EQUAL (v.Get (), 4);
  44.255 -  v = b->GetAttribute ("B");
  44.256 +  b->GetAttribute ("B", v);
  44.257    NS_TEST_ASSERT_EQUAL (v.Get (), -4);
  44.258  
  44.259    Ptr<MyNode> c = CreateObject<MyNode> ();
  44.260    root->SetNodeB (c);
  44.261 -  Config::Set ("/NodeB/A", Integer (5));
  44.262 -  Config::Set ("/NodeB/B", Integer (-5));
  44.263 -  v = c->GetAttribute ("A");
  44.264 +  Config::Set ("/NodeB/A", IntegerValue (5));
  44.265 +  Config::Set ("/NodeB/B", IntegerValue (-5));
  44.266 +  c->GetAttribute ("A", v);
  44.267    NS_TEST_ASSERT_EQUAL (v.Get (), 5);
  44.268 -  v = c->GetAttribute ("B");
  44.269 +  c->GetAttribute ("B", v);
  44.270    NS_TEST_ASSERT_EQUAL (v.Get (), -5);
  44.271  
  44.272  
  44.273 @@ -664,49 +690,49 @@
  44.274    b->AddNodeB (d1);
  44.275    b->AddNodeB (d2);
  44.276    b->AddNodeB (d3);
  44.277 -  Config::Set ("/NodeA/NodeB/NodesB/0/A", Integer (-11));
  44.278 -  v = d0->GetAttribute ("A");
  44.279 +  Config::Set ("/NodeA/NodeB/NodesB/0/A", IntegerValue (-11));
  44.280 +  d0->GetAttribute ("A", v);
  44.281    NS_TEST_ASSERT_EQUAL (v.Get (), -11);
  44.282 -  v = d0->GetAttribute ("B");
  44.283 +  d0->GetAttribute ("B", v);
  44.284    NS_TEST_ASSERT_EQUAL (v.Get (), 9);
  44.285 -  v = d1->GetAttribute ("A");
  44.286 +  d1->GetAttribute ("A", v);
  44.287    NS_TEST_ASSERT_EQUAL (v.Get (), 10);
  44.288 -  v = d1->GetAttribute ("B");
  44.289 +  d1->GetAttribute ("B", v);
  44.290    NS_TEST_ASSERT_EQUAL (v.Get (), 9);
  44.291 -  Config::Set ("/NodeA/NodeB/NodesB/0|1/A", Integer (-12));
  44.292 -  v = d0->GetAttribute ("A");
  44.293 +  Config::Set ("/NodeA/NodeB/NodesB/0|1/A", IntegerValue (-12));
  44.294 +  d0->GetAttribute ("A", v);
  44.295    NS_TEST_ASSERT_EQUAL (v.Get (), -12);
  44.296 -  v = d1->GetAttribute ("A");
  44.297 +  d1->GetAttribute ("A", v);
  44.298    NS_TEST_ASSERT_EQUAL (v.Get (), -12);
  44.299 -  Config::Set ("/NodeA/NodeB/NodesB/|0|1|/A", Integer (-13));
  44.300 -  v = d0->GetAttribute ("A");
  44.301 +  Config::Set ("/NodeA/NodeB/NodesB/|0|1|/A", IntegerValue (-13));
  44.302 +  d0->GetAttribute ("A", v);
  44.303    NS_TEST_ASSERT_EQUAL (v.Get (), -13);
  44.304 -  v = d1->GetAttribute ("A");
  44.305 +  d1->GetAttribute ("A", v);
  44.306    NS_TEST_ASSERT_EQUAL (v.Get (), -13);
  44.307 -  Config::Set ("/NodeA/NodeB/NodesB/[0-2]/A", Integer (-14));
  44.308 -  v = d0->GetAttribute ("A");
  44.309 +  Config::Set ("/NodeA/NodeB/NodesB/[0-2]/A", IntegerValue (-14));
  44.310 +  d0->GetAttribute ("A", v);
  44.311    NS_TEST_ASSERT_EQUAL (v.Get (), -14);
  44.312 -  v = d1->GetAttribute ("A");
  44.313 +  d1->GetAttribute ("A", v);
  44.314    NS_TEST_ASSERT_EQUAL (v.Get (), -14);
  44.315 -  v = d2->GetAttribute ("A");
  44.316 +  d2->GetAttribute ("A", v);
  44.317    NS_TEST_ASSERT_EQUAL (v.Get (), -14);
  44.318 -  Config::Set ("/NodeA/NodeB/NodesB/[1-3]/A", Integer (-15));
  44.319 -  v = d0->GetAttribute ("A");
  44.320 +  Config::Set ("/NodeA/NodeB/NodesB/[1-3]/A", IntegerValue (-15));
  44.321 +  d0->GetAttribute ("A", v);
  44.322    NS_TEST_ASSERT_EQUAL (v.Get (), -14);
  44.323 -  v = d1->GetAttribute ("A");
  44.324 +  d1->GetAttribute ("A", v);
  44.325    NS_TEST_ASSERT_EQUAL (v.Get (), -15);
  44.326 -  v = d2->GetAttribute ("A");
  44.327 +  d2->GetAttribute ("A", v);
  44.328    NS_TEST_ASSERT_EQUAL (v.Get (), -15);
  44.329 -  v = d3->GetAttribute ("A");
  44.330 +  d3->GetAttribute ("A", v);
  44.331    NS_TEST_ASSERT_EQUAL (v.Get (), -15);
  44.332 -  Config::Set ("/NodeA/NodeB/NodesB/[0-1]|3/A", Integer (-16));
  44.333 -  v = d0->GetAttribute ("A");
  44.334 +  Config::Set ("/NodeA/NodeB/NodesB/[0-1]|3/A", IntegerValue (-16));
  44.335 +  d0->GetAttribute ("A", v);
  44.336    NS_TEST_ASSERT_EQUAL (v.Get (), -16);
  44.337 -  v = d1->GetAttribute ("A");
  44.338 +  d1->GetAttribute ("A", v);
  44.339    NS_TEST_ASSERT_EQUAL (v.Get (), -16);
  44.340 -  v = d2->GetAttribute ("A");
  44.341 +  d2->GetAttribute ("A", v);
  44.342    NS_TEST_ASSERT_EQUAL (v.Get (), -15);
  44.343 -  v = d3->GetAttribute ("A");
  44.344 +  d3->GetAttribute ("A", v);
  44.345    NS_TEST_ASSERT_EQUAL (v.Get (), -16);
  44.346  
  44.347  
  44.348 @@ -714,17 +740,17 @@
  44.349  		   MakeCallback (&ConfigTest::ChangeNotification, this));
  44.350    m_traceNotification = 0;
  44.351    // this should trigger no notification
  44.352 -  d2->SetAttribute ("Source", Integer (-2));
  44.353 +  d2->SetAttribute ("Source", IntegerValue (-2));
  44.354    NS_TEST_ASSERT_EQUAL (m_traceNotification, 0);
  44.355    m_traceNotification = 0;
  44.356    // this should trigger a notification
  44.357 -  d1->SetAttribute ("Source", Integer (-3));
  44.358 +  d1->SetAttribute ("Source", IntegerValue (-3));
  44.359    NS_TEST_ASSERT_EQUAL (m_traceNotification, -3);
  44.360    Config::DisconnectWithoutContext ("/NodeA/NodeB/NodesB/[0-1]|3/Source", 
  44.361  		      MakeCallback (&ConfigTest::ChangeNotification, this));
  44.362    m_traceNotification = 0;
  44.363    // this should _not_ trigger a notification
  44.364 -  d1->SetAttribute ("Source", Integer (-4));
  44.365 +  d1->SetAttribute ("Source", IntegerValue (-4));
  44.366    NS_TEST_ASSERT_EQUAL (m_traceNotification, 0);
  44.367  
  44.368    
  44.369 @@ -732,25 +758,25 @@
  44.370  			      MakeCallback (&ConfigTest::ChangeNotificationWithPath, this));
  44.371    m_traceNotification = 0;
  44.372    // this should trigger no notification
  44.373 -  d2->SetAttribute ("Source", Integer (-2));
  44.374 +  d2->SetAttribute ("Source", IntegerValue (-2));
  44.375    NS_TEST_ASSERT_EQUAL (m_traceNotification, 0);
  44.376    m_traceNotification = 0;
  44.377    m_tracePath = "";
  44.378    // this should trigger a notification
  44.379 -  d1->SetAttribute ("Source", Integer (-3));
  44.380 +  d1->SetAttribute ("Source", IntegerValue (-3));
  44.381    NS_TEST_ASSERT_EQUAL (m_traceNotification, -3);
  44.382    NS_TEST_ASSERT_EQUAL (m_tracePath, "/NodeA/NodeB/NodesB/1/Source")
  44.383    m_traceNotification = 0;
  44.384    m_tracePath = "";
  44.385    // this should trigger a notification
  44.386 -  d3->SetAttribute ("Source", Integer (-3));
  44.387 +  d3->SetAttribute ("Source", IntegerValue (-3));
  44.388    NS_TEST_ASSERT_EQUAL (m_traceNotification, -3);
  44.389    NS_TEST_ASSERT_EQUAL (m_tracePath, "/NodeA/NodeB/NodesB/3/Source");
  44.390    Config::Disconnect ("/NodeA/NodeB/NodesB/[0-1]|3/Source", 
  44.391  				 MakeCallback (&ConfigTest::ChangeNotificationWithPath, this));
  44.392    m_traceNotification = 0;
  44.393    // this should _not_ trigger a notification
  44.394 -  d1->SetAttribute ("Source", Integer (-4));
  44.395 +  d1->SetAttribute ("Source", IntegerValue (-4));
  44.396    NS_TEST_ASSERT_EQUAL (m_traceNotification, 0);
  44.397  
  44.398  
    45.1 --- a/src/core/config.h	Mon Apr 21 08:58:23 2008 -0700
    45.2 +++ b/src/core/config.h	Mon Apr 21 09:04:08 2008 -0700
    45.3 @@ -20,13 +20,15 @@
    45.4  #ifndef CONFIG_H
    45.5  #define CONFIG_H
    45.6  
    45.7 -#include "attribute.h"
    45.8  #include "ptr.h"
    45.9 -#include "object.h"
   45.10  #include <string>
   45.11  
   45.12  namespace ns3 {
   45.13  
   45.14 +class AttributeValue;
   45.15 +class Object;
   45.16 +class CallbackBase;
   45.17 +
   45.18  namespace Config {
   45.19  
   45.20  /**
   45.21 @@ -37,7 +39,7 @@
   45.22   * match the input path and will then set their value to the input
   45.23   * value.
   45.24   */
   45.25 -void Set (std::string path, Attribute value);
   45.26 +void Set (std::string path, const AttributeValue &value);
   45.27  /**
   45.28   * \param name the full name of the attribute
   45.29   * \param value the value to set.
   45.30 @@ -46,7 +48,7 @@
   45.31   * matching attribute. This method cannot fail: it will
   45.32   * crash if the input attribute name or value is invalid.
   45.33   */
   45.34 -void SetDefault (std::string name, Attribute value);
   45.35 +void SetDefault (std::string name, const AttributeValue &value);
   45.36  /**
   45.37   * \param name the full name of the attribute
   45.38   * \param value the value to set.
   45.39 @@ -55,21 +57,21 @@
   45.40   * This method overrides the initial value of the 
   45.41   * matching attribute. 
   45.42   */
   45.43 -bool SetDefaultFailSafe (std::string name, Attribute value);
   45.44 +bool SetDefaultFailSafe (std::string name, const AttributeValue &value);
   45.45  /**
   45.46   * \param name the name of the requested GlobalValue.
   45.47   * \param value the value to set
   45.48   *
   45.49   * This method is equivalent to GlobalValue::Bind
   45.50   */
   45.51 -void SetGlobal (std::string name, Attribute value);
   45.52 +void SetGlobal (std::string name, const AttributeValue &value);
   45.53  /**
   45.54   * \param name the name of the requested GlobalValue.
   45.55   * \param value the value to set
   45.56   *
   45.57   * This method is equivalent to GlobalValue::BindFailSafe
   45.58   */
   45.59 -bool SetGlobalFailSafe (std::string name, Attribute value);
   45.60 +bool SetGlobalFailSafe (std::string name, const AttributeValue &value);
   45.61  /**
   45.62   * \param path a path to match trace sources.
   45.63   * \param cb the callback to connect to the matching trace sources.
   45.64 @@ -118,6 +120,17 @@
   45.65   */
   45.66  void UnregisterRootNamespaceObject (Ptr<Object> obj);
   45.67  
   45.68 +/**
   45.69 + * \returns the number of registered root namespace objects.
   45.70 + */
   45.71 +uint32_t GetRootNamespaceObjectN (void);
   45.72 +
   45.73 +/**
   45.74 + * \param i the index of the requested object.
   45.75 + * \returns the requested root namespace object
   45.76 + */
   45.77 +Ptr<Object> GetRootNamespaceObject (uint32_t i);
   45.78 +
   45.79  } // namespace Config
   45.80  
   45.81  } // namespace ns3
    46.1 --- a/src/core/double.cc	Mon Apr 21 08:58:23 2008 -0700
    46.2 +++ b/src/core/double.cc	Mon Apr 21 09:04:08 2008 -0700
    46.3 @@ -23,40 +23,7 @@
    46.4  
    46.5  namespace ns3 {
    46.6  
    46.7 -Double::Double ()
    46.8 -{}
    46.9 -Double::Double (double value)
   46.10 -  : m_value (value)
   46.11 -{}
   46.12 -void 
   46.13 -Double::Set (double value)
   46.14 -{
   46.15 -  m_value = value;
   46.16 -}
   46.17 -double 
   46.18 -Double::Get (void) const
   46.19 -{
   46.20 -  return m_value;
   46.21 -}
   46.22 -Double::operator double () const
   46.23 -{
   46.24 -  return m_value;
   46.25 -}
   46.26 -std::ostream & operator << (std::ostream &os, const Double &value)
   46.27 -{
   46.28 -  os << value.Get ();
   46.29 -  return os;
   46.30 -}
   46.31 -std::istream & operator >> (std::istream &is, Double &value)
   46.32 -{
   46.33 -  double v;
   46.34 -  is >> v;
   46.35 -  value.Set (v);
   46.36 -  return is;
   46.37 -}
   46.38 -
   46.39 -ATTRIBUTE_VALUE_IMPLEMENT (Double);
   46.40 -ATTRIBUTE_CONVERTER_IMPLEMENT (Double);
   46.41 +ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME (double, Double);
   46.42  
   46.43  namespace internal {
   46.44  
   46.45 @@ -68,27 +35,37 @@
   46.46        : m_minValue (minValue),
   46.47          m_maxValue (maxValue),
   46.48          m_name (name) {}
   46.49 -    virtual bool Check (Attribute value) const {
   46.50 -      const DoubleValue *v = value.DynCast<const DoubleValue *> ();
   46.51 +    virtual bool Check (const AttributeValue &value) const {
   46.52 +      const DoubleValue *v = dynamic_cast<const DoubleValue *> (&value);
   46.53        if (v == 0)
   46.54  	{
   46.55  	  return false;
   46.56  	}
   46.57        return v->Get () >= m_minValue && v->Get () <= m_maxValue;
   46.58      }
   46.59 -    virtual std::string GetType (void) const {
   46.60 -      return m_name;
   46.61 +    virtual std::string GetValueTypeName (void) const {
   46.62 +      return "ns3::DoubleValue";
   46.63      }
   46.64 -    virtual bool HasTypeConstraints (void) const {
   46.65 +    virtual bool HasUnderlyingTypeInformation (void) const {
   46.66        return true;
   46.67      }
   46.68 -    virtual std::string GetTypeConstraints (void) const {
   46.69 +    virtual std::string GetUnderlyingTypeInformation (void) const {
   46.70        std::ostringstream oss;
   46.71 -      oss << m_minValue << ":" << m_maxValue;
   46.72 +      oss << m_name << " " << m_minValue << ":" << m_maxValue;
   46.73        return oss.str ();
   46.74      }
   46.75 -    virtual Attribute Create (void) const {
   46.76 -      return Attribute::Create<DoubleValue> ();
   46.77 +    virtual Ptr<AttributeValue> Create (void) const {
   46.78 +      return ns3::Create<DoubleValue> ();
   46.79 +    }
   46.80 +    virtual bool Copy (const AttributeValue &source, AttributeValue &destination) const {
   46.81 +      const DoubleValue *src = dynamic_cast<const DoubleValue *> (&source);
   46.82 +      DoubleValue *dst = dynamic_cast<DoubleValue *> (&destination);
   46.83 +      if (src == 0 || dst == 0)
   46.84 +        {
   46.85 +          return false;
   46.86 +        }
   46.87 +      *dst = *src;
   46.88 +      return true;
   46.89      }
   46.90      double m_minValue;
   46.91      double m_maxValue;
    47.1 --- a/src/core/double.h	Mon Apr 21 08:58:23 2008 -0700
    47.2 +++ b/src/core/double.h	Mon Apr 21 09:04:08 2008 -0700
    47.3 @@ -27,31 +27,15 @@
    47.4  namespace ns3 {
    47.5  
    47.6  /**
    47.7 + * \class ns3::DoubleValue
    47.8   * \brief Hold an floating point type
    47.9   *
   47.10 + * \anchor double
   47.11   * This class can be used to hold variables of floating point type
   47.12   * such as 'double' or 'float'. The internal format is 'double'.
   47.13   */
   47.14 -class Double
   47.15 -{
   47.16 -public:
   47.17 -  Double ();
   47.18 -  Double (double value);
   47.19  
   47.20 -  void Set (double value);
   47.21 -  double Get (void) const;
   47.22 -
   47.23 -  operator double () const;
   47.24 -
   47.25 -  ATTRIBUTE_CONVERTER_DEFINE (Double);
   47.26 -private:
   47.27 -  double m_value;
   47.28 -};
   47.29 -
   47.30 -std::ostream & operator << (std::ostream &os, const Double &value);
   47.31 -std::istream & operator >> (std::istream &is, Double &value);
   47.32 -
   47.33 -ATTRIBUTE_VALUE_DEFINE (Double);
   47.34 +ATTRIBUTE_VALUE_DEFINE_WITH_NAME (double, Double);
   47.35  ATTRIBUTE_ACCESSOR_DEFINE (Double);
   47.36  
   47.37  template <typename T>
    48.1 --- a/src/core/enum.cc	Mon Apr 21 08:58:23 2008 -0700
    48.2 +++ b/src/core/enum.cc	Mon Apr 21 09:04:08 2008 -0700
    48.3 @@ -23,30 +23,30 @@
    48.4  
    48.5  namespace ns3 {
    48.6  
    48.7 -Enum::Enum ()
    48.8 +EnumValue::EnumValue ()
    48.9    : m_v ()
   48.10  {}
   48.11 -Enum::Enum (int v)
   48.12 +EnumValue::EnumValue (int v)
   48.13    : m_v (v)
   48.14  {}
   48.15  void 
   48.16 -Enum::Set (int v)
   48.17 +EnumValue::Set (int v)
   48.18  {
   48.19    m_v = v;
   48.20  }
   48.21  int 
   48.22 -Enum::Get (void) const
   48.23 +EnumValue::Get (void) const
   48.24  {
   48.25    return m_v;
   48.26  }
   48.27  
   48.28 -Attribute
   48.29 -Enum::Copy (void) const
   48.30 +Ptr<AttributeValue>
   48.31 +EnumValue::Copy (void) const
   48.32  {
   48.33 -  return Attribute::Create<Enum> (*this);
   48.34 +  return ns3::Create<EnumValue> (*this);
   48.35  }
   48.36  std::string 
   48.37 -Enum::SerializeToString (Ptr<const AttributeChecker> checker) const
   48.38 +EnumValue::SerializeToString (Ptr<const AttributeChecker> checker) const
   48.39  {
   48.40    const EnumChecker *p = dynamic_cast<const EnumChecker *> (PeekPointer (checker));
   48.41    NS_ASSERT (p != 0);
   48.42 @@ -63,7 +63,7 @@
   48.43    return "";
   48.44  }
   48.45  bool 
   48.46 -Enum::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
   48.47 +EnumValue::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
   48.48  {
   48.49    const EnumChecker *p = dynamic_cast<const EnumChecker *> (PeekPointer (checker));
   48.50    NS_ASSERT (p != 0);
   48.51 @@ -78,22 +78,6 @@
   48.52    return false;
   48.53  }
   48.54  
   48.55 -Enum::Enum (Attribute value)
   48.56 -{
   48.57 -  const Enum *v = value.DynCast<const Enum *> ();
   48.58 -  if (v == 0)
   48.59 -    {
   48.60 -      NS_FATAL_ERROR ("assigning non-Enum value to Enum value.");
   48.61 -    }
   48.62 -  m_v = v->m_v;
   48.63 -}
   48.64 -Enum::operator Attribute () const
   48.65 -{
   48.66 -  return Attribute::Create<Enum> (*this);
   48.67 -}
   48.68 -
   48.69 -
   48.70 -
   48.71  EnumChecker::EnumChecker ()
   48.72  {}
   48.73  
   48.74 @@ -108,9 +92,9 @@
   48.75    m_valueSet.push_back (std::make_pair (v, name));
   48.76  }
   48.77  bool 
   48.78 -EnumChecker::Check (Attribute value) const
   48.79 +EnumChecker::Check (const AttributeValue &value) const
   48.80  {
   48.81 -  const Enum *p = value.DynCast<const Enum *> ();
   48.82 +  const EnumValue *p = dynamic_cast<const EnumValue *> (&value);
   48.83    if (p == 0)
   48.84      {
   48.85        return false;
   48.86 @@ -125,17 +109,17 @@
   48.87    return false;
   48.88  }
   48.89  std::string 
   48.90 -EnumChecker::GetType (void) const
   48.91 +EnumChecker::GetValueTypeName (void) const
   48.92  {
   48.93 -  return "Enum";
   48.94 +  return "ns3::EnumValue";
   48.95  }
   48.96  bool 
   48.97 -EnumChecker::HasTypeConstraints (void) const
   48.98 +EnumChecker::HasUnderlyingTypeInformation (void) const
   48.99  {
  48.100    return true;
  48.101  }
  48.102  std::string 
  48.103 -EnumChecker::GetTypeConstraints (void) const
  48.104 +EnumChecker::GetUnderlyingTypeInformation (void) const
  48.105  {
  48.106    std::ostringstream oss;
  48.107    for (ValueSet::const_iterator i = m_valueSet.begin (); i != m_valueSet.end ();)
  48.108 @@ -149,10 +133,23 @@
  48.109      }
  48.110    return oss.str ();
  48.111  }
  48.112 -Attribute 
  48.113 +Ptr<AttributeValue>
  48.114  EnumChecker::Create (void) const
  48.115  {
  48.116 -  return Attribute::Create<Enum> ();
  48.117 +  return ns3::Create<EnumValue> ();
  48.118 +}
  48.119 +
  48.120 +bool 
  48.121 +EnumChecker::Copy (const AttributeValue &source, AttributeValue &destination) const
  48.122 +{
  48.123 +  const EnumValue *src = dynamic_cast<const EnumValue *> (&source);
  48.124 +  EnumValue *dst = dynamic_cast<EnumValue *> (&destination);
  48.125 +  if (src == 0 || dst == 0)
  48.126 +    {
  48.127 +      return false;
  48.128 +    }
  48.129 +  *dst = *src;
  48.130 +  return true;
  48.131  }
  48.132  
  48.133  
    49.1 --- a/src/core/enum.h	Mon Apr 21 08:58:23 2008 -0700
    49.2 +++ b/src/core/enum.h	Mon Apr 21 09:04:08 2008 -0700
    49.3 @@ -32,20 +32,18 @@
    49.4   * This class can be used to hold variables of any kind
    49.5   * of enum.
    49.6   */
    49.7 -class Enum : public AttributeValue
    49.8 +class EnumValue : public AttributeValue
    49.9  {
   49.10  public:
   49.11 -  Enum ();
   49.12 -  Enum (int v);
   49.13 +  EnumValue ();
   49.14 +  EnumValue (int v);
   49.15    void Set (int v);
   49.16    int Get (void) const;
   49.17  
   49.18 -  virtual Attribute Copy (void) const;
   49.19 +  virtual Ptr<AttributeValue> Copy (void) const;
   49.20    virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
   49.21    virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
   49.22  
   49.23 -  Enum (Attribute value);
   49.24 -  operator Attribute () const;
   49.25  private:
   49.26    int m_v;
   49.27  };
   49.28 @@ -58,14 +56,15 @@
   49.29    void AddDefault (int v, std::string name);
   49.30    void Add (int v, std::string name);
   49.31  
   49.32 -  virtual bool Check (Attribute value) const;
   49.33 -  virtual std::string GetType (void) const;
   49.34 -  virtual bool HasTypeConstraints (void) const;
   49.35 -  virtual std::string GetTypeConstraints (void) const;
   49.36 -  virtual Attribute Create (void) const;
   49.37 +  virtual bool Check (const AttributeValue &value) const;
   49.38 +  virtual std::string GetValueTypeName (void) const;
   49.39 +  virtual bool HasUnderlyingTypeInformation (void) const;
   49.40 +  virtual std::string GetUnderlyingTypeInformation (void) const;
   49.41 +  virtual Ptr<AttributeValue> Create (void) const;
   49.42 +  virtual bool Copy (const AttributeValue &src, AttributeValue &dst) const;
   49.43  
   49.44  private:
   49.45 -  friend class Enum;
   49.46 +  friend class EnumValue;
   49.47    typedef std::list<std::pair<int,std::string> > ValueSet;
   49.48    ValueSet m_valueSet;
   49.49  };
   49.50 @@ -97,13 +96,13 @@
   49.51  template <typename T1>
   49.52  Ptr<const AttributeAccessor> MakeEnumAccessor (T1 a1)
   49.53  {
   49.54 -  return MakeAccessorHelper<Enum> (a1);
   49.55 +  return MakeAccessorHelper<EnumValue> (a1);
   49.56  }
   49.57  
   49.58  template <typename T1, typename T2>
   49.59  Ptr<const AttributeAccessor> MakeEnumAccessor (T1 a1, T2 a2)
   49.60  {
   49.61 -  return MakeAccessorHelper<Enum> (a1, a2);
   49.62 +  return MakeAccessorHelper<EnumValue> (a1, a2);
   49.63  }
   49.64  
   49.65  } // namespace ns3
    50.1 --- a/src/core/global-value.cc	Mon Apr 21 08:58:23 2008 -0700
    50.2 +++ b/src/core/global-value.cc	Mon Apr 21 09:04:08 2008 -0700
    50.3 @@ -25,11 +25,11 @@
    50.4  namespace ns3 {
    50.5  
    50.6  GlobalValue::GlobalValue (std::string name, std::string help,
    50.7 -			  Attribute initialValue,
    50.8 +			  const AttributeValue &initialValue,
    50.9  			  Ptr<const AttributeChecker> checker)
   50.10    : m_name (name),
   50.11      m_help (help),
   50.12 -    m_initialValue (initialValue),
   50.13 +    m_initialValue (initialValue.Copy ()),
   50.14      m_checker (checker)
   50.15  {
   50.16    if (m_checker == 0)
   50.17 @@ -49,10 +49,20 @@
   50.18  {
   50.19    return m_help;
   50.20  }
   50.21 -Attribute 
   50.22 -GlobalValue::GetValue (void) const
   50.23 +void
   50.24 +GlobalValue::GetValue (AttributeValue &value) const
   50.25  {
   50.26 -  return m_initialValue;
   50.27 +  bool ok = m_checker->Copy (*m_initialValue, value);
   50.28 +  if (ok)
   50.29 +    {
   50.30 +      return;
   50.31 +    }
   50.32 +  StringValue *str = dynamic_cast<StringValue *> (&value);
   50.33 +  if (str == 0)
   50.34 +    {
   50.35 +      NS_FATAL_ERROR ("GlobalValue name="<<m_name<<": input value is not a string");
   50.36 +    }
   50.37 +  str->Set (m_initialValue->SerializeToString (m_checker));
   50.38  }
   50.39  Ptr<const AttributeChecker> 
   50.40  GlobalValue::GetChecker (void) const
   50.41 @@ -61,37 +71,37 @@
   50.42  }
   50.43    
   50.44  bool
   50.45 -GlobalValue::SetValue (Attribute value)
   50.46 +GlobalValue::SetValue (const AttributeValue &value)
   50.47  {
   50.48    if (m_checker->Check (value))
   50.49      {
   50.50 -      m_initialValue = value;
   50.51 +      m_initialValue = value.Copy ();
   50.52        return true;
   50.53      }
   50.54    // attempt to convert to string.
   50.55 -  const StringValue *str = value.DynCast<const StringValue *> ();
   50.56 +  const StringValue *str = dynamic_cast<const StringValue *> (&value);
   50.57    if (str == 0)
   50.58      {
   50.59        return false;
   50.60      }
   50.61    // attempt to convert back to value.
   50.62 -  Attribute v = m_checker->Create ();
   50.63 -  bool ok = v.DeserializeFromString (str->Get ().Get (), m_checker);
   50.64 +  Ptr<AttributeValue> v = m_checker->Create ();
   50.65 +  bool ok = v->DeserializeFromString (str->Get (), m_checker);
   50.66    if (!ok)
   50.67      {
   50.68        return false;
   50.69      }
   50.70 -  ok = m_checker->Check (v);
   50.71 +  ok = m_checker->Check (*v);
   50.72    if (!ok)
   50.73      {
   50.74        return false;
   50.75      }
   50.76 -  m_initialValue = v;
   50.77 +  m_checker->Copy (*v, *PeekPointer (m_initialValue));
   50.78    return true;
   50.79  }
   50.80  
   50.81  void 
   50.82 -GlobalValue::Bind (std::string name, Attribute value)
   50.83 +GlobalValue::Bind (std::string name, const AttributeValue &value)
   50.84  {
   50.85    for (Iterator i = Begin (); i != End (); i++)
   50.86      {
   50.87 @@ -107,7 +117,7 @@
   50.88    NS_FATAL_ERROR ("Non-existant global value: "<<name);
   50.89  }
   50.90  bool 
   50.91 -GlobalValue::BindFailSafe (std::string name, Attribute value)
   50.92 +GlobalValue::BindFailSafe (std::string name, const AttributeValue &value)
   50.93  {
   50.94    for (Iterator i = Begin (); i != End (); i++)
   50.95      {
   50.96 @@ -160,11 +170,13 @@
   50.97  {
   50.98    bool result = true;
   50.99    GlobalValue uint = GlobalValue ("TestUint", "help text",
  50.100 -				  Uinteger (10),
  50.101 +				  UintegerValue (10),
  50.102  				  MakeUintegerChecker<uint32_t> ());
  50.103  
  50.104  
  50.105 -  NS_TEST_ASSERT_EQUAL (10, Uinteger (uint.GetValue ()).Get ());
  50.106 +  UintegerValue v;
  50.107 +  uint.GetValue (v);
  50.108 +  NS_TEST_ASSERT_EQUAL (10, v.Get ());
  50.109  
  50.110    GlobalValue::Vector *vector = GlobalValue::GetVector ();
  50.111    for (GlobalValue::Vector::iterator i = vector->begin (); i != vector->end (); ++i)
    51.1 --- a/src/core/global-value.h	Mon Apr 21 08:58:23 2008 -0700
    51.2 +++ b/src/core/global-value.h	Mon Apr 21 09:04:08 2008 -0700
    51.3 @@ -51,8 +51,8 @@
    51.4     *        value matches the requested type constraints.
    51.5     */
    51.6    GlobalValue (std::string name, std::string help,
    51.7 -		Attribute initialValue,
    51.8 -		Ptr<const AttributeChecker> checker);
    51.9 +               const AttributeValue &initialValue,
   51.10 +               Ptr<const AttributeChecker> checker);
   51.11  
   51.12    /**
   51.13     * \returns the name of this GlobalValue.
   51.14 @@ -65,7 +65,7 @@
   51.15    /**
   51.16     * \returns the current value of this GlobalValue.
   51.17     */
   51.18 -  Attribute GetValue (void) const;
   51.19 +  void GetValue (AttributeValue &value) const;
   51.20    /**
   51.21     * \returns the checker associated to this GlobalValue.
   51.22     */
   51.23 @@ -73,7 +73,7 @@
   51.24    /**
   51.25     * \param value the new value to set in this GlobalValue.
   51.26     */
   51.27 -  bool SetValue (Attribute value);
   51.28 +  bool SetValue (const AttributeValue &value);
   51.29  
   51.30    /**
   51.31     * \param name the name of the global value
   51.32 @@ -84,7 +84,7 @@
   51.33     *
   51.34     * This method cannot fail. It will crash if the input is not valid.
   51.35     */
   51.36 -  static void Bind (std::string name, Attribute value);
   51.37 +  static void Bind (std::string name, const AttributeValue &value);
   51.38    
   51.39    /**
   51.40     * \param name the name of the global value
   51.41 @@ -94,7 +94,7 @@
   51.42     * Iterate over the set of GlobalValues until a matching name is found
   51.43     * and then set its value with GlobalValue::SetValue.
   51.44     */
   51.45 -  static bool BindFailSafe (std::string name, Attribute value);
   51.46 +  static bool BindFailSafe (std::string name, const AttributeValue &value);
   51.47  
   51.48    /**
   51.49     * \returns an iterator which represents a pointer to the first GlobalValue registered.
   51.50 @@ -109,7 +109,7 @@
   51.51    static Vector *GetVector (void);
   51.52    std::string m_name;
   51.53    std::string m_help;
   51.54 -  Attribute m_initialValue;
   51.55 +  Ptr<AttributeValue> m_initialValue;
   51.56    Ptr<const AttributeChecker> m_checker;
   51.57  };
   51.58  
    52.1 --- a/src/core/integer.cc	Mon Apr 21 08:58:23 2008 -0700
    52.2 +++ b/src/core/integer.cc	Mon Apr 21 09:04:08 2008 -0700
    52.3 @@ -23,44 +23,7 @@
    52.4  
    52.5  namespace ns3 {
    52.6  
    52.7 -Integer::Integer (int64_t value)
    52.8 -  : m_value (value)
    52.9 -{}
   52.10 -Integer::Integer ()
   52.11 -  : m_value (0)
   52.12 -{}
   52.13 -void 
   52.14 -Integer::Set (int64_t value)
   52.15 -{
   52.16 -  m_value = value;
   52.17 -}
   52.18 -int64_t 
   52.19 -Integer::Get (void) const
   52.20 -{
   52.21 -  return m_value;
   52.22 -}
   52.23 -
   52.24 -Integer::operator int64_t () const
   52.25 -{
   52.26 -  return m_value;
   52.27 -}
   52.28 -
   52.29 -ATTRIBUTE_VALUE_IMPLEMENT (Integer);
   52.30 -
   52.31 -std::ostream &operator << (std::ostream &os, const Integer &integer)
   52.32 -{
   52.33 -  os << integer.Get ();
   52.34 -  return os;
   52.35 -}
   52.36 -std::istream &operator >> (std::istream &is, Integer &integer)
   52.37 -{
   52.38 -  int64_t v;
   52.39 -  is >> v;
   52.40 -  integer.Set (v);
   52.41 -  return is;
   52.42 -}
   52.43 -
   52.44 -ATTRIBUTE_CONVERTER_IMPLEMENT (Integer);
   52.45 +ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME (int64_t, Integer);
   52.46  
   52.47  namespace internal {
   52.48  
   52.49 @@ -73,27 +36,37 @@
   52.50        : m_minValue (minValue),
   52.51          m_maxValue (maxValue),
   52.52          m_name (name) {}
   52.53 -    virtual bool Check (Attribute value) const {
   52.54 -      const IntegerValue *v = value.DynCast<const IntegerValue *> ();
   52.55 +    virtual bool Check (const AttributeValue &value) const {
   52.56 +      const IntegerValue *v = dynamic_cast<const IntegerValue *> (&value);
   52.57        if (v == 0)
   52.58  	{
   52.59  	  return false;
   52.60  	}
   52.61 -      return v->Get ().Get () >= m_minValue && v->Get ().Get() <= m_maxValue;
   52.62 +      return v->Get () >= m_minValue && v->Get () <= m_maxValue;
   52.63      }
   52.64 -    virtual std::string GetType (void) const {
   52.65 -      return m_name;
   52.66 +    virtual std::string GetValueTypeName (void) const {
   52.67 +      return "ns3::IntegerValue";
   52.68      }
   52.69 -    virtual bool HasTypeConstraints (void) const {
   52.70 +    virtual bool HasUnderlyingTypeInformation (void) const {
   52.71        return true;
   52.72      }
   52.73 -    virtual std::string GetTypeConstraints (void) const {
   52.74 +    virtual std::string GetUnderlyingTypeInformation (void) const {
   52.75        std::ostringstream oss;
   52.76 -      oss << m_minValue << ":" << m_maxValue;
   52.77 +      oss << m_name << " " << m_minValue << ":" << m_maxValue;
   52.78        return oss.str ();
   52.79      }
   52.80 -    virtual Attribute Create (void) const {
   52.81 -      return Attribute::Create<IntegerValue> ();
   52.82 +    virtual Ptr<AttributeValue> Create (void) const {
   52.83 +      return ns3::Create<IntegerValue> ();
   52.84 +    }
   52.85 +    virtual bool Copy (const AttributeValue &src, AttributeValue &dst) const {
   52.86 +      const IntegerValue *source = dynamic_cast<const IntegerValue *> (&src);
   52.87 +      IntegerValue *destination = dynamic_cast<IntegerValue *> (&dst);
   52.88 +      if (source == 0 || destination == 0)
   52.89 +        {
   52.90 +          return false;
   52.91 +        }
   52.92 +      *destination = *source;
   52.93 +      return true;
   52.94      }
   52.95      int64_t m_minValue;
   52.96      int64_t m_maxValue;
    53.1 --- a/src/core/integer.h	Mon Apr 21 08:58:23 2008 -0700
    53.2 +++ b/src/core/integer.h	Mon Apr 21 09:04:08 2008 -0700
    53.3 @@ -27,30 +27,20 @@
    53.4  namespace ns3 {
    53.5  
    53.6  /**
    53.7 + * \class ns3::IntegerValue
    53.8   * \brief Hold a signed integer type
    53.9   *
   53.10 + * \anchor int8_t
   53.11 + * \anchor int16_t
   53.12 + * \anchor int32_t
   53.13 + * \anchor int64_t
   53.14 + *
   53.15   * This class can be used to hold variables of signed integer
   53.16   * type such as int8_t, int16_t, int32_t, int64_t, or,
   53.17   * int, etc.
   53.18   */
   53.19 -class Integer
   53.20 -{
   53.21 -public:
   53.22 -  Integer (int64_t value);
   53.23 -  Integer ();
   53.24 -  void Set (int64_t value);
   53.25 -  int64_t Get (void) const;
   53.26  
   53.27 -  operator int64_t () const;
   53.28 -  ATTRIBUTE_CONVERTER_DEFINE (Integer);
   53.29 -private:
   53.30 -  int64_t m_value;
   53.31 -};
   53.32 -
   53.33 -std::ostream &operator << (std::ostream &os, const Integer &integer);
   53.34 -std::istream &operator >> (std::istream &is, Integer &integer);
   53.35 -
   53.36 -ATTRIBUTE_VALUE_DEFINE(Integer);
   53.37 +ATTRIBUTE_VALUE_DEFINE_WITH_NAME(int64_t, Integer);
   53.38  ATTRIBUTE_ACCESSOR_DEFINE(Integer);
   53.39  
   53.40  template <typename T>
    54.1 --- a/src/core/object-base.cc	Mon Apr 21 08:58:23 2008 -0700
    54.2 +++ b/src/core/object-base.cc	Mon Apr 21 09:04:08 2008 -0700
    54.3 @@ -20,6 +20,7 @@
    54.4  #include "object-base.h"
    54.5  #include "log.h"
    54.6  #include "trace-source-accessor.h"
    54.7 +#include "attribute-list.h"
    54.8  #include "string.h"
    54.9  
   54.10  NS_LOG_COMPONENT_DEFINE ("ObjectBase");
   54.11 @@ -58,8 +59,8 @@
   54.12      NS_LOG_DEBUG ("construct tid="<<tid.GetName ()<<", params="<<tid.GetAttributeN ());
   54.13      for (uint32_t i = 0; i < tid.GetAttributeN (); i++)
   54.14        {
   54.15 -        Ptr<const AttributeAccessor> paramSpec = tid.GetAttributeAccessor (i);
   54.16 -        Attribute initial = tid.GetAttributeInitialValue (i);
   54.17 +        Ptr<const AttributeAccessor> accessor = tid.GetAttributeAccessor (i);
   54.18 +        Ptr<const AttributeValue> initial = tid.GetAttributeInitialValue (i);
   54.19          Ptr<const AttributeChecker> checker = tid.GetAttributeChecker (i);
   54.20          NS_LOG_DEBUG ("try to construct \""<< tid.GetName ()<<"::"<<
   54.21                        tid.GetAttributeName (i)<<"\"");
   54.22 @@ -75,7 +76,7 @@
   54.23              if (j->checker == checker)
   54.24                {
   54.25                  // We have a matching attribute value.
   54.26 -                DoSet (paramSpec, initial, checker, j->value);
   54.27 +                DoSet (accessor, checker, *j->value);
   54.28                  NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<<
   54.29                                tid.GetAttributeName (i)<<"\"");
   54.30                  found = true;
   54.31 @@ -91,7 +92,7 @@
   54.32                  if (j->checker == checker)
   54.33                    {
   54.34                      // We have a matching attribute value.
   54.35 -                    DoSet (paramSpec, initial, checker, j->value);
   54.36 +                    DoSet (accessor, checker, *j->value);
   54.37                      NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<<
   54.38                                    tid.GetAttributeName (i)<<"\" from global");
   54.39                      found = true;
   54.40 @@ -102,7 +103,7 @@
   54.41          if (!found)
   54.42            {
   54.43              // No matching attribute value so we set the default value.
   54.44 -            paramSpec->Set (this, initial);
   54.45 +            DoSet (accessor, checker, *initial);
   54.46              NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<<
   54.47                            tid.GetAttributeName (i)<<"\" from initial value.");
   54.48            }
   54.49 @@ -113,37 +114,39 @@
   54.50  }
   54.51  
   54.52  bool
   54.53 -ObjectBase::DoSet (Ptr<const AttributeAccessor> spec, Attribute initialValue, 
   54.54 -		   Ptr<const AttributeChecker> checker, Attribute value)
   54.55 +ObjectBase::DoSet (Ptr<const AttributeAccessor> spec, 
   54.56 +		   Ptr<const AttributeChecker> checker, 
   54.57 +                   const AttributeValue &value)
   54.58  {
   54.59    bool ok = checker->Check (value);
   54.60 +  if (ok)
   54.61 +    {
   54.62 +      ok = spec->Set (this, value);
   54.63 +      return ok;
   54.64 +    }
   54.65 +  // attempt to convert to string
   54.66 +  const StringValue *str = dynamic_cast<const StringValue *> (&value);
   54.67 +  if (str == 0)
   54.68 +    {
   54.69 +      return false;
   54.70 +    }
   54.71 +  // attempt to convert back from string.
   54.72 +  Ptr<AttributeValue> v = checker->Create ();
   54.73 +  ok = v->DeserializeFromString (str->Get (), checker);
   54.74    if (!ok)
   54.75      {
   54.76 -      // attempt to convert to string
   54.77 -      const StringValue *str = value.DynCast<const StringValue *> ();
   54.78 -      if (str == 0)
   54.79 -        {
   54.80 -          return false;
   54.81 -        }
   54.82 -      // attempt to convert back from string.
   54.83 -      Attribute v = checker->Create ();
   54.84 -      ok = v.DeserializeFromString (str->Get ().Get (), checker);
   54.85 -      if (!ok)
   54.86 -        {
   54.87 -          return false;
   54.88 -        }
   54.89 -      ok = checker->Check (v);
   54.90 -      if (!ok)
   54.91 -        {
   54.92 -          return false;
   54.93 -        }
   54.94 -      value = v;
   54.95 +      return false;
   54.96      }
   54.97 -  ok = spec->Set (this, value);
   54.98 +  ok = checker->Check (*v);
   54.99 +  if (!ok)
  54.100 +    {
  54.101 +      return false;
  54.102 +    }
  54.103 +  ok = spec->Set (this, *v);
  54.104    return ok;
  54.105  }
  54.106  void
  54.107 -ObjectBase::SetAttribute (std::string name, Attribute value)
  54.108 +ObjectBase::SetAttribute (std::string name, const AttributeValue &value)
  54.109  {
  54.110    struct TypeId::AttributeInfo info;
  54.111    TypeId tid = GetInstanceTypeId ();
  54.112 @@ -151,17 +154,18 @@
  54.113      {
  54.114        NS_FATAL_ERROR ("Attribute name="<<name<<" does not exist for this object: tid="<<tid.GetName ());
  54.115      }
  54.116 -  if (!(info.flags & TypeId::ATTR_SET))
  54.117 +  if (!(info.flags & TypeId::ATTR_SET) ||
  54.118 +      !info.accessor->HasSetter ())
  54.119      {
  54.120        NS_FATAL_ERROR ("Attribute name="<<name<<" is not settable for this object: tid="<<tid.GetName ());
  54.121      }
  54.122 -  if (!DoSet (info.accessor, info.initialValue, info.checker, value))
  54.123 +  if (!DoSet (info.accessor, info.checker, value))
  54.124      {
  54.125        NS_FATAL_ERROR ("Attribute name="<<name<<" could not be set for this object: tid="<<tid.GetName ());
  54.126      }
  54.127  }
  54.128  bool 
  54.129 -ObjectBase::SetAttributeFailSafe (std::string name, Attribute value)
  54.130 +ObjectBase::SetAttributeFailSafe (std::string name, const AttributeValue &value)
  54.131  {
  54.132    struct TypeId::AttributeInfo info;
  54.133    TypeId tid = GetInstanceTypeId ();
  54.134 @@ -169,14 +173,16 @@
  54.135      {
  54.136        return false;
  54.137      }
  54.138 -  if (!(info.flags & TypeId::ATTR_SET))
  54.139 +  if (!(info.flags & TypeId::ATTR_SET) ||
  54.140 +      !info.accessor->HasSetter ())
  54.141      {
  54.142        return false;
  54.143      }
  54.144 -  return DoSet (info.accessor, info.initialValue, info.checker, value);
  54.145 +  return DoSet (info.accessor, info.checker, value);
  54.146  }
  54.147 -std::string
  54.148 -ObjectBase::GetAttributeAsString (std::string name) const
  54.149 +
  54.150 +void
  54.151 +ObjectBase::GetAttribute (std::string name, AttributeValue &value) const
  54.152  {
  54.153    struct TypeId::AttributeInfo info;
  54.154    TypeId tid = GetInstanceTypeId ();
  54.155 @@ -184,44 +190,33 @@
  54.156      {
  54.157        NS_FATAL_ERROR ("Attribute name="<<name<<" does not exist for this object: tid="<<tid.GetName ());
  54.158      }
  54.159 -  if (!(info.flags & TypeId::ATTR_GET))
  54.160 +  if (!(info.flags & TypeId::ATTR_GET) || 
  54.161 +      !info.accessor->HasGetter ())
  54.162      {
  54.163        NS_FATAL_ERROR ("Attribute name="<<name<<" is not gettable for this object: tid="<<tid.GetName ());
  54.164      }
  54.165 -  Attribute v = info.checker->Create ();
  54.166 -  bool ok = info.accessor->Get (this, v);
  54.167 +  bool ok = info.accessor->Get (this, value);
  54.168 +  if (ok)
  54.169 +    {
  54.170 +      return;
  54.171 +    }
  54.172 +  StringValue *str = dynamic_cast<StringValue *> (&value);
  54.173 +  if (str == 0)
  54.174 +    {
  54.175 +      NS_FATAL_ERROR ("Attribute name="<<name<<" tid="<<tid.GetName () << ": input value is not a string");
  54.176 +    }
  54.177 +  Ptr<AttributeValue> v = info.checker->Create ();
  54.178 +  ok = info.accessor->Get (this, *PeekPointer (v));
  54.179    if (!ok)
  54.180      {
  54.181 -      NS_FATAL_ERROR ("Attribute name="<<name<<" is not gettable for this object: tid="<<tid.GetName ());
  54.182 +      NS_FATAL_ERROR ("Attribute name="<<name<<" tid="<<tid.GetName () << ": could not get value");
  54.183      }
  54.184 -  std::string value = v.SerializeToString (info.checker);
  54.185 -  return value;
  54.186 +  str->Set (v->SerializeToString (info.checker));
  54.187  }
  54.188  
  54.189 -Attribute
  54.190 -ObjectBase::GetAttribute (std::string name) const
  54.191 -{
  54.192 -  struct TypeId::AttributeInfo info;
  54.193 -  TypeId tid = GetInstanceTypeId ();
  54.194 -  if (!tid.LookupAttributeByName (name, &info))
  54.195 -    {
  54.196 -      return Attribute ();
  54.197 -    }
  54.198 -  if (!(info.flags & TypeId::ATTR_GET))
  54.199 -    {
  54.200 -      return Attribute ();
  54.201 -    }
  54.202 -  Attribute value = info.checker->Create ();
  54.203 -  bool ok = info.accessor->Get (this, value);
  54.204 -  if (!ok)
  54.205 -    {
  54.206 -      return Attribute ();
  54.207 -    }
  54.208 -  return value;
  54.209 -}
  54.210  
  54.211  bool
  54.212 -ObjectBase::GetAttributeAsStringFailSafe (std::string name, std::string &value) const
  54.213 +ObjectBase::GetAttributeFailSafe (std::string name, AttributeValue &value) const
  54.214  {
  54.215    struct TypeId::AttributeInfo info;
  54.216    TypeId tid = GetInstanceTypeId ();
  54.217 @@ -229,35 +224,29 @@
  54.218      {
  54.219        return false;
  54.220      }
  54.221 -  if (!(info.flags & TypeId::ATTR_GET))
  54.222 +  if (!(info.flags & TypeId::ATTR_GET) ||
  54.223 +      !info.accessor->HasGetter ())
  54.224      {
  54.225        return false;
  54.226      }
  54.227 -  Attribute v = info.checker->Create ();
  54.228 -  bool ok = info.accessor->Get (this, v);
  54.229 +  bool ok = info.accessor->Get (this, value);
  54.230    if (ok)
  54.231      {
  54.232 -      value = v.SerializeToString (info.checker);
  54.233 +      return true;
  54.234      }
  54.235 -  return ok;
  54.236 -}
  54.237 -
  54.238 -bool
  54.239 -ObjectBase::GetAttributeFailSafe (std::string name, Attribute &value) const
  54.240 -{
  54.241 -  struct TypeId::AttributeInfo info;
  54.242 -  TypeId tid = GetInstanceTypeId ();
  54.243 -  if (!tid.LookupAttributeByName (name, &info))
  54.244 +  StringValue *str = dynamic_cast<StringValue *> (&value);
  54.245 +  if (str == 0)
  54.246      {
  54.247        return false;
  54.248      }
  54.249 -  if (!(info.flags & TypeId::ATTR_GET))
  54.250 +  Ptr<AttributeValue> v = info.checker->Create ();
  54.251 +  ok = info.accessor->Get (this, *PeekPointer (v));
  54.252 +  if (!ok)
  54.253      {
  54.254        return false;
  54.255      }
  54.256 -  value = info.checker->Create ();
  54.257 -  bool ok = info.accessor->Get (this, value);
  54.258 -  return ok;
  54.259 +  str->Set (v->SerializeToString (info.checker));
  54.260 +  return true;
  54.261  }
  54.262  
  54.263  bool 
    55.1 --- a/src/core/object-base.h	Mon Apr 21 08:58:23 2008 -0700
    55.2 +++ b/src/core/object-base.h	Mon Apr 21 09:04:08 2008 -0700
    55.3 @@ -22,7 +22,6 @@
    55.4  
    55.5  #include "type-id.h"
    55.6  #include "callback.h"
    55.7 -#include "attribute-list.h"
    55.8  #include <string>
    55.9  
   55.10  /**
   55.11 @@ -40,6 +39,8 @@
   55.12  
   55.13  namespace ns3 {
   55.14  
   55.15 +class AttributeList;
   55.16 +
   55.17  /**
   55.18   * \brief implement the ns-3 type and attribute system
   55.19   *
   55.20 @@ -72,35 +73,22 @@
   55.21     * Set a single attribute. This cannot fail: if the input is invalid,
   55.22     * it will crash immediately.
   55.23     */
   55.24 -  void SetAttribute (std::string name, Attribute value);
   55.25 +  void SetAttribute (std::string name, const AttributeValue &value);
   55.26    /**
   55.27     * \param name the name of the attribute to set
   55.28     * \param value the name of the attribute to set
   55.29     * \returns true if the requested attribute exists and could be set, 
   55.30     * false otherwise.
   55.31     */
   55.32 -  bool SetAttributeFailSafe (std::string name, Attribute value);
   55.33 +  bool SetAttributeFailSafe (std::string name, const AttributeValue &value);
   55.34    /**
   55.35     * \param name the name of the attribute to read
   55.36 -   * \returns true if the requested attribute was found, false otherwise.
   55.37 -   *
   55.38 -   * If the input attribute name does not exist, this method crashes.
   55.39 -   */
   55.40 -  std::string GetAttributeAsString (std::string name) const;
   55.41 -  /**
   55.42 -   * \param name the name of the attribute to read
   55.43 +   * \param value a reference to the value where the result should be stored.
   55.44     * \returns the attribute read.
   55.45     *
   55.46     * If the input attribute name does not exist, this method crashes.
   55.47     */
   55.48 -  Attribute GetAttribute (std::string name) const;
   55.49 -
   55.50 -  /**
   55.51 -   * \param name the name of the attribute to read
   55.52 -   * \param value the string where the result value should be stored
   55.53 -   * \returns true if the requested attribute was found, false otherwise.
   55.54 -   */
   55.55 -  bool GetAttributeAsStringFailSafe (std::string name, std::string &value) const;
   55.56 +  void GetAttribute (std::string name, AttributeValue &value) const;
   55.57    /**
   55.58     * \param name the name of the attribute to read
   55.59     * \param attribute the attribute where the result value should be stored
   55.60 @@ -108,7 +96,7 @@
   55.61     *
   55.62     * If the input attribute name does not exist, this method crashes.
   55.63     */
   55.64 -  bool GetAttributeFailSafe (std::string name, Attribute &attribute) const;
   55.65 +  bool GetAttributeFailSafe (std::string name, AttributeValue &attribute) const;
   55.66  
   55.67    /**
   55.68     * \param name the name of the targetted trace source
   55.69 @@ -163,8 +151,9 @@
   55.70    void ConstructSelf (const AttributeList &attributes);
   55.71  
   55.72  private:
   55.73 -  bool DoSet (Ptr<const AttributeAccessor> spec, Attribute intialValue, 
   55.74 -              Ptr<const AttributeChecker> checker, Attribute value);
   55.75 +  bool DoSet (Ptr<const AttributeAccessor> spec,
   55.76 +              Ptr<const AttributeChecker> checker, 
   55.77 +              const AttributeValue &value);
   55.78  
   55.79  };
   55.80  
    56.1 --- a/src/core/object-factory.cc	Mon Apr 21 08:58:23 2008 -0700
    56.2 +++ b/src/core/object-factory.cc	Mon Apr 21 09:04:08 2008 -0700
    56.3 @@ -41,7 +41,7 @@
    56.4    m_tid = TypeId::LookupByName (tid);
    56.5  }
    56.6  void 
    56.7 -ObjectFactory::Set (std::string name, Attribute value)
    56.8 +ObjectFactory::Set (std::string name, const AttributeValue &value)
    56.9  {
   56.10    if (name == "")
   56.11      {
   56.12 @@ -70,12 +70,22 @@
   56.13  
   56.14  std::ostream & operator << (std::ostream &os, const ObjectFactory &factory)
   56.15  {
   56.16 -  // XXX
   56.17 +  os << factory.m_tid.GetName () << "[" << factory.m_parameters.SerializeToString () << "]";
   56.18    return os;
   56.19  }
   56.20  std::istream & operator >> (std::istream &is, ObjectFactory &factory)
   56.21  {
   56.22 -  // XXX
   56.23 +  std::string v;
   56.24 +  is >> v;
   56.25 +  std::string::size_type lbracket, rbracket;
   56.26 +  lbracket = v.find ("[");
   56.27 +  rbracket = v.find ("]");
   56.28 +  NS_ASSERT (lbracket != std::string::npos);
   56.29 +  NS_ASSERT (rbracket != std::string::npos);
   56.30 +  std::string tid = v.substr (0, lbracket);
   56.31 +  std::string parameters = v.substr (lbracket+1,rbracket-(lbracket+1));
   56.32 +  factory.SetTypeId (tid);
   56.33 +  factory.m_parameters.DeserializeFromString (parameters);
   56.34    return is;
   56.35  }
   56.36  
    57.1 --- a/src/core/object-factory.h	Mon Apr 21 08:58:23 2008 -0700
    57.2 +++ b/src/core/object-factory.h	Mon Apr 21 09:04:08 2008 -0700
    57.3 @@ -20,11 +20,14 @@
    57.4  #ifndef OBJECT_FACTORY_H
    57.5  #define OBJECT_FACTORY_H
    57.6  
    57.7 -#include "attribute.h"
    57.8 +#include "attribute-list.h"
    57.9  #include "object.h"
   57.10 +#include "type-id.h"
   57.11  
   57.12  namespace ns3 {
   57.13  
   57.14 +class AttributeValue;
   57.15 +
   57.16  /**
   57.17   * \brief instantiate subclasses of ns3::Object.
   57.18   *
   57.19 @@ -52,7 +55,7 @@
   57.20     * \param name the name of the attribute to set during object construction
   57.21     * \param value the value of the attribute to set during object construction
   57.22     */
   57.23 -  void Set (std::string name, Attribute value);
   57.24 +  void Set (std::string name, const AttributeValue &value);
   57.25  
   57.26    /**
   57.27     * \returns the currently-selected TypeId to use to create an object
   57.28 @@ -76,6 +79,9 @@
   57.29  
   57.30    ATTRIBUTE_HELPER_HEADER_1 (ObjectFactory);
   57.31  private:
   57.32 +  friend std::ostream & operator << (std::ostream &os, const ObjectFactory &factory);
   57.33 +  friend std::istream & operator >> (std::istream &is, ObjectFactory &factory);
   57.34 +
   57.35    TypeId m_tid;
   57.36    AttributeList m_parameters;
   57.37  };
   57.38 @@ -83,6 +89,11 @@
   57.39  std::ostream & operator << (std::ostream &os, const ObjectFactory &factory);
   57.40  std::istream & operator >> (std::istream &is, ObjectFactory &factory);
   57.41  
   57.42 +/**
   57.43 + * \class ns3::ObjectFactoryValue
   57.44 + * \brief hold objects of type ns3::ObjectFactory
   57.45 + */
   57.46 +
   57.47  ATTRIBUTE_HELPER_HEADER_2 (ObjectFactory);
   57.48  
   57.49  } // namespace ns3
    58.1 --- a/src/core/object-vector.cc	Mon Apr 21 08:58:23 2008 -0700
    58.2 +++ b/src/core/object-vector.cc	Mon Apr 21 09:04:08 2008 -0700
    58.3 @@ -2,63 +2,34 @@
    58.4  
    58.5  namespace ns3 {
    58.6  
    58.7 -ObjectVector::ObjectVector ()
    58.8 +ObjectVectorValue::ObjectVectorValue ()
    58.9  {}
   58.10  
   58.11 -ObjectVector::Iterator 
   58.12 -ObjectVector::Begin (void) const
   58.13 +ObjectVectorValue::Iterator 
   58.14 +ObjectVectorValue::Begin (void) const
   58.15  {
   58.16    return m_objects.begin ();
   58.17  }
   58.18 -ObjectVector::Iterator 
   58.19 -ObjectVector::End (void) const
   58.20 +ObjectVectorValue::Iterator 
   58.21 +ObjectVectorValue::End (void) const
   58.22  {
   58.23    return m_objects.end ();
   58.24  }
   58.25  uint32_t 
   58.26 -ObjectVector::GetN (void) const
   58.27 +ObjectVectorValue::GetN (void) const
   58.28  {
   58.29    return m_objects.size ();
   58.30  }
   58.31  Ptr<Object> 
   58.32 -ObjectVector::Get (uint32_t i) const
   58.33 +ObjectVectorValue::Get (uint32_t i) const
   58.34  {
   58.35    return m_objects[i];
   58.36  }
   58.37  
   58.38 -ObjectVector::ObjectVector (Attribute value)
   58.39 -{
   58.40 -  const ObjectVectorValue *v = value.DynCast<const ObjectVectorValue *> ();
   58.41 -  if (v == 0)
   58.42 -    {
   58.43 -      NS_FATAL_ERROR ("Expected value of type ObjectVectorValue.");
   58.44 -    }
   58.45 -  *this = v->Get ();
   58.46 -}
   58.47 -
   58.48 -ObjectVector::operator Attribute () const
   58.49 -{
   58.50 -  return Attribute::Create<ObjectVectorValue> ();
   58.51 -}
   58.52 -
   58.53 -ObjectVectorValue::ObjectVectorValue ()
   58.54 -  : m_vector ()
   58.55 -{}
   58.56 -
   58.57 -ObjectVectorValue::ObjectVectorValue (const ObjectVector &vector)
   58.58 -  : m_vector (vector)
   58.59 -{}
   58.60 -
   58.61 -ObjectVector 
   58.62 -ObjectVectorValue::Get (void) const
   58.63 -{
   58.64 -  return m_vector;
   58.65 -}
   58.66 -
   58.67 -Attribute 
   58.68 +Ptr<AttributeValue>
   58.69  ObjectVectorValue::Copy (void) const
   58.70  {
   58.71 -  return Attribute::Create<ObjectVectorValue> (*this);
   58.72 +  return ns3::Create<ObjectVectorValue> (*this);
   58.73  }
   58.74  std::string 
   58.75  ObjectVectorValue::SerializeToString (Ptr<const AttributeChecker> checker) const
   58.76 @@ -69,25 +40,25 @@
   58.77  bool 
   58.78  ObjectVectorValue::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
   58.79  {
   58.80 -  // XXX ?? Can we implement this correctly ?? I doubt it very much.
   58.81 +  NS_FATAL_ERROR ("cannot deserialize a vector of object pointers.");
   58.82    return true;
   58.83  }
   58.84  
   58.85  bool 
   58.86 -ObjectVectorAccessor::Set (ObjectBase * object, Attribute value) const
   58.87 +ObjectVectorAccessor::Set (ObjectBase * object, const AttributeValue & value) const
   58.88  {
   58.89    // not allowed.
   58.90    return false;
   58.91  }
   58.92  bool 
   58.93 -ObjectVectorAccessor::Get (const ObjectBase * object, Attribute value) const
   58.94 +ObjectVectorAccessor::Get (const ObjectBase * object, AttributeValue &value) const
   58.95  {
   58.96 -  ObjectVectorValue *v = value.DynCast<ObjectVectorValue *> ();
   58.97 +  ObjectVectorValue *v = dynamic_cast<ObjectVectorValue *> (&value);
   58.98    if (v == 0)
   58.99      {
  58.100        return false;
  58.101      }
  58.102 -  v->m_vector.m_objects.clear ();
  58.103 +  v->m_objects.clear ();
  58.104    uint32_t n;
  58.105    bool ok = DoGetN (object, &n);
  58.106    if (!ok)
  58.107 @@ -97,11 +68,19 @@
  58.108    for (uint32_t i = 0; i < n; i++)
  58.109      {
  58.110        Ptr<Object> o = DoGet (object, i);
  58.111 -      v->m_vector.m_objects.push_back (o);
  58.112 +      v->m_objects.push_back (o);
  58.113      }
  58.114    return true;
  58.115  }
  58.116 -
  58.117 -ATTRIBUTE_CHECKER_IMPLEMENT (ObjectVector);
  58.118 +bool 
  58.119 +ObjectVectorAccessor::HasGetter (void) const
  58.120 +{
  58.121 +  return true;
  58.122 +}
  58.123 +bool 
  58.124 +ObjectVectorAccessor::HasSetter (void) const
  58.125 +{
  58.126 +  return false;
  58.127 +}
  58.128  
  58.129  } // name
    59.1 --- a/src/core/object-vector.h	Mon Apr 21 08:58:23 2008 -0700
    59.2 +++ b/src/core/object-vector.h	Mon Apr 21 09:04:08 2008 -0700
    59.3 @@ -5,24 +5,44 @@
    59.4  #include "object.h"
    59.5  #include "ptr.h"
    59.6  #include "attribute.h"
    59.7 -#include "attribute-helper.h"
    59.8  
    59.9  namespace ns3 {
   59.10  
   59.11 -class ObjectVector
   59.12 +/**
   59.13 + * \brief contain a vector of ns3::Object pointers.
   59.14 + *
   59.15 + * This class it used to get attribute access to an array of
   59.16 + * ns3::Object pointers.
   59.17 + */
   59.18 +class ObjectVectorValue : public AttributeValue
   59.19  {
   59.20  public:
   59.21    typedef std::vector<Ptr<Object> >::const_iterator Iterator;
   59.22  
   59.23 -  ObjectVector ();
   59.24 +  ObjectVectorValue ();
   59.25  
   59.26 +  /**
   59.27 +   * \returns an iterator to the first object contained in this vector
   59.28 +   */
   59.29    Iterator Begin (void) const;
   59.30 +  /**
   59.31 +   * \returns an iterator to the last object contained in this vector
   59.32 +   */
   59.33    Iterator End (void) const;
   59.34 +  /**
   59.35 +   * \returns the number of objects contained in this vector.
   59.36 +   */
   59.37    uint32_t GetN (void) const;
   59.38 +  /**
   59.39 +   * \param i the index of the requested object.
   59.40 +   * \returns the requested object
   59.41 +   */
   59.42    Ptr<Object> Get (uint32_t i) const;
   59.43  
   59.44 -  ObjectVector (Attribute value);
   59.45 -  operator Attribute () const;
   59.46 +  virtual Ptr<AttributeValue> Copy (void) const;
   59.47 +  virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
   59.48 +  virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
   59.49 +
   59.50  private:
   59.51    friend class ObjectVectorAccessor;
   59.52    std::vector<Ptr<Object> > m_objects;
   59.53 @@ -42,35 +62,65 @@
   59.54  MakeObjectVectorAccessor (INDEX (T::*getN) (void) const,
   59.55  			  Ptr<U> (T::*get) (INDEX) const);
   59.56  
   59.57 +class ObjectVectorChecker : public AttributeChecker
   59.58 +{
   59.59 +public:
   59.60 +  virtual TypeId GetItemTypeId (void) const = 0;
   59.61 +};
   59.62  
   59.63 -ATTRIBUTE_CHECKER_DEFINE (ObjectVector);
   59.64 +template <typename T>
   59.65 +Ptr<const AttributeChecker> MakeObjectVectorChecker (void);
   59.66  
   59.67  } // namespace ns3
   59.68  
   59.69  namespace ns3 {
   59.70  
   59.71 -class ObjectVectorValue : public AttributeValue
   59.72 +namespace internal {
   59.73 +
   59.74 +template <typename T>
   59.75 +class AnObjectVectorChecker : public ObjectVectorChecker
   59.76  {
   59.77  public:
   59.78 -  ObjectVectorValue ();
   59.79 -  ObjectVectorValue (const ObjectVector &vector);
   59.80 +  virtual TypeId GetItemTypeId (void) const {
   59.81 +    return T::GetTypeId ();
   59.82 +  }
   59.83 +  virtual bool Check (const AttributeValue &value) const {
   59.84 +    return dynamic_cast<const ObjectVectorValue *> (&value) != 0;
   59.85 +  }
   59.86 +  virtual std::string GetValueTypeName (void) const {
   59.87 +    return "ns3::ObjectVectorValue";
   59.88 +  }
   59.89 +  virtual bool HasUnderlyingTypeInformation (void) const {
   59.90 +    return true;
   59.91 +  }
   59.92 +  virtual std::string GetUnderlyingTypeInformation (void) const {
   59.93 +    return "ns3::Ptr< " + T::GetTypeId ().GetName () + " >";
   59.94 +  }
   59.95 +  virtual Ptr<AttributeValue> Create (void) const {
   59.96 +    return ns3::Create<ObjectVectorValue> ();
   59.97 +  }
   59.98 +  virtual bool Copy (const AttributeValue &source, AttributeValue &destination) const {
   59.99 +    const ObjectVectorValue *src = dynamic_cast<const ObjectVectorValue *> (&source);
  59.100 +    ObjectVectorValue *dst = dynamic_cast<ObjectVectorValue *> (&destination);
  59.101 +    if (src == 0 || dst == 0)
  59.102 +      {
  59.103 +	return false;
  59.104 +      }
  59.105 +    *dst = *src;
  59.106 +    return true;    
  59.107 +  }
  59.108 +};
  59.109  
  59.110 -  ObjectVector Get (void) const;
  59.111 +} // namespace internal
  59.112  
  59.113 -  virtual Attribute Copy (void) const;
  59.114 -  virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
  59.115 -  virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
  59.116 -
  59.117 -private:
  59.118 -  friend class ObjectVectorAccessor;
  59.119 -  ObjectVector m_vector;
  59.120 -};
  59.121  
  59.122  class ObjectVectorAccessor : public AttributeAccessor
  59.123  {
  59.124  public:
  59.125 -  virtual bool Set (ObjectBase * object, Attribute value) const;
  59.126 -  virtual bool Get (const ObjectBase * object, Attribute value) const;
  59.127 +  virtual bool Set (ObjectBase * object, const AttributeValue &value) const;
  59.128 +  virtual bool Get (const ObjectBase * object, AttributeValue &value) const;
  59.129 +  virtual bool HasGetter (void) const;
  59.130 +  virtual bool HasSetter (void) const;
  59.131  private:
  59.132    virtual bool DoGetN (const ObjectBase *object, uint32_t *n) const = 0;
  59.133    virtual Ptr<Object> DoGet (const ObjectBase *object, uint32_t i) const = 0;
  59.134 @@ -150,6 +200,13 @@
  59.135    return MakeObjectVectorAccessor (get, getN);
  59.136  }
  59.137  
  59.138 +template <typename T>
  59.139 +Ptr<const AttributeChecker> MakeObjectVectorChecker (void)
  59.140 +{
  59.141 +  return Create<internal::AnObjectVectorChecker<T> > ();
  59.142 +}
  59.143 +
  59.144 +
  59.145  } // namespace ns3
  59.146  
  59.147  #endif /* OBJECT_VECTOR_H */
    60.1 --- a/src/core/object.cc	Mon Apr 21 08:58:23 2008 -0700
    60.2 +++ b/src/core/object.cc	Mon Apr 21 09:04:08 2008 -0700
    60.3 @@ -37,6 +37,32 @@
    60.4  
    60.5  NS_OBJECT_ENSURE_REGISTERED (Object);
    60.6  
    60.7 +Object::AggregateIterator::AggregateIterator ()
    60.8 +  : m_first (0),
    60.9 +    m_current (0)
   60.10 +{}
   60.11 +
   60.12 +bool 
   60.13 +Object::AggregateIterator::HasNext (void) const
   60.14 +{
   60.15 +  if (m_current != 0 && m_current->m_next != PeekPointer (m_first))
   60.16 +    {
   60.17 +      return true;
   60.18 +    }
   60.19 +  return false;
   60.20 +}
   60.21 +Ptr<const Object> 
   60.22 +Object::AggregateIterator::Next (void)
   60.23 +{
   60.24 +  m_current = m_current->m_next;
   60.25 +  return m_current;
   60.26 +}
   60.27 +Object::AggregateIterator::AggregateIterator (Ptr<const Object> first)
   60.28 +  : m_first (first),
   60.29 +    m_current (first)
   60.30 +{}
   60.31 +
   60.32 +
   60.33  TypeId 
   60.34  Object::GetInstanceTypeId (void) const
   60.35  {
   60.36 @@ -129,6 +155,12 @@
   60.37    NS_ASSERT (o->CheckLoose ());
   60.38  }
   60.39  
   60.40 +Object::AggregateIterator 
   60.41 +Object::GetAggregateIterator (void) const
   60.42 +{
   60.43 +  return AggregateIterator (this);
   60.44 +}
   60.45 +
   60.46  void 
   60.47  Object::SetTypeId (TypeId tid)
   60.48  {
    61.1 --- a/src/core/object.h	Mon Apr 21 08:58:23 2008 -0700
    61.2 +++ b/src/core/object.h	Mon Apr 21 09:04:08 2008 -0700
    61.3 @@ -47,6 +47,36 @@
    61.4  public:
    61.5    static TypeId GetTypeId (void);
    61.6  
    61.7 +  /**
    61.8 +   * \brief Iterate over the objects aggregated to an ns3::Object.
    61.9 +   *
   61.10 +   * This iterator does not allow you to iterate over the initial
   61.11 +   * object used to call Object::GetAggregateIterator. 
   61.12 +   *
   61.13 +   * Note: this is a java-style iterator.
   61.14 +   */
   61.15 +  class AggregateIterator
   61.16 +  {
   61.17 +  public:
   61.18 +    AggregateIterator ();
   61.19 +
   61.20 +    /**
   61.21 +     * \returns true if HasNext can be called and return a non-null
   61.22 +     *          pointer, false otherwise.
   61.23 +     */
   61.24 +    bool HasNext (void) const;
   61.25 +
   61.26 +    /**
   61.27 +     * \returns the next aggregated object.
   61.28 +     */
   61.29 +    Ptr<const Object> Next (void);
   61.30 +  private:
   61.31 +    friend class Object;
   61.32 +    AggregateIterator (Ptr<const Object> first);
   61.33 +    Ptr<const Object> m_first;
   61.34 +    Ptr<const Object> m_current;
   61.35 +  };
   61.36 +
   61.37    Object ();
   61.38    virtual ~Object ();
   61.39  
   61.40 @@ -100,6 +130,16 @@
   61.41     */
   61.42    void AggregateObject (Ptr<Object> other);
   61.43  
   61.44 +  /**
   61.45 +   * \returns an iterator to the first object aggregated to this
   61.46 +   *          object.
   61.47 +   *
   61.48 +   * If no objects are aggregated to this object, then, the returned
   61.49 +   * iterator will be empty and AggregateIterator::HasNext will
   61.50 +   * always return false.
   61.51 +   */
   61.52 +  AggregateIterator GetAggregateIterator (void) const;
   61.53 +
   61.54  protected:
   61.55    /**
   61.56     * This method is called by Object::Dispose or by the object's 
   61.57 @@ -141,6 +181,7 @@
   61.58    friend Ptr<T> CopyObject (Ptr<const T> object);
   61.59  
   61.60    friend class ObjectFactory;
   61.61 +  friend class AggregateIterator;
   61.62  
   61.63    Ptr<Object> DoGetObject (TypeId tid) const;
   61.64    bool Check (void) const;
   61.65 @@ -247,15 +288,15 @@
   61.66   */
   61.67  template <typename T>
   61.68  Ptr<T> 
   61.69 -CreateObject (std::string n1 = "", Attribute v1 = Attribute (),
   61.70 -              std::string n2 = "", Attribute v2 = Attribute (),
   61.71 -              std::string n3 = "", Attribute v3 = Attribute (),
   61.72 -              std::string n4 = "", Attribute v4 = Attribute (),
   61.73 -              std::string n5 = "", Attribute v5 = Attribute (),
   61.74 -              std::string n6 = "", Attribute v6 = Attribute (),
   61.75 -              std::string n7 = "", Attribute v7 = Attribute (),
   61.76 -              std::string n8 = "", Attribute v8 = Attribute (),
   61.77 -              std::string n9 = "", Attribute v9 = Attribute ());
   61.78 +CreateObject (std::string n1 = "", const AttributeValue & v1 = EmptyAttributeValue (),
   61.79 +              std::string n2 = "", const AttributeValue & v2 = EmptyAttributeValue (),
   61.80 +              std::string n3 = "", const AttributeValue & v3 = EmptyAttributeValue (),
   61.81 +              std::string n4 = "", const AttributeValue & v4 = EmptyAttributeValue (),
   61.82 +              std::string n5 = "", const AttributeValue & v5 = EmptyAttributeValue (),
   61.83 +              std::string n6 = "", const AttributeValue & v6 = EmptyAttributeValue (),
   61.84 +              std::string n7 = "", const AttributeValue & v7 = EmptyAttributeValue (),
   61.85 +              std::string n8 = "", const AttributeValue & v8 = EmptyAttributeValue (),
   61.86 +              std::string n9 = "", const AttributeValue & v9 = EmptyAttributeValue ());
   61.87    
   61.88  
   61.89  
   61.90 @@ -339,16 +380,15 @@
   61.91  
   61.92  template <typename T>
   61.93  Ptr<T> 
   61.94 -CreateObject (std::string n1 = "", Attribute v1 = Attribute (),
   61.95 -              std::string n2 = "", Attribute v2 = Attribute (),
   61.96 -              std::string n3 = "", Attribute v3 = Attribute (),
   61.97 -              std::string n4 = "", Attribute v4 = Attribute (),
   61.98 -              std::string n5 = "", Attribute v5 = Attribute (),
   61.99 -              std::string n6 = "", Attribute v6 = Attribute (),
  61.100 -              std::string n7 = "", Attribute v7 = Attribute (),
  61.101 -              std::string n8 = "", Attribute v8 = Attribute (),
  61.102 -              std::string n9 = "", Attribute v9 = Attribute ())
  61.103 -  
  61.104 +CreateObject (std::string n1 = "", const AttributeValue & v1 = EmptyAttributeValue (),
  61.105 +              std::string n2 = "", const AttributeValue & v2 = EmptyAttributeValue (),
  61.106 +              std::string n3 = "", const AttributeValue & v3 = EmptyAttributeValue (),
  61.107 +              std::string n4 = "", const AttributeValue & v4 = EmptyAttributeValue (),
  61.108 +              std::string n5 = "", const AttributeValue & v5 = EmptyAttributeValue (),
  61.109 +              std::string n6 = "", const AttributeValue & v6 = EmptyAttributeValue (),
  61.110 +              std::string n7 = "", const AttributeValue & v7 = EmptyAttributeValue (),
  61.111 +              std::string n8 = "", const AttributeValue & v8 = EmptyAttributeValue (),
  61.112 +              std::string n9 = "", const AttributeValue & v9 = EmptyAttributeValue ())
  61.113  {
  61.114    AttributeList attributes;
  61.115    if (n1 == "")
    62.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    62.2 +++ b/src/core/pointer.cc	Mon Apr 21 09:04:08 2008 -0700
    62.3 @@ -0,0 +1,64 @@
    62.4 +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
    62.5 +/*
    62.6 + * Copyright (c) 2008 INRIA
    62.7 + *
    62.8 + * This program is free software; you can redistribute it and/or modify
    62.9 + * it under the terms of the GNU General Public License version 2 as
   62.10 + * published by the Free Software Foundation;
   62.11 + *
   62.12 + * This program is distributed in the hope that it will be useful,
   62.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   62.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   62.15 + * GNU General Public License for more details.
   62.16 + *
   62.17 + * You should have received a copy of the GNU General Public License
   62.18 + * along with this program; if not, write to the Free Software
   62.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   62.20 + *
   62.21 + * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
   62.22 + */
   62.23 +#include "pointer.h"
   62.24 +
   62.25 +namespace ns3 {
   62.26 +
   62.27 +PointerValue::PointerValue ()
   62.28 +  : m_value ()
   62.29 +{}
   62.30 +
   62.31 +PointerValue::PointerValue (Ptr<Object> object)
   62.32 +  : m_value (object)
   62.33 +{}
   62.34 +
   62.35 +void 
   62.36 +PointerValue::SetObject (Ptr<Object> object)
   62.37 +{
   62.38 +  m_value = object;
   62.39 +}
   62.40 +
   62.41 +Ptr<Object> 
   62.42 +PointerValue::GetObject (void) const
   62.43 +{
   62.44 +  return m_value;
   62.45 +}
   62.46 +
   62.47 +Ptr<AttributeValue> 
   62.48 +PointerValue::Copy (void) const
   62.49 +{
   62.50 +  return Create<PointerValue> (*this);
   62.51 +}
   62.52 +std::string 
   62.53 +PointerValue::SerializeToString (Ptr<const AttributeChecker> checker) const
   62.54 +{
   62.55 +  std::ostringstream oss;
   62.56 +  oss << m_value;
   62.57 +  return oss.str ();
   62.58 +}
   62.59 +
   62.60 +bool 
   62.61 +PointerValue::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
   62.62 +{
   62.63 +  NS_FATAL_ERROR ("It is not possible to deserialize a pointer.");
   62.64 +  return false;
   62.65 +}
   62.66 +
   62.67 +} // namespace ns3
    63.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    63.2 +++ b/src/core/pointer.h	Mon Apr 21 09:04:08 2008 -0700
    63.3 @@ -0,0 +1,338 @@
    63.4 +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
    63.5 +/*
    63.6 + * Copyright (c) 2008 INRIA
    63.7 + *
    63.8 + * This program is free software; you can redistribute it and/or modify
    63.9 + * it under the terms of the GNU General Public License version 2 as
   63.10 + * published by the Free Software Foundation;
   63.11 + *
   63.12 + * This program is distributed in the hope that it will be useful,
   63.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   63.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   63.15 + * GNU General Public License for more details.
   63.16 + *
   63.17 + * You should have received a copy of the GNU General Public License
   63.18 + * along with this program; if not, write to the Free Software
   63.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   63.20 + *
   63.21 + * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
   63.22 + */
   63.23 +#ifndef NS_POINTER_H
   63.24 +#define NS_POINTER_H
   63.25 +
   63.26 +#include "attribute.h"
   63.27 +#include "object.h"
   63.28 +
   63.29 +namespace ns3 {
   63.30 +
   63.31 +/**
   63.32 + * \brief hold objects of type Ptr<T>
   63.33 + */
   63.34 +class PointerValue : public AttributeValue
   63.35 +{
   63.36 +public:
   63.37 +  PointerValue ();
   63.38 +
   63.39 +  PointerValue (Ptr<Object> object);
   63.40 +
   63.41 +  void SetObject (Ptr<Object> object);
   63.42 +
   63.43 +  Ptr<Object> GetObject (void) const;
   63.44 +
   63.45 +  template <typename T>
   63.46 +  PointerValue (const Ptr<T> &object);
   63.47 +
   63.48 +  template <typename T>
   63.49 +  void Set (const Ptr<T> &object);
   63.50 +
   63.51 +  template <typename T>
   63.52 +  Ptr<T> Get (void) const;
   63.53 +
   63.54 +  template <typename T>
   63.55 +  operator Ptr<T> () const;
   63.56 +
   63.57 +  virtual Ptr<AttributeValue> Copy (void) const;
   63.58 +  virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
   63.59 +  virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
   63.60 +
   63.61 +private:
   63.62 +  Ptr<Object> m_value;
   63.63 +};
   63.64 +
   63.65 +template <typename T, typename U>
   63.66 +Ptr<const AttributeAccessor>
   63.67 +MakePointerAccessor (Ptr<U> T::*memberVariable);
   63.68 +template <typename T, typename U>
   63.69 +Ptr<const AttributeAccessor>
   63.70 +MakePointerAccessor (void (T::*setter) (Ptr<U>));
   63.71 +template <typename T, typename U>
   63.72 +Ptr<const AttributeAccessor>
   63.73 +MakePointerAccessor (Ptr<U> (T::*getter) (void) const);
   63.74 +template <typename T, typename U>
   63.75 +Ptr<const AttributeAccessor>
   63.76 +MakePointerAccessor (void (T::*setter) (Ptr<U>),
   63.77 +		     Ptr<U> (T::*getter) (void) const);
   63.78 +template <typename T, typename U>
   63.79 +Ptr<const AttributeAccessor>
   63.80 +MakePointerAccessor (Ptr<U> (T::*getter) (void) const,
   63.81 +		     void (T::*setter) (Ptr<U>));
   63.82 +
   63.83 +class PointerChecker : public AttributeChecker 
   63.84 +{
   63.85 +public:
   63.86 +  virtual TypeId GetPointeeTypeId (void) const = 0;
   63.87 +};
   63.88 +template <typename T>
   63.89 +Ptr<AttributeChecker> MakePointerChecker (void);
   63.90 +
   63.91 +} // namespace ns3
   63.92 +
   63.93 +namespace ns3 {
   63.94 +
   63.95 +
   63.96 +namespace internal {
   63.97 +
   63.98 +template <typename T>
   63.99 +class APointerChecker : public PointerChecker
  63.100 +{
  63.101 +  virtual bool Check (const AttributeValue &val) const {
  63.102 +    const PointerValue *value = dynamic_cast<const PointerValue *> (&val);
  63.103 +    if (value == 0)
  63.104 +      {
  63.105 +	return false;
  63.106 +      }
  63.107 +    if (value->GetObject () == 0)
  63.108 +      {
  63.109 +	return true;
  63.110 +      }
  63.111 +    T *ptr = dynamic_cast<T*> (PeekPointer (value->GetObject ()));
  63.112 +    if (ptr == 0)
  63.113 +      {
  63.114 +	return false;
  63.115 +      }
  63.116 +    return true;
  63.117 +  }
  63.118 +  virtual std::string GetValueTypeName (void) const {
  63.119 +    return "ns3::PointerValue";
  63.120 +  }
  63.121 +  virtual bool HasUnderlyingTypeInformation (void) const {
  63.122 +    return true;
  63.123 +  }
  63.124 +  virtual std::string GetUnderlyingTypeInformation (void) const {
  63.125 +    TypeId tid = T::GetTypeId ();
  63.126 +    return "ns3::Ptr< " + tid.GetName () + " >";
  63.127 +  }
  63.128 +  virtual Ptr<AttributeValue> Create (void) const {
  63.129 +    return ns3::Create<PointerValue> ();
  63.130 +  }
  63.131 +  virtual bool Copy (const AttributeValue &source, AttributeValue &destination) const {
  63.132 +    const PointerValue *src = dynamic_cast<const PointerValue *> (&source);
  63.133 +    PointerValue *dst = dynamic_cast<PointerValue *> (&destination);
  63.134 +    if (src == 0 || dst == 0)
  63.135 +      {
  63.136 +        return false;
  63.137 +      }
  63.138 +    *dst = *src;
  63.139 +    return true;
  63.140 +  }
  63.141 +  virtual TypeId GetPointeeTypeId (void) const {
  63.142 +    return T::GetTypeId ();
  63.143 +  }
  63.144 +};
  63.145 +
  63.146 +/********************************************************
  63.147 + *              The Accessor associated to 
  63.148 + *               PointerValue
  63.149 + ********************************************************/
  63.150 +
  63.151 +template <typename T, typename U>
  63.152 +class PointerAccessor : public AttributeAccessor
  63.153 +{
  63.154 +public:
  63.155 +  virtual ~PointerAccessor () {}
  63.156 +  virtual bool Set (ObjectBase * object, const AttributeValue &val) const {
  63.157 +      T *obj = dynamic_cast<T *> (object);
  63.158 +      if (obj == 0)
  63.159 +        {
  63.160 +          return false;
  63.161 +        }
  63.162 +      const PointerValue *value = dynamic_cast<const PointerValue *> (&val);
  63.163 +      if (value == 0)
  63.164 +        {
  63.165 +          return false;
  63.166 +        }
  63.167 +      Ptr<U> ptr = dynamic_cast<U*> (PeekPointer (value->GetObject ()));
  63.168 +      if (ptr == 0)
  63.169 +        {
  63.170 +          return false;
  63.171 +        }
  63.172 +      DoSet (obj, ptr);
  63.173 +      return true;
  63.174 +    }
  63.175 +  virtual bool Get (const ObjectBase * object, AttributeValue &val) const {
  63.176 +      const T *obj = dynamic_cast<const T *> (object);
  63.177 +      if (obj == 0)
  63.178 +        {
  63.179 +          return false;
  63.180 +        }
  63.181 +      PointerValue *value = dynamic_cast<PointerValue *> (&val);
  63.182 +      if (value == 0)
  63.183 +        {
  63.184 +          return false;
  63.185 +        }
  63.186 +      value->Set (DoGet (obj));
  63.187 +      return true;
  63.188 +    }
  63.189 +private:
  63.190 +  virtual void DoSet (T *object, Ptr<U> value) const = 0;
  63.191 +  virtual Ptr<U> DoGet (const T *object) const = 0;
  63.192 +};
  63.193 +
  63.194 +} // namespace internal
  63.195 +
  63.196 +
  63.197 +template <typename T>
  63.198 +PointerValue::PointerValue (const Ptr<T> &object)
  63.199 +{
  63.200 +  m_value = object;
  63.201 +}
  63.202 +
  63.203 +template <typename T>
  63.204 +void 
  63.205 +PointerValue::Set (const Ptr<T> &object)
  63.206 +{
  63.207 +  m_value = object;
  63.208 +}
  63.209 +
  63.210 +template <typename T>
  63.211 +Ptr<T> 
  63.212 +PointerValue::Get (void) const
  63.213 +{
  63.214 +  T *v = dynamic_cast<T *> (PeekPointer (m_value));
  63.215 +  return v;
  63.216 +}
  63.217 +
  63.218 +template <typename T>
  63.219 +PointerValue::operator Ptr<T> () const
  63.220 +{
  63.221 +  return Get<T> ();
  63.222 +}
  63.223 +
  63.224 +
  63.225 +template <typename T, typename U>
  63.226 +Ptr<const AttributeAccessor>
  63.227 +MakePointerAccessor (Ptr<U> T::*memberVariable)
  63.228 +{
  63.229 +  struct MemberVariable : public internal::PointerAccessor<T,U>
  63.230 +  {
  63.231 +    Ptr<U> T::*m_memberVariable;
  63.232 +    virtual void DoSet (T *object, Ptr<U> value) const {
  63.233 +      (object->*m_memberVariable) = value;
  63.234 +    }
  63.235 +    virtual Ptr<U> DoGet (const T *object) const {
  63.236 +      return object->*m_memberVariable;
  63.237 +    }
  63.238 +    virtual bool HasGetter (void) const {
  63.239 +      return true;
  63.240 +    }
  63.241 +    virtual bool HasSetter (void) const {
  63.242 +      return true;
  63.243 +    }
  63.244 +  } *spec = new MemberVariable ();
  63.245 +  spec->m_memberVariable = memberVariable;
  63.246 +  return Ptr<const AttributeAccessor> (spec, false);
  63.247 +}
  63.248 +
  63.249 +template <typename T, typename U>
  63.250 +Ptr<const AttributeAccessor>
  63.251 +MakePointerAccessor (void (T::*setter) (Ptr<U>))
  63.252 +{
  63.253 +  struct MemberMethod : public internal::PointerAccessor<T,U>
  63.254 +  {
  63.255 +    void (T::*m_setter) (Ptr<U>);
  63.256 +    virtual void DoSet (T *object, Ptr<U> value) const {
  63.257 +      (object->*m_setter) (value);
  63.258 +    }
  63.259 +    virtual Ptr<U> DoGet (const T *object) const {
  63.260 +      return 0;
  63.261 +      //return (object->*m_getter) ();
  63.262 +    }
  63.263 +    virtual bool HasGetter (void) const {
  63.264 +      return false;
  63.265 +    }
  63.266 +    virtual bool HasSetter (void) const {
  63.267 +      return true;
  63.268 +    }
  63.269 +  } *spec = new MemberMethod ();
  63.270 +  spec->m_setter = setter;
  63.271 +  return Ptr<const AttributeAccessor> (spec, false);
  63.272 +}
  63.273 +
  63.274 +template <typename T, typename U>
  63.275 +Ptr<const AttributeAccessor>
  63.276 +MakePointerAccessor (Ptr<U> (T::*getter) (void) const)
  63.277 +{
  63.278 +  struct MemberMethod : public internal::PointerAccessor<T,U>
  63.279 +  {
  63.280 +    Ptr<U> (T::*m_getter) (void) const;
  63.281 +    virtual void DoSet (T *object, Ptr<U> value) const {
  63.282 +      //(object->*m_setter) (value);
  63.283 +    }
  63.284 +    virtual Ptr<U> DoGet (const T *object) const {
  63.285 +      return (object->*m_getter) ();
  63.286 +    }
  63.287 +    virtual bool HasGetter (void) const {
  63.288 +      return true;
  63.289 +    }
  63.290 +    virtual bool HasSetter (void) const {
  63.291 +      return false;
  63.292 +    }
  63.293 +  } *spec = new MemberMethod ();
  63.294 +  spec->m_getter = getter;
  63.295 +  return Ptr<const AttributeAccessor> (spec, false);
  63.296 +}
  63.297 +template <typename T, typename U>
  63.298 +Ptr<const AttributeAccessor>
  63.299 +MakePointerAccessor (void (T::*setter) (Ptr<U>),
  63.300 +		     Ptr<U> (T::*getter) (void) const)
  63.301 +{
  63.302 +  return MakePointerAccessor (getter, setter);
  63.303 +}
  63.304 +template <typename T, typename U>
  63.305 +Ptr<const AttributeAccessor>
  63.306 +MakePointerAccessor (Ptr<U> (T::*getter) (void) const,
  63.307 +		     void (T::*setter) (Ptr<U>))
  63.308 +{
  63.309 +  struct MemberMethod : public internal::PointerAccessor<T,U>
  63.310 +  {
  63.311 +    void (T::*m_setter) (Ptr<U>);
  63.312 +    Ptr<U> (T::*m_getter) (void) const;
  63.313 +    virtual void DoSet (T *object, Ptr<U> value) const {
  63.314 +      (object->*m_setter) (value);
  63.315 +    }
  63.316 +    virtual Ptr<U> DoGet (const T *object) const {
  63.317 +      return (object->*m_getter) ();
  63.318 +    }
  63.319 +    virtual bool HasGetter (void) const {
  63.320 +      return true;
  63.321 +    }
  63.322 +    virtual bool HasSetter (void) const {
  63.323 +      return true;
  63.324 +    }
  63.325 +  } *spec = new MemberMethod ();
  63.326 +  spec->m_setter = setter;
  63.327 +  spec->m_getter = getter;
  63.328 +  return Ptr<const AttributeAccessor> (spec, false);
  63.329 +}
  63.330 +
  63.331 +template <typename T>
  63.332 +Ptr<AttributeChecker>
  63.333 +MakePointerChecker (void)
  63.334 +{
  63.335 +  return Create<internal::APointerChecker<T> > ();
  63.336 +}
  63.337 +
  63.338 +
  63.339 +} // namespace ns3
  63.340 +
  63.341 +#endif /* NS_POINTER_H */
    64.1 --- a/src/core/ptr.h	Mon Apr 21 08:58:23 2008 -0700
    64.2 +++ b/src/core/ptr.h	Mon Apr 21 09:04:08 2008 -0700
    64.3 @@ -447,7 +447,6 @@
    64.4    return *m_ptr;
    64.5  }
    64.6  
    64.7 -
    64.8  template <typename T>
    64.9  bool 
   64.10  Ptr<T>::operator! () 
    65.1 --- a/src/core/random-variable.cc	Mon Apr 21 08:58:23 2008 -0700
    65.2 +++ b/src/core/random-variable.cc	Mon Apr 21 09:04:08 2008 -0700
    65.3 @@ -299,20 +299,6 @@
    65.4  {
    65.5    return m_variable;
    65.6  }
    65.7 -RandomVariable::RandomVariable (Attribute value)
    65.8 -  : m_variable (0)
    65.9 -{
   65.10 -  const RandomVariableValue *v = value.DynCast<const RandomVariableValue *> ();
   65.11 -  if (v == 0)
   65.12 -    {
   65.13 -      NS_FATAL_ERROR ("Unexpected type of value. Expected \"RandomVariableValue\"");
   65.14 -    }
   65.15 -  *this = v->Get ();
   65.16 -}
   65.17 -RandomVariable::operator Attribute () const
   65.18 -{
   65.19 -  return Attribute::Create<RandomVariableValue> (*this);
   65.20 -}
   65.21  
   65.22  ATTRIBUTE_VALUE_IMPLEMENT (RandomVariable);
   65.23  ATTRIBUTE_CHECKER_IMPLEMENT (RandomVariable);
   65.24 @@ -1267,7 +1253,7 @@
   65.25  
   65.26  //-----------------------------------------------------------------------------
   65.27  //-----------------------------------------------------------------------------
   65.28 -// Integer EmpiricalVariableImpl methods
   65.29 +// IntegerValue EmpiricalVariableImpl methods
   65.30  class IntEmpiricalVariableImpl : public EmpiricalVariableImpl {
   65.31  public:
   65.32  
    66.1 --- a/src/core/random-variable.h	Mon Apr 21 08:58:23 2008 -0700
    66.2 +++ b/src/core/random-variable.h	Mon Apr 21 09:04:08 2008 -0700
    66.3 @@ -163,10 +163,6 @@
    66.4     */
    66.5    static void SetRunNumber(uint32_t n);
    66.6  
    66.7 -
    66.8 -  RandomVariable (Attribute value);
    66.9 -  operator Attribute () const;
   66.10 -
   66.11  private:
   66.12    friend std::ostream &operator << (std::ostream &os, const RandomVariable &var);
   66.13    friend std::istream &operator >> (std::istream &os, RandomVariable &var);
   66.14 @@ -666,6 +662,11 @@
   66.15  std::ostream &operator << (std::ostream &os, const RandomVariable &var);
   66.16  std::istream &operator >> (std::istream &os, RandomVariable &var);
   66.17  
   66.18 +/**
   66.19 + * \class ns3::RandomVariableValue
   66.20 + * \brief hold objects of type ns3::RandomVariable
   66.21 + */
   66.22 +
   66.23  ATTRIBUTE_VALUE_DEFINE (RandomVariable);
   66.24  ATTRIBUTE_CHECKER_DEFINE (RandomVariable);
   66.25  ATTRIBUTE_ACCESSOR_DEFINE (RandomVariable);
    67.1 --- a/src/core/ref-count-base.cc	Mon Apr 21 08:58:23 2008 -0700
    67.2 +++ b/src/core/ref-count-base.cc	Mon Apr 21 09:04:08 2008 -0700
    67.3 @@ -30,6 +30,15 @@
    67.4  {
    67.5  }
    67.6  
    67.7 +RefCountBase::RefCountBase (const RefCountBase &o)
    67.8 + : m_count (1)
    67.9 +{}
   67.10 +RefCountBase &
   67.11 +RefCountBase::operator = (const RefCountBase &o)
   67.12 +{
   67.13 +  return *this;
   67.14 +}
   67.15 +
   67.16  RefCountBase::~RefCountBase () 
   67.17  {
   67.18  }
    68.1 --- a/src/core/ref-count-base.h	Mon Apr 21 08:58:23 2008 -0700
    68.2 +++ b/src/core/ref-count-base.h	Mon Apr 21 09:04:08 2008 -0700
    68.3 @@ -41,6 +41,8 @@
    68.4  { 
    68.5  public:
    68.6    RefCountBase();
    68.7 +  RefCountBase (const RefCountBase &o);
    68.8 +  RefCountBase &operator = (const RefCountBase &o);
    68.9    virtual ~RefCountBase ();
   68.10    /**
   68.11     * Increment the reference count. This method should not be called
    69.1 --- a/src/core/string.cc	Mon Apr 21 08:58:23 2008 -0700
    69.2 +++ b/src/core/string.cc	Mon Apr 21 09:04:08 2008 -0700
    69.3 @@ -2,44 +2,8 @@
    69.4  
    69.5  namespace ns3 {
    69.6  
    69.7 -String::String ()
    69.8 -  : m_value ()
    69.9 -{}
   69.10 -String::String (const char *value)
   69.11 -  : m_value (value)
   69.12 -{}
   69.13 -String::String (std::string value)
   69.14 -  : m_value (value)
   69.15 -{}
   69.16 -void 
   69.17 -String::Set (std::string value)
   69.18 -{
   69.19 -  m_value = value;
   69.20 -}
   69.21 -void 
   69.22 -String::Set (const char *value)
   69.23 -{
   69.24 -  m_value = value;
   69.25 -}
   69.26 -std::string 
   69.27 -String::Get (void) const
   69.28 -{
   69.29 -  return m_value;
   69.30 -}
   69.31 -
   69.32 -std::ostream & operator << (std::ostream &os, const String &value)
   69.33 -{
   69.34 -  os << value.Get ();
   69.35 -  return os;
   69.36 -}
   69.37 -std::istream &operator >> (std::istream &is, String &value)
   69.38 -{
   69.39 -  std::string str;
   69.40 -  is >> str;
   69.41 -  value = String (str);
   69.42 -  return is;
   69.43 -}
   69.44 -
   69.45 -ATTRIBUTE_HELPER_CPP (String);
   69.46 +ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME (String, "std::string");
   69.47 +ATTRIBUTE_CONVERTER_IMPLEMENT (String);
   69.48 +ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME (std::string, String);
   69.49  
   69.50  } // namespace ns3
    70.1 --- a/src/core/string.h	Mon Apr 21 08:58:23 2008 -0700
    70.2 +++ b/src/core/string.h	Mon Apr 21 09:04:08 2008 -0700
    70.3 @@ -7,30 +7,16 @@
    70.4  namespace ns3 {
    70.5  
    70.6  /**
    70.7 + * \class ns3::StringValue
    70.8   * \brief hold variables of type string
    70.9   *
   70.10   * This class can be used to hold variables of type string,
   70.11   * that is, either char * or std::string.
   70.12   */
   70.13 -class String
   70.14 -{
   70.15 -public:
   70.16 -  String ();
   70.17 -  String (const char *value);
   70.18 -  String (std::string value);
   70.19 -  void Set (std::string value);
   70.20 -  void Set (const char *value);
   70.21 -  std::string Get (void) const;
   70.22  
   70.23 -  ATTRIBUTE_HELPER_HEADER_1 (String);
   70.24 -private:
   70.25 -  std::string m_value;
   70.26 -};
   70.27 -
   70.28 -std::ostream & operator << (std::ostream &os, const String &value);
   70.29 -std::istream &operator >> (std::istream &is, String &value);
   70.30 -
   70.31 -ATTRIBUTE_HELPER_HEADER_2 (String);
   70.32 +ATTRIBUTE_VALUE_DEFINE_WITH_NAME (std::string, String);
   70.33 +ATTRIBUTE_ACCESSOR_DEFINE (String);
   70.34 +ATTRIBUTE_CHECKER_DEFINE (String);
   70.35  
   70.36  } // namespace ns3
   70.37  
    71.1 --- a/src/core/traced-value.h	Mon Apr 21 08:58:23 2008 -0700
    71.2 +++ b/src/core/traced-value.h	Mon Apr 21 09:04:08 2008 -0700
    71.3 @@ -1,3 +1,22 @@
    71.4 +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
    71.5 +/*
    71.6 + * Copyright (c) 2005,2006,2007 INRIA
    71.7 + *
    71.8 + * This program is free software; you can redistribute it and/or modify
    71.9 + * it under the terms of the GNU General Public License version 2 as
   71.10 + * published by the Free Software Foundation;
   71.11 + *
   71.12 + * This program is distributed in the hope that it will be useful,
   71.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   71.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   71.15 + * GNU General Public License for more details.
   71.16 + *
   71.17 + * You should have received a copy of the GNU General Public License
   71.18 + * along with this program; if not, write to the Free Software
   71.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   71.20 + *
   71.21 + * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
   71.22 + */
   71.23  #ifndef TRACED_VALUE_H
   71.24  #define TRACED_VALUE_H
   71.25  
   71.26 @@ -41,25 +60,25 @@
   71.27      Set (o.m_v);
   71.28      return *this;
   71.29    }
   71.30 -  TracedValue (const Integer &value) 
   71.31 +  TracedValue (const IntegerValue &value) 
   71.32      : m_v (value.Get ()) {}
   71.33 -  operator Integer () const {
   71.34 -    return Integer (m_v);
   71.35 +  operator IntegerValue () const {
   71.36 +    return IntegerValue (m_v);
   71.37    }
   71.38 -  TracedValue (const Uinteger &value)
   71.39 +  TracedValue (const UintegerValue &value)
   71.40      : m_v (value.Get ()) {}
   71.41 -  operator Uinteger () const {
   71.42 -    return Uinteger (m_v);
   71.43 +  operator UintegerValue () const {
   71.44 +    return UintegerValue (m_v);
   71.45    }
   71.46 -  TracedValue (const Boolean &value)
   71.47 +  TracedValue (const BooleanValue &value)
   71.48      : m_v (value.Get ()) {}
   71.49 -  operator Boolean () const {
   71.50 -    return Boolean (m_v);
   71.51 +  operator BooleanValue () const {
   71.52 +    return BooleanValue (m_v);
   71.53    }
   71.54 -  TracedValue (const Enum &value)
   71.55 +  TracedValue (const EnumValue &value)
   71.56      : m_v (value.Get ()) {}
   71.57 -  operator Enum () const {
   71.58 -    return Enum (m_v);
   71.59 +  operator EnumValue () const {
   71.60 +    return EnumValue (m_v);
   71.61    }
   71.62    void ConnectWithoutContext (const CallbackBase &cb) {
   71.63      m_cb.ConnectWithoutContext (cb);
    72.1 --- a/src/core/type-id.cc	Mon Apr 21 08:58:23 2008 -0700
    72.2 +++ b/src/core/type-id.cc	Mon Apr 21 09:04:08 2008 -0700
    72.3 @@ -50,14 +50,14 @@
    72.4                       std::string name,
    72.5                       std::string help, 
    72.6                       uint32_t flags,
    72.7 -                     ns3::Attribute initialValue,
    72.8 +                     ns3::Ptr<const ns3::AttributeValue> initialValue,
    72.9                       ns3::Ptr<const ns3::AttributeAccessor> spec,
   72.10                       ns3::Ptr<const ns3::AttributeChecker> checker);
   72.11    uint32_t GetAttributeN (uint16_t uid) const;
   72.12    std::string GetAttributeName (uint16_t uid, uint32_t i) const;
   72.13    std::string GetAttributeHelp (uint16_t uid, uint32_t i) const;
   72.14    uint32_t GetAttributeFlags (uint16_t uid, uint32_t i) const;
   72.15 -  ns3::Attribute GetAttributeInitialValue (uint16_t uid, uint32_t i) const;
   72.16 +  ns3::Ptr<const ns3::AttributeValue> GetAttributeInitialValue (uint16_t uid, uint32_t i) const;
   72.17    ns3::Ptr<const ns3::AttributeAccessor> GetAttributeAccessor (uint16_t uid, uint32_t i) const;
   72.18    ns3::Ptr<const ns3::AttributeChecker> GetAttributeChecker (uint16_t uid, uint32_t i) const;
   72.19    void AddTraceSource (uint16_t uid,
   72.20 @@ -75,7 +75,7 @@
   72.21      std::string name;
   72.22      std::string help;
   72.23      uint32_t flags;
   72.24 -    ns3::Attribute initialValue;
   72.25 +    ns3::Ptr<const ns3::AttributeValue> initialValue;
   72.26      ns3::Ptr<const ns3::AttributeAccessor> param;
   72.27      ns3::Ptr<const ns3::AttributeChecker> checker;
   72.28    };
   72.29 @@ -236,7 +236,7 @@
   72.30                            std::string name,
   72.31                            std::string help, 
   72.32                            uint32_t flags,
   72.33 -                          ns3::Attribute initialValue,
   72.34 +                          ns3::Ptr<const ns3::AttributeValue> initialValue,
   72.35                            ns3::Ptr<const ns3::AttributeAccessor> spec,
   72.36                            ns3::Ptr<const ns3::AttributeChecker> checker)
   72.37  {
   72.38 @@ -288,7 +288,7 @@
   72.39    NS_ASSERT (i < information->attributes.size ());
   72.40    return information->attributes[i].flags;
   72.41  }
   72.42 -ns3::Attribute 
   72.43 +ns3::Ptr<const ns3::AttributeValue> 
   72.44  IidManager::GetAttributeInitialValue (uint16_t uid, uint32_t i) const
   72.45  {
   72.46    struct IidInformation *information = LookupInformation (uid);
   72.47 @@ -480,7 +480,7 @@
   72.48      {
   72.49        tmp = tmp.GetParent ();
   72.50      }
   72.51 -  return tmp == other;
   72.52 +  return tmp == other && *this != other;
   72.53  }
   72.54  std::string 
   72.55  TypeId::GetGroupName (void) const
   72.56 @@ -512,11 +512,11 @@
   72.57  TypeId 
   72.58  TypeId::AddAttribute (std::string name,
   72.59                        std::string help, 
   72.60 -                      Attribute initialValue,
   72.61 +                      const AttributeValue &initialValue,
   72.62                        Ptr<const AttributeAccessor> param,
   72.63                        Ptr<const AttributeChecker> checker)
   72.64  {
   72.65 -  Singleton<IidManager>::Get ()->AddAttribute (m_tid, name, help, ATTR_SGC, initialValue, param, checker);
   72.66 +  Singleton<IidManager>::Get ()->AddAttribute (m_tid, name, help, ATTR_SGC, initialValue.Copy (), param, checker);
   72.67    return *this;
   72.68  }
   72.69  
   72.70 @@ -524,11 +524,11 @@
   72.71  TypeId::AddAttribute (std::string name,
   72.72                        std::string help, 
   72.73                        uint32_t flags,
   72.74 -                      Attribute initialValue,
   72.75 +                      const AttributeValue &initialValue,
   72.76                        Ptr<const AttributeAccessor> param,
   72.77                        Ptr<const AttributeChecker> checker)
   72.78  {
   72.79 -  Singleton<IidManager>::Get ()->AddAttribute (m_tid, name, help, flags, initialValue, param, checker);
   72.80 +  Singleton<IidManager>::Get ()->AddAttribute (m_tid, name, help, flags, initialValue.Copy (), param, checker);
   72.81    return *this;
   72.82  }
   72.83  
   72.84 @@ -569,10 +569,10 @@
   72.85  {
   72.86    return GetName () + "::" + GetAttributeName (i);
   72.87  }
   72.88 -Attribute 
   72.89 +Ptr<const AttributeValue>
   72.90  TypeId::GetAttributeInitialValue (uint32_t i) const
   72.91  {
   72.92 -  Attribute value = Singleton<IidManager>::Get ()->GetAttributeInitialValue (m_tid, i);
   72.93 +  Ptr<const AttributeValue> value = Singleton<IidManager>::Get ()->GetAttributeInitialValue (m_tid, i);
   72.94    return value;
   72.95  }
   72.96  Ptr<const AttributeAccessor>
   72.97 @@ -696,4 +696,9 @@
   72.98    return a.m_tid != b.m_tid;
   72.99  }
  72.100  
  72.101 +bool operator < (TypeId a, TypeId b)
  72.102 +{
  72.103 +  return a.m_tid < b.m_tid;
  72.104 +}
  72.105 +
  72.106  } // namespace ns3
    73.1 --- a/src/core/type-id.h	Mon Apr 21 08:58:23 2008 -0700
    73.2 +++ b/src/core/type-id.h	Mon Apr 21 09:04:08 2008 -0700
    73.3 @@ -163,7 +163,7 @@
    73.4     * \returns the value with which the associated attribute 
    73.5     *          is initialized.
    73.6     */
    73.7 -  Attribute GetAttributeInitialValue (uint32_t i) const;
    73.8 +  Ptr<const AttributeValue> GetAttributeInitialValue (uint32_t i) const;
    73.9    /**
   73.10     * \param i index into attribute array.
   73.11     * \returns the flags associated to the requested attribute.
   73.12 @@ -264,7 +264,7 @@
   73.13     */
   73.14    TypeId AddAttribute (std::string name,
   73.15                         std::string help, 
   73.16 -                       Attribute initialValue,
   73.17 +                       const AttributeValue &initialValue,
   73.18                         Ptr<const AttributeAccessor> accessor,
   73.19                         Ptr<const AttributeChecker> checker);
   73.20  
   73.21 @@ -283,7 +283,7 @@
   73.22    TypeId AddAttribute (std::string name,
   73.23                         std::string help, 
   73.24                         uint32_t flags,
   73.25 -                       Attribute initialValue,
   73.26 +                       const AttributeValue &initialValue,
   73.27                         Ptr<const AttributeAccessor> accessor,
   73.28                         Ptr<const AttributeChecker> checker);
   73.29  
   73.30 @@ -308,7 +308,7 @@
   73.31      // The accessor associated to the attribute.
   73.32      Ptr<const AttributeAccessor> accessor;
   73.33      // The initial value associated to the attribute.
   73.34 -    Attribute initialValue;
   73.35 +    Ptr<const AttributeValue> initialValue;
   73.36      // The set of access control flags associated to the attribute.
   73.37      uint32_t flags;
   73.38      // The checker associated to the attribute.
   73.39 @@ -357,6 +357,7 @@
   73.40    friend class AttributeList;
   73.41    friend bool operator == (TypeId a, TypeId b);
   73.42    friend bool operator != (TypeId a, TypeId b);
   73.43 +  friend bool operator <  (TypeId a, TypeId b);
   73.44  
   73.45  
   73.46    /**
   73.47 @@ -375,6 +376,15 @@
   73.48  
   73.49  std::ostream & operator << (std::ostream &os, TypeId tid);
   73.50  std::istream & operator >> (std::istream &is, TypeId &tid);
   73.51 +bool operator == (TypeId a, TypeId b);
   73.52 +bool operator != (TypeId a, TypeId b);
   73.53 +bool operator <  (TypeId a, TypeId b);
   73.54 +
   73.55 +/**
   73.56 + * \class ns3::TypeIdValue
   73.57 + * \brief hold objects of type ns3::TypeId
   73.58 + */
   73.59 +
   73.60  
   73.61  ATTRIBUTE_HELPER_HEADER_2 (TypeId);
   73.62  
    74.1 --- a/src/core/uinteger.cc	Mon Apr 21 08:58:23 2008 -0700
    74.2 +++ b/src/core/uinteger.cc	Mon Apr 21 09:04:08 2008 -0700
    74.3 @@ -23,40 +23,7 @@
    74.4  
    74.5  namespace ns3 {
    74.6  
    74.7 -Uinteger::Uinteger (uint64_t value)
    74.8 -  : m_value (value)
    74.9 -{}
   74.10 -Uinteger::Uinteger ()
   74.11 -{}
   74.12 -void 
   74.13 -Uinteger::Set (uint64_t value)
   74.14 -{
   74.15 -  m_value = value;
   74.16 -}
   74.17 -uint64_t 
   74.18 -Uinteger::Get (void) const
   74.19 -{
   74.20 -  return m_value;
   74.21 -}
   74.22 -Uinteger::operator uint64_t () const
   74.23 -{
   74.24 -  return m_value;
   74.25 -}
   74.26 -std::ostream & operator << (std::ostream &os, const Uinteger &uinteger)
   74.27 -{
   74.28 -  os << uinteger.Get ();
   74.29 -  return os;
   74.30 -}
   74.31 -std::istream & operator >> (std::istream &is, Uinteger &uinteger)
   74.32 -{
   74.33 -  uint64_t v;
   74.34 -  is >> v;
   74.35 -  uinteger.Set (v);
   74.36 -  return is;
   74.37 -}
   74.38 -
   74.39 -ATTRIBUTE_CONVERTER_IMPLEMENT(Uinteger);
   74.40 -ATTRIBUTE_VALUE_IMPLEMENT(Uinteger);
   74.41 +ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME(uint64_t,Uinteger);
   74.42  
   74.43  namespace internal {
   74.44  
   74.45 @@ -68,27 +35,37 @@
   74.46        : m_minValue (minValue),
   74.47          m_maxValue (maxValue),
   74.48          m_name (name) {}
   74.49 -    virtual bool Check (Attribute value) const {
   74.50 -      const UintegerValue *v = value.DynCast<const UintegerValue *> ();
   74.51 +    virtual bool Check (const AttributeValue &value) const {
   74.52 +      const UintegerValue *v = dynamic_cast<const UintegerValue *> (&value);
   74.53        if (v == 0)
   74.54  	{
   74.55  	  return false;
   74.56  	}
   74.57 -      return v->Get ().Get () >= m_minValue && v->Get ().Get () <= m_maxValue;
   74.58 +      return v->Get () >= m_minValue && v->Get () <= m_maxValue;
   74.59      }
   74.60 -    virtual std::string GetType (void) const {
   74.61 -      return m_name;
   74.62 +    virtual std::string GetValueTypeName (void) const {
   74.63 +      return "ns3::UintegerValue";
   74.64      }
   74.65 -    virtual bool HasTypeConstraints (void) const {
   74.66 +    virtual bool HasUnderlyingTypeInformation (void) const {
   74.67        return true;
   74.68      }
   74.69 -    virtual std::string GetTypeConstraints (void) const {
   74.70 +    virtual std::string GetUnderlyingTypeInformation (void) const {
   74.71        std::ostringstream oss;
   74.72 -      oss << m_minValue << ":" << m_maxValue;
   74.73 +      oss << m_name << " " << m_minValue << ":" << m_maxValue;
   74.74        return oss.str ();
   74.75      }
   74.76 -    virtual Attribute Create (void) const {
   74.77 -      return Attribute::Create<UintegerValue> ();
   74.78 +    virtual Ptr<AttributeValue> Create (void) const {
   74.79 +      return ns3::Create<UintegerValue> ();
   74.80 +    }
   74.81 +    virtual bool Copy (const AttributeValue &source, AttributeValue &destination) const {
   74.82 +      const UintegerValue *src = dynamic_cast<const UintegerValue *> (&source);
   74.83 +      UintegerValue *dst = dynamic_cast<UintegerValue *> (&destination);
   74.84 +      if (src == 0 || dst == 0)
   74.85 +        {
   74.86 +          return false;
   74.87 +        }
   74.88 +      *dst = *src;
   74.89 +      return true;
   74.90      }
   74.91      uint64_t m_minValue;
   74.92      uint64_t m_maxValue;
    75.1 --- a/src/core/uinteger.h	Mon Apr 21 08:58:23 2008 -0700
    75.2 +++ b/src/core/uinteger.h	Mon Apr 21 09:04:08 2008 -0700
    75.3 @@ -27,32 +27,20 @@
    75.4  namespace ns3 {
    75.5  
    75.6  /**
    75.7 + * \class ns3::UintegerValue
    75.8   * \brief Hold an unsigned integer type
    75.9   *
   75.10 + * \anchor uint8_t
   75.11 + * \anchor uint16_t
   75.12 + * \anchor uint32_t
   75.13 + * \anchor uint64_t
   75.14 + *
   75.15   * This class can be used to hold variables of unsigned integer
   75.16   * type such as uint8_t, uint16_t, uint32_t, uint64_t, or,
   75.17   * unsigned int, etc.
   75.18   */
   75.19 -class Uinteger
   75.20 -{
   75.21 -public:
   75.22 -  Uinteger (uint64_t value);
   75.23 -  Uinteger ();
   75.24  
   75.25 -  void Set (uint64_t value);
   75.26 -  uint64_t Get (void) const;
   75.27 -
   75.28 -  operator uint64_t () const;
   75.29 -
   75.30 -  ATTRIBUTE_CONVERTER_DEFINE (Uinteger);
   75.31 -private:
   75.32 -  uint64_t m_value;
   75.33 -};
   75.34 -
   75.35 -std::ostream & operator << (std::ostream &os, const Uinteger &uinteger);
   75.36 -std::istream & operator >> (std::istream &is, Uinteger &uinteger);
   75.37 -
   75.38 -ATTRIBUTE_VALUE_DEFINE (Uinteger);
   75.39 +ATTRIBUTE_VALUE_DEFINE_WITH_NAME (uint64_t, Uinteger);
   75.40  ATTRIBUTE_ACCESSOR_DEFINE (Uinteger);
   75.41  
   75.42  template <typename T>
    76.1 --- a/src/core/wscript	Mon Apr 21 08:58:23 2008 -0700
    76.2 +++ b/src/core/wscript	Mon Apr 21 09:04:08 2008 -0700
    76.3 @@ -46,14 +46,15 @@
    76.4          'type-traits-test.cc',
    76.5          'attribute.cc',
    76.6          'boolean.cc',
    76.7 -        'attribute-test.cc',
    76.8          'integer.cc',
    76.9          'uinteger.cc',
   76.10          'enum.cc',
   76.11          'double.cc',
   76.12          'string.cc',
   76.13 +        'pointer.cc',
   76.14 +        'object-vector.cc',
   76.15 +        'attribute-test.cc',
   76.16          'object-factory.cc',
   76.17 -        'object-vector.cc',
   76.18          'global-value.cc',
   76.19          'traced-callback.cc',
   76.20          'trace-source-accessor.cc',
   76.21 @@ -100,6 +101,7 @@
   76.22          'double.h',
   76.23          'enum.h',
   76.24          'string.h',
   76.25 +        'pointer.h',
   76.26          'object-factory.h',
   76.27          'attribute-helper.h',
   76.28          'global-value.h',
    77.1 --- a/src/devices/csma/csma-channel.cc	Mon Apr 21 08:58:23 2008 -0700
    77.2 +++ b/src/devices/csma/csma-channel.cc	Mon Apr 21 09:04:08 2008 -0700
    77.3 @@ -53,11 +53,11 @@
    77.4      .SetParent<Channel> ()
    77.5      .AddConstructor<CsmaChannel> ()
    77.6      .AddAttribute ("BitRate", "The maximum bitrate of the channel",
    77.7 -                   DataRate (0xffffffff),
    77.8 +                   DataRateValue (DataRate (0xffffffff)),
    77.9                     MakeDataRateAccessor (&CsmaChannel::m_bps),
   77.10                     MakeDataRateChecker ())
   77.11      .AddAttribute ("Delay", "Transmission delay through the channel",
   77.12 -                   Seconds (0),
   77.13 +                   TimeValue (Seconds (0)),
   77.14                     MakeTimeAccessor (&CsmaChannel::m_delay),
   77.15                     MakeTimeChecker ())
   77.16      ;
    78.1 --- a/src/devices/csma/csma-net-device.cc	Mon Apr 21 08:58:23 2008 -0700
    78.2 +++ b/src/devices/csma/csma-net-device.cc	Mon Apr 21 09:04:08 2008 -0700
    78.3 @@ -27,6 +27,7 @@
    78.4  #include "ns3/error-model.h"
    78.5  #include "ns3/enum.h"
    78.6  #include "ns3/boolean.h"
    78.7 +#include "ns3/pointer.h"
    78.8  #include "ns3/trace-source-accessor.h"
    78.9  #include "csma-net-device.h"
   78.10  #include "csma-channel.h"
   78.11 @@ -45,36 +46,36 @@
   78.12      .SetParent<NetDevice> ()
   78.13      .AddConstructor<CsmaNetDevice> ()
   78.14      .AddAttribute ("Address", "The address of this device.",
   78.15 -                   Mac48Address ("ff:ff:ff:ff:ff:ff"),
   78.16 +                   Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
   78.17                     MakeMac48AddressAccessor (&CsmaNetDevice::m_address),
   78.18                     MakeMac48AddressChecker ())
   78.19      .AddAttribute ("EncapsulationMode", "The mode of link-layer encapsulation to use.",
   78.20 -                   Enum (LLC),
   78.21 +                   EnumValue (LLC),
   78.22                     MakeEnumAccessor (&CsmaNetDevice::m_encapMode),
   78.23                     MakeEnumChecker (ETHERNET_V1, "EthernetV1",
   78.24                                      IP_ARP, "IpArp",
   78.25                                      RAW, "Raw",
   78.26                                      LLC, "Llc"))
   78.27      .AddAttribute ("SendEnable", "should tx be enabled ?",
   78.28 -                   Boolean (true),
   78.29 +                   BooleanValue (true),
   78.30                     MakeBooleanAccessor (&CsmaNetDevice::m_sendEnable),
   78.31                     MakeBooleanChecker ())
   78.32      .AddAttribute ("ReceiveEnable", "should rx be enabled ?",
   78.33 -                   Boolean (true),
   78.34 +                   BooleanValue (true),
   78.35                     MakeBooleanAccessor (&CsmaNetDevice::m_receiveEnable),
   78.36                     MakeBooleanChecker ())
   78.37      .AddAttribute ("DataRate", "XXX",
   78.38 -                   DataRate (0xffffffff),
   78.39 +                   DataRateValue (DataRate (0xffffffff)),
   78.40                     MakeDataRateAccessor (&CsmaNetDevice::m_bps),
   78.41                     MakeDataRateChecker ())
   78.42      .AddAttribute ("RxErrorModel", "XXX",
   78.43 -                   Ptr<ErrorModel> (0),
   78.44 -                   MakePtrAccessor (&CsmaNetDevice::m_receiveErrorModel),
   78.45 -                   MakePtrChecker<ErrorModel> ())
   78.46 +                   PointerValue (),
   78.47 +                   MakePointerAccessor (&CsmaNetDevice::m_receiveErrorModel),
   78.48 +                   MakePointerChecker<ErrorModel> ())
   78.49      .AddAttribute ("TxQueue", "XXX",
   78.50 -                   Ptr<Queue> (0),
   78.51 -                   MakePtrAccessor (&CsmaNetDevice::m_queue),
   78.52 -                   MakePtrChecker<Queue> ())
   78.53 +                   PointerValue (),
   78.54 +                   MakePointerAccessor (&CsmaNetDevice::m_queue),
   78.55 +                   MakePointerChecker<Queue> ())
   78.56      .AddTraceSource ("Rx", "Receive MAC packet.",
   78.57                       MakeTraceSourceAccessor (&CsmaNetDevice::m_rxTrace))
   78.58      .AddTraceSource ("Drop", "Drop MAC packet.",
    79.1 --- a/src/devices/point-to-point/point-to-point-channel.cc	Mon Apr 21 08:58:23 2008 -0700
    79.2 +++ b/src/devices/point-to-point/point-to-point-channel.cc	Mon Apr 21 09:04:08 2008 -0700
    79.3 @@ -37,11 +37,11 @@
    79.4      .SetParent<Channel> ()
    79.5      .AddConstructor<PointToPointChannel> ()
    79.6      .AddAttribute ("BitRate", "The maximum bitrate of the channel",
    79.7 -                   DataRate (0xffffffff),
    79.8 +                   DataRateValue (DataRate (0xffffffff)),
    79.9                     MakeDataRateAccessor (&PointToPointChannel::m_bps),
   79.10                     MakeDataRateChecker ())
   79.11      .AddAttribute ("Delay", "Transmission delay through the channel",
   79.12 -                   Seconds (0),
   79.13 +                   TimeValue (Seconds (0)),
   79.14                     MakeTimeAccessor (&PointToPointChannel::m_delay),
   79.15                     MakeTimeChecker ())
   79.16      ;
    80.1 --- a/src/devices/point-to-point/point-to-point-net-device.cc	Mon Apr 21 08:58:23 2008 -0700
    80.2 +++ b/src/devices/point-to-point/point-to-point-net-device.cc	Mon Apr 21 09:04:08 2008 -0700
    80.3 @@ -26,6 +26,7 @@
    80.4  #include "ns3/llc-snap-header.h"
    80.5  #include "ns3/error-model.h"
    80.6  #include "ns3/trace-source-accessor.h"
    80.7 +#include "ns3/pointer.h"
    80.8  #include "point-to-point-net-device.h"
    80.9  #include "point-to-point-channel.h"
   80.10  
   80.11 @@ -42,23 +43,23 @@
   80.12      .SetParent<NetDevice> ()
   80.13      .AddConstructor<PointToPointNetDevice> ()
   80.14      .AddAttribute ("Address", "The address of this device.",
   80.15 -                   Mac48Address ("ff:ff:ff:ff:ff:ff"),
   80.16 +                   Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
   80.17                     MakeMac48AddressAccessor (&PointToPointNetDevice::m_address),
   80.18                     MakeMac48AddressChecker ())
   80.19      .AddAttribute ("DataRate", "The default data rate for point to point links",
   80.20 -                   DataRate ("10Mb/s"),
   80.21 +                   DataRateValue (DataRate ("10Mb/s")),
   80.22                     MakeDataRateAccessor (&PointToPointNetDevice::m_bps),
   80.23                     MakeDataRateChecker ())
   80.24      .AddAttribute ("ReceiveErrorModel", "XXX",
   80.25 -                   Ptr<ErrorModel> (0),
   80.26 -                   MakePtrAccessor (&PointToPointNetDevice::m_receiveErrorModel),
   80.27 -                   MakePtrChecker<ErrorModel> ())
   80.28 +                   PointerValue (),
   80.29 +                   MakePointerAccessor (&PointToPointNetDevice::m_receiveErrorModel),
   80.30 +                   MakePointerChecker<ErrorModel> ())
   80.31      .AddAttribute ("TxQueue", "XXX",
   80.32 -                   Ptr<Queue> (0),
   80.33 -                   MakePtrAccessor (&PointToPointNetDevice::m_queue),
   80.34 -                   MakePtrChecker<Queue> ())
   80.35 +                   PointerValue (),
   80.36 +                   MakePointerAccessor (&PointToPointNetDevice::m_queue),
   80.37 +                   MakePointerChecker<Queue> ())
   80.38      .AddAttribute ("InterframeGap", "XXX",
   80.39 -                   Seconds (0.0),
   80.40 +                   TimeValue (Seconds (0.0)),
   80.41                     MakeTimeAccessor (&PointToPointNetDevice::m_tInterframeGap),
   80.42                     MakeTimeChecker ())
   80.43      .AddTraceSource ("Rx", "Receive MAC packet.",
    81.1 --- a/src/devices/wifi/aarf-wifi-manager.cc	Mon Apr 21 08:58:23 2008 -0700
    81.2 +++ b/src/devices/wifi/aarf-wifi-manager.cc	Mon Apr 21 09:04:08 2008 -0700
    81.3 @@ -37,27 +37,27 @@
    81.4      .SetParent<ArfWifiManager> ()
    81.5      .AddConstructor<AarfWifiManager> ()
    81.6      .AddAttribute ("SuccessK", "Multiplication factor for the success threshold in the AARF algorithm.",
    81.7 -                   Double (2.0),
    81.8 +                   DoubleValue (2.0),
    81.9                     MakeDoubleAccessor (&AarfWifiManager::m_successK),
   81.10                     MakeDoubleChecker<double> ())
   81.11      .AddAttribute ("TimerK",
   81.12                     "Multiplication factor for the timer threshold in the AARF algorithm.",
   81.13 -                   Double (2.0),
   81.14 +                   DoubleValue (2.0),
   81.15                     MakeDoubleAccessor (&AarfWifiManager::m_timerK),
   81.16                     MakeDoubleChecker<double> ())
   81.17      .AddAttribute ("MaxSuccessThreshold",
   81.18                     "Maximum value of the success threshold in the AARF algorithm.",
   81.19 -                   Uinteger (60),
   81.20 +                   UintegerValue (60),
   81.21                     MakeUintegerAccessor (&AarfWifiManager::m_maxSuccessThreshold),
   81.22                     MakeUintegerChecker<uint32_t> ())
   81.23      .AddAttribute ("MinTimerThreshold",
   81.24                     "The minimum value for the 'timer' threshold in the AARF algorithm.",
   81.25 -                   Uinteger (15),
   81.26 +                   UintegerValue (15),
   81.27                     MakeUintegerAccessor (&AarfWifiManager::m_minTimerThreshold),
   81.28                     MakeUintegerChecker<uint32_t> ())
   81.29      .AddAttribute ("MinSuccessThreshold",
   81.30                     "The minimum value for the success threshold in the AARF algorithm.",
   81.31 -                   Uinteger (10),
   81.32 +                   UintegerValue (10),
   81.33                     MakeUintegerAccessor (&AarfWifiManager::m_minSuccessThreshold),
   81.34                     MakeUintegerChecker<uint32_t> ())
   81.35      ;
    82.1 --- a/src/devices/wifi/amrr-wifi-manager.cc	Mon Apr 21 08:58:23 2008 -0700
    82.2 +++ b/src/devices/wifi/amrr-wifi-manager.cc	Mon Apr 21 09:04:08 2008 -0700
    82.3 @@ -38,27 +38,27 @@
    82.4      .AddConstructor<AmrrWifiManager> ()
    82.5      .AddAttribute ("UpdatePeriod",
    82.6                     "The interval between decisions about rate control changes",
    82.7 -                   Seconds (1.0),
    82.8 +                   TimeValue (Seconds (1.0)),
    82.9                     MakeTimeAccessor (&AmrrWifiManager::m_updatePeriod),
   82.10                     MakeTimeChecker ())
   82.11      .AddAttribute ("FailureRatio",
   82.12                     "Ratio of minimum erronous transmissions needed to switch to a lower rate",
   82.13 -                   Double (1.0/3.0),
   82.14 +                   DoubleValue (1.0/3.0),
   82.15                     MakeDoubleAccessor (&AmrrWifiManager::m_failureRatio),
   82.16                     MakeDoubleChecker<double> (0.0, 1.0))
   82.17      .AddAttribute ("SuccessRatio",
   82.18                     "Ratio of maximum erronous transmissions needed to switch to a higher rate",
   82.19 -                   Double (1.0/10.0),
   82.20 +                   DoubleValue (1.0/10.0),
   82.21                     MakeDoubleAccessor (&AmrrWifiManager::m_successRatio),
   82.22                     MakeDoubleChecker<double> (0.0, 1.0))
   82.23      .AddAttribute ("MaxSuccessThreshold",
   82.24                     "Maximum number of consecutive success periods needed to switch to a higher rate",
   82.25 -                   Uinteger (10),
   82.26 +                   UintegerValue (10),
   82.27                     MakeUintegerAccessor (&AmrrWifiManager::m_maxSuccessThreshold),
   82.28                     MakeUintegerChecker<uint32_t> ())
   82.29      .AddAttribute ("MinSuccessThreshold",
   82.30                     "Minimum number of consecutive success periods needed to switch to a higher rate",
   82.31 -                   Uinteger (1),
   82.32 +                   UintegerValue (1),
   82.33                     MakeUintegerAccessor (&AmrrWifiManager::m_minSuccessThreshold),
   82.34                     MakeUintegerChecker<uint32_t> ())
   82.35      ;
    83.1 --- a/src/devices/wifi/amrr-wifi-manager.h	Mon Apr 21 08:58:23 2008 -0700
    83.2 +++ b/src/devices/wifi/amrr-wifi-manager.h	Mon Apr 21 09:04:08 2008 -0700
    83.3 @@ -25,6 +25,14 @@
    83.4  
    83.5  namespace ns3 {
    83.6  
    83.7 +/**
    83.8 + * \brief AMRR Rate control algorithm
    83.9 + *
   83.10 + * This class implements the AMRR rate control algorithm which
   83.11 + * was initially described in <i>IEEE 802.11 Rate Adaptation:
   83.12 + * A Practical Approach</i>, by M. Lacage, M.H. Manshaei, and 
   83.13 + * T. Turletti.
   83.14 + */
   83.15  class AmrrWifiManager : public WifiRemoteStationManager
   83.16  {
   83.17  public:
    84.1 --- a/src/devices/wifi/arf-wifi-manager.cc	Mon Apr 21 08:58:23 2008 -0700
    84.2 +++ b/src/devices/wifi/arf-wifi-manager.cc	Mon Apr 21 09:04:08 2008 -0700
    84.3 @@ -228,12 +228,12 @@
    84.4      .SetParent<WifiRemoteStationManager> ()
    84.5      .AddConstructor<ArfWifiManager> ()
    84.6      .AddAttribute ("TimerThreshold", "The 'timer' threshold in the ARF algorithm.",
    84.7 -                   Uinteger (15),
    84.8 +                   UintegerValue (15),
    84.9                     MakeUintegerAccessor (&ArfWifiManager::m_timerThreshold),
   84.10                     MakeUintegerChecker<uint32_t> ())
   84.11      .AddAttribute ("SuccessThreshold",
   84.12                     "The minimum number of sucessfull transmissions to try a new rate.",
   84.13 -                   Uinteger (10),
   84.14 +                   UintegerValue (10),
   84.15                     MakeUintegerAccessor (&ArfWifiManager::m_successThreshold),
   84.16                     MakeUintegerChecker<uint32_t> ())
   84.17      ;
    85.1 --- a/src/devices/wifi/constant-rate-wifi-manager.cc	Mon Apr 21 08:58:23 2008 -0700
    85.2 +++ b/src/devices/wifi/constant-rate-wifi-manager.cc	Mon Apr 21 09:04:08 2008 -0700
    85.3 @@ -78,11 +78,11 @@
    85.4      .SetParent<WifiRemoteStationManager> ()
    85.5      .AddConstructor<ConstantRateWifiManager> ()
    85.6      .AddAttribute ("DataMode", "XXX",
    85.7 -                   String ("wifia-6mbs"),
    85.8 +                   StringValue ("wifia-6mbs"),
    85.9                     MakeWifiModeAccessor (&ConstantRateWifiManager::m_dataMode),
   85.10                     MakeWifiModeChecker ())
   85.11      .AddAttribute ("ControlMode", "XXX",
   85.12 -                   String ("wifia-6mbs"),
   85.13 +                   StringValue ("wifia-6mbs"),
   85.14                     MakeWifiModeAccessor (&ConstantRateWifiManager::m_ctlMode),
   85.15                     MakeWifiModeChecker ())
   85.16      ;
    86.1 --- a/src/devices/wifi/dca-txop.cc	Mon Apr 21 08:58:23 2008 -0700
    86.2 +++ b/src/devices/wifi/dca-txop.cc	Mon Apr 21 09:04:08 2008 -0700
    86.3 @@ -100,17 +100,17 @@
    86.4      .SetParent<Object> ()
    86.5      .AddConstructor<DcaTxop> ()
    86.6      .AddAttribute ("MinCw", "XXX",
    86.7 -                   Uinteger (15),
    86.8 +                   UintegerValue (15),
    86.9                     MakeUintegerAccessor (&DcaTxop::SetMinCw,
   86.10                                           &DcaTxop::GetMinCw),
   86.11                     MakeUintegerChecker<uint32_t> ())
   86.12      .AddAttribute ("MaxCw", "XXX",
   86.13 -                   Uinteger (1023),
   86.14 +                   UintegerValue (1023),
   86.15                     MakeUintegerAccessor (&DcaTxop::SetMaxCw,
   86.16                                           &DcaTxop::GetMaxCw),
   86.17                     MakeUintegerChecker<uint32_t> ())
   86.18      .AddAttribute ("Aifsn", "XXX",
   86.19 -                   Uinteger (2),
   86.20 +                   UintegerValue (2),
   86.21                     MakeUintegerAccessor (&DcaTxop::SetAifsn,
   86.22                                           &DcaTxop::GetAifsn),
   86.23                     MakeUintegerChecker<uint32_t> ())
    87.1 --- a/src/devices/wifi/ideal-wifi-manager.cc	Mon Apr 21 08:58:23 2008 -0700
    87.2 +++ b/src/devices/wifi/ideal-wifi-manager.cc	Mon Apr 21 09:04:08 2008 -0700
    87.3 @@ -35,7 +35,7 @@
    87.4      .AddConstructor<IdealWifiManager> ()
    87.5      .AddAttribute ("BerThreshold",
    87.6                     "The maximum Bit Error Rate acceptable at any transmission mode",
    87.7 -                   Double (10e-6),
    87.8 +                   DoubleValue (10e-6),
    87.9                     MakeDoubleAccessor (&IdealWifiManager::m_ber),
   87.10                     MakeDoubleChecker<double> ())
   87.11      ;
    88.1 --- a/src/devices/wifi/jakes-propagation-loss-model.cc	Mon Apr 21 08:58:23 2008 -0700
    88.2 +++ b/src/devices/wifi/jakes-propagation-loss-model.cc	Mon Apr 21 09:04:08 2008 -0700
    88.3 @@ -131,22 +131,22 @@
    88.4      .AddConstructor<JakesPropagationLossModel> ()
    88.5      .AddAttribute ("NumberOfRaysPerPath",
    88.6                     "The number of rays to use by default for compute the fading coeficent for a given path (default is 1)",
    88.7 -                   Uinteger (1),
    88.8 +                   UintegerValue (1),
    88.9  		   MakeUintegerAccessor (&JakesPropagationLossModel::m_nRays),
   88.10  		   MakeUintegerChecker<uint8_t> ())
   88.11      .AddAttribute ("NumberOfOscillatorsPerRay",
   88.12                     "The number of oscillators to use by default for compute the coeficent for a given ray of a given path (default is 4)",
   88.13 -                   Uinteger (4),
   88.14 +                   UintegerValue (4),
   88.15  		   MakeUintegerAccessor (&JakesPropagationLossModel::m_nOscillators),
   88.16  		   MakeUintegerChecker<uint8_t> ())
   88.17      .AddAttribute ("DopplerFreq",
   88.18                     "The doppler frequency in Hz (f_d = v / lambda = v * f / c, the defualt is 0)",
   88.19 -                   Double(0.0),
   88.20 +                   DoubleValue (0.0),
   88.21  		   MakeDoubleAccessor (&JakesPropagationLossModel::m_fd),
   88.22  		   MakeDoubleChecker<double> ())
   88.23      .AddAttribute ("Distribution",
   88.24                     "The distribution to choose the initial phases.",
   88.25 -                   ConstantVariable (1.0),
   88.26 +                   RandomVariableValue (ConstantVariable (1.0)),
   88.27                     MakeRandomVariableAccessor (&JakesPropagationLossModel::m_variable),
   88.28                     MakeRandomVariableChecker ())
   88.29      ;
    89.1 --- a/src/devices/wifi/nqap-wifi-mac.cc	Mon Apr 21 08:58:23 2008 -0700
    89.2 +++ b/src/devices/wifi/nqap-wifi-mac.cc	Mon Apr 21 09:04:08 2008 -0700
    89.3 @@ -44,11 +44,11 @@
    89.4      .SetParent<WifiMac> ()
    89.5      .AddConstructor<NqapWifiMac> ()
    89.6      .AddAttribute ("BeaconInterval", "Delay between two beacons",
    89.7 -                   Seconds (1.0),
    89.8 +                   TimeValue (Seconds (1.0)),
    89.9                     MakeTimeAccessor (&NqapWifiMac::m_beaconInterval),
   89.10                     MakeTimeChecker ())
   89.11      .AddAttribute ("BeaconGeneration", "Whether or not beacons are generated.",
   89.12 -                   Boolean (false),
   89.13 +                   BooleanValue (false),
   89.14                     MakeBooleanAccessor (&NqapWifiMac::SetBeaconGeneration,
   89.15                                          &NqapWifiMac::GetBeaconGeneration),
   89.16                     MakeBooleanChecker ())
    90.1 --- a/src/devices/wifi/nqsta-wifi-mac.cc	Mon Apr 21 08:58:23 2008 -0700
    90.2 +++ b/src/devices/wifi/nqsta-wifi-mac.cc	Mon Apr 21 09:04:08 2008 -0700
    90.3 @@ -63,21 +63,21 @@
    90.4      .SetParent<WifiMac> ()
    90.5      .AddConstructor<NqstaWifiMac> ()
    90.6      .AddAttribute ("ProbeRequestTimeout", "XXX",
    90.7 -                   Seconds (0.5),
    90.8 +                   TimeValue (Seconds (0.5)),
    90.9                     MakeTimeAccessor (&NqstaWifiMac::m_probeRequestTimeout),
   90.10                     MakeTimeChecker ())
   90.11      .AddAttribute ("AssocRequestTimeout", "XXX",
   90.12 -                   Seconds (0.5),
   90.13 +                   TimeValue (Seconds (0.5)),
   90.14                     MakeTimeAccessor (&NqstaWifiMac::m_assocRequestTimeout),
   90.15                     MakeTimeChecker ())
   90.16      .AddAttribute ("MaxMissedBeacons", 
   90.17                     "Number of beacons which much be consecutively missed before "
   90.18                     "we attempt to restart association.",
   90.19 -                   Uinteger (10),
   90.20 +                   UintegerValue (10),
   90.21                     MakeUintegerAccessor (&NqstaWifiMac::m_maxMissedBeacons),
   90.22                     MakeUintegerChecker<uint32_t> ())
   90.23      .AddAttribute ("ActiveProbing", "XXX",
   90.24 -                   Boolean (false),
   90.25 +                   BooleanValue (false),
   90.26                     MakeBooleanAccessor (&NqstaWifiMac::SetActiveProbing),
   90.27                     MakeBooleanChecker ())
   90.28      ;
    91.1 --- a/src/devices/wifi/onoe-wifi-manager.cc	Mon Apr 21 08:58:23 2008 -0700
    91.2 +++ b/src/devices/wifi/onoe-wifi-manager.cc	Mon Apr 21 09:04:08 2008 -0700
    91.3 @@ -37,15 +37,15 @@
    91.4      .AddConstructor<OnoeWifiManager> ()
    91.5      .AddAttribute ("UpdatePeriod",
    91.6                     "The interval between decisions about rate control changes",
    91.7 -                   Seconds (1.0),
    91.8 +                   TimeValue (Seconds (1.0)),
    91.9                     MakeTimeAccessor (&OnoeWifiManager::m_updatePeriod),
   91.10                     MakeTimeChecker ())
   91.11      .AddAttribute ("RaiseThreshold", "XXX",
   91.12 -                   Uinteger (10),
   91.13 +                   UintegerValue (10),
   91.14                     MakeUintegerAccessor (&OnoeWifiManager::m_raiseThreshold),
   91.15                     MakeUintegerChecker<uint32_t> ())
   91.16      .AddAttribute ("AddCreditThreshold", "Add credit threshold",
   91.17 -                   Uinteger (10),
   91.18 +                   UintegerValue (10),
   91.19                     MakeUintegerAccessor (&OnoeWifiManager::m_addCreditThreshold),
   91.20                     MakeUintegerChecker<uint32_t> ())
   91.21      ;
    92.1 --- a/src/devices/wifi/onoe-wifi-manager.h	Mon Apr 21 08:58:23 2008 -0700
    92.2 +++ b/src/devices/wifi/onoe-wifi-manager.h	Mon Apr 21 09:04:08 2008 -0700
    92.3 @@ -25,6 +25,15 @@
    92.4  
    92.5  namespace ns3 {
    92.6  
    92.7 +/**
    92.8 + * \brief an implementation of rate control algorithm developed 
    92.9 + *        by Atsushi Onoe
   92.10 + *
   92.11 + * This algorithm is well known because it has been used as the default
   92.12 + * rate control algorithm for the madwifi driver. I am not aware of
   92.13 + * any publication or reference about this algorithm beyond the madwifi
   92.14 + * source code.
   92.15 + */
   92.16  class OnoeWifiManager : public WifiRemoteStationManager
   92.17  {
   92.18  public:
   92.19 @@ -41,15 +50,6 @@
   92.20    uint32_t m_raiseThreshold;
   92.21  };
   92.22  
   92.23 -/**
   92.24 - * \brief an implementation of rate control algorithm developed 
   92.25 - *        by Atsushi Onoe
   92.26 - *
   92.27 - * This algorithm is well known because it has been used as the default
   92.28 - * rate control algorithm for the madwifi driver. I am not aware of
   92.29 - * any publication or reference about this algorithm beyond the madwifi
   92.30 - * source code.
   92.31 - */
   92.32  class OnoeWifiRemoteStation : public WifiRemoteStation
   92.33  {
   92.34  public:
    93.1 --- a/src/devices/wifi/propagation-delay-model.cc	Mon Apr 21 08:58:23 2008 -0700
    93.2 +++ b/src/devices/wifi/propagation-delay-model.cc	Mon Apr 21 09:04:08 2008 -0700
    93.3 @@ -24,6 +24,17 @@
    93.4  
    93.5  namespace ns3 {
    93.6  
    93.7 +NS_OBJECT_ENSURE_REGISTERED (PropagationDelayModel);
    93.8 +
    93.9 +TypeId 
   93.10 +PropagationDelayModel::GetTypeId (void)
   93.11 +{
   93.12 +  static TypeId tid = TypeId ("ns3::PropagationDelayModel")
   93.13 +    .SetParent<Object> ()
   93.14 +    ;
   93.15 +  return tid;
   93.16 +}
   93.17 +
   93.18  PropagationDelayModel::~PropagationDelayModel ()
   93.19  {}
   93.20  
   93.21 @@ -37,7 +48,7 @@
   93.22      .AddConstructor<RandomPropagationDelayModel> ()
   93.23      .AddAttribute ("Variable",
   93.24                     "The random variable which generates random delays (s).",
   93.25 -                   UniformVariable (0.0, 1.0),
   93.26 +                   RandomVariableValue (UniformVariable (0.0, 1.0)),
   93.27                     MakeRandomVariableAccessor (&RandomPropagationDelayModel::m_variable),
   93.28                     MakeRandomVariableChecker ())
   93.29      ;
   93.30 @@ -63,7 +74,7 @@
   93.31      .SetParent<PropagationDelayModel> ()
   93.32      .AddConstructor<ConstantSpeedPropagationDelayModel> ()
   93.33      .AddAttribute ("Speed", "The speed (m/s)",
   93.34 -                   Double (300000000.0),
   93.35 +                   DoubleValue (300000000.0),
   93.36                     MakeDoubleAccessor (&ConstantSpeedPropagationDelayModel::m_speed),
   93.37                     MakeDoubleChecker<double> ())
   93.38      ;
    94.1 --- a/src/devices/wifi/propagation-delay-model.h	Mon Apr 21 08:58:23 2008 -0700
    94.2 +++ b/src/devices/wifi/propagation-delay-model.h	Mon Apr 21 09:04:08 2008 -0700
    94.3 @@ -35,6 +35,7 @@
    94.4  class PropagationDelayModel : public Object
    94.5  {
    94.6  public:
    94.7 +  static TypeId GetTypeId (void);
    94.8    virtual ~PropagationDelayModel ();
    94.9    /**
   94.10     * \param a the source
    95.1 --- a/src/devices/wifi/propagation-loss-model.cc	Mon Apr 21 08:58:23 2008 -0700
    95.2 +++ b/src/devices/wifi/propagation-loss-model.cc	Mon Apr 21 09:04:08 2008 -0700
    95.3 @@ -22,6 +22,7 @@
    95.4  #include "ns3/mobility-model.h"
    95.5  #include "ns3/static-mobility-model.h"
    95.6  #include "ns3/double.h"
    95.7 +#include "ns3/pointer.h"
    95.8  #include <math.h>
    95.9  
   95.10  NS_LOG_COMPONENT_DEFINE ("PropagationLossModel");
   95.11 @@ -31,17 +32,31 @@
   95.12  
   95.13  const double FriisPropagationLossModel::PI = 3.1415;
   95.14  
   95.15 +NS_OBJECT_ENSURE_REGISTERED (PropagationLossModel);
   95.16 +
   95.17 +TypeId 
   95.18 +PropagationLossModel::GetTypeId (void)
   95.19 +{
   95.20 +  static TypeId tid = TypeId ("ns3::PropagationLossModel")
   95.21 +    .SetParent<Object> ()
   95.22 +    ;
   95.23 +  return tid;
   95.24 +}
   95.25 +
   95.26 +
   95.27  PropagationLossModel::~PropagationLossModel ()
   95.28  {}
   95.29  
   95.30 +NS_OBJECT_ENSURE_REGISTERED (RandomPropagationLossModel);
   95.31 +
   95.32  TypeId 
   95.33  RandomPropagationLossModel::GetTypeId (void)
   95.34  {
   95.35 -  static TypeId tid = TypeId ("RandomPropagationLossModel")
   95.36 +  static TypeId tid = TypeId ("ns3::RandomPropagationLossModel")
   95.37      .SetParent<PropagationLossModel> ()
   95.38      .AddConstructor<RandomPropagationLossModel> ()
   95.39      .AddAttribute ("Variable", "XXX",
   95.40 -                   ConstantVariable (1.0),
   95.41 +                   RandomVariableValue (ConstantVariable (1.0)),
   95.42                     MakeRandomVariableAccessor (&RandomPropagationLossModel::m_variable),
   95.43                     MakeRandomVariableChecker ())
   95.44      ;
   95.45 @@ -62,24 +77,26 @@
   95.46    return rxc;
   95.47  }
   95.48  
   95.49 +NS_OBJECT_ENSURE_REGISTERED (FriisPropagationLossModel);
   95.50 +
   95.51  TypeId 
   95.52  FriisPropagationLossModel::GetTypeId (void)
   95.53  {
   95.54 -  static TypeId tid = TypeId ("FriisPropagationLossModel")
   95.55 +  static TypeId tid = TypeId ("ns3::FriisPropagationLossModel")
   95.56      .SetParent<PropagationLossModel> ()
   95.57      .AddConstructor<FriisPropagationLossModel> ()
   95.58      .AddAttribute ("Lambda", 
   95.59                     "The wavelength  (default is 5.15 GHz at 300 000 km/s).",
   95.60 -                   Double (300000000.0 / 5.150e9),
   95.61 +                   DoubleValue (300000000.0 / 5.150e9),
   95.62                     MakeDoubleAccessor (&FriisPropagationLossModel::m_lambda),
   95.63                     MakeDoubleChecker<double> ())
   95.64      .AddAttribute ("SystemLoss", "The system loss",
   95.65 -                   Double (1.0),
   95.66 +                   DoubleValue (1.0),
   95.67                     MakeDoubleAccessor (&FriisPropagationLossModel::m_systemLoss),
   95.68                     MakeDoubleChecker<double> ())
   95.69      .AddAttribute ("MinDistance", 
   95.70                     "The distance under which the propagation model refuses to give results (m)",
   95.71 -                   Double (0.5),
   95.72 +                   DoubleValue (0.5),
   95.73                     MakeDoubleAccessor (&FriisPropagationLossModel::m_minDistance),
   95.74                     MakeDoubleChecker<double> ())
   95.75      ;
   95.76 @@ -174,27 +191,29 @@
   95.77    return pr;
   95.78  }
   95.79  
   95.80 +NS_OBJECT_ENSURE_REGISTERED (LogDistancePropagationLossModel);
   95.81 +
   95.82  TypeId
   95.83  LogDistancePropagationLossModel::GetTypeId (void)
   95.84  {
   95.85 -  static TypeId tid = TypeId ("LogDistancePropagationLossModel")
   95.86 +  static TypeId tid = TypeId ("ns3::LogDistancePropagationLossModel")
   95.87      .SetParent<PropagationLossModel> ()
   95.88      .AddConstructor<LogDistancePropagationLossModel> ()
   95.89      .AddAttribute ("Exponent",
   95.90                     "The exponent of the Path Loss propagation model",
   95.91 -                   Double (3.0),
   95.92 +                   DoubleValue (3.0),
   95.93                     MakeDoubleAccessor (&LogDistancePropagationLossModel::m_exponent),
   95.94                     MakeDoubleChecker<double> ())
   95.95      .AddAttribute ("ReferenceDistance",
   95.96                     "The distance at which the reference loss is calculated (m)",
   95.97 -                   Double (1.0),
   95.98 +                   DoubleValue (1.0),
   95.99                     MakeDoubleAccessor (&LogDistancePropagationLossModel::m_referenceDistance),
  95.100                     MakeDoubleChecker<double> ())
  95.101      .AddAttribute ("ReferenceModel",
  95.102                     "The reference model at the reference distance.",
  95.103 -                   Ptr<PropagationLossModel> (0),
  95.104 -                   MakePtrAccessor (&LogDistancePropagationLossModel::m_reference),
  95.105 -                   MakePtrChecker<PropagationLossModel> ())
  95.106 +                   PointerValue (),
  95.107 +                   MakePointerAccessor (&LogDistancePropagationLossModel::m_reference),
  95.108 +                   MakePointerChecker<PropagationLossModel> ())
  95.109      ;
  95.110    return tid;
  95.111                     
  95.112 @@ -249,10 +268,10 @@
  95.113     */
  95.114    static Ptr<StaticMobilityModel> zero = 
  95.115      CreateObject<StaticMobilityModel> ("Position", 
  95.116 -                                       Vector (0.0, 0.0, 0.0));
  95.117 +                                       VectorValue (Vector (0.0, 0.0, 0.0)));
  95.118    static Ptr<StaticMobilityModel> reference = 
  95.119      CreateObject<StaticMobilityModel> ("Position", 
  95.120 -                                       Vector (m_referenceDistance, 0.0, 0.0));
  95.121 +                                       VectorValue (Vector (m_referenceDistance, 0.0, 0.0)));
  95.122    double ref = m_reference->GetLoss (zero, reference);
  95.123    double pathLossDb = 10 * m_exponent * log10 (distance / m_referenceDistance);
  95.124    double rxc = ref - pathLossDb;
    96.1 --- a/src/devices/wifi/propagation-loss-model.h	Mon Apr 21 08:58:23 2008 -0700
    96.2 +++ b/src/devices/wifi/propagation-loss-model.h	Mon Apr 21 09:04:08 2008 -0700
    96.3 @@ -36,6 +36,8 @@
    96.4  class PropagationLossModel : public Object
    96.5  {
    96.6  public:
    96.7 +  static TypeId GetTypeId (void);
    96.8 +
    96.9    virtual ~PropagationLossModel ();
   96.10    /**
   96.11     * \param a the mobility model of the source
    97.1 --- a/src/devices/wifi/rraa-wifi-manager.cc	Mon Apr 21 08:58:23 2008 -0700
    97.2 +++ b/src/devices/wifi/rraa-wifi-manager.cc	Mon Apr 21 09:04:08 2008 -0700
    97.3 @@ -193,122 +193,122 @@
    97.4      .AddConstructor<RraaWifiManager> ()
    97.5      .AddAttribute ("Basic",
    97.6                     "If true the RRAA-BASIC algorithm will be used, otherwise the RRAA wil be used",
    97.7 -                   Boolean (false),
    97.8 +                   BooleanValue (false),
    97.9                     MakeBooleanAccessor (&RraaWifiManager::m_basic),
   97.10                     MakeBooleanChecker ())
   97.11      .AddAttribute ("Timeout",
   97.12                     "Timeout for the RRAA BASIC loss estimaton block (s)",
   97.13 -                   Seconds (0.05),
   97.14 +                   TimeValue (Seconds (0.05)),
   97.15                     MakeTimeAccessor (&RraaWifiManager::m_timeout),
   97.16                     MakeTimeChecker ())
   97.17      .AddAttribute ("ewndFor54mbps",
   97.18                     "ewnd parameter for 54 Mbs data mode",
   97.19 -                   Uinteger (40),
   97.20 +                   UintegerValue (40),
   97.21                     MakeUintegerAccessor (&RraaWifiManager::m_ewndfor54),
   97.22                     MakeUintegerChecker<uint32_t> ())
   97.23      .AddAttribute ("ewndFor48mbps",
   97.24                     "ewnd parameter for 48 Mbs data mode",
   97.25 -                   Uinteger (40),
   97.26 +                   UintegerValue (40),
   97.27                     MakeUintegerAccessor (&RraaWifiManager::m_ewndfor48),
   97.28                     MakeUintegerChecker<uint32_t> ())
   97.29      .AddAttribute ("ewndFor36mbps",
   97.30                     "ewnd parameter for 36 Mbs data mode",
   97.31 -                   Uinteger (40),
   97.32 +                   UintegerValue (40),
   97.33                     MakeUintegerAccessor (&RraaWifiManager::m_ewndfor36),
   97.34                     MakeUintegerChecker<uint32_t> ())
   97.35      .AddAttribute ("ewndFor24mbps",
   97.36                     "ewnd parameter for 24 Mbs data mode",
   97.37 -                   Uinteger (40),
   97.38 +                   UintegerValue (40),
   97.39                     MakeUintegerAccessor (&RraaWifiManager::m_ewndfor24),
   97.40                     MakeUintegerChecker<uint32_t> ())
   97.41      .AddAttribute ("ewndFor18mbps",
   97.42                     "ewnd parameter for 18 Mbs data mode",
   97.43 -                   Uinteger (20),
   97.44 +                   UintegerValue (20),
   97.45                     MakeUintegerAccessor (&RraaWifiManager::m_ewndfor18),
   97.46                     MakeUintegerChecker<uint32_t> ())
   97.47      .AddAttribute ("ewndFor12mbps",
   97.48                     "ewnd parameter for 12 Mbs data mode",
   97.49 -                   Uinteger (20),
   97.50 +                   UintegerValue (20),
   97.51                     MakeUintegerAccessor (&RraaWifiManager::m_ewndfor12),
   97.52                     MakeUintegerChecker<uint32_t> ())
   97.53      .AddAttribute ("ewndFor9mbps",
   97.54                     "ewnd parameter for 9 Mbs data mode",
   97.55 -                   Uinteger (10),
   97.56 +                   UintegerValue (10),
   97.57                     MakeUintegerAccessor (&RraaWifiManager::m_ewndfor9),
   97.58                     MakeUintegerChecker<uint32_t> ())
   97.59      .AddAttribute ("ewndFor6mbps",
   97.60                     "ewnd parameter for 6 Mbs data mode",
   97.61 -                   Uinteger (6),
   97.62 +                   UintegerValue (6),
   97.63                     MakeUintegerAccessor (&RraaWifiManager::m_ewndfor6),
   97.64                     MakeUintegerChecker<uint32_t> ())
   97.65      .AddAttribute ("poriFor48mbps",
   97.66                     "Pori parameter for 48 Mbs data mode",
   97.67 -                   Double (0.047),
   97.68 +                   DoubleValue (0.047),
   97.69                     MakeDoubleAccessor (&RraaWifiManager::m_porifor48),
   97.70                     MakeDoubleChecker<double> ())
   97.71      .AddAttribute ("poriFor36mbps",
   97.72                     "Pori parameter for 36 Mbs data mode",
   97.73 -                   Double (0.115),
   97.74 +                   DoubleValue (0.115),
   97.75                     MakeDoubleAccessor (&RraaWifiManager::m_porifor36),
   97.76                     MakeDoubleChecker<double> ())
   97.77      .AddAttribute ("poriFor24mbps",
   97.78                     "Pori parameter for 24 Mbs data mode",
   97.79 -                   Double (0.1681),
   97.80 +                   DoubleValue (0.1681),
   97.81                     MakeDoubleAccessor (&RraaWifiManager::m_porifor24),
   97.82                     MakeDoubleChecker<double> ())
   97.83      .AddAttribute ("poriFor18mbps",
   97.84                     "Pori parameter for 18 Mbs data mode",
   97.85 -                   Double (0.1325),
   97.86 +                   DoubleValue (0.1325),
   97.87                     MakeDoubleAccessor (&RraaWifiManager::m_porifor18),
   97.88                     MakeDoubleChecker<double> ())
   97.89      .AddAttribute ("poriFor12mbps",
   97.90                     "Pori parameter for 12 Mbs data mode",
   97.91 -                   Double (0.1861),
   97.92 +                   DoubleValue (0.1861),
   97.93                     MakeDoubleAccessor (&RraaWifiManager::m_porifor12),
   97.94                     MakeDoubleChecker<double> ())
   97.95      .AddAttribute ("poriFor9mbps",
   97.96                     "Pori parameter for 9 Mbs data mode",
   97.97 -                   Double (0.1434),
   97.98 +                   DoubleValue (0.1434),
   97.99                     MakeDoubleAccessor (&RraaWifiManager::m_porifor9),
  97.100                     MakeDoubleChecker<double> ())
  97.101      .AddAttribute ("poriFor6mbps",
  97.102                     "Pori parameter for 6 Mbs data mode",
  97.103 -                   Double (0.5),
  97.104 +                   DoubleValue (0.5),
  97.105                     MakeDoubleAccessor (&RraaWifiManager::m_porifor6),
  97.106                     MakeDoubleChecker<double> ())
  97.107      .AddAttribute ("pmtlFor54mbps",
  97.108                     "Pmtl parameter for 54 Mbs data mode",
  97.109 -                   Double (0.094),
  97.110 +                   DoubleValue (0.094),
  97.111                     MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor54),
  97.112                     MakeDoubleChecker<double> ())
  97.113      .AddAttribute ("pmtlFor48mbps",
  97.114                     "Pmtl parameter for 48 Mbs data mode",
  97.115 -                   Double (0.23),
  97.116 +                   DoubleValue (0.23),
  97.117                     MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor48),
  97.118                     MakeDoubleChecker<double> ())
  97.119      .AddAttribute ("pmtlFor36mbps",
  97.120                     "Pmtl parameter for 36 Mbs data mode",
  97.121 -                   Double (0.3363),
  97.122 +                   DoubleValue (0.3363),
  97.123                     MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor36),
  97.124                     MakeDoubleChecker<double> ())
  97.125      .AddAttribute ("pmtlFor24mbps",
  97.126                     "Pmtl parameter for 24 Mbs data mode",
  97.127 -                   Double (0.265),
  97.128 +                   DoubleValue (0.265),
  97.129                     MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor24),
  97.130                     MakeDoubleChecker<double> ())
  97.131      .AddAttribute ("pmtlFor18mbps",
  97.132                     "Pmtl parameter for 18 Mbs data mode",
  97.133 -                   Double (0.3722),
  97.134 +                   DoubleValue (0.3722),
  97.135                     MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor18),
  97.136                     MakeDoubleChecker<double> ())
  97.137      .AddAttribute ("pmtlFor12mbps",
  97.138                     "Pmtl parameter for 12 Mbs data mode",
  97.139 -                   Double(0.2868),
  97.140 +                   DoubleValue (0.2868),
  97.141                     MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor12),
  97.142                     MakeDoubleChecker<double> ())
  97.143      .AddAttribute ("pmtlFor9mbps",
  97.144                     "Pmtl parameter for 9 Mbs data mode",
  97.145 -                   Double (0.3932),
  97.146 +                   DoubleValue (0.3932),
  97.147                     MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor9),
  97.148                     MakeDoubleChecker<double> ())
  97.149      ;
    98.1 --- a/src/devices/wifi/ssid.h	Mon Apr 21 08:58:23 2008 -0700
    98.2 +++ b/src/devices/wifi/ssid.h	Mon Apr 21 09:04:08 2008 -0700
    98.3 @@ -26,6 +26,10 @@
    98.4  
    98.5  namespace ns3 {
    98.6  
    98.7 +/**
    98.8 + * \brief a IEEE 802.11 SSID
    98.9 + *
   98.10 + */
   98.11  class Ssid 
   98.12  {
   98.13  public:
   98.14 @@ -54,6 +58,11 @@
   98.15  std::ostream &operator << (std::ostream &os, const Ssid &ssid);
   98.16  std::istream &operator >> (std::istream &is, Ssid &ssid);
   98.17  
   98.18 +/**
   98.19 + * \class ns3::SsidValue
   98.20 + * \brief hold objects of type ns3::Ssid
   98.21 + */
   98.22 +
   98.23  ATTRIBUTE_HELPER_HEADER_2 (Ssid);
   98.24  
   98.25  } // namespace ns3
    99.1 --- a/src/devices/wifi/wifi-channel.cc	Mon Apr 21 08:58:23 2008 -0700
    99.2 +++ b/src/devices/wifi/wifi-channel.cc	Mon Apr 21 09:04:08 2008 -0700
    99.3 @@ -23,6 +23,7 @@
    99.4  #include "ns3/net-device.h"
    99.5  #include "ns3/node.h"
    99.6  #include "ns3/log.h"
    99.7 +#include "ns3/pointer.h"
    99.8  #include "wifi-channel.h"
    99.9  #include "propagation-loss-model.h"
   99.10  #include "propagation-delay-model.h"
   99.11 @@ -32,19 +33,19 @@
   99.12  namespace ns3 {
   99.13  
   99.14  TypeId 
   99.15 -WifiChannel::GetTypdId (void)
   99.16 +WifiChannel::GetTypeId (void)
   99.17  {
   99.18    static TypeId tid = TypeId ("ns3::WifiChannel")
   99.19 -    .SetParent<WifiChannel> ()
   99.20 +    .SetParent<Channel> ()
   99.21      .AddConstructor<WifiChannel> ()
   99.22      .AddAttribute ("PropagationLossModel", "XXX",
   99.23 -                   Ptr<PropagationLossModel> (0),
   99.24 -                   MakePtrAccessor (&WifiChannel::m_loss),
   99.25 -                   MakePtrChecker<PropagationLossModel> ())
   99.26 +                   PointerValue (),
   99.27 +                   MakePointerAccessor (&WifiChannel::m_loss),
   99.28 +                   MakePointerChecker<PropagationLossModel> ())
   99.29      .AddAttribute ("PropagationDelayModel", "XXX",
   99.30 -                   Ptr<PropagationDelayModel> (0),
   99.31 -                   MakePtrAccessor (&WifiChannel::m_delay),
   99.32 -                   MakePtrChecker<PropagationDelayModel> ())
   99.33 +                   PointerValue (),
   99.34 +                   MakePointerAccessor (&WifiChannel::m_delay),
   99.35 +                   MakePointerChecker<PropagationDelayModel> ())
   99.36      ;
   99.37    return tid;
   99.38  }
   100.1 --- a/src/devices/wifi/wifi-channel.h	Mon Apr 21 08:58:23 2008 -0700
   100.2 +++ b/src/devices/wifi/wifi-channel.h	Mon Apr 21 09:04:08 2008 -0700
   100.3 @@ -47,7 +47,7 @@
   100.4  class WifiChannel : public Channel
   100.5  {
   100.6  public:
   100.7 -  static TypeId GetTypdId (void);
   100.8 +  static TypeId GetTypeId (void);
   100.9  
  100.10    WifiChannel ();
  100.11    virtual ~WifiChannel ();
   101.1 --- a/src/devices/wifi/wifi-mac-queue.cc	Mon Apr 21 08:58:23 2008 -0700
   101.2 +++ b/src/devices/wifi/wifi-mac-queue.cc	Mon Apr 21 09:04:08 2008 -0700
   101.3 @@ -40,12 +40,12 @@
   101.4    static TypeId tid = TypeId ("WifiMacQueue")
   101.5      .SetParent<Object> ()
   101.6      .AddConstructor<WifiMacQueue> ()
   101.7 -    .AddAttribute ("MaxPacketNumber", "XXX",
   101.8 -                   Uinteger (400),
   101.9 +    .AddAttribute ("MaxPacketNumber", "If a packet arrives when there are already this number of packets, it is dropped.",
  101.10 +                   UintegerValue (400),
  101.11                     MakeUintegerAccessor (&WifiMacQueue::m_maxSize),
  101.12                     MakeUintegerChecker<uint32_t> ())
  101.13 -    .AddAttribute ("MaxDelay", "XXX",
  101.14 -                   Seconds (10.0),
  101.15 +    .AddAttribute ("MaxDelay", "If a packet stays longer than this delay in the queue, it is dropped.",
  101.16 +                   TimeValue (Seconds (10.0)),
  101.17                     MakeTimeAccessor (&WifiMacQueue::m_maxDelay),
  101.18                     MakeTimeChecker ())
  101.19      ;
   102.1 --- a/src/devices/wifi/wifi-mac.cc	Mon Apr 21 08:58:23 2008 -0700
   102.2 +++ b/src/devices/wifi/wifi-mac.cc	Mon Apr 21 09:04:08 2008 -0700
   102.3 @@ -74,42 +74,42 @@
   102.4    static TypeId tid = TypeId ("ns3::WifiMac")
   102.5      .SetParent<Object> ()
   102.6      .AddAttribute ("CtsTimeout", "XXX",
   102.7 -                   GetDefaultCtsAckTimeout (),
   102.8 +                   TimeValue (GetDefaultCtsAckTimeout ()),
   102.9                     MakeTimeAccessor (&WifiMac::m_ctsTimeout),
  102.10                     MakeTimeChecker ())
  102.11      .AddAttribute ("AckTimeout", "XXX",
  102.12 -                   GetDefaultCtsAckTimeout (),
  102.13 +                   TimeValue (GetDefaultCtsAckTimeout ()),
  102.14                     MakeTimeAccessor (&WifiMac::m_ackTimeout),
  102.15                     MakeTimeChecker ())
  102.16      .AddAttribute ("Sifs", "XXX",
  102.17 -                   GetDefaultSifs (),
  102.18 +                   TimeValue (GetDefaultSifs ()),
  102.19                     MakeTimeAccessor (&WifiMac::SetSifs,
  102.20  				     &WifiMac::GetSifs),
  102.21                     MakeTimeChecker ())
  102.22      .AddAttribute ("EifsNoDifs", "XXX",
  102.23 -		   GetDefaultEifsNoDifs (),
  102.24 +		   TimeValue (GetDefaultEifsNoDifs ()),
  102.25  		   MakeTimeAccessor (&WifiMac::SetEifsNoDifs,
  102.26  				     &WifiMac::GetEifsNoDifs),
  102.27  		   MakeTimeChecker ())
  102.28      .AddAttribute ("Slot", "XXX",
  102.29 -                   GetDefaultSlot (),
  102.30 +                   TimeValue (GetDefaultSlot ()),
  102.31                     MakeTimeAccessor (&WifiMac::SetSlot,
  102.32  				     &WifiMac::GetSlot),
  102.33                     MakeTimeChecker ())
  102.34      .AddAttribute ("Pifs", "XXX",
  102.35 -                   GetDefaultSifs () + GetDefaultSlot (),
  102.36 +                   TimeValue (GetDefaultSifs () + GetDefaultSlot ()),
  102.37                     MakeTimeAccessor (&WifiMac::m_pifs),
  102.38                     MakeTimeChecker ())
  102.39      .AddAttribute ("MaxPropagationDelay", "XXX",
  102.40 -                   GetDefaultMaxPropagationDelay (),
  102.41 +                   TimeValue (GetDefaultMaxPropagationDelay ()),
  102.42                     MakeTimeAccessor (&WifiMac::m_maxPropagationDelay),
  102.43                     MakeTimeChecker ())
  102.44      .AddAttribute ("MaxMsduSize", "XXX",
  102.45 -		   Uinteger (2304),
  102.46 +		   UintegerValue (2304),
  102.47  		   MakeUintegerAccessor (&WifiMac::m_maxMsduSize),
  102.48  		   MakeUintegerChecker<uint16_t> (1,2304))
  102.49      .AddAttribute ("Ssid", "XXX",
  102.50 -		   Ssid ("default"),
  102.51 +		   SsidValue (Ssid ("default")),
  102.52  		   MakeSsidAccessor (&WifiMac::GetSsid,
  102.53  				     &WifiMac::SetSsid),
  102.54  		   MakeSsidChecker ())
   103.1 --- a/src/devices/wifi/wifi-mode.h	Mon Apr 21 08:58:23 2008 -0700
   103.2 +++ b/src/devices/wifi/wifi-mode.h	Mon Apr 21 09:04:08 2008 -0700
   103.3 @@ -118,6 +118,11 @@
   103.4  std::ostream & operator << (std::ostream & os, const WifiMode &mode);
   103.5  std::istream & operator >> (std::istream &is, WifiMode &mode);
   103.6  
   103.7 +/**
   103.8 + * \class ns3::WifiModeValue
   103.9 + * \brief hold objects of type ns3::WifiMode
  103.10 + */
  103.11 +
  103.12  ATTRIBUTE_HELPER_HEADER_2 (WifiMode);
  103.13  
  103.14  /**
   104.1 --- a/src/devices/wifi/wifi-net-device.cc	Mon Apr 21 08:58:23 2008 -0700
   104.2 +++ b/src/devices/wifi/wifi-net-device.cc	Mon Apr 21 09:04:08 2008 -0700
   104.3 @@ -25,39 +25,42 @@
   104.4  #include "ns3/llc-snap-header.h"
   104.5  #include "ns3/packet.h"
   104.6  #include "ns3/uinteger.h"
   104.7 +#include "ns3/pointer.h"
   104.8  #include "ns3/node.h"
   104.9  #include "ns3/trace-source-accessor.h"
  104.10  
  104.11  namespace ns3 {
  104.12  
  104.13 +NS_OBJECT_ENSURE_REGISTERED (WifiNetDevice);
  104.14 +
  104.15  TypeId 
  104.16  WifiNetDevice::GetTypeId (void)
  104.17  {
  104.18    static TypeId tid = TypeId ("ns3::WifiNetDevice")
  104.19      .SetParent<NetDevice> ()
  104.20 -    .AddAttribute ("Channel", "XXX",
  104.21 -                   Ptr<Channel> (0),
  104.22 -                   MakePtrAccessor (&WifiNetDevice::DoGetChannel,
  104.23 -                                    &WifiNetDevice::SetChannel),
  104.24 -                   MakePtrChecker<Channel> ())
  104.25 -    .AddAttribute ("Phy", "XXX",
  104.26 -                   Ptr<WifiPhy> (0),
  104.27 -                   MakePtrAccessor (&WifiNetDevice::GetPhy,
  104.28 -                                    &WifiNetDevice::SetPhy),
  104.29 -                   MakePtrChecker<WifiPhy> ())
  104.30 -    .AddAttribute ("Mac", "XXX",
  104.31 -                   Ptr<WifiMac> (0),
  104.32 -                   MakePtrAccessor (&WifiNetDevice::GetMac,
  104.33 -                                    &WifiNetDevice::SetMac),
  104.34 -                   MakePtrChecker<WifiMac> ())
  104.35 -    .AddAttribute ("RemoteStationManager", "XXX",
  104.36 -                   Ptr<WifiRemoteStationManager> (0),
  104.37 -                   MakePtrAccessor (&WifiNetDevice::SetRemoteStationManager,
  104.38 -                                    &WifiNetDevice::GetRemoteStationManager),
  104.39 -                   MakePtrChecker<WifiRemoteStationManager> ())
  104.40 -    .AddTraceSource ("Rx", "XXX",
  104.41 +    .AddAttribute ("Channel", "The channel attached to this device",
  104.42 +                   PointerValue (),
  104.43 +                   MakePointerAccessor (&WifiNetDevice::DoGetChannel,
  104.44 +                                        &WifiNetDevice::SetChannel),
  104.45 +                   MakePointerChecker<WifiChannel> ())
  104.46 +    .AddAttribute ("Phy", "The PHY layer attached to this device.",
  104.47 +                   PointerValue (),
  104.48 +                   MakePointerAccessor (&WifiNetDevice::GetPhy,
  104.49 +                                        &WifiNetDevice::SetPhy),
  104.50 +                   MakePointerChecker<WifiPhy> ())
  104.51 +    .AddAttribute ("Mac", "The MAC layer attached to this device.",
  104.52 +                   PointerValue (),
  104.53 +                   MakePointerAccessor (&WifiNetDevice::GetMac,
  104.54 +                                        &WifiNetDevice::SetMac),
  104.55 +                   MakePointerChecker<WifiMac> ())
  104.56 +    .AddAttribute ("RemoteStationManager", "The station manager attached to this device.",
  104.57 +                   PointerValue (),
  104.58 +                   MakePointerAccessor (&WifiNetDevice::SetRemoteStationManager,
  104.59 +                                        &WifiNetDevice::GetRemoteStationManager),
  104.60 +                   MakePointerChecker<WifiRemoteStationManager> ())
  104.61 +    .AddTraceSource ("Rx", "Received payload from the MAC layer.",
  104.62                       MakeTraceSourceAccessor (&WifiNetDevice::m_rxLogger))
  104.63 -    .AddTraceSource ("Tx", "XXX",
  104.64 +    .AddTraceSource ("Tx", "Send payload to the MAC layer.",
  104.65                       MakeTraceSourceAccessor (&WifiNetDevice::m_txLogger))
  104.66      ;
  104.67    return tid;
  104.68 @@ -204,8 +207,9 @@
  104.69  bool 
  104.70  WifiNetDevice::SetMtu (const uint16_t mtu)
  104.71  {
  104.72 -  Uinteger maxMsduSize = m_mac->GetAttribute ("MaxMsduSize");
  104.73 -  if (mtu > maxMsduSize && mtu > 0)
  104.74 +  UintegerValue maxMsduSize;
  104.75 +  m_mac->GetAttribute ("MaxMsduSize", maxMsduSize);
  104.76 +  if (mtu > maxMsduSize.Get () || mtu == 0)
  104.77      {
  104.78        return false;
  104.79      }
  104.80 @@ -217,8 +221,9 @@
  104.81  {
  104.82    if (m_mtu == 0)
  104.83      {
  104.84 -      Uinteger maxMsduSize = m_mac->GetAttribute ("MaxMsduSize");
  104.85 -      m_mtu = maxMsduSize;
  104.86 +      UintegerValue maxMsduSize;
  104.87 +      m_mac->GetAttribute ("MaxMsduSize", maxMsduSize);
  104.88 +      m_mtu = maxMsduSize.Get ();
  104.89      }
  104.90    return m_mtu;
  104.91  }
   105.1 --- a/src/devices/wifi/wifi-phy.cc	Mon Apr 21 08:58:23 2008 -0700
   105.2 +++ b/src/devices/wifi/wifi-phy.cc	Mon Apr 21 09:04:08 2008 -0700
   105.3 @@ -187,48 +187,48 @@
   105.4      .AddAttribute ("EnergyDetectionThreshold",
   105.5                     "The energy of a received signal should be higher than "
   105.6                     "this threshold (dbm) to allow the PHY layer to detect the signal.",
   105.7 -                   Double (-140.0),
   105.8 +                   DoubleValue (-140.0),
   105.9                     MakeDoubleAccessor (&WifiPhy::SetEdThreshold,
  105.10                                         &WifiPhy::GetEdThreshold),
  105.11                     MakeDoubleChecker<double> ())
  105.12      .AddAttribute ("TxGain",
  105.13                     "Transmission gain (dB).",
  105.14 -                   Double (1.0),
  105.15 +                   DoubleValue (1.0),
  105.16                     MakeDoubleAccessor (&WifiPhy::SetTxGain,
  105.17                                         &WifiPhy::GetTxGain),
  105.18                     MakeDoubleChecker<double> ())
  105.19      .AddAttribute ("RxGain",
  105.20                     "Reception gain (dB).",
  105.21 -                   Double (1.0),
  105.22 +                   DoubleValue (1.0),
  105.23                     MakeDoubleAccessor (&WifiPhy::SetRxGain,
  105.24                                         &WifiPhy::GetRxGain),
  105.25                     MakeDoubleChecker<double> ())
  105.26      .AddAttribute ("TxPowerLevels",
  105.27                     "Number of transmission power levels available between "
  105.28                     "TxPowerBase and TxPowerEnd included.",
  105.29 -                   Uinteger (1),
  105.30 +                   UintegerValue (1),
  105.31                     MakeUintegerAccessor (&WifiPhy::m_nTxPower),
  105.32                     MakeUintegerChecker<uint32_t> ())
  105.33      .AddAttribute ("TxPowerEnd",
  105.34                     "Maximum available transmission level (dbm).",
  105.35 -                   Double (16.0206),
  105.36 +                   DoubleValue (16.0206),
  105.37                     MakeDoubleAccessor (&WifiPhy::SetTxPowerEnd, 
  105.38                                         &WifiPhy::GetTxPowerEnd),
  105.39                     MakeDoubleChecker<double> ())
  105.40      .AddAttribute ("TxPowerStart",
  105.41                     "Minimum available transmission level (dbm).",
  105.42 -                   Double (16.0206),
  105.43 +                   DoubleValue (16.0206),
  105.44                     MakeDoubleAccessor (&WifiPhy::SetTxPowerStart, 
  105.45                                         &WifiPhy::GetTxPowerStart),
  105.46                     MakeDoubleChecker<double> ())
  105.47      .AddAttribute ("RxNoise",
  105.48                     "Ratio of energy lost by receiver (dB).",
  105.49 -                   Double (7),
  105.50 +                   DoubleValue (7),
  105.51                     MakeDoubleAccessor (&WifiPhy::SetRxNoise,
  105.52                                         &WifiPhy::GetRxNoise),
  105.53                     MakeDoubleChecker<double> ())
  105.54      .AddAttribute ("Standard", "XXX",
  105.55 -                   Enum (WIFI_PHY_STANDARD_80211a),
  105.56 +                   EnumValue (WIFI_PHY_STANDARD_80211a),
  105.57                     MakeEnumAccessor (&WifiPhy::SetStandard),
  105.58                     MakeEnumChecker (WIFI_PHY_STANDARD_80211a, "802.11a",
  105.59                                      WIFI_PHY_STANDARD_holland, "holland"))
   106.1 --- a/src/devices/wifi/wifi-remote-station-manager.cc	Mon Apr 21 08:58:23 2008 -0700
   106.2 +++ b/src/devices/wifi/wifi-remote-station-manager.cc	Mon Apr 21 09:04:08 2008 -0700
   106.3 @@ -127,23 +127,23 @@
   106.4    static TypeId tid = TypeId ("ns3::WifiRemoteStationManager")
   106.5      .SetParent<Object> ()
   106.6      .AddAttribute ("IsLowLatency", "XXX",
   106.7 -                   Boolean (true),
   106.8 +                   BooleanValue (true),
   106.9                     MakeBooleanAccessor (&WifiRemoteStationManager::m_isLowLatency),
  106.10                     MakeBooleanChecker ())
  106.11      .AddAttribute ("MaxSsrc", "XXX",
  106.12 -                   Uinteger (7),
  106.13 +                   UintegerValue (7),
  106.14                     MakeUintegerAccessor (&WifiRemoteStationManager::m_maxSsrc),
  106.15                     MakeUintegerChecker<uint32_t> ())
  106.16      .AddAttribute ("MaxSlrc", "XXX",
  106.17 -                   Uinteger (7),
  106.18 +                   UintegerValue (7),
  106.19                     MakeUintegerAccessor (&WifiRemoteStationManager::m_maxSlrc),
  106.20                     MakeUintegerChecker<uint32_t> ())
  106.21      .AddAttribute ("RtsCtsThreshold", "XXX",
  106.22 -                   Uinteger (1500),
  106.23 +                   UintegerValue (1500),
  106.24                     MakeUintegerAccessor (&WifiRemoteStationManager::m_rtsCtsThreshold),
  106.25                     MakeUintegerChecker<uint32_t> ())
  106.26      .AddAttribute ("FragmentationThreshold", "XXX",
  106.27 -                   Uinteger (1500),
  106.28 +                   UintegerValue (1500),
  106.29                     MakeUintegerAccessor (&WifiRemoteStationManager::m_fragmentationThreshold),
  106.30                     MakeUintegerChecker<uint32_t> ())
  106.31      ;
   107.1 --- a/src/helper/csma-helper.cc	Mon Apr 21 08:58:23 2008 -0700
   107.2 +++ b/src/helper/csma-helper.cc	Mon Apr 21 09:04:08 2008 -0700
   107.3 @@ -39,10 +39,10 @@
   107.4  
   107.5  void 
   107.6  CsmaHelper::SetQueue (std::string type,
   107.7 -		      std::string n1, Attribute v1,
   107.8 -		      std::string n2, Attribute v2,
   107.9 -		      std::string n3, Attribute v3,
  107.10 -		      std::string n4, Attribute v4)
  107.11 +		      std::string n1, const AttributeValue &v1,
  107.12 +		      std::string n2, const AttributeValue &v2,
  107.13 +		      std::string n3, const AttributeValue &v3,
  107.14 +		      std::string n4, const AttributeValue &v4)
  107.15  {
  107.16    m_queueFactory.SetTypeId (type);
  107.17    m_queueFactory.Set (n1, v1);
  107.18 @@ -52,13 +52,13 @@
  107.19  }
  107.20  
  107.21  void 
  107.22 -CsmaHelper::SetDeviceParameter (std::string n1, Attribute v1)
  107.23 +CsmaHelper::SetDeviceParameter (std::string n1, const AttributeValue &v1)
  107.24  {
  107.25    m_deviceFactory.Set (n1, v1);
  107.26  }
  107.27  
  107.28  void 
  107.29 -CsmaHelper::SetChannelParameter (std::string n1, Attribute v1)
  107.30 +CsmaHelper::SetChannelParameter (std::string n1, const AttributeValue &v1)
  107.31  {
  107.32    m_channelFactory.Set (n1, v1);
  107.33  }
   108.1 --- a/src/helper/csma-helper.h	Mon Apr 21 08:58:23 2008 -0700
   108.2 +++ b/src/helper/csma-helper.h	Mon Apr 21 09:04:08 2008 -0700
   108.3 @@ -56,10 +56,10 @@
   108.4     * CsmaNetDevice created through CsmaHelper::Install.
   108.5     */
   108.6    void SetQueue (std::string type,
   108.7 -		 std::string n1 = "", Attribute v1 = Attribute (),
   108.8 -		 std::string n2 = "", Attribute v2 = Attribute (),
   108.9 -		 std::string n3 = "", Attribute v3 = Attribute (),
  108.10 -		 std::string n4 = "", Attribute v4 = Attribute ());
  108.11 +		 std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
  108.12 +		 std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
  108.13 +		 std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
  108.14 +		 std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue ());
  108.15  
  108.16    /**
  108.17     * \param n1 the name of the attribute to set
  108.18 @@ -68,7 +68,7 @@
  108.19     * Set these parameters on each ns3::CsmaNetDevice created
  108.20     * by CsmaHelper::Install
  108.21     */
  108.22 -  void SetDeviceParameter (std::string n1, Attribute v1);
  108.23 +  void SetDeviceParameter (std::string n1, const AttributeValue &v1);
  108.24  
  108.25    /**
  108.26     * \param n1 the name of the attribute to set
  108.27 @@ -77,7 +77,7 @@
  108.28     * Set these parameters on each ns3::CsmaChannel created
  108.29     * by CsmaHelper::Install
  108.30     */
  108.31 -  void SetChannelParameter (std::string n1, Attribute v1);
  108.32 +  void SetChannelParameter (std::string n1, const AttributeValue &v1);
  108.33  
  108.34    /**
  108.35     * \param filename filename prefix to use for pcap files.
   109.1 --- a/src/helper/mobility-helper.cc	Mon Apr 21 08:58:23 2008 -0700
   109.2 +++ b/src/helper/mobility-helper.cc	Mon Apr 21 09:04:08 2008 -0700
   109.3 @@ -23,6 +23,7 @@
   109.4  #include "ns3/position-allocator.h"
   109.5  #include "ns3/hierarchical-mobility-model.h"
   109.6  #include "ns3/log.h"
   109.7 +#include "ns3/pointer.h"
   109.8  
   109.9  namespace ns3 {
  109.10  
  109.11 @@ -31,8 +32,9 @@
  109.12  MobilityHelper::MobilityHelper ()
  109.13    : m_notifierEnabled (false)
  109.14  {
  109.15 -  m_position = CreateObject<RandomRectanglePositionAllocator> ("X", ConstantVariable (0.0),
  109.16 -								   "Y", ConstantVariable (0.0));
  109.17 +  m_position = CreateObject<RandomRectanglePositionAllocator> 
  109.18 +    ("X", RandomVariableValue (ConstantVariable (0.0)),
  109.19 +     "Y", RandomVariableValue (ConstantVariable (0.0)));
  109.20    m_mobility.SetTypeId ("ns3::StaticMobilityModel");
  109.21  }
  109.22  MobilityHelper::~MobilityHelper ()
  109.23 @@ -54,15 +56,15 @@
  109.24  }
  109.25  void 
  109.26  MobilityHelper::SetPositionAllocator (std::string type,
  109.27 -				      std::string n1, Attribute v1,
  109.28 -				      std::string n2, Attribute v2,
  109.29 -				      std::string n3, Attribute v3,
  109.30 -				      std::string n4, Attribute v4,
  109.31 -				      std::string n5, Attribute v5,
  109.32 -				      std::string n6, Attribute v6,
  109.33 -				      std::string n7, Attribute v7,
  109.34 -				      std::string n8, Attribute v8,
  109.35 -				      std::string n9, Attribute v9)
  109.36 +				      std::string n1, const AttributeValue &v1,
  109.37 +				      std::string n2, const AttributeValue &v2,
  109.38 +				      std::string n3, const AttributeValue &v3,
  109.39 +				      std::string n4, const AttributeValue &v4,
  109.40 +				      std::string n5, const AttributeValue &v5,
  109.41 +				      std::string n6, const AttributeValue &v6,
  109.42 +				      std::string n7, const AttributeValue &v7,
  109.43 +				      std::string n8, const AttributeValue &v8,
  109.44 +				      std::string n9, const AttributeValue &v9)
  109.45  {
  109.46    ObjectFactory pos;
  109.47    pos.SetTypeId (type);
  109.48 @@ -80,15 +82,15 @@
  109.49  
  109.50  void 
  109.51  MobilityHelper::SetMobilityModel (std::string type,
  109.52 -				  std::string n1, Attribute v1,
  109.53 -				  std::string n2, Attribute v2,
  109.54 -				  std::string n3, Attribute v3,
  109.55 -				  std::string n4, Attribute v4,
  109.56 -				  std::string n5, Attribute v5,
  109.57 -				  std::string n6, Attribute v6,
  109.58 -				  std::string n7, Attribute v7,
  109.59 -				  std::string n8, Attribute v8,
  109.60 -				  std::string n9, Attribute v9)
  109.61 +				  std::string n1, const AttributeValue &v1,
  109.62 +				  std::string n2, const AttributeValue &v2,
  109.63 +				  std::string n3, const AttributeValue &v3,
  109.64 +				  std::string n4, const AttributeValue &v4,
  109.65 +				  std::string n5, const AttributeValue &v5,
  109.66 +				  std::string n6, const AttributeValue &v6,
  109.67 +				  std::string n7, const AttributeValue &v7,
  109.68 +				  std::string n8, const AttributeValue &v8,
  109.69 +				  std::string n9, const AttributeValue &v9)
  109.70  {
  109.71    m_mobility.SetTypeId (type);
  109.72    m_mobility.Set (n1, v1);
  109.73 @@ -146,8 +148,8 @@
  109.74  	      // we need to setup a hierarchical mobility model
  109.75  	      Ptr<MobilityModel> parent = m_mobilityStack.back ();
  109.76  	      Ptr<MobilityModel> hierarchical = 
  109.77 -		CreateObject<HierarchicalMobilityModel> ("Child", model,
  109.78 -							 "Parent", parent);
  109.79 +		CreateObject<HierarchicalMobilityModel> ("Child", PointerValue (model),
  109.80 +							 "Parent", PointerValue (parent));
  109.81  	      object->AggregateObject (hierarchical);
  109.82  	      NS_LOG_DEBUG ("node="<<object<<", mob="<<hierarchical);
  109.83  	    }
   110.1 --- a/src/helper/mobility-helper.h	Mon Apr 21 08:58:23 2008 -0700
   110.2 +++ b/src/helper/mobility-helper.h	Mon Apr 21 09:04:08 2008 -0700
   110.3 @@ -86,15 +86,15 @@
   110.4     * \param v9 the value of the attribute to set in the mobility model.
   110.5     */
   110.6    void SetPositionAllocator (std::string type,
   110.7 -			     std::string n1 = "", Attribute v1 = Attribute (),
   110.8 -			     std::string n2 = "", Attribute v2 = Attribute (),
   110.9 -			     std::string n3 = "", Attribute v3 = Attribute (),
  110.10 -			     std::string n4 = "", Attribute v4 = Attribute (),
  110.11 -			     std::string n5 = "", Attribute v5 = Attribute (),
  110.12 -			     std::string n6 = "", Attribute v6 = Attribute (),
  110.13 -			     std::string n7 = "", Attribute v7 = Attribute (),
  110.14 -			     std::string n8 = "", Attribute v8 = Attribute (),
  110.15 -			     std::string n9 = "", Attribute v9 = Attribute ());
  110.16 +			     std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
  110.17 +			     std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
  110.18 +			     std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
  110.19 +			     std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
  110.20 +			     std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
  110.21 +			     std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
  110.22 +			     std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (),
  110.23 +			     std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (),
  110.24 +			     std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue ());
  110.25  
  110.26    /**
  110.27     * \param type the type of mobility model to use.
  110.28 @@ -121,15 +121,15 @@
  110.29     * mobility model for each node.
  110.30     */
  110.31    void SetMobilityModel (std::string type,
  110.32 -			 std::string n1 = "", Attribute v1 = Attribute (),
  110.33 -			 std::string n2 = "", Attribute v2 = Attribute (),
  110.34 -			 std::string n3 = "", Attribute v3 = Attribute (),
  110.35 -			 std::string n4 = "", Attribute v4 = Attribute (),
  110.36 -			 std::string n5 = "", Attribute v5 = Attribute (),
  110.37 -			 std::string n6 = "", Attribute v6 = Attribute (),
  110.38 -			 std::string n7 = "", Attribute v7 = Attribute (),
  110.39 -			 std::string n8 = "", Attribute v8 = Attribute (),
  110.40 -			 std::string n9 = "", Attribute v9 = Attribute ());
  110.41 +			 std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
  110.42 +			 std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
  110.43 +			 std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
  110.44 +			 std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
  110.45 +			 std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
  110.46 +			 std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
  110.47 +			 std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (),
  110.48 +			 std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (),
  110.49 +			 std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue ());
  110.50  
  110.51    /**
  110.52     * \param reference item to push.
   111.1 --- a/src/helper/olsr-helper.cc	Mon Apr 21 08:58:23 2008 -0700
   111.2 +++ b/src/helper/olsr-helper.cc	Mon Apr 21 09:04:08 2008 -0700
   111.3 @@ -30,14 +30,14 @@
   111.4  
   111.5  void 
   111.6  OlsrHelper::SetAgent (std::string tid,
   111.7 -		      std::string n0, Attribute v0,
   111.8 -		      std::string n1, Attribute v1,
   111.9 -		      std::string n2, Attribute v2,
  111.10 -		      std::string n3, Attribute v3,
  111.11 -		      std::string n4, Attribute v4,
  111.12 -		      std::string n5, Attribute v5,
  111.13 -		      std::string n6, Attribute v6,
  111.14 -		      std::string n7, Attribute v7)
  111.15 +		      std::string n0, const AttributeValue &v0,
  111.16 +		      std::string n1, const AttributeValue &v1,
  111.17 +		      std::string n2, const AttributeValue &v2,
  111.18 +		      std::string n3, const AttributeValue &v3,
  111.19 +		      std::string n4, const AttributeValue &v4,
  111.20 +		      std::string n5, const AttributeValue &v5,
  111.21 +		      std::string n6, const AttributeValue &v6,
  111.22 +		      std::string n7, const AttributeValue &v7)
  111.23  {
  111.24    m_agentFactory.SetTypeId (tid);
  111.25    m_agentFactory.Set (n0, v0);
   112.1 --- a/src/helper/olsr-helper.h	Mon Apr 21 08:58:23 2008 -0700
   112.2 +++ b/src/helper/olsr-helper.h	Mon Apr 21 09:04:08 2008 -0700
   112.3 @@ -32,14 +32,14 @@
   112.4    OlsrHelper ();
   112.5  
<