src/core/config.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Sun, 02 Mar 2008 21:12:21 +0100
changeset 2532 86a40c7cbfe9
parent 2531 b451b5fc8b57
child 2569 d5cff2968984
permissions -rw-r--r--
register and unregister the NodeList as a config root namespace
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
#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
     2
#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
     3
#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
     4
#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
     5
#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
     6
#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
     7
#include <sstream>
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
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
    10
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
namespace ns3 {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
class ArrayMatcher
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
public:
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
  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
    17
  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
    18
private:
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
  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
    20
  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
    21
};
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
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
    25
  : 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
    26
{}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
bool 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
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
    29
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
  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
    31
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
      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
    33
      return true;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
  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
    36
  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
    37
  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
    38
    {
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 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
    40
      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
    41
      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
    42
      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
    43
	{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    44
	  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
    45
	  return true;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    46
	}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    47
      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
    48
      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
    49
	{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    50
	  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
    51
	  return true;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    52
	}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    53
      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
    54
      return false;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    55
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    56
  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
    57
  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
    58
  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
    59
  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
    60
      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
    61
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    62
      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
    63
      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
    64
      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
    65
      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
    66
      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
    67
	  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
    68
	  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
    69
        {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
	  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
    71
          return true;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    72
        }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    73
      else
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
	  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
    76
	  return false;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    77
	}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    78
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    79
  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
    80
  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
    81
      i == value)
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    82
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    83
      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
    84
      return true;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    85
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    86
  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
    87
  return false;
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
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    90
bool
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    91
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
    92
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    93
  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
    94
  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
    95
  iss >> (*value);
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    96
  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
    97
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    98
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    99
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   100
class Resolver
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
public:
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   103
  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
   104
  virtual ~Resolver ();
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   105
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   106
  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
   107
private:
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   108
  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
   109
  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
   110
  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
   111
  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
   112
  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
   113
  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
   114
  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
   115
};
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
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
   118
  : 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
   119
{}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   120
Resolver::~Resolver ()
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   121
{}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   122
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   123
void 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   124
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
   125
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   126
  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
   127
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   128
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   129
std::string
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   130
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
   131
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   132
  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
   133
  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
   134
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   135
      fullPath += "/" + *i;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   136
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   137
  fullPath += "/" + name;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   138
  return fullPath;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   139
}
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
void 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   142
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
   143
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   144
  NS_LOG_DEBUG ("resolved="<<GetResolvedPath (name));
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   145
  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
   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
void
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   149
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
   150
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   151
  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
   152
  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
   153
  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
   154
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   155
      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
   156
      return;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   157
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   158
  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
   159
  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
   160
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   161
      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
   162
      NS_LOG_DEBUG ("handle attr="<<attributeName);
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   163
      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
   164
      return;
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
  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
   167
  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
   168
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   169
  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
   170
  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
   171
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   172
      // 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
   173
      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
   174
      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
   175
      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
   176
      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
   177
      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
   178
	{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   179
	  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
   180
	  return;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   181
	}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   182
      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
   183
      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
   184
      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
   185
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   186
  else 
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
      // this is a normal attribute.
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   189
      TypeId tid = root->GetRealTypeId ();
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   190
      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
   191
      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
   192
	{
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 ("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
   194
	  return;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   195
	}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   196
      // 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
   197
      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
   198
      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
   199
	{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   200
	  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
   201
	  // 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
   202
	  // 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
   203
	  // object hierarchy.
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   204
	  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
   205
	  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
   206
	    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   207
	      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
   208
			    "\" 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
   209
			    " 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
   210
	      return;
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
	  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
   213
	  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
   214
	  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
   215
	}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   216
      // 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
   217
      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
   218
      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
   219
	{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   220
	  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
   221
	  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
   222
	  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
   223
	  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
   224
	  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
   225
	}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   226
      // 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
   227
      // 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
   228
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   229
}
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
void 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   232
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
   233
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   234
  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
   235
  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
   236
  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
   237
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   238
      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
   239
      return;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   240
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   241
  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
   242
  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
   243
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   244
      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
   245
      return;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   246
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   247
  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
   248
  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
   249
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   250
  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
   251
  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
   252
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   253
      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
   254
	{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   255
	  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
   256
	  oss << i;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   257
	  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
   258
	  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
   259
	  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
   260
	}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   261
    }
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
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   264
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   265
class ConfigImpl 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   266
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   267
public:
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   268
  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
   269
  void 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
   270
  void ConnectWithContext (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
   271
  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
   272
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   273
  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
   274
  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
   275
  
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   276
private:
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   277
  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
   278
  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
   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
void 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   282
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
   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 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
   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
    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
   288
      : Resolver (path),
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   289
	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
   290
  private:
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   291
    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
   292
      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
   293
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   294
    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
   295
  } 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
   296
  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
   297
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   298
      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
   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::Connect (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
   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 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
   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
    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
   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_cb (cb) {}
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->TraceSourceConnect (name, m_cb);
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
    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
   315
  } 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
   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 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   322
