src/core/config.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Sun, 16 Mar 2008 20:59:04 +0100
changeset 2634 44a92f1d3728
parent 2594 a8f89acd17a1
child 2718 9fe723baa16b
permissions -rw-r--r--
introduce ObjectBase::GetInstanceTypeId
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2586
50d78910a997 add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
50d78910a997 add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
     2
/*
50d78910a997 add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
     3
 * Copyright (c) 2008 INRIA
50d78910a997 add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
     4
 *
50d78910a997 add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
50d78910a997 add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
50d78910a997 add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
     7
 * published by the Free Software Foundation;
50d78910a997 add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
     8
 *
50d78910a997 add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
50d78910a997 add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
50d78910a997 add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
50d78910a997 add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
    12
 * GNU General Public License for more details.
50d78910a997 add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
    13
 *
50d78910a997 add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
    14
 * You should have received a copy of the GNU General Public License
50d78910a997 add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
    15
 * along with this program; if not, write to the Free Software
50d78910a997 add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
50d78910a997 add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
    17
 *
50d78910a997 add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
    18
 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
50d78910a997 add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
    19
 */
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
#include "config.h"
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
#include "singleton.h"
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
#include "object.h"
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
#include "global-value.h"
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
#include "object-vector.h"
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
#include "log.h"
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
#include <sstream>
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
NS_LOG_COMPONENT_DEFINE ("Config");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
namespace ns3 {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
class ArrayMatcher
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
public:
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
  ArrayMatcher (std::string element);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    36
  bool Matches (uint32_t i) const;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    37
private:
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    38
  bool StringToUint32 (std::string str, uint32_t *value) const;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    39
  std::string m_element;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    40
};
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    41
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    42
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    43
ArrayMatcher::ArrayMatcher (std::string element)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    44
  : m_element (element)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    45
{}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    46
bool 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    47
ArrayMatcher::Matches (uint32_t i) const
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    49
  if (m_element == "*")
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    50
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
      NS_LOG_DEBUG ("Array "<<i<<" matches *");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    52
      return true;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    53
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    54
  std::string::size_type tmp;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    55
  tmp = m_element.find ("|");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    56
  if (tmp != std::string::npos)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    57
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    58
      std::string left = m_element.substr (0, tmp-0);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    59
      std::string right = m_element.substr (tmp+1, m_element.size () - (tmp + 1));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    60
      ArrayMatcher matcher = ArrayMatcher (left);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    61
      if (matcher.Matches (i))
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    62
	{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    63
	  NS_LOG_DEBUG ("Array "<<i<<" matches "<<left);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    64
	  return true;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    65
	}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    66
      matcher = ArrayMatcher (right);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    67
      if (matcher.Matches (i))
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
	{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    69
	  NS_LOG_DEBUG ("Array "<<i<<" matches "<<right);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
	  return true;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
	}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    72
      NS_LOG_DEBUG ("Array "<<i<<" does not match "<<m_element);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    73
      return false;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    74
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    75
  std::string::size_type leftBracket = m_element.find ("[");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    76
  std::string::size_type rightBracket = m_element.find ("]");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    77
  std::string::size_type dash = m_element.find ("-");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    78
  if (leftBracket == 0 && rightBracket == m_element.size () - 1 &&
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    79
      dash > leftBracket && dash < rightBracket)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    80
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    81
      std::string lowerBound = m_element.substr (leftBracket + 1, dash - (leftBracket + 1));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    82
      std::string upperBound = m_element.substr (dash + 1, rightBracket - (dash + 1));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    83
      uint32_t min;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    84
      uint32_t max;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    85
      if (StringToUint32 (lowerBound, &min) && 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    86
	  StringToUint32 (upperBound, &max) &&
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    87
	  i >= min && i <= max)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    88
        {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    89
	  NS_LOG_DEBUG ("Array "<<i<<" matches "<<m_element);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    90
          return true;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    91
        }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    92
      else
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    93
	{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    94
	  NS_LOG_DEBUG ("Array "<<i<<" does not "<<m_element);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    95
	  return false;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    96
	}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    97
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    98
  uint32_t value;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    99
  if (StringToUint32 (m_element, &value) &&
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   100
      i == value)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   101
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   102
      NS_LOG_DEBUG ("Array "<<i<<" matches "<<m_element);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   103
      return true;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   104
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   105
  NS_LOG_DEBUG ("Array "<<i<<" does not match "<<m_element);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   106
  return false;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   107
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   108
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   109
bool
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   110
ArrayMatcher::StringToUint32 (std::string str, uint32_t *value) const
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   111
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   112
  std::istringstream iss;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   113
  iss.str (str);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   114
  iss >> (*value);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   115
  return !iss.bad () && !iss.fail ();
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   116
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   117
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   118
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   119
class Resolver
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   120
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   121
public:
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   122
  Resolver (std::string path);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   123
  virtual ~Resolver ();
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   124
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   125
  void Resolve (Ptr<Object> root);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   126
