kill DefaultValue
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Mon, 10 Mar 2008 00:27:53 +0100
changeset 25775b41cb5c3fcf
parent 2576 793375cbbed6
child 2578 685b62ddfbd8
kill DefaultValue
examples/csma-broadcast.cc
examples/csma-multicast.cc
examples/csma-one-subnet.cc
examples/csma-packet-socket.cc
examples/mixed-global-routing.cc
examples/simple-alternate-routing.cc
examples/simple-error-model.cc
examples/simple-global-routing.cc
examples/simple-point-to-point-olsr.cc
examples/simple-point-to-point.cc
examples/tcp-large-transfer-errors.cc
examples/tcp-large-transfer.cc
examples/tcp-nonlistening-server.cc
examples/tcp-small-transfer-oneloss.cc
examples/tcp-small-transfer.cc
examples/udp-echo.cc
samples/main-propagation-loss.cc
samples/main-random-walk.cc
src/core/default-value.cc
src/core/default-value.h
src/core/random-variable-default-value.cc
src/core/random-variable-default-value.h
src/core/type-id-default-value.cc
src/core/type-id-default-value.h
src/core/wscript
src/internet-node/rtt-estimator.h
src/simulator/scheduler-factory.cc
src/simulator/scheduler-factory.h
src/simulator/scheduler-heap.cc
src/simulator/scheduler-list.cc
src/simulator/scheduler-map.cc
src/simulator/simulator.cc
src/simulator/time.cc
src/simulator/wscript
utils/print-introspected-doxygen.cc
     1.1 --- a/examples/csma-broadcast.cc	Mon Mar 10 00:26:54 2008 +0100
     1.2 +++ b/examples/csma-broadcast.cc	Mon Mar 10 00:27:53 2008 +0100
     1.3 @@ -33,7 +33,6 @@
     1.4  #include <cassert>
     1.5  
     1.6  #include "ns3/command-line.h"
     1.7 -#include "ns3/default-value.h"
     1.8  #include "ns3/ptr.h"
     1.9  #include "ns3/random-variable.h"
    1.10  #include "ns3/log.h"
     2.1 --- a/examples/csma-multicast.cc	Mon Mar 10 00:26:54 2008 +0100
     2.2 +++ b/examples/csma-multicast.cc	Mon Mar 10 00:27:53 2008 +0100
     2.3 @@ -30,7 +30,6 @@
     2.4  // - Node n4 listens for the data (actual listener not yet implementted)
     2.5  
     2.6  #include "ns3/command-line.h"
     2.7 -#include "ns3/default-value.h"
     2.8  #include "ns3/ptr.h"
     2.9  #include "ns3/random-variable.h"
    2.10  #include "ns3/log.h"
     3.1 --- a/examples/csma-one-subnet.cc	Mon Mar 10 00:26:54 2008 +0100
     3.2 +++ b/examples/csma-one-subnet.cc	Mon Mar 10 00:27:53 2008 +0100
     3.3 @@ -26,7 +26,6 @@
     3.4  // - Tracing of queues and packet receptions to file "csma-one-subnet.tr"
     3.5  
     3.6  #include "ns3/command-line.h"
     3.7 -#include "ns3/default-value.h"
     3.8  #include "ns3/ptr.h"
     3.9  #include "ns3/random-variable.h"
    3.10  #include "ns3/log.h"
     4.1 --- a/examples/csma-packet-socket.cc	Mon Mar 10 00:26:54 2008 +0100
     4.2 +++ b/examples/csma-packet-socket.cc	Mon Mar 10 00:27:53 2008 +0100
     4.3 @@ -34,7 +34,6 @@
     4.4  #include <cassert>
     4.5  
     4.6  #include "ns3/command-line.h"
     4.7 -#include "ns3/default-value.h"
     4.8  #include "ns3/ptr.h"
     4.9  #include "ns3/random-variable.h"
    4.10  #include "ns3/log.h"
     5.1 --- a/examples/mixed-global-routing.cc	Mon Mar 10 00:26:54 2008 +0100
     5.2 +++ b/examples/mixed-global-routing.cc	Mon Mar 10 00:27:53 2008 +0100
     5.3 @@ -39,7 +39,6 @@
     5.4  #include "ns3/log.h"
     5.5  
     5.6  #include "ns3/command-line.h"
     5.7 -#include "ns3/default-value.h"
     5.8  #include "ns3/ptr.h"
     5.9  #include "ns3/random-variable.h"
    5.10  #include "ns3/config.h"
     6.1 --- a/examples/simple-alternate-routing.cc	Mon Mar 10 00:26:54 2008 +0100
     6.2 +++ b/examples/simple-alternate-routing.cc	Mon Mar 10 00:27:53 2008 +0100
     6.3 @@ -40,7 +40,6 @@
     6.4  #include "ns3/log.h"
     6.5  
     6.6  #include "ns3/command-line.h"
     6.7 -#include "ns3/default-value.h"
     6.8  #include "ns3/ptr.h"
     6.9  #include "ns3/random-variable.h"
    6.10  #include "ns3/config.h"
     7.1 --- a/examples/simple-error-model.cc	Mon Mar 10 00:26:54 2008 +0100
     7.2 +++ b/examples/simple-error-model.cc	Mon Mar 10 00:27:53 2008 +0100
     7.3 @@ -41,7 +41,6 @@
     7.4  #include "ns3/log.h"
     7.5  #include "ns3/assert.h"
     7.6  #include "ns3/command-line.h"
     7.7 -#include "ns3/default-value.h"
     7.8  #include "ns3/ptr.h"
     7.9  #include "ns3/config.h"
    7.10  #include "ns3/uinteger.h"
    7.11 @@ -54,7 +53,6 @@
    7.12  #include "ns3/ascii-trace.h"
    7.13  #include "ns3/pcap-trace.h"
    7.14  #include "ns3/internet-node.h"
    7.15 -#include "ns3/default-value.h"
    7.16  #include "ns3/random-variable.h"
    7.17  #include "ns3/point-to-point-channel.h"
    7.18  #include "ns3/point-to-point-net-device.h"
     8.1 --- a/examples/simple-global-routing.cc	Mon Mar 10 00:26:54 2008 +0100
     8.2 +++ b/examples/simple-global-routing.cc	Mon Mar 10 00:27:53 2008 +0100
     8.3 @@ -45,7 +45,6 @@
     8.4  #include "ns3/log.h"
     8.5  
     8.6  #include "ns3/command-line.h"
     8.7 -#include "ns3/default-value.h"
     8.8  #include "ns3/ptr.h"
     8.9  #include "ns3/random-variable.h"
    8.10  #include "ns3/config.h"
     9.1 --- a/examples/simple-point-to-point-olsr.cc	Mon Mar 10 00:26:54 2008 +0100
     9.2 +++ b/examples/simple-point-to-point-olsr.cc	Mon Mar 10 00:27:53 2008 +0100
     9.3 @@ -40,7 +40,6 @@
     9.4  
     9.5  #include "ns3/log.h"
     9.6  #include "ns3/command-line.h"
     9.7 -#include "ns3/default-value.h"
     9.8  #include "ns3/ptr.h"
     9.9  #include "ns3/random-variable.h"
    9.10  #include "ns3/config.h"
    10.1 --- a/examples/simple-point-to-point.cc	Mon Mar 10 00:26:54 2008 +0100
    10.2 +++ b/examples/simple-point-to-point.cc	Mon Mar 10 00:27:53 2008 +0100
    10.3 @@ -40,7 +40,6 @@
    10.4  
    10.5  #include "ns3/log.h"
    10.6  #include "ns3/command-line.h"
    10.7 -#include "ns3/default-value.h"
    10.8  #include "ns3/ptr.h"
    10.9  #include "ns3/random-variable.h"
   10.10  #include "ns3/config.h"
    11.1 --- a/examples/tcp-large-transfer-errors.cc	Mon Mar 10 00:26:54 2008 +0100
    11.2 +++ b/examples/tcp-large-transfer-errors.cc	Mon Mar 10 00:27:53 2008 +0100
    11.3 @@ -35,7 +35,6 @@
    11.4  #include <cassert>
    11.5  
    11.6  #include "ns3/command-line.h"
    11.7 -#include "ns3/default-value.h"
    11.8  #include "ns3/ptr.h"
    11.9  #include "ns3/random-variable.h"
   11.10  #include "ns3/log.h"
    12.1 --- a/examples/tcp-large-transfer.cc	Mon Mar 10 00:26:54 2008 +0100
    12.2 +++ b/examples/tcp-large-transfer.cc	Mon Mar 10 00:27:53 2008 +0100
    12.3 @@ -35,7 +35,6 @@
    12.4  #include <cassert>
    12.5  
    12.6  #include "ns3/command-line.h"
    12.7 -#include "ns3/default-value.h"
    12.8  #include "ns3/ptr.h"
    12.9  #include "ns3/random-variable.h"
   12.10  #include "ns3/log.h"
    13.1 --- a/examples/tcp-nonlistening-server.cc	Mon Mar 10 00:26:54 2008 +0100
    13.2 +++ b/examples/tcp-nonlistening-server.cc	Mon Mar 10 00:27:53 2008 +0100
    13.3 @@ -34,7 +34,6 @@
    13.4  #include <cassert>
    13.5  
    13.6  #include "ns3/command-line.h"
    13.7 -#include "ns3/default-value.h"
    13.8  #include "ns3/ptr.h"
    13.9  #include "ns3/random-variable.h"
   13.10  #include "ns3/log.h"
    14.1 --- a/examples/tcp-small-transfer-oneloss.cc	Mon Mar 10 00:26:54 2008 +0100
    14.2 +++ b/examples/tcp-small-transfer-oneloss.cc	Mon Mar 10 00:27:53 2008 +0100
    14.3 @@ -35,7 +35,6 @@
    14.4  #include <cassert>
    14.5  
    14.6  #include "ns3/command-line.h"
    14.7 -#include "ns3/default-value.h"
    14.8  #include "ns3/ptr.h"
    14.9  #include "ns3/random-variable.h"
   14.10  #include "ns3/log.h"
    15.1 --- a/examples/tcp-small-transfer.cc	Mon Mar 10 00:26:54 2008 +0100
    15.2 +++ b/examples/tcp-small-transfer.cc	Mon Mar 10 00:27:53 2008 +0100
    15.3 @@ -35,7 +35,6 @@
    15.4  #include <cassert>
    15.5  
    15.6  #include "ns3/command-line.h"
    15.7 -#include "ns3/default-value.h"
    15.8  #include "ns3/ptr.h"
    15.9  #include "ns3/random-variable.h"
   15.10  #include "ns3/log.h"
    16.1 --- a/examples/udp-echo.cc	Mon Mar 10 00:26:54 2008 +0100
    16.2 +++ b/examples/udp-echo.cc	Mon Mar 10 00:27:53 2008 +0100
    16.3 @@ -26,7 +26,6 @@
    16.4  // - Tracing of queues and packet receptions to file "udp-echo.tr"
    16.5  
    16.6  #include "ns3/command-line.h"
    16.7 -#include "ns3/default-value.h"
    16.8  #include "ns3/ptr.h"
    16.9  #include "ns3/log.h"
   16.10  #include "ns3/simulator.h"
    17.1 --- a/samples/main-propagation-loss.cc	Mon Mar 10 00:26:54 2008 +0100
    17.2 +++ b/samples/main-propagation-loss.cc	Mon Mar 10 00:27:53 2008 +0100
    17.3 @@ -18,8 +18,9 @@
    17.4   * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
    17.5   */
    17.6  #include "ns3/propagation-loss-model.h"
    17.7 -#include "ns3/default-value.h"
    17.8  #include "ns3/static-mobility-model.h"
    17.9 +#include "ns3/config.h"
   17.10 +#include "ns3/string.h"
   17.11  
   17.12  using namespace ns3;
   17.13  
   17.14 @@ -50,19 +51,8 @@
   17.15  int main (int argc, char *argv[])
   17.16  {
   17.17  
   17.18 -#if 0
   17.19 -  DefaultValue::Bind ("PropagationLossModelType", "Friis");
   17.20 -  DefaultValue::Bind ("FriisPropagationLossLambda", "0.6");
   17.21 -  DefaultValue::Bind ("FriisPropagationLossSystemLoss", "1.0");
   17.22 -
   17.23 -  PrintOne (-10, 20, 5, 0, 1000, 5);
   17.24 -#endif
   17.25 -
   17.26 -  DefaultValue::Bind ("PropagationLossModelType", "LogDistance");
   17.27 -  DefaultValue::Bind ("LogDistancePropagationLossReferenceDistance", "1.0");
   17.28 -  DefaultValue::Bind ("LogDistancePropagationLossReferenceType", "Random");
   17.29 -  DefaultValue::Bind ("RandomPropagationLossDistribution", "Constant:10");
   17.30 -  DefaultValue::Bind ("LogDistancePropagationLossExponent", "4");
   17.31 +  Config::SetGlobal ("LogDistancePropagationLossModel::ReferenceDistance", String ("1.0"));
   17.32 +  Config::SetGlobal ("LogDistancePropagationLossModel::Exponent", String ("4"));
   17.33  
   17.34    PrintOne (-10, 20, 5, 0, 10000, 2);
   17.35  
    18.1 --- a/samples/main-random-walk.cc	Mon Mar 10 00:26:54 2008 +0100
    18.2 +++ b/samples/main-random-walk.cc	Mon Mar 10 00:27:53 2008 +0100
    18.3 @@ -5,7 +5,6 @@
    18.4  #include "ns3/ptr.h"
    18.5  #include "ns3/mobility-model.h"
    18.6  #include "ns3/position-allocator.h"
    18.7 -#include "ns3/default-value.h"
    18.8  #include "ns3/command-line.h"
    18.9  #include "ns3/simulator.h"
   18.10  #include "ns3/nstime.h"
    19.1 --- a/src/core/default-value.cc	Mon Mar 10 00:26:54 2008 +0100
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,510 +0,0 @@
    19.4 -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
    19.5 -/*
    19.6 - * Copyright (c) 2007 INRIA
    19.7 - *
    19.8 - * This program is free software; you can redistribute it and/or modify
    19.9 - * it under the terms of the GNU General Public License version 2 as
   19.10 - * published by the Free Software Foundation;
   19.11 - *
   19.12 - * This program is distributed in the hope that it will be useful,
   19.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   19.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   19.15 - * GNU General Public License for more details.
   19.16 - *
   19.17 - * You should have received a copy of the GNU General Public License
   19.18 - * along with this program; if not, write to the Free Software
   19.19 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   19.20 - *
   19.21 - * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
   19.22 - */
   19.23 -
   19.24 -#include "default-value.h"
   19.25 -#include "fatal-error.h"
   19.26 -
   19.27 -namespace ns3 {
   19.28 -
   19.29 -namespace DefaultValue {
   19.30 -
   19.31 -enum BindStatus {
   19.32 -  OK,
   19.33 -  INVALID_VALUE,
   19.34 -  NOT_FOUND
   19.35 -};
   19.36 -
   19.37 -
   19.38 -static 
   19.39 -enum BindStatus
   19.40 -BindSafe (std::string name, std::string value)
   19.41 -{
   19.42 -  for (DefaultValueList::Iterator i = DefaultValueList::Begin ();
   19.43 -       i != DefaultValueList::End (); i++)
   19.44 -    {
   19.45 -      DefaultValueBase *cur = *i;
   19.46 -      if (cur->GetName () == name)
   19.47 -	{
   19.48 -	  if (!cur->ParseValue (value))
   19.49 -	    {
   19.50 -	      return INVALID_VALUE;
   19.51 -	    }
   19.52 -	  return OK;
   19.53 -	}
   19.54 -    }
   19.55 -  return NOT_FOUND;
   19.56 -}
   19.57 -
   19.58 -void
   19.59 -Bind (std::string name, std::string value)
   19.60 -{
   19.61 -  switch (BindSafe (name, value)) {
   19.62 -  case INVALID_VALUE:
   19.63 -    NS_FATAL_ERROR ("Invalid value: "<<name<<"="<<value);
   19.64 -    break;
   19.65 -  case NOT_FOUND:
   19.66 -    NS_FATAL_ERROR ("No registered DefaultValue=\"" << name << "\"");
   19.67 -    break;
   19.68 -  case OK:
   19.69 -    break;
   19.70 -  }
   19.71 -}
   19.72 -
   19.73 -}
   19.74 -
   19.75 -DefaultValueBase::DefaultValueBase (const std::string &name,
   19.76 -				    const std::string &help)
   19.77 -  : m_name (name),
   19.78 -    m_help (help),
   19.79 -    m_dirty (false)
   19.80 -{}
   19.81 -DefaultValueBase::~DefaultValueBase ()
   19.82 -{}
   19.83 -std::string 
   19.84 -DefaultValueBase::GetName (void) const
   19.85 -{
   19.86 -  return m_name;
   19.87 -}
   19.88 -std::string 
   19.89 -DefaultValueBase::GetHelp (void) const
   19.90 -{
   19.91 -  return m_help;
   19.92 -}
   19.93 -bool 
   19.94 -DefaultValueBase::IsDirty (void) const
   19.95 -{
   19.96 -  return m_dirty;
   19.97 -}
   19.98 -void 
   19.99 -DefaultValueBase::ClearDirtyFlag (void)
  19.100 -{
  19.101 -  m_dirty = false;
  19.102 -}
  19.103 -bool 
  19.104 -DefaultValueBase::ParseValue (const std::string &value)
  19.105 -{
  19.106 -  bool ok = DoParseValue (value);
  19.107 -  if (ok)
  19.108 -    {
  19.109 -      m_dirty = true;
  19.110 -    }
  19.111 -  return ok;
  19.112 -}
  19.113 -std::string 
  19.114 -DefaultValueBase::GetType (void) const
  19.115 -{
  19.116 -  return DoGetType ();
  19.117 -}
  19.118 -std::string 
  19.119 -DefaultValueBase::GetDefaultValue (void) const
  19.120 -{
  19.121 -  return DoGetDefaultValue ();
  19.122 -}
  19.123 -
  19.124 -
  19.125 -DefaultValueList::Iterator 
  19.126 -DefaultValueList::Begin (void)
  19.127 -{
  19.128 -  return GetList ()->begin ();
  19.129 -}
  19.130 -DefaultValueList::Iterator 
  19.131 -DefaultValueList::End (void)
  19.132 -{
  19.133 -  return GetList ()->end ();
  19.134 -}
  19.135 -void
  19.136 -DefaultValueList::Remove (const std::string &name)
  19.137 -{
  19.138 -  DefaultValueList::List *list = GetList ();
  19.139 -  for (List::iterator i = list->begin (); i != list->end (); /* nothing */)
  19.140 -    {
  19.141 -      if ((*i)->GetName () == name)
  19.142 -        {
  19.143 -          i = list->erase (i);
  19.144 -        }
  19.145 -      else
  19.146 -        {
  19.147 -          i++;
  19.148 -        }
  19.149 -    }
  19.150 -}
  19.151 -void 
  19.152 -DefaultValueList::Add (DefaultValueBase *defaultValue)
  19.153 -{
  19.154 -  GetList ()->push_back (defaultValue);
  19.155 -}
  19.156 -
  19.157 -DefaultValueList::List *
  19.158 -DefaultValueList::GetList (void)
  19.159 -{
  19.160 -  static List list;
  19.161 -  return &list;
  19.162 -}
  19.163 -
  19.164 -BooleanDefaultValue::BooleanDefaultValue (std::string name,
  19.165 -					  std::string help,
  19.166 -					  bool defaultValue)
  19.167 -  : DefaultValueBase (name, help),
  19.168 -    m_defaultValue (defaultValue),
  19.169 -    m_value (defaultValue)
  19.170 -{
  19.171 -  DefaultValueList::Add (this);
  19.172 -}
  19.173 -bool 
  19.174 -BooleanDefaultValue::GetValue (void) const
  19.175 -{
  19.176 -  return m_value;
  19.177 -}
  19.178 -bool 
  19.179 -BooleanDefaultValue::DoParseValue (const std::string &value)
  19.180 -{
  19.181 -  if (value.compare ("0") == 0 ||
  19.182 -      value.compare ("f") == 0 ||
  19.183 -      value.compare ("false") == 0 ||
  19.184 -      value.compare ("FALSE") == 0) 
  19.185 -    {
  19.186 -      m_value = false;
  19.187 -      return true;
  19.188 -    } 
  19.189 -  else if (value.compare ("1") == 0 ||
  19.190 -	   value.compare ("t") == 0 ||
  19.191 -	   value.compare ("true") == 0 ||
  19.192 -	   value.compare ("TRUE") == 0) 
  19.193 -    {
  19.194 -      m_value = true;
  19.195 -      return true;
  19.196 -    } 
  19.197 -  else 
  19.198 -    {
  19.199 -      return false;
  19.200 -    }
  19.201 -}
  19.202 -std::string 
  19.203 -BooleanDefaultValue::DoGetType (void) const
  19.204 -{
  19.205 -  return "bool";
  19.206 -}
  19.207 -std::string 
  19.208 -BooleanDefaultValue::DoGetDefaultValue (void) const
  19.209 -{
  19.210 -  return m_defaultValue?"true":"false";
  19.211 -}
  19.212 -
  19.213 -
  19.214 -StringEnumDefaultValue::StringEnumDefaultValue (const std::string &name,
  19.215 -                                                const std::string &help)
  19.216 -  : DefaultValueBase (name, help),
  19.217 -    m_oneDefault (false)
  19.218 -{
  19.219 -  DefaultValueList::Add (this);
  19.220 -}
  19.221 -void 
  19.222 -StringEnumDefaultValue::AddDefaultValue (const std::string &value)
  19.223 -{
  19.224 -  if (m_oneDefault)
  19.225 -    {
  19.226 -      NS_FATAL_ERROR ("More than one default value registered: " << value);
  19.227 -    }
  19.228 -  m_oneDefault = true;
  19.229 -  for (std::list<std::string>::iterator i = m_possibleValues.begin ();
  19.230 -       i != m_possibleValues.end (); i++)
  19.231 -    {
  19.232 -      if (value == *i)
  19.233 -        {
  19.234 -          NS_FATAL_ERROR ("Value already exists: " << value);
  19.235 -        }
  19.236 -    }  
  19.237 -  m_possibleValues.push_back (value);
  19.238 -  m_value = value;
  19.239 -  m_defaultValue = value;
  19.240 -}
  19.241 -void 
  19.242 -StringEnumDefaultValue::AddPossibleValue (const std::string &value)
  19.243 -{
  19.244 -  for (std::list<std::string>::iterator i = m_possibleValues.begin ();
  19.245 -       i != m_possibleValues.end (); i++)
  19.246 -    {
  19.247 -      if (value == *i)
  19.248 -        {
  19.249 -          NS_FATAL_ERROR ("Value already exists: " << value);
  19.250 -        }
  19.251 -    }
  19.252 -  m_possibleValues.push_back (value);
  19.253 -}
  19.254 -std::string 
  19.255 -StringEnumDefaultValue::GetValue (void) const
  19.256 -{
  19.257 -  return m_value;
  19.258 -}
  19.259 -bool 
  19.260 -StringEnumDefaultValue::DoParseValue (const std::string &value)
  19.261 -{
  19.262 -  for (std::list<std::string>::iterator i = m_possibleValues.begin ();
  19.263 -       i != m_possibleValues.end (); i++)
  19.264 -    {
  19.265 -      if (value == *i)
  19.266 -        {
  19.267 -          m_value = value;
  19.268 -          return true;
  19.269 -        }
  19.270 -    }
  19.271 -  return false;
  19.272 -}
  19.273 -std::string 
  19.274 -StringEnumDefaultValue::DoGetType (void) const
  19.275 -{
  19.276 -  std::string retval;
  19.277 -  retval += "(";
  19.278 -  for (std::list<std::string>::const_iterator i = m_possibleValues.begin ();
  19.279 -       i != m_possibleValues.end (); i++)
  19.280 -    {
  19.281 -      if (i != m_possibleValues.begin ())
  19.282 -	{
  19.283 -	  retval += "|";
  19.284 -	}
  19.285 -      retval += *i;
  19.286 -    }
  19.287 -  retval += ")";
  19.288 -  return retval;
  19.289 -}
  19.290 -std::string 
  19.291 -StringEnumDefaultValue::DoGetDefaultValue (void) const
  19.292 -{
  19.293 -  return m_defaultValue;
  19.294 -}
  19.295 -
  19.296 -
  19.297 -CommandDefaultValue::CommandDefaultValue (const std::string &name,
  19.298 -					  const std::string &help,
  19.299 -					  Callback<void> cb)
  19.300 -  : DefaultValueBase (name, help),
  19.301 -    m_cb (cb)
  19.302 -{
  19.303 -  DefaultValueList::Add (this);
  19.304 -}
  19.305 -bool 
  19.306 -CommandDefaultValue::DoParseValue (const std::string &value)
  19.307 -{
  19.308 -  m_cb ();
  19.309 -  return true;
  19.310 -}
  19.311 -std::string 
  19.312 -CommandDefaultValue::DoGetType (void) const
  19.313 -{
  19.314 -  return "";
  19.315 -}
  19.316 -std::string 
  19.317 -CommandDefaultValue::DoGetDefaultValue (void) const
  19.318 -{
  19.319 -  return "";
  19.320 -}
  19.321 -
  19.322 -
  19.323 -StringDefaultValue::StringDefaultValue (const std::string &name,
  19.324 -                                        const std::string &help,
  19.325 -                                        const std::string defaultValue)
  19.326 -  : DefaultValueBase (name, help),
  19.327 -    m_defaultValue (defaultValue),
  19.328 -    m_value (defaultValue),
  19.329 -    m_minSize (0),
  19.330 -    m_maxSize (-1)
  19.331 -{
  19.332 -  DefaultValueList::Add (this);
  19.333 -}
  19.334 -StringDefaultValue::StringDefaultValue (const std::string &name,
  19.335 -                                        const std::string &help,
  19.336 -                                        const std::string defaultValue,
  19.337 -                                        int maxSize)
  19.338 -  : DefaultValueBase (name, help),
  19.339 -    m_defaultValue (defaultValue),
  19.340 -    m_value (defaultValue),
  19.341 -    m_minSize (0),
  19.342 -    m_maxSize (maxSize)
  19.343 -{
  19.344 -  DefaultValueList::Add (this);
  19.345 -}
  19.346 -StringDefaultValue::StringDefaultValue (const std::string &name,
  19.347 -                                        const std::string &help,
  19.348 -                                        const std::string defaultValue,
  19.349 -                                        int minSize,
  19.350 -                                        int maxSize)
  19.351 -  : DefaultValueBase (name, help),
  19.352 -    m_defaultValue (defaultValue),
  19.353 -    m_value (defaultValue),
  19.354 -    m_minSize (minSize),
  19.355 -    m_maxSize (maxSize)
  19.356 -{
  19.357 -  DefaultValueList::Add (this);
  19.358 -}
  19.359 -
  19.360 -
  19.361 -std::string 
  19.362 -StringDefaultValue::GetValue (void) const
  19.363 -{
  19.364 -  return m_value;
  19.365 -}
  19.366 -
  19.367 -bool 
  19.368 -StringDefaultValue::DoParseValue (const std::string &value)
  19.369 -{
  19.370 -  if ((int)value.size () < m_minSize)
  19.371 -    {
  19.372 -      return false;
  19.373 -    }
  19.374 -  if (m_maxSize != -1 && (int)value.size () > m_maxSize)
  19.375 -    {
  19.376 -      return false;
  19.377 -    }
  19.378 -  m_value = value;
  19.379 -  return true;
  19.380 -}
  19.381 -std::string 
  19.382 -StringDefaultValue::DoGetType (void) const
  19.383 -{
  19.384 -  if (m_maxSize == -1)
  19.385 -    {
  19.386 -      return "string:0";
  19.387 -    }
  19.388 -  else 
  19.389 -    {
  19.390 -      std::ostringstream oss;
  19.391 -      oss << "string:0:" << m_maxSize;
  19.392 -      return oss.str ();
  19.393 -    }
  19.394 -}
  19.395 -std::string 
  19.396 -StringDefaultValue::DoGetDefaultValue (void) const
  19.397 -{
  19.398 -  return m_defaultValue;
  19.399 -}
  19.400 -
  19.401 -
  19.402 -
  19.403 -}//namespace ns3
  19.404 -
  19.405 -#ifdef RUN_SELF_TESTS
  19.406 -#include "test.h"
  19.407 -
  19.408 -namespace ns3 {
  19.409 -
  19.410 -enum MyEnum {
  19.411 -  MY_ENUM_A,
  19.412 -  MY_ENUM_B,
  19.413 -  MY_ENUM_C,
  19.414 -  MY_ENUM_D,
  19.415 -};
  19.416 -
  19.417 -
  19.418 -class DefaultValueTest : public Test
  19.419 -{
  19.420 -public:
  19.421 -  DefaultValueTest ();
  19.422 -  virtual bool RunTests (void);
  19.423 -};
  19.424 -
  19.425 -DefaultValueTest::DefaultValueTest ()
  19.426 -  : Test ("DefaultValue")
  19.427 -{}
  19.428 -bool 
  19.429 -DefaultValueTest::RunTests (void)
  19.430 -{
  19.431 -  bool result = true;
  19.432 -
  19.433 -  BooleanDefaultValue a ("bool-a", "help a", true);
  19.434 -  NS_TEST_ASSERT (a.GetValue ());
  19.435 -  DefaultValue::Bind ("bool-a", "false");
  19.436 -  NS_TEST_ASSERT (!a.GetValue ());
  19.437 -  BooleanDefaultValue b ("bool-b", "help b", false);
  19.438 -  DefaultValue::Bind ("bool-b", "true");
  19.439 -  NS_TEST_ASSERT (b.GetValue ());
  19.440 -  DefaultValue::Bind ("bool-b", "0");
  19.441 -  NS_TEST_ASSERT (!b.GetValue ());
  19.442 -  DefaultValue::Bind ("bool-b", "1");
  19.443 -  NS_TEST_ASSERT (b.GetValue ());
  19.444 -  DefaultValue::Bind ("bool-b", "f");
  19.445 -  NS_TEST_ASSERT (!b.GetValue ());
  19.446 -  DefaultValue::Bind ("bool-b", "t");
  19.447 -  NS_TEST_ASSERT (b.GetValue ());
  19.448 -
  19.449 -  DefaultValue::Bind ("bool-b", "false");
  19.450 -  NS_TEST_ASSERT (!b.GetValue ());
  19.451 -  NS_TEST_ASSERT_EQUAL (DefaultValue::BindSafe ("bool-b", "tr"), DefaultValue::INVALID_VALUE)
  19.452 -
  19.453 -  NumericDefaultValue<int32_t> i ("test-i", "help-i", -1);
  19.454 -  NS_TEST_ASSERT_EQUAL (i.GetValue (), -1);
  19.455 -  DefaultValue::Bind ("test-i", "-2");
  19.456 -  NS_TEST_ASSERT_EQUAL (i.GetValue (), -2);
  19.457 -  DefaultValue::Bind ("test-i", "+2");
  19.458 -  NS_TEST_ASSERT_EQUAL (i.GetValue (), 2);
  19.459 -  NS_TEST_ASSERT_EQUAL (i.GetType (), "int32_t(-2147483648:2147483647)");
  19.460 -  NumericDefaultValue<uint32_t> ui32 ("test-ui32", "help-ui32", 10);
  19.461 -  NS_TEST_ASSERT_EQUAL (ui32.GetType (), "uint32_t(0:4294967295)");
  19.462 -  NumericDefaultValue<int8_t> c ("test-c", "help-c", 10);
  19.463 -  NS_TEST_ASSERT_EQUAL (c.GetValue (), 10);
  19.464 -  DefaultValue::Bind ("test-c", "257");  
  19.465 -  NumericDefaultValue<float> x ("test-x", "help-x", 10.0);
  19.466 -  NumericDefaultValue<double> y ("test-y", "help-y", 10.0);
  19.467 -  DefaultValue::Bind ("test-y", "-3");  
  19.468 -
  19.469 -  EnumDefaultValue<enum MyEnum> e ("test-e", "help-e",
  19.470 -				   MY_ENUM_C, "C",
  19.471 -				   MY_ENUM_A, "A",
  19.472 -				   MY_ENUM_B, "B",
  19.473 -				   0, (void*)0);
  19.474 -  NS_TEST_ASSERT_EQUAL (e.GetValue (), MY_ENUM_C);
  19.475 -  DefaultValue::Bind ("test-e", "B");
  19.476 -  NS_TEST_ASSERT_EQUAL (e.GetValue (), MY_ENUM_B);
  19.477 -  NS_TEST_ASSERT_EQUAL (DefaultValue::BindSafe ("test-e", "D"), DefaultValue::INVALID_VALUE);
  19.478 -
  19.479 -  class MyEnumSubclass : public EnumDefaultValue<enum MyEnum>
  19.480 -  {
  19.481 -  public:
  19.482 -    MyEnumSubclass () 
  19.483 -      : EnumDefaultValue<enum MyEnum> ("test-e1", "help-e1",
  19.484 -				       MY_ENUM_B, "B",
  19.485 -				       MY_ENUM_A, "A",
  19.486 -				       0, (void*)0)
  19.487 -    {
  19.488 -      AddPossibleValue (MY_ENUM_C, "C");
  19.489 -      AddPossibleValue (MY_ENUM_D, "D");
  19.490 -    }
  19.491 -  } e1 ;
  19.492 -  NS_TEST_ASSERT_EQUAL (e1.GetValue (), MY_ENUM_B);
  19.493 -  DefaultValue::Bind ("test-e1", "D");
  19.494 -  NS_TEST_ASSERT_EQUAL (e1.GetValue (), MY_ENUM_D);
  19.495 -
  19.496 -  DefaultValueList::Remove ("test-e1");
  19.497 -  DefaultValueList::Remove ("test-e");
  19.498 -  DefaultValueList::Remove ("bool-b");
  19.499 -  DefaultValueList::Remove ("bool-a");
  19.500 -  DefaultValueList::Remove ("test-i");
  19.501 -  DefaultValueList::Remove ("test-c");
  19.502 -  DefaultValueList::Remove ("test-x");
  19.503 -  DefaultValueList::Remove ("test-y");
  19.504 -  DefaultValueList::Remove ("test-ui32");
  19.505 -  
  19.506 -  return result;
  19.507 -}
  19.508 -
  19.509 -static DefaultValueTest g_default_value_tests;
  19.510 -
  19.511 -}//namespace ns3
  19.512 -
  19.513 -#endif /* RUN_SELF_TESTS */
    20.1 --- a/src/core/default-value.h	Mon Mar 10 00:26:54 2008 +0100
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,621 +0,0 @@
    20.4 -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
    20.5 -/*
    20.6 - * Copyright (c) 2007 INRIA
    20.7 - *
    20.8 - * This program is free software; you can redistribute it and/or modify
    20.9 - * it under the terms of the GNU General Public License version 2 as
   20.10 - * published by the Free Software Foundation;
   20.11 - *
   20.12 - * This program is distributed in the hope that it will be useful,
   20.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   20.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   20.15 - * GNU General Public License for more details.
   20.16 - *
   20.17 - * You should have received a copy of the GNU General Public License
   20.18 - * along with this program; if not, write to the Free Software
   20.19 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   20.20 - *
   20.21 - * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
   20.22 - */
   20.23 -#ifndef DEFAULT_VALUE_H
   20.24 -#define DEFAULT_VALUE_H
   20.25 -
   20.26 -#include <string>
   20.27 -#include <list>
   20.28 -#include "callback.h"
   20.29 -
   20.30 -/**
   20.31 - * \ingroup core
   20.32 - * \defgroup config Simulation configuration
   20.33 - *
   20.34 - */
   20.35 -
   20.36 -namespace ns3 {
   20.37 -
   20.38 -namespace DefaultValue
   20.39 -{
   20.40 -
   20.41 -/**
   20.42 - * \ingroup config
   20.43 - * \param name name of variable to bind
   20.44 - * \param value value to bind to the specified variable
   20.45 - *
   20.46 - * If the variable name does not match any existing
   20.47 - * variable or if the value is not compatible with
   20.48 - * the variable type, this function will abort
   20.49 - * at runtime and print an error message detailing
   20.50 - * which variable or value triggered the problem.
   20.51 - */
   20.52 -void Bind (std::string name, std::string value);
   20.53 -
   20.54 -}
   20.55 -
   20.56 -
   20.57 -class DefaultValueBase
   20.58 -{
   20.59 -public:
   20.60 -  virtual ~DefaultValueBase ();
   20.61 -  std::string GetName (void) const;
   20.62 -  std::string GetHelp (void) const;
   20.63 -
   20.64 -  /**
   20.65 -   * \returns true if this value is dirty, false otherwise.
   20.66 -   *
   20.67 -   * A value becomes dirty when ParseValue is invoked
   20.68 -   * and it successfully completes. Dirtyness indicates
   20.69 -   * that the state of the value was changed by a user.
   20.70 -   */
   20.71 -  bool IsDirty (void) const;
   20.72 -  /**
   20.73 -   * Clear the dirty state.
   20.74 -   */
   20.75 -  void ClearDirtyFlag (void);
   20.76 -  // parse a matching parameter
   20.77 -  // return true in case of success, false otherwise.
   20.78 -  bool ParseValue (const std::string &value);
   20.79 -  std::string GetType (void) const;
   20.80 -  std::string GetDefaultValue (void) const;
   20.81 -protected:
   20.82 -  DefaultValueBase (const std::string &name, 
   20.83 -		    const std::string &help);
   20.84 -private:
   20.85 -  DefaultValueBase ();
   20.86 -private:
   20.87 -  virtual bool DoParseValue (const std::string &value) = 0;
   20.88 -  virtual std::string DoGetType (void) const = 0;
   20.89 -  virtual std::string DoGetDefaultValue (void) const = 0;
   20.90 -  std::string m_name;
   20.91 -  std::string m_help;
   20.92 -  bool m_dirty;
   20.93 -};
   20.94 -
   20.95 -class DefaultValueList
   20.96 -{
   20.97 - public:
   20.98 -  typedef std::list<DefaultValueBase *>::iterator Iterator;
   20.99 -
  20.100 -  static Iterator Begin (void);
  20.101 -  static Iterator End (void);
  20.102 -  static void Remove (const std::string &name);
  20.103 -  static void Add (DefaultValueBase *defaultValue);
  20.104 -
  20.105 -  template <typename T>
  20.106 -  static const T* Get (const std::string &name)
  20.107 -  {
  20.108 -    for (Iterator iter = Begin (); iter != End (); iter++)
  20.109 -      {
  20.110 -        const DefaultValueBase *value = *iter;
  20.111 -        if (value->GetName () == name)
  20.112 -          {
  20.113 -            return dynamic_cast<const T*> (value);
  20.114 -          }
  20.115 -      }
  20.116 -    return NULL;
  20.117 -  }
  20.118 -
  20.119 - private:
  20.120 -  typedef std::list<DefaultValueBase *> List;
  20.121 -  static List *GetList (void);
  20.122 -};
  20.123 -
  20.124 -/**
  20.125 - * \brief A Boolean variable for ns3::Bind
  20.126 - * \ingroup config
  20.127 - *
  20.128 - * Every instance of this type is automatically 
  20.129 - * registered in the variable pool which is used
  20.130 - * by ns3::Bind. 
  20.131 - */
  20.132 -class BooleanDefaultValue : public DefaultValueBase
  20.133 -{
  20.134 -public:
  20.135 -  /**
  20.136 -   * \param name name of variable
  20.137 -   * \param help help text which explains the purpose
  20.138 -   *        and the semantics of this variable
  20.139 -   * \param defaultValue the default value to assign
  20.140 -   *        to this variable.
  20.141 -   *
  20.142 -   * Unless the user invokes ns3::Bind with the right arguments,
  20.143 -   * the GetValue method will return the default value. Otherwise,
  20.144 -   * it will return the user-specified value.
  20.145 -   */
  20.146 -  BooleanDefaultValue (std::string name,
  20.147 -		       std::string help,
  20.148 -		       bool defaultValue);
  20.149 -  /**
  20.150 -   * \returns the default value for this variable or a
  20.151 -   *          user-provided overriden variable.
  20.152 -   */
  20.153 -  bool GetValue (void) const;
  20.154 -private:
  20.155 -  virtual bool DoParseValue (const std::string &value);
  20.156 -  virtual std::string DoGetType (void) const;
  20.157 -  virtual std::string DoGetDefaultValue (void) const;
  20.158 -  bool m_defaultValue;
  20.159 -  bool m_value;
  20.160 -};
  20.161 -
  20.162 -/**
  20.163 - * \brief A Numeric variable for ns3::Bind
  20.164 - * \ingroup config
  20.165 - *
  20.166 - * Every instance of this type is automatically 
  20.167 - * registered in the variable pool which is used
  20.168 - * by ns3::Bind. 
  20.169 - */
  20.170 -template <typename T>
  20.171 -class NumericDefaultValue : public DefaultValueBase
  20.172 -{
  20.173 -public:
  20.174 -  /**
  20.175 -   * \param name the name of the variable
  20.176 -   * \param help help text which explains the purpose
  20.177 -   *        and the semantics of this variable
  20.178 -   * \param defaultValue the default value assigned
  20.179 -   *        to this variable
  20.180 -   *
  20.181 -   * By default, the set of allowed values is the entire range
  20.182 -   * of values which can be stored and retrieved from the underlying
  20.183 -   * type.
  20.184 -   */
  20.185 -  NumericDefaultValue (std::string name,
  20.186 -		       std::string help,
  20.187 -		       T defaultValue);
  20.188 -  /**
  20.189 -   * \param name the name of the variable
  20.190 -   * \param help help text which explains the purpose
  20.191 -   *        and the semantics of this variable
  20.192 -   * \param defaultValue the default value assigned to this
  20.193 -   *        variable
  20.194 -   * \param minValue the minimum value which can be set
  20.195 -   *        in this variable
  20.196 -   */
  20.197 -  NumericDefaultValue (std::string name,
  20.198 -		       std::string help,
  20.199 -		       T defaultValue,
  20.200 -		       T minValue);
  20.201 -
  20.202 -  /**
  20.203 -   * \param name the name of the variable
  20.204 -   * \param help help text which explains the purpose
  20.205 -   *        and the semantics of this variable
  20.206 -   * \param defaultValue the default value assigned to this
  20.207 -   *        variable
  20.208 -   * \param minValue the minimum value which can be set
  20.209 -   *        in this variable
  20.210 -   * \param maxValue the maximum value which can be set in this
  20.211 -   *        variable.
  20.212 -   */
  20.213 -  NumericDefaultValue (std::string name,
  20.214 -		       std::string help,
  20.215 -		       T defaultValue,
  20.216 -		       T minValue,
  20.217 -		       T maxValue);
  20.218 -
  20.219 -  void SetValue (T v);
  20.220 -
  20.221 -  T GetValue (void) const;
  20.222 -private:
  20.223 -  virtual bool DoParseValue (const std::string &value);
  20.224 -  virtual std::string DoGetType (void) const;
  20.225 -  virtual std::string DoGetDefaultValue (void) const;
  20.226 -  T RealMin (void) const;
  20.227 -  T m_defaultValue;
  20.228 -  T m_minValue;
  20.229 -  T m_maxValue;
  20.230 -  T m_value;
  20.231 -};
  20.232 -
  20.233 -/**
  20.234 - * \brief Named enumeration defaults
  20.235 - * \ingroup config
  20.236 - *
  20.237 - * Every instance of this type is automatically 
  20.238 - * registered in the variable pool which is used
  20.239 - * by ns3::Bind. 
  20.240 - */
  20.241 -class StringEnumDefaultValue : public DefaultValueBase
  20.242 -{
  20.243 -public:
  20.244 -  /**
  20.245 -   * \param name The name of the variable
  20.246 -   * \param help The help string
  20.247 -   */
  20.248 -  StringEnumDefaultValue (const std::string &name,
  20.249 -                          const std::string &help);
  20.250 -  /**
  20.251 -   * \brief Add a default value to this enumeration of strings
  20.252 -   * \param value The string to make the default for this
  20.253 -   */
  20.254 -  void AddDefaultValue (const std::string &value);
  20.255 -  /**
  20.256 -   * \brief Add a possible value to accept for this default value
  20.257 -   */
  20.258 -  void AddPossibleValue (const std::string &value);
  20.259 -  /**
  20.260 -   * \brief Get the value of this default value.
  20.261 -   * \return The string that has been assigned to this default value, either by
  20.262 -   * Bind() or by a command line setting
  20.263 -   */
  20.264 -  std::string GetValue (void) const;
  20.265 -private:
  20.266 -  virtual bool DoParseValue (const std::string &value);
  20.267 -  virtual std::string DoGetType (void) const;
  20.268 -  virtual std::string DoGetDefaultValue (void) const;
  20.269 -
  20.270 -  bool m_oneDefault;
  20.271 -  std::list<std::string> m_possibleValues;
  20.272 -  std::string m_defaultValue;
  20.273 -  std::string m_value;
  20.274 -};
  20.275 -
  20.276 -/**
  20.277 - * \brief An enum variable for ns3::Bind
  20.278 - * \ingroup config
  20.279 - *
  20.280 - * Every instance of this type is automatically 
  20.281 - * registered in the variable pool which is used
  20.282 - * by ns3::Bind. 
  20.283 - */
  20.284 -template <typename T>
  20.285 -class EnumDefaultValue : public DefaultValueBase
  20.286 -{
  20.287 -public:
  20.288 -  /**
  20.289 -   * \param name the name of this variable
  20.290 -   * \param help help text which explains the purpose
  20.291 -   *        and the semantics of this variable
  20.292 -   * \param defaultValue the default value assigned to this
  20.293 -   *        variable unless it is overriden with ns3::Bind
  20.294 -   * \param defaultValueString the string which represents
  20.295 -   *        the default value which should be used by ns3::Bind
  20.296 -   *
  20.297 -   * This method takes a variable number of arguments. The list of
  20.298 -   * arguments is terminated by the pair of values 0 and (void *)0.
  20.299 -   * Each pair of extra argument is assumed to be of the form 
  20.300 -   * (enum value, string representing enum value). If ns3::Bind
  20.301 -   * is invoked on this variable, it will check that the user-provided
  20.302 -   * values are within the set of values specified in this constructor.
  20.303 -   *
  20.304 -   * Typical useage of this method will look like this:
  20.305 -   * \code
  20.306 -   * enum MyEnum {
  20.307 -   *   MY_ENUM_A,
  20.308 -   *   MY_ENUM_B,
  20.309 -   *   MY_ENUM_C,
  20.310 -   * };
  20.311 -   * // set default value to be "B".
  20.312 -   * static EnumDefaultValue<enum MyEnum> 
  20.313 -   *  g_myDefaultValue ("my", "my help",
  20.314 -   *                    MY_ENUM_B, "B",
  20.315 -   *                    MY_ENUM_A, "A",
  20.316 -   *                    MY_ENUM_C, "C",);
  20.317 -   *                    0, (void*)0);
  20.318 -   * \endcode
  20.319 -   * Note that to ensure portability to 64 bit systems, make sure that
  20.320 -   * the last element in the variable list of arguments is (void *)0.
  20.321 -   */
  20.322 -  EnumDefaultValue (const std::string &name, const std::string &help,
  20.323 -		    T defaultValue, const char *defaultValueString, 
  20.324 -		    ...);
  20.325 -  void AddPossibleValue (T value, const std::string &valueString);
  20.326 -  /**
  20.327 -   * \returns the default value or any other value specified by the 
  20.328 -   *          user with ns3::Bind
  20.329 -   */
  20.330 -  T GetValue (void);
  20.331 -  /**
  20.332 -   * \param value the new default value.
  20.333 -   */
  20.334 -  void SetValue (T value);
  20.335 - private:
  20.336 -  virtual bool DoParseValue (const std::string &value);
  20.337 -  virtual std::string DoGetType (void) const;
  20.338 -  virtual std::string DoGetDefaultValue (void) const;
  20.339 -
  20.340 -  typedef std::list<std::pair<T,std::string> > PossibleValues;
  20.341 -
  20.342 -  T m_defaultValue;
  20.343 -  PossibleValues m_possibleValues;
  20.344 -  T m_value;
  20.345 -};
  20.346 -
  20.347 -/**
  20.348 - * \brief A string variable for ns3::Bind
  20.349 - * \ingroup config
  20.350 - *
  20.351 - * Every instance of this type is automatically 
  20.352 - * registered in the variable pool which is used
  20.353 - * by ns3::Bind. 
  20.354 - */
  20.355 -class StringDefaultValue : public DefaultValueBase
  20.356 -{
  20.357 -public:
  20.358 -  StringDefaultValue (const std::string &name,
  20.359 -                      const std::string &help,
  20.360 -                      const std::string defaultValue);
  20.361 -  StringDefaultValue (const std::string &name,
  20.362 -                      const std::string &help,
  20.363 -                      const std::string defaultValue, 
  20.364 -                      int maxSize);
  20.365 -  StringDefaultValue (const std::string &name,
  20.366 -                      const std::string &help,
  20.367 -                      const std::string defaultValue, 
  20.368 -                      int minSize,
  20.369 -                      int maxSize);
  20.370 -
  20.371 -  std::string GetValue (void) const;
  20.372 -private:
  20.373 -  virtual bool DoParseValue (const std::string &value);
  20.374 -  virtual std::string DoGetType (void) const;
  20.375 -  virtual std::string DoGetDefaultValue (void) const;
  20.376 -
  20.377 -  std::string m_defaultValue;
  20.378 -  std::string m_value;
  20.379 -  int m_minSize;
  20.380 -  int m_maxSize;
  20.381 -};
  20.382 -
  20.383 -/**
  20.384 - * \brief Class used to call a certain function during the configuration of the
  20.385 - * simulation
  20.386 - * \ingroup config
  20.387 - */
  20.388 -class CommandDefaultValue : public DefaultValueBase
  20.389 -{
  20.390 -public:
  20.391 -  CommandDefaultValue (const std::string &name,
  20.392 -		       const std::string &help,
  20.393 -		       Callback<void> cb);
  20.394 -private:
  20.395 -  virtual bool DoParseValue (const std::string &value);
  20.396 -  virtual std::string DoGetType (void) const;
  20.397 -  virtual std::string DoGetDefaultValue (void) const;
  20.398 -  Callback<void> m_cb;
  20.399 -};
  20.400 -
  20.401 -}//namespace ns3
  20.402 -
  20.403 -#include "type-name.h"
  20.404 -#include "assert.h"
  20.405 -#include <sstream>
  20.406 -#include <stdarg.h>
  20.407 -#include <limits>
  20.408 -
  20.409 -namespace ns3 {
  20.410 -
  20.411 -/**************************************************************
  20.412 - **************************************************************/
  20.413 -
  20.414 -
  20.415 -template <typename T>
  20.416 -NumericDefaultValue<T>::NumericDefaultValue (std::string name,
  20.417 -					     std::string help,
  20.418 -					     T defaultValue)
  20.419 -  : DefaultValueBase (name, help),
  20.420 -    m_defaultValue (defaultValue),
  20.421 -    m_minValue (RealMin ()),
  20.422 -    m_maxValue (std::numeric_limits<T>::max ()),
  20.423 -    m_value (defaultValue)
  20.424 -{
  20.425 -  DefaultValueList::Add (this);
  20.426 -  NS_ASSERT (m_minValue < m_maxValue);
  20.427 -}
  20.428 -template <typename T>
  20.429 -NumericDefaultValue<T>::NumericDefaultValue (std::string name,
  20.430 -					     std::string help,
  20.431 -					     T defaultValue,
  20.432 -					     T minValue)
  20.433 -  : DefaultValueBase (name, help),
  20.434 -    m_defaultValue (defaultValue),
  20.435 -    m_minValue (minValue),
  20.436 -    m_maxValue (std::numeric_limits<T>::max ()),
  20.437 -    m_value (defaultValue)
  20.438 -{
  20.439 -  DefaultValueList::Add (this);
  20.440 -  NS_ASSERT (m_minValue < m_maxValue);
  20.441 -  NS_ASSERT (m_defaultValue <= m_maxValue &&
  20.442 -	     m_defaultValue >= m_minValue);
  20.443 -}
  20.444 -template <typename T>
  20.445 -NumericDefaultValue<T>::NumericDefaultValue (std::string name,
  20.446 -					     std::string help,
  20.447 -					     T defaultValue,
  20.448 -					     T minValue,
  20.449 -					     T maxValue)
  20.450 -  : DefaultValueBase (name, help),
  20.451 -    m_defaultValue (defaultValue),
  20.452 -    m_minValue (minValue),
  20.453 -    m_maxValue (maxValue),
  20.454 -    m_value (defaultValue)
  20.455 -{
  20.456 -  DefaultValueList::Add (this);
  20.457 -  NS_ASSERT (m_minValue < m_maxValue);
  20.458 -  NS_ASSERT (m_defaultValue <= m_maxValue &&
  20.459 -	     m_defaultValue >= m_minValue);
  20.460 -}
  20.461 -
  20.462 -template <typename T>
  20.463 -void 
  20.464 -NumericDefaultValue<T>::SetValue (T v)
  20.465 -{
  20.466 -  NS_ASSERT (v <= m_maxValue &&
  20.467 -	     v >= m_minValue);
  20.468 -  m_value = v;
  20.469 -}
  20.470 -
  20.471 -template <typename T>
  20.472 -T
  20.473 -NumericDefaultValue<T>::GetValue (void) const
  20.474 -{
  20.475 -  return m_value;
  20.476 -}
  20.477 -
  20.478 -template <typename T>
  20.479 -bool
  20.480 -NumericDefaultValue<T>::DoParseValue (const std::string &value)
  20.481 -{
  20.482 -  std::istringstream iss;
  20.483 -  iss.str (value);
  20.484 -  iss >> m_value;
  20.485 -  if (m_value > m_maxValue ||
  20.486 -      m_value < m_minValue)
  20.487 -    {
  20.488 -      return false;
  20.489 -    }
  20.490 -  return !iss.bad () && !iss.fail ();
  20.491 -}
  20.492 -
  20.493 -template <typename T>
  20.494 -std::string
  20.495 -NumericDefaultValue<T>::DoGetType (void) const
  20.496 -{
  20.497 -  std::ostringstream oss;
  20.498 -  oss << TypeNameGet<T> () << "("
  20.499 -      << m_minValue << ":" 
  20.500 -      << m_maxValue << ")";
  20.501 -  return oss.str ();
  20.502 -}
  20.503 -
  20.504 -template <typename T>
  20.505 -std::string
  20.506 -NumericDefaultValue<T>::DoGetDefaultValue (void) const
  20.507 -{
  20.508 -  std::ostringstream oss;
  20.509 -  oss << m_defaultValue;
  20.510 -  return oss.str ();
  20.511 -}
  20.512 -
  20.513 -template <typename T>
  20.514 -T
  20.515 -NumericDefaultValue<T>::RealMin (void) const
  20.516 -{
  20.517 -  if (std::numeric_limits<T>::is_integer) 
  20.518 -    {
  20.519 -      return std::numeric_limits<T>::min ();
  20.520 -    }
  20.521 -  else 
  20.522 -    {
  20.523 -      return -std::numeric_limits<T>::max ();
  20.524 -    }
  20.525 -}
  20.526 -
  20.527 -
  20.528 -/**************************************************************
  20.529 - **************************************************************/
  20.530 -
  20.531 -template <typename T>
  20.532 -EnumDefaultValue<T>::EnumDefaultValue (const std::string &name, const std::string &help,
  20.533 -				       T defaultValue, const char *defaultValueString, 
  20.534 -				       ...)
  20.535 -  : DefaultValueBase (name, help),
  20.536 -    m_defaultValue (defaultValue),
  20.537 -    m_value (defaultValue)
  20.538 -{
  20.539 -  AddPossibleValue (defaultValue, defaultValueString);
  20.540 -  va_list list;
  20.541 -  va_start (list, defaultValueString);
  20.542 -  while (true)
  20.543 -    {
  20.544 -      T v = (T) va_arg (list, int);
  20.545 -      const char *str = va_arg (list, const char *);
  20.546 -      if (v == 0 && str == 0)
  20.547 -	{
  20.548 -	  break;
  20.549 -	}
  20.550 -      AddPossibleValue (v, str);
  20.551 -    }
  20.552 -  DefaultValueList::Add (this);
  20.553 -}
  20.554 -template <typename T>
  20.555 -void 
  20.556 -EnumDefaultValue<T>::AddPossibleValue (T value, const std::string &valueString)
  20.557 -{
  20.558 -  m_possibleValues.push_back (std::make_pair (value, valueString));
  20.559 -}
  20.560 -template <typename T>
  20.561 -T 
  20.562 -EnumDefaultValue<T>::GetValue (void)
  20.563 -{
  20.564 -  return m_value;
  20.565 -}
  20.566 -template <typename T>
  20.567 -void
  20.568 -EnumDefaultValue<T>::SetValue (T value)
  20.569 -{
  20.570 -  m_value = value;
  20.571 -}
  20.572 -template <typename T>
  20.573 -bool 
  20.574 -EnumDefaultValue<T>::DoParseValue (const std::string &value)
  20.575 -{
  20.576 -  for (typename PossibleValues::iterator i = m_possibleValues.begin ();
  20.577 -       i != m_possibleValues.end (); i++)
  20.578 -    {
  20.579 -      if (value == i->second)
  20.580 -	{
  20.581 -	  m_value = i->first;
  20.582 -	  return true;
  20.583 -	}
  20.584 -    }
  20.585 -  return false;
  20.586 -}
  20.587 -template <typename T>
  20.588 -std::string 
  20.589 -EnumDefaultValue<T>::DoGetType (void) const
  20.590 -{
  20.591 -  std::string retval;
  20.592 -  retval += "(";
  20.593 -  for (typename PossibleValues::const_iterator i = m_possibleValues.begin ();
  20.594 -       i != m_possibleValues.end (); i++)
  20.595 -    {
  20.596 -      if (i != m_possibleValues.begin ())
  20.597 -	{
  20.598 -	  retval += "|";
  20.599 -	}
  20.600 -      retval += i->second;
  20.601 -    }
  20.602 -  retval += ")";
  20.603 -  return retval;
  20.604 -}
  20.605 -template <typename T>
  20.606 -std::string 
  20.607 -EnumDefaultValue<T>::DoGetDefaultValue (void) const
  20.608 -{
  20.609 -  for (typename PossibleValues::const_iterator i = m_possibleValues.begin ();
  20.610 -       i != m_possibleValues.end (); i++)
  20.611 -    {
  20.612 -      if (i->first == m_defaultValue)
  20.613 -	{
  20.614 -	  return i->second;
  20.615 -	}
  20.616 -    }
  20.617 -  // cannot happen theoretically.
  20.618 -  NS_ASSERT (false);
  20.619 -  return ""; // quiet compiler
  20.620 -}
  20.621 -
  20.622 -}//namespace ns3
  20.623 -
  20.624 -#endif /* DEFAULT_VALUE_H */
    21.1 --- a/src/core/random-variable-default-value.cc	Mon Mar 10 00:26:54 2008 +0100
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,138 +0,0 @@
    21.4 -/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
    21.5 -/*
    21.6 - * Copyright (c) 2007 INRIA
    21.7 - * All rights reserved.
    21.8 - *
    21.9 - * This program is free software; you can redistribute it and/or modify
   21.10 - * it under the terms of the GNU General Public License version 2 as
   21.11 - * published by the Free Software Foundation;
   21.12 - *
   21.13 - * This program is distributed in the hope that it will be useful,
   21.14 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   21.15 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   21.16 - * GNU General Public License for more details.
   21.17 - *
   21.18 - * You should have received a copy of the GNU General Public License
   21.19 - * along with this program; if not, write to the Free Software
   21.20 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   21.21 - *
   21.22 - * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
   21.23 - */
   21.24 -#include "random-variable-default-value.h"
   21.25 -#include "log.h"
   21.26 -
   21.27 -NS_LOG_COMPONENT_DEFINE ("RandomVariableDefaultValue");
   21.28 -
   21.29 -namespace ns3 {
   21.30 -
   21.31 -RandomVariableDefaultValue::RandomVariableDefaultValue (std::string name,
   21.32 -							std::string help,
   21.33 -							std::string defaultValue)
   21.34 -  : DefaultValueBase (name, help),
   21.35 -    m_defaultValue (defaultValue),
   21.36 -    m_value (defaultValue)
   21.37 -{
   21.38 -  if (!Parse (defaultValue, false, 0))
   21.39 -    {
   21.40 -      NS_FATAL_ERROR ("Invalid Random Variable specification: " << defaultValue);
   21.41 -    }
   21.42 -  DefaultValueList::Add (this);
   21.43 -}
   21.44 -
   21.45 -RandomVariable
   21.46 -RandomVariableDefaultValue::Get (void) const
   21.47 -{
   21.48 -  RandomVariable variable;
   21.49 -  bool ok;
   21.50 -  ok = Parse (m_value, true, &variable);
   21.51 -  NS_ASSERT (ok);
   21.52 -  return variable;
   21.53 -}
   21.54 -double
   21.55 -RandomVariableDefaultValue::ReadAsDouble (std::string value, bool &ok) const
   21.56 -{
   21.57 -  double v;
   21.58 -  std::istringstream iss;
   21.59 -  iss.str (value);
   21.60 -  iss >> v;
   21.61 -  ok = !iss.bad () && !iss.fail ();
   21.62 -  return v;
   21.63 -}
   21.64 -bool
   21.65 -RandomVariableDefaultValue::Parse (const std::string &value, 
   21.66 -				   bool mustCreate, RandomVariable *pVariable) const
   21.67 -{
   21.68 -  std::string::size_type pos = value.find_first_of(":");
   21.69 -  if (pos == std::string::npos)
   21.70 -    {
   21.71 -      return false;
   21.72 -    }
   21.73 -  bool ok;
   21.74 -  std::string type = value.substr (0, pos);
   21.75 -  std::string v = value.substr (pos+1, std::string::npos);
   21.76 -  if (type == "Constant")
   21.77 -    {
   21.78 -      double constant = ReadAsDouble (v, ok);
   21.79 -      if (mustCreate)
   21.80 -	{
   21.81 -          NS_LOG_LOGIC ("create Constant constant=" << constant);
   21.82 -	  *pVariable = ConstantVariable (constant);
   21.83 -	}
   21.84 -      else
   21.85 -        {
   21.86 -          NS_LOG_LOGIC ("parse  Constant constant=" << constant);
   21.87 -        }
   21.88 -      return ok;
   21.89 -    }
   21.90 -  else if (type == "Uniform")
   21.91 -    {
   21.92 -      std::string::size_type maxPos = v.find_first_of(":");
   21.93 -      if (maxPos == std::string::npos)
   21.94 -	{
   21.95 -	  return false;
   21.96 -	}
   21.97 -      std::string min = v.substr (0, maxPos);
   21.98 -      std::string max = v.substr (maxPos + 1, std::string::npos);
   21.99 -      double minVal;
  21.100 -      double maxVal;
  21.101 -      minVal = ReadAsDouble (min, ok);
  21.102 -      maxVal = ReadAsDouble (max, ok);
  21.103 -      if (mustCreate)
  21.104 -	{
  21.105 -          NS_LOG_LOGIC ("create Uniform min=" << min << ", max=" << max);
  21.106 -	  *pVariable = UniformVariable (minVal, maxVal);
  21.107 -	}
  21.108 -      else
  21.109 -        {
  21.110 -          NS_LOG_LOGIC ("parse  Uniform min=" << min << ", max=" << max);
  21.111 -        }
  21.112 -      return ok;
  21.113 -    }
  21.114 -  else
  21.115 -    {
  21.116 -      // XXX parse other types of distributions.
  21.117 -      return false;
  21.118 -    }
  21.119 -}
  21.120 -bool 
  21.121 -RandomVariableDefaultValue::DoParseValue (const std::string &value)
  21.122 -{
  21.123 -  bool ok = Parse (value, false, 0);
  21.124 -  if (ok)
  21.125 -    {
  21.126 -      m_value = value;
  21.127 -    }
  21.128 -  return ok;
  21.129 -}
  21.130 -std::string 
  21.131 -RandomVariableDefaultValue::DoGetType (void) const
  21.132 -{
  21.133 -  return "(Uniform:min:max|Constant:cst)";
  21.134 -}
  21.135 -std::string 
  21.136 -RandomVariableDefaultValue::DoGetDefaultValue (void) const
  21.137 -{
  21.138 -  return m_defaultValue;
  21.139 -}
  21.140 -
  21.141 -} // namespace ns3
    22.1 --- a/src/core/random-variable-default-value.h	Mon Mar 10 00:26:54 2008 +0100
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,50 +0,0 @@
    22.4 -/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
    22.5 -/*
    22.6 - * Copyright (c) 2007 INRIA
    22.7 - * All rights reserved.
    22.8 - *
    22.9 - * This program is free software; you can redistribute it and/or modify
   22.10 - * it under the terms of the GNU General Public License version 2 as
   22.11 - * published by the Free Software Foundation;
   22.12 - *
   22.13 - * This program is distributed in the hope that it will be useful,
   22.14 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   22.15 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   22.16 - * GNU General Public License for more details.
   22.17 - *
   22.18 - * You should have received a copy of the GNU General Public License
   22.19 - * along with this program; if not, write to the Free Software
   22.20 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   22.21 - *
   22.22 - * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
   22.23 - */
   22.24 -#ifndef RANDOM_VARIABLE_DEFAULT_VALUE_H
   22.25 -#define RANDOM_VARIABLE_DEFAULT_VALUE_H
   22.26 -
   22.27 -#include "random-variable.h"
   22.28 -#include "default-value.h"
   22.29 -
   22.30 -namespace ns3 {
   22.31 -
   22.32 -class RandomVariableDefaultValue : public DefaultValueBase
   22.33 -{
   22.34 - public:
   22.35 -  RandomVariableDefaultValue (std::string name,
   22.36 -			      std::string help,
   22.37 -			      std::string defaultValue);
   22.38 -
   22.39 -  RandomVariable Get (void) const;
   22.40 -private:
   22.41 -  bool Parse (const std::string &value, bool mustCreate, RandomVariable *pVariable) const;
   22.42 -  double ReadAsDouble (const std::string value, bool &ok) const;
   22.43 -  virtual bool DoParseValue (const std::string &value);
   22.44 -  virtual std::string DoGetType (void) const;
   22.45 -  virtual std::string DoGetDefaultValue (void) const;
   22.46 -
   22.47 -  std::string m_defaultValue;
   22.48 -  std::string m_value;
   22.49 -};
   22.50 -
   22.51 -} // namespace ns3
   22.52 -
   22.53 -#endif /* RANDOM_VARIABLE_DEFAULT_VALUE_H */
    23.1 --- a/src/core/type-id-default-value.cc	Mon Mar 10 00:26:54 2008 +0100
    23.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.3 @@ -1,96 +0,0 @@
    23.4 -#include "type-id-default-value.h"
    23.5 -
    23.6 -namespace ns3 {
    23.7 -
    23.8 -TypeIdDefaultValue::TypeIdDefaultValue (std::string name, 
    23.9 -						  std::string help,
   23.10 -						  TypeId tid,
   23.11 -						  std::string defaultValue)
   23.12 -  : DefaultValueBase (name, help),
   23.13 -    m_defaultName (defaultValue),
   23.14 -    m_name (defaultValue),
   23.15 -    m_interfaceId (tid)
   23.16 -{
   23.17 -  DefaultValueList::Add (this);
   23.18 -}
   23.19 -TypeId 
   23.20 -TypeIdDefaultValue::GetValue (void) const
   23.21 -{
   23.22 -  return TypeId::LookupByName (m_name);
   23.23 -}
   23.24 -void 
   23.25 -TypeIdDefaultValue::SetValue (TypeId interfaceId)
   23.26 -{
   23.27 -  m_name = interfaceId.GetName ();
   23.28 -}
   23.29 -void 
   23.30 -TypeIdDefaultValue::SetValue (std::string name)
   23.31 -{
   23.32 -  m_name = name;
   23.33 -}
   23.34 -bool 
   23.35 -TypeIdDefaultValue::DoParseValue (const std::string &value)
   23.36 -{
   23.37 -  for (uint32_t i = 0; i < TypeId::GetRegisteredN (); i++)
   23.38 -    {
   23.39 -      TypeId tid = TypeId::GetRegistered (i);
   23.40 -      do {
   23.41 -	if (tid.GetName () == value &&
   23.42 -	    tid.HasConstructor ())
   23.43 -	  {
   23.44 -	    // check that it really supports the requested interface.
   23.45 -	    TypeId tmp = tid;
   23.46 -	    do {
   23.47 -	      if (tmp == m_interfaceId)
   23.48 -		{
   23.49 -		  m_name = value;
   23.50 -		  return true;
   23.51 -		}
   23.52 -	      tmp = tmp.GetParent ();
   23.53 -	    } while (tmp != Object::GetTypeId ());
   23.54 -	  }
   23.55 -	tid = tid.GetParent ();
   23.56 -      } while (tid != Object::GetTypeId ());
   23.57 -    }
   23.58 -  return false;
   23.59 -}
   23.60 -
   23.61 -std::string 
   23.62 -TypeIdDefaultValue::DoGetType (void) const
   23.63 -{
   23.64 -  std::ostringstream oss;
   23.65 -  oss << "(";
   23.66 -  bool first = true;
   23.67 -  for (uint32_t i = 0; i < TypeId::GetRegisteredN (); i++)
   23.68 -    {
   23.69 -      TypeId tid = TypeId::GetRegistered (i);
   23.70 -      // can this interface id be used to create objects ?
   23.71 -      if (tid.HasConstructor ())
   23.72 -	{
   23.73 -	  TypeId tmp = tid;
   23.74 -	  // does this interface id supports the requested interface id ?
   23.75 -	  do {
   23.76 -	    if (tmp == m_interfaceId)
   23.77 -	      {
   23.78 -		if (!first)
   23.79 -		  {
   23.80 -		    oss << "|";
   23.81 -		    first = false;
   23.82 -		  }
   23.83 -		oss << tid.GetName ();
   23.84 -	      }
   23.85 -	    tmp = tmp.GetParent ();
   23.86 -	  } while (tmp != Object::GetTypeId ());
   23.87 -	}
   23.88 -    }
   23.89 -  oss << ")";
   23.90 -  return oss.str ();
   23.91 -}
   23.92 -
   23.93 -std::string 
   23.94 -TypeIdDefaultValue::DoGetDefaultValue (void) const
   23.95 -{
   23.96 -  return m_name;
   23.97 -}
   23.98 -
   23.99 -} // namespace ns3
    24.1 --- a/src/core/type-id-default-value.h	Mon Mar 10 00:26:54 2008 +0100
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,51 +0,0 @@
    24.4 -#ifndef INTERFACE_ID_DEFAULT_VALUE_H
    24.5 -#define INTERFACE_ID_DEFAULT_VALUE_H
    24.6 -
    24.7 -#include "default-value.h"
    24.8 -#include "object.h"
    24.9 -
   24.10 -namespace ns3 {
   24.11 -
   24.12 -class TypeIdDefaultValue : public DefaultValueBase
   24.13 -{
   24.14 -public:
   24.15 -  /**
   24.16 -   * \param name the name of this default value.
   24.17 -   * \param help the help text associated to this default value
   24.18 -   * \param tid the interface id which all objects created
   24.19 -   *        through this "default value" must support.
   24.20 -   * \param defaultValue the name of the object to create
   24.21 -   *        by default.
   24.22 -   */
   24.23 -  TypeIdDefaultValue (std::string name, 
   24.24 -			   std::string help,
   24.25 -			   TypeId tid,
   24.26 -			   std::string defaultValue);
   24.27 -  /**
   24.28 -   * \returns the TypeId of the object selected by the user.
   24.29 -   */
   24.30 -  TypeId GetValue (void) const;
   24.31 -  /**
   24.32 -   * \param interfaceId the new ClassId selected.
   24.33 -   *
   24.34 -   * Override the currently-selected value.
   24.35 -   */
   24.36 -  void SetValue (TypeId interfaceId);
   24.37 -  /**
   24.38 -   * \param name the new object selected.
   24.39 -   *
   24.40 -   * Override the currently-selected value.
   24.41 -   */
   24.42 -  void SetValue (std::string name);
   24.43 -private:
   24.44 -  virtual bool DoParseValue (const std::string &value);
   24.45 -  virtual std::string DoGetType (void) const;
   24.46 -  virtual std::string DoGetDefaultValue (void) const;
   24.47 -  std::string m_defaultName;
   24.48 -  std::string m_name;
   24.49 -  TypeId m_interfaceId;
   24.50 -};
   24.51 -
   24.52 -} // namespace ns3
   24.53 -
   24.54 -#endif /* INTERFACE_ID_DEFAULT_VALUE_H */
    25.1 --- a/src/core/wscript	Mon Mar 10 00:26:54 2008 +0100
    25.2 +++ b/src/core/wscript	Mon Mar 10 00:27:53 2008 +0100
    25.3 @@ -38,12 +38,9 @@
    25.4          'random-variable.cc',
    25.5          'rng-stream.cc',
    25.6          'uid-manager.cc',
    25.7 -        'default-value.cc',
    25.8          'command-line.cc',
    25.9          'type-name.cc',
   25.10 -        'random-variable-default-value.cc',
   25.11          'type-traits-test.cc',
   25.12 -        'type-id-default-value.cc',
   25.13          'attribute.cc',
   25.14          'boolean.cc',
   25.15          'attribute-test.cc',
   25.16 @@ -84,13 +81,10 @@
   25.17          'test.h',
   25.18          'random-variable.h',
   25.19          'rng-stream.h',
   25.20 -        'default-value.h',
   25.21          'command-line.h',
   25.22          'type-name.h',
   25.23          'type-traits.h',
   25.24 -        'random-variable-default-value.h',
   25.25          'int-to-type.h',
   25.26 -        'type-id-default-value.h',
   25.27          'attribute.h',
   25.28          'attribute-accessor-helper.h',
   25.29          'boolean.h',
    26.1 --- a/src/internet-node/rtt-estimator.h	Mon Mar 10 00:26:54 2008 +0100
    26.2 +++ b/src/internet-node/rtt-estimator.h	Mon Mar 10 00:27:53 2008 +0100
    26.3 @@ -30,7 +30,6 @@
    26.4  #include "sequence-number.h"
    26.5  #include "ns3/nstime.h"
    26.6  #include "ns3/object.h"
    26.7 -#include "ns3/type-id-default-value.h"
    26.8  
    26.9  namespace ns3 {
   26.10  
    27.1 --- a/src/simulator/scheduler-factory.cc	Mon Mar 10 00:26:54 2008 +0100
    27.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.3 @@ -1,102 +0,0 @@
    27.4 -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
    27.5 -/*
    27.6 - * Copyright (c) 2006 INRIA
    27.7 - *
    27.8 - * This program is free software; you can redistribute it and/or modify
    27.9 - * it under the terms of the GNU General Public License version 2 as
   27.10 - * published by the Free Software Foundation;
   27.11 - *
   27.12 - * This program is distributed in the hope that it will be useful,
   27.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   27.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   27.15 - * GNU General Public License for more details.
   27.16 - *
   27.17 - * You should have received a copy of the GNU General Public License
   27.18 - * along with this program; if not, write to the Free Software
   27.19 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   27.20 - *
   27.21 - * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
   27.22 - */
   27.23 -#include "scheduler-factory.h"
   27.24 -#include "ns3/assert.h"
   27.25 -#include "ns3/fatal-error.h"
   27.26 -#include "ns3/default-value.h"
   27.27 -
   27.28 -namespace ns3 {
   27.29 -
   27.30 -SchedulerFactory::~SchedulerFactory ()
   27.31 -{}
   27.32 -
   27.33 -Scheduler *
   27.34 -SchedulerFactory::Create (void) const
   27.35 -{
   27.36 -  return DoCreate ();
   27.37 -}
   27.38 -
   27.39 -Scheduler *
   27.40 -SchedulerFactory::CreateDefault (void)
   27.41 -{
   27.42 -  NS_ASSERT_MSG (!GetList ()->empty (), "No Scheduler factory registered");
   27.43 -  std::string defaultValue = GetDefault ()->GetValue ();
   27.44 -  for (List::const_iterator i = GetList ()->begin ();
   27.45 -       i != GetList ()->end (); i++)
   27.46 -    {
   27.47 -      if (i->second == defaultValue)
   27.48 -        {
   27.49 -          return i->first->Create ();
   27.50 -        }
   27.51 -    }
   27.52 -  NS_ASSERT (false);
   27.53 -  // quiet compiler
   27.54 -  return 0;
   27.55 -}
   27.56 -
   27.57 -Scheduler *
   27.58 -SchedulerFactory::Create (const std::string &name)
   27.59 -{
   27.60 -  for (List::iterator i = GetList ()->begin ();
   27.61 -       i != GetList ()->end (); i++)
   27.62 -    {
   27.63 -      if (i->second == name)
   27.64 -        {
   27.65 -          return i->first->Create ();
   27.66 -        }
   27.67 -    }
   27.68 -  NS_ASSERT_MSG (false, "Tried to create non-existant scheduler: " << name);
   27.69 -  // quiet compiler.
   27.70 -  return 0;
   27.71 -}
   27.72 -
   27.73 -void 
   27.74 -SchedulerFactory::AddDefault (const SchedulerFactory *factory,
   27.75 -                              const std::string &name)
   27.76 -{
   27.77 -  GetDefault ()->AddDefaultValue (name);
   27.78 -  GetList ()->push_back (std::make_pair (factory, name));
   27.79 -}
   27.80 -
   27.81 -
   27.82 -void 
   27.83 -SchedulerFactory::Add (const SchedulerFactory *factory,
   27.84 -                       const std::string &name)
   27.85 -{
   27.86 -  GetDefault ()->AddPossibleValue (name);
   27.87 -  GetList ()->push_back (std::make_pair (factory, name));
   27.88 -}
   27.89 -
   27.90 -StringEnumDefaultValue *
   27.91 -SchedulerFactory::GetDefault (void)
   27.92 -{
   27.93 -  static StringEnumDefaultValue value ("Scheduler", "Event Scheduler algorithm");
   27.94 -  return &value;
   27.95 -}
   27.96 -
   27.97 -SchedulerFactory::List *
   27.98 -SchedulerFactory::GetList (void)
   27.99 -{
  27.100 -  static SchedulerFactory::List list;
  27.101 -  return &list;
  27.102 -}
  27.103 -
  27.104 -
  27.105 -}; // namespace ns3
    28.1 --- a/src/simulator/scheduler-factory.h	Mon Mar 10 00:26:54 2008 +0100
    28.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.3 @@ -1,78 +0,0 @@
    28.4 -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
    28.5 -/*
    28.6 - * Copyright (c) 2006 INRIA
    28.7 - *
    28.8 - * This program is free software; you can redistribute it and/or modify
    28.9 - * it under the terms of the GNU General Public License version 2 as
   28.10 - * published by the Free Software Foundation;
   28.11 - *
   28.12 - * This program is distributed in the hope that it will be useful,
   28.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   28.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   28.15 - * GNU General Public License for more details.
   28.16 - *
   28.17 - * You should have received a copy of the GNU General Public License
   28.18 - * along with this program; if not, write to the Free Software
   28.19 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   28.20 - *
   28.21 - * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
   28.22 - */
   28.23 -#ifndef SCHEDULER_FACTORY_H
   28.24 -#define SCHEDULER_FACTORY_H
   28.25 -
   28.26 -#include <list>
   28.27 -
   28.28 -namespace ns3 {
   28.29 -
   28.30 -class Scheduler;
   28.31 -class StringEnumDefaultValue;
   28.32 -
   28.33 -/**
   28.34 - * \brief a base class to create event schedulers
   28.35 - *
   28.36 - * If you want to make the core simulation engine use a new
   28.37 - * event scheduler without editing the code of the simulator,
   28.38 - * you need to create a subclass of this base class and implement
   28.39 - * the ns3::SchedulerFactory::realCreate method.
   28.40 - */
   28.41 -class SchedulerFactory {
   28.42 -public:
   28.43 -  virtual ~SchedulerFactory ();
   28.44 -  /**
   28.45 -   * \returns a newly-created scheduler.
   28.46 -   */
   28.47 -  Scheduler *Create (void) const;
   28.48 -  /**
   28.49 -   * \returns a newly-created scheduler.
   28.50 -   *
   28.51 -   * Return a "default" scheduler.
   28.52 -   */
   28.53 -  static Scheduler *CreateDefault (void);
   28.54 -  /**
   28.55 -   * \param name of scheduler to create.
   28.56 -   * \returns a newly-created scheduler.
   28.57 -   *
   28.58 -   * Create a scheduler registered under the specified name.
   28.59 -   */
   28.60 -  static Scheduler *Create (const std::string &name);
   28.61 -protected:
   28.62 -  static void Add (const SchedulerFactory *factory,
   28.63 -                   const std::string &name);  
   28.64 -  static void AddDefault (const SchedulerFactory *factory,
   28.65 -                          const std::string &name);  
   28.66 -private:
   28.67 -  typedef std::list<std::pair<const SchedulerFactory *, std::string> > List;
   28.68 -  static SchedulerFactory::List *GetList (void);
   28.69 -  static StringEnumDefaultValue *GetDefault (void);
   28.70 -  /**
   28.71 -   * \returns a newly-created scheduler. The caller takes 
   28.72 -   *      ownership of the returned pointer.
   28.73 -   *
   28.74 -   * This method must be implemented by subclasses.
   28.75 -   */
   28.76 -  virtual Scheduler *DoCreate (void) const = 0;
   28.77 -};
   28.78 -
   28.79 -}; // namespace ns3
   28.80 -
   28.81 -#endif /* SCHEDULER_FACTORY_H */
    29.1 --- a/src/simulator/scheduler-heap.cc	Mon Mar 10 00:26:54 2008 +0100
    29.2 +++ b/src/simulator/scheduler-heap.cc	Mon Mar 10 00:27:53 2008 +0100
    29.3 @@ -32,7 +32,6 @@
    29.4   */
    29.5  
    29.6  #include "scheduler-heap.h"
    29.7 -#include "scheduler-factory.h"
    29.8  #include "event-impl.h"
    29.9  #include "ns3/assert.h"
   29.10  
   29.11 @@ -52,20 +51,6 @@
   29.12  
   29.13  namespace ns3 {
   29.14  
   29.15 -static class SchedulerHeapFactory : public SchedulerFactory 
   29.16 -{
   29.17 -public:
   29.18 -  SchedulerHeapFactory ()
   29.19 -  {
   29.20 -    SchedulerFactory::Add (this, "BinaryHeap");
   29.21 -  }
   29.22 -private:
   29.23 -  virtual Scheduler *DoCreate (void) const
   29.24 -  {
   29.25 -    return new SchedulerHeap ();
   29.26 -  }
   29.27 -} g_schedulerHeapFactory;
   29.28 -
   29.29  
   29.30  SchedulerHeap::SchedulerHeap ()
   29.31  {
    30.1 --- a/src/simulator/scheduler-list.cc	Mon Mar 10 00:26:54 2008 +0100
    30.2 +++ b/src/simulator/scheduler-list.cc	Mon Mar 10 00:27:53 2008 +0100
    30.3 @@ -19,7 +19,6 @@
    30.4   */
    30.5  
    30.6  #include "scheduler-list.h"
    30.7 -#include "scheduler-factory.h"
    30.8  #include "event-impl.h"
    30.9  #include <utility>
   30.10  #include <string>
   30.11 @@ -27,20 +26,6 @@
   30.12  
   30.13  namespace ns3 {
   30.14  
   30.15 -static class SchedulerListFactory : public SchedulerFactory 
   30.16 -{
   30.17 -public:
   30.18 -  SchedulerListFactory ()
   30.19 -  {
   30.20 -    SchedulerFactory::Add (this, "List");
   30.21 -  }
   30.22 -private:
   30.23 -  virtual Scheduler *DoCreate (void) const
   30.24 -  {
   30.25 -    return new SchedulerList ();
   30.26 -  }
   30.27 -} g_schedulerListFactory;
   30.28 -
   30.29  
   30.30  SchedulerList::SchedulerList ()
   30.31  {}
    31.1 --- a/src/simulator/scheduler-map.cc	Mon Mar 10 00:26:54 2008 +0100
    31.2 +++ b/src/simulator/scheduler-map.cc	Mon Mar 10 00:27:53 2008 +0100
    31.3 @@ -20,7 +20,6 @@
    31.4   */
    31.5  
    31.6  #include "scheduler-map.h"
    31.7 -#include "scheduler-factory.h"
    31.8  #include "event-impl.h"
    31.9  #include "ns3/assert.h"
   31.10  #include <string>
   31.11 @@ -38,21 +37,6 @@
   31.12  
   31.13  namespace ns3 {
   31.14  
   31.15 -static class SchedulerMapFactory : public SchedulerFactory 
   31.16 -{
   31.17 -public:
   31.18 -  SchedulerMapFactory ()
   31.19 -  {
   31.20 -    SchedulerFactory::AddDefault (this, "Map");
   31.21 -  }
   31.22 -private:
   31.23 -  virtual Scheduler *DoCreate (void) const
   31.24 -  {
   31.25 -    return new SchedulerMap ();
   31.26 -  }
   31.27 -} g_schedulerMapFactory;
   31.28 -
   31.29 -
   31.30  SchedulerMap::SchedulerMap ()
   31.31  {}
   31.32  SchedulerMap::~SchedulerMap ()
    32.1 --- a/src/simulator/simulator.cc	Mon Mar 10 00:26:54 2008 +0100
    32.2 +++ b/src/simulator/simulator.cc	Mon Mar 10 00:27:53 2008 +0100
    32.3 @@ -390,7 +390,6 @@
    32.4  #include "scheduler-list.h"
    32.5  #include "scheduler-heap.h"
    32.6  #include "scheduler-map.h"
    32.7 -#include "scheduler-factory.h"
    32.8  
    32.9  
   32.10  namespace ns3 {
    33.1 --- a/src/simulator/time.cc	Mon Mar 10 00:26:54 2008 +0100
    33.2 +++ b/src/simulator/time.cc	Mon Mar 10 00:27:53 2008 +0100
    33.3 @@ -21,8 +21,11 @@
    33.4   */
    33.5  #include "nstime.h"
    33.6  #include "ns3/fatal-error.h"
    33.7 -#include "ns3/default-value.h"
    33.8 +#include "ns3/global-value.h"
    33.9 +#include "ns3/enum.h"
   33.10 +#include "ns3/string.h"
   33.11  #include "ns3/object.h"
   33.12 +#include "ns3/config.h"
   33.13  #include <math.h>
   33.14  
   33.15  namespace ns3 {
   33.16 @@ -36,26 +39,28 @@
   33.17  static const uint64_t FS_FACTOR = (uint64_t)pow(10,15);
   33.18  static uint64_t g_tsPrecFactor = NS_FACTOR;
   33.19  
   33.20 -static EnumDefaultValue<enum precision_t> g_precisionDefaultValue ("TimeStepPrecision", 
   33.21 -                                                                   "The time unit of the internal 64 bit integer time.",
   33.22 -                                                                   NS, "NS",
   33.23 -                                                                   S, "S",
   33.24 -                                                                   MS, "MS",
   33.25 -                                                                   US, "US",
   33.26 -                                                                   PS, "PS",
   33.27 -                                                                   FS, "FS",
   33.28 -                                                                   0, (void *)0);
   33.29 +static GlobalValue g_precisionDefaultValue ("TimeStepPrecision", 
   33.30 +                                            "The time unit of the internal 64 bit integer time.",
   33.31 +                                            Enum (NS),
   33.32 +                                            MakeEnumChecker (NS, "NS",
   33.33 +                                                             S, "S",
   33.34 +                                                             MS, "MS",
   33.35 +                                                             US, "US",
   33.36 +                                                             PS, "PS",
   33.37 +                                                             FS, "FS")
   33.38 +                                            );
   33.39  
   33.40  precision_t
   33.41  Get (void)
   33.42  {
   33.43 -  return g_precisionDefaultValue.GetValue ();
   33.44 +  Enum v = g_precisionDefaultValue.GetValue ();
   33.45 +  return (precision_t) v.Get ();
   33.46  }
   33.47  
   33.48  void 
   33.49  Set (precision_t precision)
   33.50  {
   33.51 -  g_precisionDefaultValue.SetValue (precision);
   33.52 +  g_precisionDefaultValue.SetValue (Enum (precision));
   33.53    g_tsPrecFactor = (uint64_t)pow(10, precision);
   33.54  }
   33.55  
   33.56 @@ -486,12 +491,12 @@
   33.57  
   33.58    TimeStepPrecision::Set (TimeStepPrecision::NS);
   33.59  
   33.60 -  DefaultValue::Bind ("TimeStepPrecision", "S");
   33.61 -  DefaultValue::Bind ("TimeStepPrecision", "MS");
   33.62 -  DefaultValue::Bind ("TimeStepPrecision", "US");
   33.63 -  DefaultValue::Bind ("TimeStepPrecision", "NS");
   33.64 -  DefaultValue::Bind ("TimeStepPrecision", "PS");
   33.65 -  DefaultValue::Bind ("TimeStepPrecision", "FS");
   33.66 +  Config::SetGlobal ("TimeStepPrecision", String ("S"));
   33.67 +  Config::SetGlobal ("TimeStepPrecision", String ("MS"));
   33.68 +  Config::SetGlobal ("TimeStepPrecision", String ("US"));
   33.69 +  Config::SetGlobal ("TimeStepPrecision", String ("NS"));
   33.70 +  Config::SetGlobal ("TimeStepPrecision", String ("PS"));
   33.71 +  Config::SetGlobal ("TimeStepPrecision", String ("FS"));
   33.72  
   33.73  
   33.74    Time tooBig = TimeStep (0x8000000000000000LL);
    34.1 --- a/src/simulator/wscript	Mon Mar 10 00:26:54 2008 +0100
    34.2 +++ b/src/simulator/wscript	Mon Mar 10 00:27:53 2008 +0100
    34.3 @@ -53,7 +53,6 @@
    34.4          'time.cc',
    34.5          'event-id.cc',
    34.6          'scheduler.cc',
    34.7 -        'scheduler-factory.cc',
    34.8          'scheduler-list.cc',
    34.9          'scheduler-heap.cc',
   34.10          'scheduler-map.cc',
    35.1 --- a/utils/print-introspected-doxygen.cc	Mon Mar 10 00:26:54 2008 +0100
    35.2 +++ b/utils/print-introspected-doxygen.cc	Mon Mar 10 00:27:53 2008 +0100
    35.3 @@ -6,43 +6,11 @@
    35.4  #include "ns3/queue.h"
    35.5  #include "ns3/drop-tail-queue.h"
    35.6  #include "ns3/mobility-model-notifier.h"
    35.7 -#include "ns3/default-value.h"
    35.8  #include "ns3/string.h"
    35.9  
   35.10  using namespace ns3;
   35.11  
   35.12  
   35.13 -static void
   35.14 -PrintOneDefaultValue (DefaultValueBase *value, std::ostream &os)
   35.15 -{
   35.16 -  os << "///  <li> \\anchor DefaultValue" << value->GetName ()
   35.17 -     << " " << value->GetName () << std::endl;
   35.18 -  os << "///    <ul>" << std::endl;
   35.19 -  os << "///         <li>Type: " << value->GetType () << "</td></tr>" << std::endl;
   35.20 -  os << "///         <li>Default value: " << value->GetDefaultValue () << "</td></tr>" << std::endl;
   35.21 -  os << "///         <li>Description: " << value->GetHelp () << "</td></tr>" << std::endl;
   35.22 -  os << "///    </ul>" << std::endl;
   35.23 -  os << "///  </li>" << std::endl;
   35.24 -}
   35.25 -
   35.26 -static void
   35.27 -PrintDefaultValuesDoxygen (std::ostream &os)
   35.28 -{
   35.29 -  os << "/// \\page ListOfDefaultValues The list of default values" << std::endl;
   35.30 -  os << "/// \\defgroup ListOfDefaultValuesGroup The list of default values" << std::endl;
   35.31 -  os << "/// <ul>" << std::endl;
   35.32 -  for (DefaultValueList::Iterator i = DefaultValueList::Begin ();
   35.33 -       i != DefaultValueList::End (); i++)
   35.34 -    {
   35.35 -      if ((*i)->GetName () == "help")
   35.36 -	{
   35.37 -	  continue;
   35.38 -	}
   35.39 -      PrintOneDefaultValue (*i, os);
   35.40 -    }
   35.41 -  os << "/// </ul>" << std::endl;
   35.42 -}
   35.43 -
   35.44  
   35.45  int main (int argc, char *argv[])
   35.46  {
   35.47 @@ -60,7 +28,5 @@
   35.48    csma->AddQueue (CreateObject<DropTailQueue> ());
   35.49  
   35.50  
   35.51 -  PrintDefaultValuesDoxygen (std::cout);
   35.52 -
   35.53    return 0;
   35.54  }