ConfigImpl::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
   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 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
   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
    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
   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) {
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   332
      object->TraceSourceDisconnect (name, m_cb);
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 = 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
   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 
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   342
ConfigImpl::ConnectWithContext (std::string path, const CallbackBase &cb)
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   343
{
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   344
  class ConnectWithContextResolver : public Resolver 
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   345
  {
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   346
  public:
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   347
    ConnectWithContextResolver (std::string path, const CallbackBase &cb)
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   348
      : Resolver (path),
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   349
	m_cb (cb) {}
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   350
  private:
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) {
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   352
      object->TraceSourceConnectWithContext (name, path, m_cb);
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   353
    }
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   354
    CallbackBase m_cb;
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   355
  } resolver = ConnectWithContextResolver (path, cb);
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   356
  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
   357
    {
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   358
      resolver.Resolve (*i);
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   359
    }
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   360
}
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   361
void 
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   362
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
   363
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   364
  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
   365
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   366
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   367
void 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   368
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
   369
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   370
  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
   371
    {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   372
      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
   373
	{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   374
	  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
   375
	  return;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   376
	}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   377
    }
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   378
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   379
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   380
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   381
namespace Config {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   382
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   383
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
   384
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   385
  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
   386
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   387
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
   388
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   389
  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
   390
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   391
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
   392
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   393
  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
   394
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   395
void Connect (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
   396
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   397
  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
   398
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   399
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
   400
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   401
  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
   402
}
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   403
void 
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   404
ConnectWithContext (std::string path, const CallbackBase &cb)
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   405
{
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   406
  Singleton<ConfigImpl>::Get ()->ConnectWithContext (path, cb);
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   407
}
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   408
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   409
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
   410
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   411
  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
   412
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   413
2532
86a40c7cbfe9 register and unregister the NodeList as a config root namespace
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2531
diff changeset
   414
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
   415
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   416
  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
   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
} // namespace Config
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 ns3
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
#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
   424
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   425
#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
   426
#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
   427
#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
   428
#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
   429