private:
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   127
  void DoResolve (std::string path, Ptr<Object> root);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   128
  void DoArrayResolve (std::string path, const ObjectVector &vector);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   129
  void DoResolveOne (Ptr<Object> object, std::string name);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   130
  std::string GetResolvedPath (std::string name) const;
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   131
  virtual void DoOne (Ptr<Object> object, std::string path, std::string name) = 0;
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   132
  std::vector<std::string> m_workStack;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   133
  std::string m_path;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   134
};
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   135
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   136
Resolver::Resolver (std::string path)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   137
  : m_path (path)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   138
{}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   139
Resolver::~Resolver ()
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   140
{}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   141
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   142
void 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   143
Resolver::Resolve (Ptr<Object> root)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   144
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   145
  DoResolve (m_path, root);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   146
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   147
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   148
std::string
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   149
Resolver::GetResolvedPath (std::string name) const
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   150
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   151
  std::string fullPath = "";
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   152
  for (std::vector<std::string>::const_iterator i = m_workStack.begin (); i != m_workStack.end (); i++)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   153
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   154
      fullPath += "/" + *i;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   155
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   156
  fullPath += "/" + name;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   157
  return fullPath;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   158
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   159
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   160
void 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   161
Resolver::DoResolveOne (Ptr<Object> object, std::string name)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   162
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   163
  NS_LOG_DEBUG ("resolved="<<GetResolvedPath (name));
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   164
  DoOne (object, GetResolvedPath (name), name);
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   165
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   166
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   167
void
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   168
Resolver::DoResolve (std::string path, Ptr<Object> root)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   169
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   170
  NS_ASSERT (path != "");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   171
  std::string::size_type pos = path.find ("/");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   172
  if (pos != 0)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   173
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   174
      NS_FATAL_ERROR ("path does not start with a \"/\": \""<<path<<"\"");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   175
      return;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   176
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   177
  std::string::size_type next = path.find ("/", 1);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   178
  if (next == std::string::npos)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   179
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   180
      std::string attributeName = path.substr (1, path.size ()-1);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   181
      NS_LOG_DEBUG ("handle attr="<<attributeName);
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   182
      DoOne (root, GetResolvedPath (attributeName), attributeName);
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   183
      return;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   184
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   185
  std::string item = path.substr (1, next-1);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   186
  std::string pathLeft = path.substr (next, path.size ()-next);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   187
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   188
  std::string::size_type dollarPos = item.find ("$");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   189
  if (dollarPos == 0)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   190
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   191
      // This is a call to GetObject
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   192
      std::string tidString = item.substr (1, item.size () - 1);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   193
      NS_LOG_DEBUG ("GetObject="<<tidString<<"on path="<<GetResolvedPath (""));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   194
      TypeId tid = TypeId::LookupByName (tidString);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   195
      Ptr<Object> object = root->GetObject<Object> (tid);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   196
      if (object == 0)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   197
	{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   198
	  NS_LOG_DEBUG ("GetObject ("<<tidString<<") failed on path="<<GetResolvedPath (""));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   199
	  return;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   200
	}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   201
      m_workStack.push_back (item);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   202
      DoResolve (pathLeft, object);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   203
      m_workStack.pop_back ();
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   204
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   205
  else 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   206
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   207
      // this is a normal attribute.
