src/core/traced-value.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Sat, 04 Jul 2009 08:15:48 +0200
changeset 4654 2eaebe77d66b
parent 3182 61fe7fe81ebd
permissions -rw-r--r--
Added tag ns-3.5 for changeset c975274c9707
mathieu@2959
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
mathieu@2959
     2
/*
mathieu@2959
     3
 * Copyright (c) 2005,2006,2007 INRIA
mathieu@2959
     4
 *
mathieu@2959
     5
 * This program is free software; you can redistribute it and/or modify
mathieu@2959
     6
 * it under the terms of the GNU General Public License version 2 as
mathieu@2959
     7
 * published by the Free Software Foundation;
mathieu@2959
     8
 *
mathieu@2959
     9
 * This program is distributed in the hope that it will be useful,
mathieu@2959
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
mathieu@2959
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
mathieu@2959
    12
 * GNU General Public License for more details.
mathieu@2959
    13
 *
mathieu@2959
    14
 * You should have received a copy of the GNU General Public License
mathieu@2959
    15
 * along with this program; if not, write to the Free Software
mathieu@2959
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
mathieu@2959
    17
 *
mathieu@2959
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
mathieu@2959
    19
 */
mathieu@2482
    20
#ifndef TRACED_VALUE_H
mathieu@2482
    21
#define TRACED_VALUE_H
tomh@345
    22
mathieu@2482
    23
#include "traced-callback.h"
mathieu@2462
    24
#include "integer.h"
mathieu@2468
    25
#include "uinteger.h"
mathieu@2468
    26
#include "boolean.h"
mathieu@2468
    27
#include "double.h"
mathieu@2468
    28
#include "enum.h"
mathieu@2468
    29
mathieu@2512
    30
#define TRACED_VALUE_DEBUG(x)
tomh@345
    31
tomh@345
    32