#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
   430
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   431
namespace ns3 {
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   432
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   433
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
   434
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   435
public:
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   436
  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
   437
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   438
  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
   439
  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
   440
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   441
  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
   442
  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
   443
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   444
  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
   445
  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
   446
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   447
private:
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   448
  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
   449
  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
   450
  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
   451
  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
   452
  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
   453
  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
   454
  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
   455
};
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   456
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   457
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
   458
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   459
  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
   460
    .SetParent<Object> ()
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   461
    .AddAttribute ("NodesA", "",
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   462
		   ObjectVector (),
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   463
		   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
   464
		   MakeObjectVectorChecker ())
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   465
    .AddAttribute ("NodesB", "",
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   466
		   ObjectVector (),
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   467
		   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
   468
		   MakeObjectVectorChecker ())
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   469
    .AddAttribute ("NodeA", "",
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   470
		   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
   471
		   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
   472
		   MakePtrChecker<MyNode> ())
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   473
    .AddAttribute ("NodeB", "",
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   474
		   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
   475
		   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
   476
		   MakePtrChecker<MyNode> ())
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   477
    .AddAttribute ("A", "",
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   478
		   Integer (10),
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   479
		   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
   480
		   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
   481
    .AddAttribute ("B", "",
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   482
		   Integer (9),
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   483
		   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
   484
		   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
   485
    .AddAttribute ("Source", "XX",
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   486
		   Integer (-1),
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   487
		   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
   488
		   MakeIntegerChecker<int16_t> ())
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   489
    .AddTraceSource ("Source", "XX",
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   490
		     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
   491
    ;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   492
  return tid;
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
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   495
void
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   496
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
   497
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   498
  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
   499
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   500
void
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   501
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
   502
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   503
  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
   504
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   505
void 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   506
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
   507
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   508
  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
   509
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   510
void 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   511
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
   512
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   513
  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
   514
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   515
int8_t 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   516
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
   517
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   518
  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
   519
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   520
int8_t 
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   521
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
   522
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   523
  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
   524
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   525
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   526
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   527
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
   528
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   529
public:
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   530
  ConfigTest ();
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   531
  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
   532
private:
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   533
  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
   534
  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
   535
  int16_t m_traceNotification;
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   536
  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
   537
};
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   538
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   539
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
   540
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   541
ConfigTest::ConfigTest ()
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   542
  : Test ("Config")
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   543
{}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   544
2504
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   545
void
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   546
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
   547
{
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   548
  m_traceNotification = newValue;
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   549
}
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   550
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   551
void 
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   552
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
   553
{
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   554
  m_traceNotification = newValue;
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   555
  m_tracePath = path;
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   556
}
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   557
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   558
bool
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   559
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
   560
{
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   561
  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
   562
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   563
  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
   564
  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
   565
  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
   566
  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
   567
  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
   568
  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
   569
  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
   570
  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
   571
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   572
  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
   573
  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
   574
  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
   575
  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
   576
  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
   577
  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
   578
  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
   579
  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
   580
  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
   581
  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
   582
  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
   583
  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
   584
  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
   585
  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
   586
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   587
  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
   588
  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
   589
  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
   590
  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
   591
  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
   592
  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
   593
  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
   594
  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
   595
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   596
  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
   597
  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
   598
  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
   599
  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
   600
  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
   601
  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
   602
  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
   603
  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
   604
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   605
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   606
  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
   607
  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
   608
  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
   609
  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
   610
  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
   611
  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
   612
  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
   613
  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
   614
  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
   615
  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
   616
  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
   617
  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
   618
  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
   619
  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
   620
  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
   621
  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
   622
  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
   623
  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
   624
  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
   625
  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
   626
  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
   627
  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
   628
  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
   629
  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
   630
  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
   631
  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
   632
  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
   633
  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
   634
  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
   635
  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
   636
  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
   637
  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
   638
  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
   639
  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
   640
  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
   641
  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
   642
  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
   643
  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
   644
  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
   645
  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
   646
  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
   647
  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
   648
  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
   649
  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
   650
  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
   651
  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
   652
  v = d1->GetAttribute ("A");
2479
7d1d80aea47b fix tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2475
diff changeset
   653
  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
   654
  v = d2->GetAttribute ("A");
2475
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2474
diff changeset
   655
  NS_TEST_ASSERT_EQUAL (v.Get (), -15);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2474
diff changeset
   656
  v = d3->GetAttribute ("A");
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2474
diff changeset
   657
  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
   658
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   659
2504
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   660
  Config::Connect ("/NodeA/NodeB/NodesB/[0-1]|3/Source", 
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   661
		   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
   662
  m_traceNotification = 0;
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   663
  // 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
   664
  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
   665
  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
   666
  m_traceNotification = 0;
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   667
  // 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
   668
  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
   669
  NS_TEST_ASSERT_EQUAL (m_traceNotification, -3);
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   670
  Config::Disconnect ("/NodeA/NodeB/NodesB/[0-1]|3/Source", 
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   671
		      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
   672
  m_traceNotification = 0;
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   673
  // 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
   674
  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
   675
  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
   676
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   677
  
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   678
  Config::ConnectWithContext ("/NodeA/NodeB/NodesB/[0-1]|3/Source", 
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   679
			      MakeCallback (&ConfigTest::ChangeNotificationWithPath, this));
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   680
  m_traceNotification = 0;
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   681
  // this should trigger no notification
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   682
  d2->SetAttribute ("Source", Integer (-2));
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   683
  NS_TEST_ASSERT_EQUAL (m_traceNotification, 0);
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   684
  m_traceNotification = 0;
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   685
  m_tracePath = "";
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   686
  // this should trigger a notification
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   687
  d1->SetAttribute ("Source", Integer (-3));
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   688
  NS_TEST_ASSERT_EQUAL (m_traceNotification, -3);
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   689
  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
   690
  m_traceNotification = 0;
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   691
  m_tracePath = "";
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   692
  // this should trigger a notification
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   693
  d3->SetAttribute ("Source", Integer (-3));
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   694
  NS_TEST_ASSERT_EQUAL (m_traceNotification, -3);
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   695
  NS_TEST_ASSERT_EQUAL (m_tracePath, "/NodeA/NodeB/NodesB/3/Source");
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   696
  // Yes, disconnection _cannot_ work with 'context-based connection.
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   697
  // XXX: what do we do about this ?
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   698
  Config::Disconnect ("/NodeA/NodeB/NodesB/[0-1]|3/Source", 
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   699
		      MakeCallback (&ConfigTest::ChangeNotificationWithPath, this));
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   700
  m_traceNotification = 0;
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   701
  // this should _not_ trigger a notification
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   702
  d1->SetAttribute ("Source", Integer (-4));
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   703
  NS_TEST_ASSERT_EQUAL (m_traceNotification, 0);
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2504
diff changeset
   704
2504
da3ec9cc3ba3 add example for trace connect/disconnection with trace paths
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2479
diff changeset
   705
2474
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   706
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   707
  return result;
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   708
}
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   709
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   710
} // namespace ns3
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
1d1f77782138 A Config class which hooks into the Object Attribute/Tracing system.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   713
#endif /* RUN_SELF_TEST */