2634
44a92f1d3728 introduce ObjectBase::GetInstanceTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2594
diff changeset
   208
      TypeId tid = root->GetInstanceTypeId ();
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   209
      struct TypeId::AttributeInfo info;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   210
      if (!tid.LookupAttributeByName (item, &info))
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   211
	{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   212
	  NS_LOG_DEBUG ("Requested item="<<item<<" does not exist on path="<<GetResolvedPath (""));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   213
	  return;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   214
	}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   215
      // attempt to cast to a pointer checker.
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   216
      const PtrChecker *ptr = dynamic_cast<const PtrChecker *> (PeekPointer (info.checker));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   217
      if (ptr != 0)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   218
	{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   219
	  NS_LOG_DEBUG ("GetAttribute(ptr)="<<item<<" on path="<<GetResolvedPath (""));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   220
	  // XXX: This is not completely right because anything could be stored in a
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   221
	  // Ptr<>. We really need to fix this by thinking seriously about our
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   222
	  // object hierarchy.
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   223
	  Ptr<Object> object = root->GetAttribute (item);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   224
	  if (object == 0)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   225
	    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   226
	      NS_LOG_ERROR ("Requested object name=\""<<item<<
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   227
			    "\" exists on path=\""<<GetResolvedPath ("")<<"\""
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   228
			    " but is null.");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   229
	      return;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   230
	    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   231
	  m_workStack.push_back (item);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   232
	  DoResolve (pathLeft, object);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   233
	  m_workStack.pop_back ();
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   234
	}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   235
      // attempt to cast to an object vector.
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   236
      const ObjectVectorChecker *vectorChecker = dynamic_cast<const ObjectVectorChecker *> (PeekPointer (info.checker));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   237
      if (vectorChecker != 0)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   238
	{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   239
	  NS_LOG_DEBUG ("GetAttribute(vector)="<<item<<" on path="<<GetResolvedPath (""));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   240
	  ObjectVector vector = root->GetAttribute (item);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   241
	  m_workStack.push_back (item);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   242
	  DoArrayResolve (pathLeft, vector);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   243
	  m_workStack.pop_back ();
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   244
	}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   245
      // this could be anything else and we don't know what to do with it.
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   246
      // So, we just ignore it.
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   247
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   248
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   249
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   250
void 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   251
Resolver::DoArrayResolve (std::string path, const ObjectVector &vector)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   252
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   253
  NS_ASSERT (path != "");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   254
  std::string::size_type pos = path.find ("/");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   255
  if (pos != 0)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   256
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   257
      NS_FATAL_ERROR ("path does not start with a \"/\": \""<<path<<"\"");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   258
      return;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   259
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   260
  std::string::size_type next = path.find ("/", 1);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   261
  if (next == std::string::npos)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   262
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   263
      NS_LOG_DEBUG ("vector path includes no index data on path=\""<<path<<"\"");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   264
      return;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   265
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   266
  std::string item = path.substr (1, next-1);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   267
  std::string pathLeft = path.substr (next, path.size ()-next);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   268
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   269
  ArrayMatcher matcher = ArrayMatcher (item);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   270
  for (uint32_t i = 0; i < vector.GetN (); i++)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   271
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   272
      if (matcher.Matches (i))
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   273
	{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   274
	  std::ostringstream oss;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   275
	  oss << i;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   276
	  m_workStack.push_back (oss.str ());
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   277
	  DoResolve (pathLeft, vector.Get (i));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   278
	  m_workStack.pop_back ();
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   279
	}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   280
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   281
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   282
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   283
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   284
class ConfigImpl 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   285
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   286
public:
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   287
  void Set (std::string path, Attribute value);
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   288
  void ConnectWithoutContext (std::string path, const CallbackBase &cb);
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   289
  void Connect (std::string path, const CallbackBase &cb);
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   290
  void DisconnectWithoutContext (std::string path, const CallbackBase &cb);
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   291
  void Disconnect (std::string path, const CallbackBase &cb);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   292
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   293
  void RegisterRootNamespaceObject (Ptr<Object> obj);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   294
  void UnregisterRootNamespaceObject (Ptr<Object> obj);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   295
  
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   296
private:
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   297
  typedef std::vector<Ptr<Object> > Roots;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   298
  Roots m_roots;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   299
};
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   300
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   301
void 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   302
ConfigImpl::Set (std::string path, Attribute value)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   303
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   304
  class SetResolver : public Resolver 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   305
  {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   306
  public:
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   307
    SetResolver (std::string path, Attribute value)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   308
      : Resolver (path),
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   309
	m_value (value) {}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   310
  private:
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   311
    virtual void DoOne (Ptr<Object> object, std::string path, std::string name) {
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   312
      object->SetAttribute (name, m_value);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   313
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   314
    Attribute m_value;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   315
  } resolver = SetResolver (path, value);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   316
  for (Roots::const_iterator i = m_roots.begin (); i != m_roots.end (); i++)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   317
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   318
      resolver.Resolve (*i);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   319
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   320
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   321
void 
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   322
ConfigImpl::ConnectWithoutContext (std::string path, const CallbackBase &cb)
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   323
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   324
  class ConnectResolver : public Resolver 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   325
  {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   326
  public:
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   327
    ConnectResolver (std::string path, const CallbackBase &cb)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   328
      : Resolver (path),
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   329
	m_cb (cb) {}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   330
  private:
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   331
    virtual void DoOne (Ptr<Object> object, std::string path, std::string name) {
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   332
      object->TraceConnectWithoutContext (name, m_cb);
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   333
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   334
    CallbackBase m_cb;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   335
  } resolver = ConnectResolver (path, cb);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   336
  for (Roots::const_iterator i = m_roots.begin (); i != m_roots.end (); i++)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   337
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   338
      resolver.Resolve (*i);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   339
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   340
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   341
void 
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   342
ConfigImpl::DisconnectWithoutContext (std::string path, const CallbackBase &cb)
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   343
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   344
  class DisconnectResolver : public Resolver 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   345
  {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   346
  public:
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   347
    DisconnectResolver (std::string path, const CallbackBase &cb)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   348
      : Resolver (path),
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   349
	m_cb (cb) {}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   350
  private:
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   351
    virtual void DoOne (Ptr<Object> object, std::string path, std::string name) {
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   352
      object->TraceDisconnectWithoutContext (name, m_cb);
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   353
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   354
    CallbackBase m_cb;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   355
  } resolver = DisconnectResolver (path, cb);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   356
  for (Roots::const_iterator i = m_roots.begin (); i != m_roots.end (); i++)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   357
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   358
      resolver.Resolve (*i);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   359
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   360
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   361
void 
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   362
ConfigImpl::Connect (std::string path, const CallbackBase &cb)
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   363
{
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   364
  class ConnectWithContextResolver : public Resolver 
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   365
  {
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   366
  public:
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   367
    ConnectWithContextResolver (std::string path, const CallbackBase &cb)
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   368
      : Resolver (path),
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   369
	m_cb (cb) {}
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   370
  private:
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   371
    virtual void DoOne (Ptr<Object> object, std::string path, std::string name) {
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   372
      object->TraceConnectWithoutContext (name, path, m_cb);
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   373
    }
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   374
    CallbackBase m_cb;
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   375
  } resolver = ConnectWithContextResolver (path, cb);
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   376
  for (Roots::const_iterator i = m_roots.begin (); i != m_roots.end (); i++)
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   377
    {
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   378
      resolver.Resolve (*i);
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   379
    }
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   380
}
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   381
void 
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   382
ConfigImpl::Disconnect (std::string path, const CallbackBase &cb)
2569
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2532
diff changeset
   383
{
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2532
diff changeset
   384
  class DisconnectWithContextResolver : public Resolver 
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2532
diff changeset
   385
  {
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2532
diff changeset
   386
  public:
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2532
diff changeset
   387
    DisconnectWithContextResolver (std::string path, const CallbackBase &cb)
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2532
diff changeset
   388
      : Resolver (path),
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2532
diff changeset
   389
	m_cb (cb) {}
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2532
diff changeset
   390
  private:
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2532
diff changeset
   391
    virtual void DoOne (Ptr<Object> object, std::string path, std::string name) {
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   392
      object->TraceDisconnectWithoutContext (name, path, m_cb);
2569
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2532
diff changeset
   393
    }
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2532
diff changeset
   394
    CallbackBase m_cb;
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2532
diff changeset
   395
  } resolver = DisconnectWithContextResolver (path, cb);
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2532
diff changeset
   396
  for (Roots::const_iterator i = m_roots.begin (); i != m_roots.end (); i++)
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2532
diff changeset
   397
    {
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2532
diff changeset
   398
      resolver.Resolve (*i);
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2532
diff changeset
   399
    }
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2532
diff changeset
   400
}
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2532
diff changeset
   401
void 
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   402
ConfigImpl::RegisterRootNamespaceObject (Ptr<Object> obj)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   403
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   404
  m_roots.push_back (obj);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   405
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   406
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   407
void 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   408
ConfigImpl::UnregisterRootNamespaceObject (Ptr<Object> obj)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   409
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   410
  for (std::vector<Ptr<Object> >::iterator i = m_roots.begin (); i != m_roots.end (); i++)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   411
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   412
      if (*i == obj)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   413
	{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   414
	  m_roots.erase (i);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   415
	  return;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   416
	}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   417
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   418
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   419
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   420
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   421
namespace Config {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   422
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   423
void Set (std::string path, Attribute value)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   424
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   425
  Singleton<ConfigImpl>::Get ()->Set (path, value);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   426
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   427
void SetDefault (std::string name, Attribute value)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   428
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   429
  AttributeList::GetGlobal ()->Set (name, value);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   430
}
2570
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   431
bool SetDefaultFailSafe (std::string name, Attribute value)
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   432
{
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   433
  return AttributeList::GetGlobal ()->SetFailSafe (name, value);
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   434
}
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   435
void SetGlobal (std::string name, Attribute value)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   436
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   437
  GlobalValue::Bind (name, value);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   438
}
2570
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   439
bool SetGlobalFailSafe (std::string name, Attribute value)
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   440
{
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   441
  return GlobalValue::BindFailSafe (name, value);
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   442
}
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   443
void ConnectWithoutContext (std::string path, const CallbackBase &cb)
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   444
{
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   445
  Singleton<ConfigImpl>::Get ()->ConnectWithoutContext (path, cb);
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   446
}
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   447
void DisconnectWithoutContext (std::string path, const CallbackBase &cb)
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   448
{
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   449
  Singleton<ConfigImpl>::Get ()->DisconnectWithoutContext (path, cb);
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   450
}
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   451
void 
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   452
Connect (std::string path, const CallbackBase &cb)
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   453
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   454
  Singleton<ConfigImpl>::Get ()->Connect (path, cb);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   455
}
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   456
void 
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   457
Disconnect (std::string path, const CallbackBase &cb)
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   458
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   459
  Singleton<ConfigImpl>::Get ()->Disconnect (path, cb);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   460
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   461
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   462
void RegisterRootNamespaceObject (Ptr<Object> obj)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   463
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   464
  Singleton<ConfigImpl>::Get ()->RegisterRootNamespaceObject (obj);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   465
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   466
2532
86a40c7cbfe9 register and unregister the NodeList as a config root namespace
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2531
diff changeset
   467
void UnregisterRootNamespaceObject (Ptr<Object> obj)
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   468
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   469
  Singleton<ConfigImpl>::Get ()->UnregisterRootNamespaceObject (obj);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   470
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   471
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   472
} // namespace Config
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   473
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   474
} // namespace ns3
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   475
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   476
#ifdef RUN_SELF_TESTS
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   477
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   478
#include "test.h"
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   479
#include "integer.h"
2504
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   480
#include "traced-value.h"
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   481
#include "trace-source-accessor.h"
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   482
#include "callback.h"
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   483
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   484
namespace ns3 {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   485
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   486
class MyNode : public Object
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   487
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   488
public:
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   489
  static TypeId GetTypeId (void);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   490
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   491
  void AddNodeA (Ptr<MyNode> a);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   492
  void AddNodeB (Ptr<MyNode> b);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   493
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   494
  void SetNodeA (Ptr<MyNode> a);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   495
  void SetNodeB (Ptr<MyNode> b);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   496
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   497
  int8_t GetA (void) const;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   498
  int8_t GetB (void) const;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   499
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   500
private:
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   501
  std::vector<Ptr<MyNode> > m_nodesA;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   502
  std::vector<Ptr<MyNode> > m_nodesB;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   503
  Ptr<MyNode> m_nodeA;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   504
  Ptr<MyNode> m_nodeB;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   505
  int8_t m_a;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   506
  int8_t m_b;
2504
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   507
  TracedValue<int16_t> m_trace;
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   508
};
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   509
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   510
TypeId MyNode::GetTypeId (void)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   511
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   512
  static TypeId tid = TypeId ("MyNode")
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   513
    .SetParent<Object> ()
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   514
    .AddAttribute ("NodesA", "",
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   515
		   ObjectVector (),
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   516
		   MakeObjectVectorAccessor (&MyNode::m_nodesA),
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   517
		   MakeObjectVectorChecker ())
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   518
    .AddAttribute ("NodesB", "",
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   519
		   ObjectVector (),
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   520
		   MakeObjectVectorAccessor (&MyNode::m_nodesB),
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   521
		   MakeObjectVectorChecker ())
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   522
    .AddAttribute ("NodeA", "",
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   523
		   Ptr<MyNode> (0),
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   524
		   MakePtrAccessor (&MyNode::m_nodeA),
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   525
		   MakePtrChecker<MyNode> ())
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   526
    .AddAttribute ("NodeB", "",
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   527
		   Ptr<MyNode> (0),
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   528
		   MakePtrAccessor (&MyNode::m_nodeB),
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   529
		   MakePtrChecker<MyNode> ())
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   530
    .AddAttribute ("A", "",
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   531
		   Integer (10),
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   532
		   MakeIntegerAccessor (&MyNode::m_a),
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   533
		   MakeIntegerChecker<int8_t> ())
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   534
    .AddAttribute ("B", "",
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   535
		   Integer (9),
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   536
		   MakeIntegerAccessor (&MyNode::m_b),
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   537
		   MakeIntegerChecker<int8_t> ())
