src/core/debug.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Fri, 16 Feb 2007 09:56:21 +0100
changeset 286 57e6a2006962
parent 280 2fe90883716a
child 385 d1dfc983f7c3
permissions -rw-r--r--
convert use of <cassert> to "ns3/assert.h"
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
265
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2006 INRIA
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
 * All rights reserved.
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 *
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * it under the terms of the GNU General Public License version 2 as
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 * published by the Free Software Foundation;
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 *
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 * GNU General Public License for more details.
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 *
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * along with this program; if not, write to the Free Software
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
 *
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
 */
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
#include <list>
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
#include <utility>
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
#include <iostream>
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
#include "debug.h"
286
57e6a2006962 convert use of <cassert> to "ns3/assert.h"
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 280
diff changeset
    25
#include "assert.h"
265
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
#include "ns3/core-config.h"
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
#ifdef HAVE_STDLIB_H
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
#include <stdlib.h>
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
#endif
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
namespace ns3 {
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
typedef std::list<std::pair <std::string, DebugComponent *> > ComponentList;
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
typedef std::list<std::pair <std::string, DebugComponent *> >::iterator ComponentListI;
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    36
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    37
static ComponentList g_components;
266
a451b8daa1e6 remove EnableEnvVar function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 265
diff changeset
    38
static bool g_firstDebug = true;
a451b8daa1e6 remove EnableEnvVar function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 265
diff changeset
    39
a451b8daa1e6 remove EnableEnvVar function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 265
diff changeset
    40
void
a451b8daa1e6 remove EnableEnvVar function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 265
diff changeset
    41
DebugComponentEnableEnvVar (void)
a451b8daa1e6 remove EnableEnvVar function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 265
diff changeset
    42
{
a451b8daa1e6 remove EnableEnvVar function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 265
diff changeset
    43
#ifdef HAVE_GETENV
a451b8daa1e6 remove EnableEnvVar function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 265
diff changeset
    44
  char *envVar = getenv("NS3_DEBUG");
a451b8daa1e6 remove EnableEnvVar function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 265
diff changeset
    45
  if (envVar == 0)
a451b8daa1e6 remove EnableEnvVar function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 265
diff changeset
    46
    {
a451b8daa1e6 remove EnableEnvVar function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 265
diff changeset
    47
      return;
a451b8daa1e6 remove EnableEnvVar function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 265
diff changeset
    48
    }
a451b8daa1e6 remove EnableEnvVar function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 265
diff changeset
    49
  std::string env = envVar;
a451b8daa1e6 remove EnableEnvVar function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 265
diff changeset
    50
  std::string::size_type cur = 0;
a451b8daa1e6 remove EnableEnvVar function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 265
diff changeset
    51
  std::string::size_type next = 0;
a451b8daa1e6 remove EnableEnvVar function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 265
diff changeset
    52
  while (true)
a451b8daa1e6 remove EnableEnvVar function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 265
diff changeset
    53
    {
a451b8daa1e6 remove EnableEnvVar function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 265
diff changeset
    54
      next = env.find_first_of (";", cur);
268
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    55
      std::string tmp = std::string (env, cur, next);
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    56
      {
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    57
        /* The following code is a workaround for a bug in the g++
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    58
         * c++ string library. Its goal is to remove any trailing ';'
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    59
         * from the string even though there should not be any in
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    60
         * it. This code should be safe even if the bug is not there.
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    61
         */
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    62
        std::string::size_type trailing = tmp.find_first_of (";");
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    63
        tmp = tmp.substr (0, trailing);
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    64
      }
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    65
      if (tmp.size () == 0)
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    66
        {
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    67
          break;
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    68
        }
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    69
      bool found = false;
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    70
      for (ComponentListI i = g_components.begin ();
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    71
           i != g_components.end ();
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    72
           i++)
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    73
        {
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    74
          if (i->first.compare (tmp) == 0)
266
a451b8daa1e6 remove EnableEnvVar function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 265
diff changeset
    75
            {
268
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    76
              found = true;
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    77
              i->second->Enable ();
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    78
              break;
266
a451b8daa1e6 remove EnableEnvVar function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 265
diff changeset
    79
            }
268
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    80
        }
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    81
      if (!found)
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    82
        {
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    83
          std::cout << "No debug component named=\"" << tmp << "\"" << std::endl;
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    84
        }
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    85
      if (next == std::string::npos)
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    86
        {
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    87
          break;
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    88
        }
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    89
      cur = next + 1;
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    90
      if (cur >= env.size ()) 
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    91
        {
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    92
          break;
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
    93
        }
266
a451b8daa1e6 remove EnableEnvVar function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 265
diff changeset
    94
    }
a451b8daa1e6 remove EnableEnvVar function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 265
diff changeset
    95
#endif
a451b8daa1e6 remove EnableEnvVar function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 265
diff changeset
    96
}
a451b8daa1e6 remove EnableEnvVar function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 265
diff changeset
    97
265
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    98
276
58651aff818b split out assert from debug.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 271
diff changeset
    99
DebugComponent::DebugComponent (char const * name)
265
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   100
  : m_isEnabled (false)
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   101
{
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   102
  for (ComponentListI i = g_components.begin ();
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   103
       i != g_components.end ();
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   104
       i++)
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   105
    {
286
57e6a2006962 convert use of <cassert> to "ns3/assert.h"
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 280
diff changeset
   106
      NS_ASSERT (i->first.compare (name) != 0);
265
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   107
    }
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   108
  g_components.push_back (std::make_pair (name, this));
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   109
}
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   110
bool 
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   111
DebugComponent::IsEnabled (void)
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   112
{
268
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
   113
  if (g_firstDebug) {
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
   114
    DebugComponentEnableEnvVar ();
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
   115
    g_firstDebug = false;
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
   116
  }
265
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   117
  return m_isEnabled;
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   118
}
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   119
void 
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   120
DebugComponent::Enable (void)
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   121
{
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   122
  m_isEnabled = true;
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   123
}
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   124
void 
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   125
DebugComponent::Disable (void)
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   126
{
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   127
  m_isEnabled = false;
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   128
}
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   129
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   130
void 
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   131
DebugComponentEnable (char const *name)
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   132
{
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   133
  for (ComponentListI i = g_components.begin ();
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   134
       i != g_components.end ();
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   135
       i++)
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   136
    {
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   137
      if (i->first.compare (name) == 0) 
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   138
	{
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   139
	  i->second->Enable ();
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   140
	  break;
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   141
	}
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   142
    }  
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   143
}
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   144
void 
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   145
DebugComponentDisable (char const *name)
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   146
{
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   147
  for (ComponentListI i = g_components.begin ();
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   148
       i != g_components.end ();
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   149
       i++)
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   150
    {
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   151
      if (i->first.compare (name) == 0) 
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   152
	{
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   153
	  i->second->Disable ();
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   154
	  break;
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   155
	}
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   156
    }  
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   157
}
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   158
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   159
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   160
void 
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   161
DebugComponentPrintList (void)
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   162
{
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   163
  for (ComponentListI i = g_components.begin ();
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   164
       i != g_components.end ();
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   165
       i++)
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   166
    {
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   167
      std::cout << i->first << "=" << (i->second->IsEnabled ()?"enabled":"disabled") << std::endl;
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   168
    }
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   169
}
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   170
fb0c531530f2 add debugging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   171
}; // namespace ns3
268
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
   172
a43b635230e8 test and debug the debug support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 266
diff changeset
   173