namespace ns3 {
tomh@345
    33
mathieu@2588
    34
/**
tomh@3182
    35
 * \ingroup core
tomh@3182
    36
 * \defgroup tracing Tracing
tomh@3182
    37
 */
tomh@3182
    38
tomh@3182
    39
/**
tomh@3182
    40
 * \ingroup tracing
tomh@3182
    41
 *
mathieu@2588
    42
 * \brief trace classes with value semantics
mathieu@2588
    43
 *
mathieu@2588
    44
 * If you want to trace the change of value of a class or
mathieu@2588
    45
 * primitive type which have value semantics (they _must_
mathieu@2588
    46
 * support operator !=), you can wrap them in an instance of
mathieu@2588
    47
 * this template: this instance will behave just like
mathieu@2588
    48
 * the original class (if it did not export any special method),
mathieu@2594
    49
 * and will define Connect/DisconnectWithoutContext methods to work
mathieu@3190
    50
 * with ns3::MakeTraceSourceAccessor.
mathieu@2588
    51
 */
mathieu@2468
    52
template <typename T>
mathieu@2482
    53
class TracedValue
mathieu@2462
    54
{
tomh@345
    55
public:
mathieu@2482
    56
  TracedValue ()
mathieu@2468
    57
    : m_v () {}
mathieu@2482
    58
  TracedValue (const TracedValue &o)
mathieu@2468
    59
    : m_v (o.m_v) {}
mathieu@2482
    60
  TracedValue (const T &v)
mathieu@2468
    61
    : m_v (v) {}
mathieu@2468
    62
  operator T () const {
mathieu@2468
    63
    return m_v;
mathieu@2468
    64
  }
mathieu@2482
    65
  TracedValue &operator = (const TracedValue &o) {
mathieu@2512
    66
    TRACED_VALUE_DEBUG ("x=");
mathieu@2468
    67
    Set (o.m_v);
mathieu@2462
    68
    return *this;
tomh@345
    69
  }
mathieu@2965
    70
  TracedValue (const IntegerValue &value) 
mathieu@2468
    71
    : m_v (value.Get ()) {}
mathieu@2965
    72
  operator IntegerValue () const {
mathieu@2965
    73
    return IntegerValue (m_v);
tomh@345
    74
  }
mathieu@2965
    75
  TracedValue (const UintegerValue &value)
mathieu@2468
    76
    : m_v (value.Get ()) {}
mathieu@2965
    77
  operator UintegerValue () const {
mathieu@2965
    78
    return UintegerValue (m_v);
tomh@345
    79
  }
mathieu@2965
    80
  TracedValue (const BooleanValue &value)
mathieu@2468
    81
    : m_v (value.Get ()) {}
mathieu@2965
    82
  operator BooleanValue () const {
mathieu@2965
    83
    return BooleanValue (m_v);
mathieu@2468
    84
  }
mathieu@2965
    85
  TracedValue (const EnumValue &value)
mathieu@2468
    86
    : m_v (value.Get ()) {}
mathieu@2965
    87
  operator EnumValue () const {
mathieu@2965
    88
    return EnumValue (m_v);
mathieu@2468
    89
  }
mathieu@2594
    90
  void ConnectWithoutContext (const CallbackBase &cb) {
mathieu@2594
    91
    m_cb.ConnectWithoutContext (cb);
mathieu@2468
    92
  }
mathieu@2594
    93
  void Connect (const CallbackBase &cb, std::string path) {
mathieu@2594
    94
    m_cb.Connect (cb, path);
mathieu@2531
    95
  }
mathieu@2594
    96
  void DisconnectWithoutContext (const CallbackBase &cb) {
mathieu@2594
    97
    m_cb.DisconnectWithoutContext (cb);
mathieu@2468
    98
  }
mathieu@2594
    99
  void Disconnect (const CallbackBase &cb, std::string path) {
mathieu@2594
   100
    m_cb.Disconnect (cb, path);
mathieu@2569
   101
  }
mathieu@2468
   102
  void Set (const T &v) {
mathieu@2468
   103
    if (m_v != v)
mathieu@2462
   104
      {
mathieu@2468
   105
	m_cb (m_v, v);
mathieu@2468
   106
	m_v = v;
mathieu@2462
   107
      }
tomh@345
   108
  }
mathieu@2468
   109
  T Get (void) const {
mathieu@2468
   110
    return m_v;
mathieu@2468
   111
  }
mathieu@2482
   112
  TracedValue &operator++ () {
mathieu@2512
   113
    TRACED_VALUE_DEBUG ("++x");
mathieu@2468
   114
    T tmp = Get ();
mathieu@2468
   115
    ++tmp;
mathieu@2468
   116
    Set (tmp);
mathieu@2468
   117
    return *this;
mathieu@2468
   118
  }
mathieu@2482
   119
  TracedValue &operator-- () {
mathieu@2512
   120
    TRACED_VALUE_DEBUG ("--x");
mathieu@2468
   121
    T tmp = Get ();
mathieu@2468
   122
    --tmp;
mathieu@2468
   123
    Set (tmp);
mathieu@2468
   124
    return *this;
mathieu@2468
   125
  }
mathieu@2482
   126
  TracedValue operator++ (int) {
mathieu@2512
   127
    TRACED_VALUE_DEBUG ("x++");
mathieu@2482
   128
    TracedValue old (*this);
mathieu@2468
   129
    T tmp = Get ();
mathieu@2468
   130
    tmp++;
mathieu@2468
   131
    Set (tmp);
mathieu@2468
   132
    return old;
mathieu@2468
   133
  }
mathieu@2482
   134
  TracedValue operator-- (int) {
mathieu@2512
   135
    TRACED_VALUE_DEBUG ("x--");
mathieu@2482
   136
    TracedValue old (*this);
mathieu@2468
   137
    T tmp = Get ();
mathieu@2468
   138
    tmp--;
mathieu@2468
   139
    Set (tmp);
mathieu@2468
   140
    return old;
mathieu@2468
   141
  }
tomh@345
   142
private:
mathieu@2468
   143
  T m_v;
mathieu@2482
   144
  TracedCallback<T,T> m_cb;
tomh@345
   145
};
tomh@345
   146
raj@2903
   147
template <typename T>
raj@2903
   148
std::ostream& operator << (std::ostream& os, const TracedValue<T>& rhs)
raj@2903
   149
{
raj@2903
   150
  return os<<rhs.Get();
raj@2903
   151
}
raj@2903
   152
mathieu@2468
   153
template <typename T, typename U>
mathieu@2482
   154
bool operator == (const TracedValue<T> &lhs, const TracedValue<U> &rhs)
mathieu@2468
   155
{
mathieu@2512
   156
  TRACED_VALUE_DEBUG ("x==x");
mathieu@2468
   157
  return lhs.Get () == rhs.Get ();
tomh@345
   158
}
mathieu@2468
   159
template <typename T, typename U>
mathieu@2482
   160
bool operator == (const TracedValue<T> &lhs, const U &rhs)
mathieu@2468
   161
{
mathieu@2512
   162
  TRACED_VALUE_DEBUG ("x==");
mathieu@2468
   163
  return lhs.Get () == rhs;
tomh@345
   164
}
mathieu@2468
   165
template <typename T, typename U>
mathieu@2482
   166
bool operator == (const U &lhs, const TracedValue<T> &rhs)
mathieu@2468
   167
{
mathieu@2512
   168
  TRACED_VALUE_DEBUG ("==x");
mathieu@2468
   169
  return lhs == rhs.Get ();
tomh@345
   170
}
tomh@345
   171
mathieu@2468
   172
template <typename T, typename U>
mathieu@2482
   173
bool operator != (const TracedValue<T> &lhs, const TracedValue<U> &rhs)
mathieu@2468
   174
{
mathieu@2512
   175
  TRACED_VALUE_DEBUG ("x!=x");
mathieu@2468
   176
  return lhs.Get () != rhs.Get ();
mathieu@2468
   177
}
mathieu@2468
   178
template <typename T, typename U>
mathieu@2482
   179
bool operator != (const TracedValue<T> &lhs, const U &rhs)
mathieu@2468
   180
{
mathieu@2512
   181
  TRACED_VALUE_DEBUG ("x!=");
mathieu@2468
   182
  return lhs.Get () != rhs;
mathieu@2468
   183
}
mathieu@2468
   184
template <typename T, typename U>
mathieu@2482
   185
bool operator != (const U &lhs, const TracedValue<T> &rhs)
mathieu@2468
   186
{
mathieu@2512
   187
  TRACED_VALUE_DEBUG ("!=x");
mathieu@2468
   188
  return lhs != rhs.Get ();
mathieu@2468
   189
}
tomh@345
   190
tomh@345
   191
template <typename T, typename U>
mathieu@2482
   192
bool operator <= (const TracedValue<T> &lhs, const TracedValue<U> &rhs)
mathieu@2468
   193
{
mathieu@2512
   194
  TRACED_VALUE_DEBUG ("x<=x");
mathieu@2468
   195
  return lhs.Get () <= rhs.Get ();
mathieu@2468
   196
}
mathieu@2468
   197
template <typename T, typename U>
mathieu@2482
   198
bool operator <= (const TracedValue<T> &lhs, const U &rhs)
mathieu@2468
   199
{
mathieu@2512
   200
  TRACED_VALUE_DEBUG ("x<=");
mathieu@2468
   201
  return lhs.Get () <= rhs;
mathieu@2468
   202
}
mathieu@2468
   203
template <typename T, typename U>
mathieu@2482
   204
bool operator <= (const U &lhs, const TracedValue<T> &rhs)
mathieu@2468
   205
{
mathieu@2512
   206
  TRACED_VALUE_DEBUG ("<=x");
mathieu@2468
   207
  return lhs <= rhs.Get ();
mathieu@2468
   208
}
mathieu@2468
   209
template <typename T, typename U>
mathieu@2482
   210
bool operator >= (const TracedValue<T> &lhs, const TracedValue<U> &rhs)
mathieu@2468
   211
{
mathieu@2512
   212
  TRACED_VALUE_DEBUG ("x>=x");
mathieu@2468
   213
  return lhs.Get () >= rhs.Get ();
mathieu@2468
   214
}
mathieu@2468
   215
template <typename T, typename U>
mathieu@2482
   216
bool operator >= (const TracedValue<T> &lhs, const U &rhs)
mathieu@2468
   217
{
mathieu@2512
   218
  TRACED_VALUE_DEBUG ("x>=");
mathieu@2468
   219
  return lhs.Get () >= rhs;
mathieu@2468
   220
}
mathieu@2468
   221
template <typename T, typename U>
mathieu@2482
   222
bool operator >= (const U &lhs, const TracedValue<T> &rhs)
mathieu@2468
   223
{
mathieu@2512
   224
  TRACED_VALUE_DEBUG (">=x");
mathieu@2468
   225
  return lhs >= rhs.Get ();
mathieu@2468
   226
}
mathieu@2468
   227
mathieu@2468
   228
template <typename T, typename U>
mathieu@2482
   229
bool operator < (const TracedValue<T> &lhs, const TracedValue<U> &rhs)
mathieu@2468
   230
{
mathieu@2512
   231
  TRACED_VALUE_DEBUG ("x<x");
mathieu@2468
   232
  return lhs.Get () < rhs.Get ();
mathieu@2468
   233
}
mathieu@2468
   234
template <typename T, typename U>
mathieu@2482
   235
bool operator < (const TracedValue<T> &lhs, const U &rhs)
mathieu@2468
   236
{
mathieu@2512
   237
  TRACED_VALUE_DEBUG ("x<");
mathieu@2468
   238
  return lhs.Get () < rhs;
mathieu@2468
   239
}
mathieu@2468
   240
template <typename T, typename U>
mathieu@2482
   241
bool operator < (const U &lhs, const TracedValue<T> &rhs)
mathieu@2468
   242
{
mathieu@2512
   243
  TRACED_VALUE_DEBUG ("<x");
mathieu@2468
   244
  return lhs < rhs.Get ();
mathieu@2468
   245
}
mathieu@2468
   246
template <typename T, typename U>
mathieu@2482
   247
bool operator > (const TracedValue<T> &lhs, const TracedValue<U> &rhs)
mathieu@2468
   248
{
mathieu@2512
   249
  TRACED_VALUE_DEBUG ("x>x");
mathieu@2468
   250
  return lhs.Get () > rhs.Get ();
mathieu@2468
   251
}
mathieu@2468
   252
template <typename T, typename U>
mathieu@2482
   253
bool operator > (const TracedValue<T> &lhs, const U &rhs)
mathieu@2468
   254
{
mathieu@2512
   255
  TRACED_VALUE_DEBUG ("x>");
mathieu@2468
   256
  return lhs.Get () > rhs;
mathieu@2468
   257
}
mathieu@2468
   258
template <typename T, typename U>
mathieu@2482
   259
bool operator > (const U &lhs, const TracedValue<T> &rhs)
mathieu@2468
   260
{
mathieu@2512
   261
  TRACED_VALUE_DEBUG (">x");
mathieu@2468
   262
  return lhs > rhs.Get ();
mathieu@2468
   263
}
mathieu@2468
   264
template <typename T, typename U>
mathieu@2482
   265
TracedValue<T> &operator += (TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   266
  TRACED_VALUE_DEBUG ("x+=");
mathieu@2468
   267
  T tmp = lhs.Get ();
mathieu@2468
   268
  tmp += rhs;
mathieu@2468
   269
  lhs.Set (tmp);
tomh@345
   270
  return lhs;
tomh@345
   271
}
tomh@345
   272
template <typename T, typename U>
mathieu@2482
   273
TracedValue<T> &operator -= (TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   274
  TRACED_VALUE_DEBUG ("x-=");
mathieu@2468
   275
  T tmp = lhs.Get ();
mathieu@2468
   276
  tmp -= rhs;
mathieu@2468
   277
  lhs.Set (tmp);
tomh@345
   278
  return lhs;
tomh@345
   279
}
tomh@345
   280
template <typename T, typename U>
mathieu@2482
   281
TracedValue<T> &operator *= (TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   282
  TRACED_VALUE_DEBUG ("x*=");
mathieu@2468
   283
  T tmp = lhs.Get ();
mathieu@2468
   284
  tmp *= rhs;
mathieu@2468
   285
  lhs.Set (tmp);
tomh@345
   286
  return lhs;
tomh@345
   287
}
tomh@345
   288
template <typename T, typename U>
mathieu@2482
   289
TracedValue<T> &operator /= (TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   290
  TRACED_VALUE_DEBUG ("x/=");
mathieu@2468
   291
  T tmp = lhs.Get ();
mathieu@2468
   292
  tmp /= rhs;
mathieu@2468
   293
  lhs.Set (tmp);
tomh@345
   294
  return lhs;
tomh@345
   295
}
tomh@345
   296
template <typename T, typename U>
mathieu@2482
   297
TracedValue<T> &operator %= (TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   298
  TRACED_VALUE_DEBUG ("x%=");
mathieu@2468
   299
  T tmp = lhs.Get ();
mathieu@2468
   300
  tmp %= rhs;
mathieu@2468
   301
  lhs.Set (tmp);
tomh@345
   302
  return lhs;
tomh@345
   303
}
tomh@345
   304
template <typename T, typename U>
mathieu@2482
   305
TracedValue<T> &operator <<= (TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   306
  TRACED_VALUE_DEBUG ("x<<=");
mathieu@2468
   307
  T tmp = lhs.Get ();
mathieu@2468
   308
  tmp <<= rhs;
mathieu@2468
   309
  lhs.Set (tmp);
tomh@345
   310
  return lhs;
tomh@345
   311
}
tomh@345
   312
template <typename T, typename U>
mathieu@2482
   313
TracedValue<T> &operator >>= (TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   314
  TRACED_VALUE_DEBUG ("x>>=");
mathieu@2468
   315
  T tmp = lhs.Get ();
mathieu@2468
   316
  tmp >>= rhs;
mathieu@2468
   317
  lhs.Set (tmp);
tomh@345
   318
  return lhs;
tomh@345
   319
}
tomh@345
   320
template <typename T, typename U>
mathieu@2482
   321
TracedValue<T> &operator &= (TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   322
  TRACED_VALUE_DEBUG ("x&=");
mathieu@2468
   323
  T tmp = lhs.Get ();
mathieu@2468
   324
  tmp &= rhs;
mathieu@2468
   325
  lhs.Set (tmp);
tomh@345
   326
  return lhs;
tomh@345
   327
}
tomh@345
   328
template <typename T, typename U>
mathieu@2482
   329
TracedValue<T> &operator |= (TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   330
  TRACED_VALUE_DEBUG ("x|=");
mathieu@2468
   331
  T tmp = lhs.Get ();
mathieu@2468
   332
  tmp |= rhs;
mathieu@2468
   333
  lhs.Set (tmp);
tomh@345
   334
  return lhs;
tomh@345
   335
}
mathieu@2468
   336
template <typename T, typename U>
mathieu@2482
   337
TracedValue<T> &operator ^= (TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   338
  TRACED_VALUE_DEBUG ("x^=");
mathieu@2468
   339
  T tmp = lhs.Get ();
mathieu@2468
   340
  tmp ^= rhs;
mathieu@2468
   341
  lhs.Set (tmp);
mathieu@2468
   342
  return lhs;
mathieu@2468
   343
}
mathieu@2468
   344
template <typename T, typename U>
mathieu@2482
   345
TracedValue<T> operator + (const TracedValue<T> &lhs, const TracedValue<U> &rhs) {
mathieu@2512
   346
  TRACED_VALUE_DEBUG ("x+x");
mathieu@2482
   347
  return TracedValue<T> (lhs.Get () + rhs.Get ());
mathieu@2468
   348
}
mathieu@2468
   349
template <typename T, typename U>
mathieu@2482
   350
TracedValue<T> operator + (const TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   351
  TRACED_VALUE_DEBUG ("x+");
mathieu@2482
   352
  return TracedValue<T> (lhs.Get () + rhs);
mathieu@2468
   353
}
mathieu@2468
   354
template <typename T, typename U>
mathieu@2482
   355
TracedValue<T> operator + (const U &lhs, const TracedValue<T> &rhs) {
mathieu@2512
   356
  TRACED_VALUE_DEBUG ("+x");
mathieu@2482
   357
  return TracedValue<T> (lhs + rhs.Get ());
mathieu@2468
   358
}
mathieu@2468
   359
mathieu@2468
   360
template <typename T, typename U>
mathieu@2482
   361
TracedValue<T> operator - (const TracedValue<T> &lhs, const TracedValue<U> &rhs) {
mathieu@2512
   362
  TRACED_VALUE_DEBUG ("x-x");
mathieu@2482
   363
  return TracedValue<T> (lhs.Get () - rhs.Get ());
mathieu@2468
   364
}
mathieu@2468
   365
template <typename T, typename U>
mathieu@2482
   366
TracedValue<T> operator - (const TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   367
  TRACED_VALUE_DEBUG ("x-");
mathieu@2482
   368
  return TracedValue<T> (lhs.Get () - rhs);
mathieu@2468
   369
}
mathieu@2468
   370
template <typename T, typename U>
mathieu@2482
   371
TracedValue<T> operator - (const U &lhs, const TracedValue<T> &rhs) {
mathieu@2512
   372
  TRACED_VALUE_DEBUG ("-x");
mathieu@2482
   373
  return TracedValue<T> (lhs - rhs.Get ());
mathieu@2468
   374
}
mathieu@2468
   375
mathieu@2468
   376
template <typename T, typename U>
mathieu@2482
   377
TracedValue<T> operator * (const TracedValue<T> &lhs, const TracedValue<U> &rhs) {
mathieu@2512
   378
  TRACED_VALUE_DEBUG ("x*x");
mathieu@2482
   379
  return TracedValue<T> (lhs.Get () * rhs.Get ());
mathieu@2468
   380
}
mathieu@2468
   381
template <typename T, typename U>
mathieu@2482
   382
TracedValue<T> operator * (const TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   383
  TRACED_VALUE_DEBUG ("x*");
mathieu@2482
   384
  return TracedValue<T> (lhs.Get () * rhs);
mathieu@2468
   385
}
mathieu@2468
   386
template <typename T, typename U>
mathieu@2482
   387
TracedValue<T> operator * (const U &lhs, const TracedValue<T> &rhs) {
mathieu@2512
   388
  TRACED_VALUE_DEBUG ("*x");
mathieu@2482
   389
  return TracedValue<T> (lhs - rhs.Get ());
mathieu@2468
   390
}
mathieu@2468
   391
mathieu@2468
   392
template <typename T, typename U>
mathieu@2482
   393
TracedValue<T> operator / (const TracedValue<T> &lhs, const TracedValue<U> &rhs) {
mathieu@2512
   394
  TRACED_VALUE_DEBUG ("x/x");
mathieu@2482
   395
  return TracedValue<T> (lhs.Get () / rhs.Get ());
mathieu@2468
   396
}
mathieu@2468
   397
template <typename T, typename U>
mathieu@2482
   398
TracedValue<T> operator / (const TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   399
  TRACED_VALUE_DEBUG ("x/");
mathieu@2482
   400
  return TracedValue<T> (lhs.Get () / rhs);
mathieu@2468
   401
}
mathieu@2468
   402
template <typename T, typename U>
mathieu@2482
   403
TracedValue<T> operator / (const U &lhs, const TracedValue<T> &rhs) {
mathieu@2512
   404
  TRACED_VALUE_DEBUG ("/x");
mathieu@2482
   405
  return TracedValue<T> (lhs / rhs.Get ());
mathieu@2468
   406
}
mathieu@2468
   407
mathieu@2468
   408
template <typename T, typename U>
mathieu@2482
   409
TracedValue<T> operator % (const TracedValue<T> &lhs, const TracedValue<U> &rhs) {
mathieu@2512
   410
  TRACED_VALUE_DEBUG ("x%x");
mathieu@2482
   411
  return TracedValue<T> (lhs.Get () % rhs.Get ());
mathieu@2468
   412
}
mathieu@2468
   413
template <typename T, typename U>
mathieu@2482
   414
TracedValue<T> operator % (const TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   415
  TRACED_VALUE_DEBUG ("x%");
mathieu@2482
   416
  return TracedValue<T> (lhs.Get () % rhs);
mathieu@2468
   417
}
mathieu@2468
   418
template <typename T, typename U>
mathieu@2482
   419
TracedValue<T> operator % (const U &lhs, const TracedValue<T> &rhs) {
mathieu@2512
   420
  TRACED_VALUE_DEBUG ("%x");
mathieu@2482
   421
  return TracedValue<T> (lhs % rhs.Get ());
mathieu@2468
   422
}
mathieu@2468
   423
mathieu@2468
   424
template <typename T, typename U>
mathieu@2482
   425
TracedValue<T> operator ^ (const TracedValue<T> &lhs, const TracedValue<U> &rhs) {
mathieu@2512
   426
  TRACED_VALUE_DEBUG ("x^x");
mathieu@2482
   427
  return TracedValue<T> (lhs.Get () ^ rhs.Get ());
mathieu@2468
   428
}
mathieu@2468
   429
template <typename T, typename U>
mathieu@2482
   430
TracedValue<T> operator ^ (const TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   431
  TRACED_VALUE_DEBUG ("x^");
mathieu@2482
   432
  return TracedValue<T> (lhs.Get () ^ rhs);
mathieu@2468
   433
}
mathieu@2468
   434
template <typename T, typename U>
mathieu@2482
   435
TracedValue<T> operator ^ (const U &lhs, const TracedValue<T> &rhs) {
mathieu@2512
   436
  TRACED_VALUE_DEBUG ("^x");
mathieu@2482
   437
  return TracedValue<T> (lhs ^ rhs.Get ());
mathieu@2468
   438
}
mathieu@2468
   439
mathieu@2468
   440
template <typename T, typename U>
mathieu@2482
   441
TracedValue<T> operator | (const TracedValue<T> &lhs, const TracedValue<U> &rhs) {
mathieu@2512
   442
  TRACED_VALUE_DEBUG ("x|x");
mathieu@2482
   443
  return TracedValue<T> (lhs.Get () | rhs.Get ());
mathieu@2468
   444
}
mathieu@2468
   445
template <typename T, typename U>
mathieu@2482
   446
TracedValue<T> operator | (const TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   447
  TRACED_VALUE_DEBUG ("x|");
mathieu@2482
   448
  return TracedValue<T> (lhs.Get () | rhs);
mathieu@2468
   449
}
mathieu@2468
   450
template <typename T, typename U>
mathieu@2482
   451
TracedValue<T> operator | (const U &lhs, const TracedValue<T> &rhs) {
mathieu@2512
   452
  TRACED_VALUE_DEBUG ("|x");
mathieu@2482
   453
  return TracedValue<T> (lhs | rhs.Get ());
mathieu@2468
   454
}
mathieu@2468
   455
mathieu@2468
   456
template <typename T, typename U>
mathieu@2482
   457
TracedValue<T> operator & (const TracedValue<T> &lhs, const TracedValue<U> &rhs) {
mathieu@2512
   458
  TRACED_VALUE_DEBUG ("x&x");
mathieu@2482
   459
  return TracedValue<T> (lhs.Get () & rhs.Get ());
mathieu@2468
   460
}
mathieu@2468
   461
template <typename T, typename U>
mathieu@2482
   462
TracedValue<T> operator & (const TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   463
  TRACED_VALUE_DEBUG ("x&");
mathieu@2482
   464
  return TracedValue<T> (lhs.Get () & rhs);
mathieu@2468
   465
}
mathieu@2468
   466
template <typename T, typename U>
mathieu@2482
   467
TracedValue<T> operator & (const U &lhs, const TracedValue<T> &rhs) {
mathieu@2512
   468
  TRACED_VALUE_DEBUG ("&x");
mathieu@2482
   469
  return TracedValue<T> (lhs & rhs.Get ());
mathieu@2468
   470
}
mathieu@2468
   471
mathieu@2468
   472
template <typename T, typename U>
mathieu@2482
   473
TracedValue<T> operator << (const TracedValue<T> &lhs, const TracedValue<U> &rhs) {
mathieu@2512
   474
  TRACED_VALUE_DEBUG ("x<<x");
mathieu@2482
   475
  return TracedValue<T> (lhs.Get () << rhs.Get ());
mathieu@2468
   476
}
mathieu@2468
   477
template <typename T, typename U>
mathieu@2482
   478
TracedValue<T> operator << (const TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   479
  TRACED_VALUE_DEBUG ("x<<");
mathieu@2482
   480
  return TracedValue<T> (lhs.Get () << rhs);
mathieu@2468
   481
}
mathieu@2468
   482
template <typename T, typename U>
mathieu@2482
   483
TracedValue<T> operator << (const U &lhs, const TracedValue<T> &rhs) {
mathieu@2512
   484
  TRACED_VALUE_DEBUG ("<<x");
mathieu@2482
   485
  return TracedValue<T> (lhs << rhs.Get ());
mathieu@2468
   486
}
mathieu@2468
   487
mathieu@2468
   488
template <typename T, typename U>
mathieu@2482
   489
TracedValue<T> operator >> (const TracedValue<T> &lhs, const TracedValue<U> &rhs) {
mathieu@2512
   490
  TRACED_VALUE_DEBUG ("x>>x");
mathieu@2482
   491
  return TracedValue<T> (lhs.Get () >> rhs.Get ());
mathieu@2468
   492
}
mathieu@2468
   493
template <typename T, typename U>
mathieu@2482
   494
TracedValue<T> operator >> (const TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   495
  TRACED_VALUE_DEBUG ("x>>");
mathieu@2482
   496
  return TracedValue<T> (lhs.Get () >> rhs);
mathieu@2468
   497
}
mathieu@2468
   498
template <typename T, typename U>
mathieu@2482
   499
TracedValue<T> operator >> (const U &lhs, const TracedValue<T> &rhs) {
mathieu@2512
   500
  TRACED_VALUE_DEBUG (">>x");
mathieu@2482
   501
  return TracedValue<T> (lhs >> rhs.Get ());
mathieu@2468
   502
}
mathieu@2468
   503
mathieu@2468
   504
mathieu@2468
   505
template <typename T>
mathieu@2482
   506
TracedValue<T> operator + (const TracedValue<T> &lhs) {
mathieu@2512
   507
  TRACED_VALUE_DEBUG ("(+x)");
mathieu@2482
   508
  return TracedValue<T> (+lhs.Get ());
mathieu@2468
   509
}
mathieu@2468
   510
template <typename T>
mathieu@2482
   511
TracedValue<T> operator - (const TracedValue<T> &lhs) {
mathieu@2512
   512
  TRACED_VALUE_DEBUG ("(-x)");
mathieu@2482
   513
  return TracedValue<T> (-lhs.Get ());
mathieu@2468
   514
}
mathieu@2468
   515
template <typename T>
mathieu@2482
   516
TracedValue<T> operator ~ (const TracedValue<T> &lhs) {
mathieu@2512
   517
  TRACED_VALUE_DEBUG ("(~x)");
mathieu@2482
   518
  return TracedValue<T> (~lhs.Get ());
mathieu@2468
   519
}
mathieu@2468
   520
template <typename T>
mathieu@2482
   521
TracedValue<T> operator ! (const TracedValue<T> &lhs) {
mathieu@2512
   522
  TRACED_VALUE_DEBUG ("(!x)");
mathieu@2482
   523
  return TracedValue<T> (!lhs.Get ());
mathieu@2468
   524
}
mathieu@2468
   525
tomh@345
   526
mathieu@2462
   527
} // namespace ns3
tomh@345
   528
mathieu@2482
   529
#endif /* TRACED_VALUE_H */