2504
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   538
    .AddAttribute ("Source", "XX",
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   539
		   Integer (-1),
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   540
		   MakeIntegerAccessor (&MyNode::m_trace),
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   541
		   MakeIntegerChecker<int16_t> ())
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   542
    .AddTraceSource ("Source", "XX",
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   543
		     MakeTraceSourceAccessor (&MyNode::m_trace))
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   544
    ;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   545
  return tid;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   546
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   547
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   548
void
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   549
MyNode::SetNodeA (Ptr<MyNode> a)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   550
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   551
  m_nodeA = a;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   552
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   553
void
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   554
MyNode::SetNodeB (Ptr<MyNode> b)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   555
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   556
  m_nodeB = b;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   557
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   558
void 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   559
MyNode::AddNodeA (Ptr<MyNode> a)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   560
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   561
  m_nodesA.push_back (a);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   562
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   563
void 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   564
MyNode::AddNodeB (Ptr<MyNode> b)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   565
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   566
  m_nodesB.push_back (b);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   567
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   568
int8_t 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   569
MyNode::GetA (void) const
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   570
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   571
  return m_a;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   572
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   573
int8_t 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   574
MyNode::GetB (void) const
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   575
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   576
  return m_b;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   577
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   578
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   579
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   580
class ConfigTest : public Test
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   581
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   582
public:
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   583
  ConfigTest ();
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   584
  virtual bool RunTests (void);
2504
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   585
private:
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   586
  void ChangeNotification (int16_t old, int16_t newValue);
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   587
  void ChangeNotificationWithPath (std::string path, int16_t old, int16_t newValue);
2504
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   588
  int16_t m_traceNotification;
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   589
  std::string m_tracePath;
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   590
};
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   591
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   592
static ConfigTest g_configTestUnique;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   593
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   594
ConfigTest::ConfigTest ()
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   595
  : Test ("Config")
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   596
{}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   597
2504
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   598
void
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   599
ConfigTest::ChangeNotification (int16_t oldValue, int16_t newValue)
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   600
{
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   601
  m_traceNotification = newValue;
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   602
}
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   603
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   604
void 
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   605
ConfigTest::ChangeNotificationWithPath (std::string path, int16_t old, int16_t newValue)
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   606
{
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   607
  m_traceNotification = newValue;
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   608
  m_tracePath = path;
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   609
}
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   610
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   611
bool
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   612
ConfigTest::RunTests (void)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   613
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   614
  bool result = true;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   615
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   616
  Ptr<MyNode> root = CreateObject<MyNode> ();
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   617
  Config::RegisterRootNamespaceObject (root);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   618
  Config::Set ("/A", Integer (1));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   619
  Config::Set ("/B", Integer (-1));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   620
  Integer v = root->GetAttribute ("A");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   621
  NS_TEST_ASSERT_EQUAL (v.Get (), 1);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   622
  v = root->GetAttribute ("B");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   623
  NS_TEST_ASSERT_EQUAL (v.Get (), -1);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   624
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   625
  Ptr<MyNode> a = CreateObject<MyNode> ();
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   626
  root->SetNodeA (a);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   627
  Config::Set ("/NodeA/A", Integer (2));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   628
  Config::Set ("/NodeA/B", Integer (-2));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   629
  v = a->GetAttribute ("A");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   630
  NS_TEST_ASSERT_EQUAL (v.Get (), 2);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   631
  v = a->GetAttribute ("B");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   632
  NS_TEST_ASSERT_EQUAL (v.Get (), -2);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   633
  Config::Set ("/NodeB/A", Integer (3));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   634
  Config::Set ("/NodeB/B", Integer (-3));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   635
  v = a->GetAttribute ("A");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   636
  NS_TEST_ASSERT_EQUAL (v.Get (), 2);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   637
  v = a->GetAttribute ("B");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   638
  NS_TEST_ASSERT_EQUAL (v.Get (), -2);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   639
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   640
  Ptr<MyNode> b = CreateObject<MyNode> ();
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   641
  a->SetNodeB (b);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   642
  Config::Set ("/NodeA/NodeB/A", Integer (4));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   643
  Config::Set ("/NodeA/NodeB/B", Integer (-4));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   644
  v = b->GetAttribute ("A");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   645
  NS_TEST_ASSERT_EQUAL (v.Get (), 4);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   646
  v = b->GetAttribute ("B");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   647
  NS_TEST_ASSERT_EQUAL (v.Get (), -4);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   648
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   649
  Ptr<MyNode> c = CreateObject<MyNode> ();
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   650
  root->SetNodeB (c);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   651
  Config::Set ("/NodeB/A", Integer (5));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   652
  Config::Set ("/NodeB/B", Integer (-5));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   653
  v = c->GetAttribute ("A");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   654
  NS_TEST_ASSERT_EQUAL (v.Get (), 5);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   655
  v = c->GetAttribute ("B");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   656
  NS_TEST_ASSERT_EQUAL (v.Get (), -5);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   657
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   658
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   659
  Ptr<MyNode> d0 = CreateObject<MyNode> ();
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   660
  Ptr<MyNode> d1 = CreateObject<MyNode> ();
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   661
  Ptr<MyNode> d2 = CreateObject<MyNode> ();
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   662
  Ptr<MyNode> d3 = CreateObject<MyNode> ();
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   663
  b->AddNodeB (d0);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   664
  b->AddNodeB (d1);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   665
  b->AddNodeB (d2);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   666
  b->AddNodeB (d3);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   667
  Config::Set ("/NodeA/NodeB/NodesB/0/A", Integer (-11));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   668
  v = d0->GetAttribute ("A");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   669
  NS_TEST_ASSERT_EQUAL (v.Get (), -11);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   670
  v = d0->GetAttribute ("B");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   671
  NS_TEST_ASSERT_EQUAL (v.Get (), 9);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   672
  v = d1->GetAttribute ("A");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   673
  NS_TEST_ASSERT_EQUAL (v.Get (), 10);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   674
  v = d1->GetAttribute ("B");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   675
  NS_TEST_ASSERT_EQUAL (v.Get (), 9);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   676
  Config::Set ("/NodeA/NodeB/NodesB/0|1/A", Integer (-12));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   677
  v = d0->GetAttribute ("A");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   678
  NS_TEST_ASSERT_EQUAL (v.Get (), -12);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   679
  v = d1->GetAttribute ("A");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   680
  NS_TEST_ASSERT_EQUAL (v.Get (), -12);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   681
  Config::Set ("/NodeA/NodeB/NodesB/|0|1|/A", Integer (-13));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   682
  v = d0->GetAttribute ("A");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   683
  NS_TEST_ASSERT_EQUAL (v.Get (), -13);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   684
  v = d1->GetAttribute ("A");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   685
  NS_TEST_ASSERT_EQUAL (v.Get (), -13);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   686
  Config::Set ("/NodeA/NodeB/NodesB/[0-2]/A", Integer (-14));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   687
  v = d0->GetAttribute ("A");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   688
  NS_TEST_ASSERT_EQUAL (v.Get (), -14);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   689
  v = d1->GetAttribute ("A");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   690
  NS_TEST_ASSERT_EQUAL (v.Get (), -14);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   691
  v = d2->GetAttribute ("A");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   692
  NS_TEST_ASSERT_EQUAL (v.Get (), -14);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   693
  Config::Set ("/NodeA/NodeB/NodesB/[1-3]/A", Integer (-15));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   694
  v = d0->GetAttribute ("A");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   695
  NS_TEST_ASSERT_EQUAL (v.Get (), -14);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   696
  v = d1->GetAttribute ("A");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   697
  NS_TEST_ASSERT_EQUAL (v.Get (), -15);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   698
  v = d2->GetAttribute ("A");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   699
  NS_TEST_ASSERT_EQUAL (v.Get (), -15);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   700
  v = d3->GetAttribute ("A");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   701
  NS_TEST_ASSERT_EQUAL (v.Get (), -15);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   702
  Config::Set ("/NodeA/NodeB/NodesB/[0-1]|3/A", Integer (-16));
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   703
  v = d0->GetAttribute ("A");
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   704
  NS_TEST_ASSERT_EQUAL (v.Get (), -16);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   705
  v = d1->GetAttribute ("A");
2479
7d1d80aea47b fix tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2475
diff changeset
   706
  NS_TEST_ASSERT_EQUAL (v.Get (), -16);
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   707
  v = d2->GetAttribute ("A");
2475
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2474
diff changeset
   708
  NS_TEST_ASSERT_EQUAL (v.Get (), -15);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2474
diff changeset
   709
  v = d3->GetAttribute ("A");
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2474
diff changeset
   710
  NS_TEST_ASSERT_EQUAL (v.Get (), -16);
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   711
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   712
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   713
  Config::ConnectWithoutContext ("/NodeA/NodeB/NodesB/[0-1]|3/Source", 
2504
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   714
		   MakeCallback (&ConfigTest::ChangeNotification, this));
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   715
  m_traceNotification = 0;
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   716
  // this should trigger no notification
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   717
  d2->SetAttribute ("Source", Integer (-2));
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   718
  NS_TEST_ASSERT_EQUAL (m_traceNotification, 0);
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   719
  m_traceNotification = 0;
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   720
  // this should trigger a notification
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   721
  d1->SetAttribute ("Source", Integer (-3));
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   722
  NS_TEST_ASSERT_EQUAL (m_traceNotification, -3);
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   723
  Config::DisconnectWithoutContext ("/NodeA/NodeB/NodesB/[0-1]|3/Source", 
2504
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   724
		      MakeCallback (&ConfigTest::ChangeNotification, this));
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   725
  m_traceNotification = 0;
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   726
  // this should _not_ trigger a notification
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   727
  d1->SetAttribute ("Source", Integer (-4));
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   728
  NS_TEST_ASSERT_EQUAL (m_traceNotification, 0);
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   729
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   730
  
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   731
  Config::Connect ("/NodeA/NodeB/NodesB/[0-1]|3/Source", 
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   732
			      MakeCallback (&ConfigTest::ChangeNotificationWithPath, this));
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   733
  m_traceNotification = 0;
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   734
  // this should trigger no notification
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   735
  d2->SetAttribute ("Source", Integer (-2));
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   736
  NS_TEST_ASSERT_EQUAL (m_traceNotification, 0);
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   737
  m_traceNotification = 0;
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   738
  m_tracePath = "";
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   739
  // this should trigger a notification
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   740
  d1->SetAttribute ("Source", Integer (-3));
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   741
  NS_TEST_ASSERT_EQUAL (m_traceNotification, -3);
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   742
  NS_TEST_ASSERT_EQUAL (m_tracePath, "/NodeA/NodeB/NodesB/1/Source")
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   743
  m_traceNotification = 0;
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   744
  m_tracePath = "";
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   745
  // this should trigger a notification
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   746
  d3->SetAttribute ("Source", Integer (-3));
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   747
  NS_TEST_ASSERT_EQUAL (m_traceNotification, -3);
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   748
  NS_TEST_ASSERT_EQUAL (m_tracePath, "/NodeA/NodeB/NodesB/3/Source");
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
   749
  Config::Disconnect ("/NodeA/NodeB/NodesB/[0-1]|3/Source", 
2569
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2532
diff changeset
   750
				 MakeCallback (&ConfigTest::ChangeNotificationWithPath, this));
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   751
  m_traceNotification = 0;
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   752
  // this should _not_ trigger a notification
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   753
  d1->SetAttribute ("Source", Integer (-4));
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   754
  NS_TEST_ASSERT_EQUAL (m_traceNotification, 0);
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   755
2504
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   756
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   757
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   758
  return result;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   759
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   760
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   761
} // namespace ns3
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   762
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   763
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   764
#endif /* RUN_SELF_TEST */