src/core/traced-value.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Sun, 02 Mar 2008 21:00:37 +0100
changeset 2531 b451b5fc8b57
parent 2512 347c418403d4
child 2569 d5cff2968984
permissions -rw-r--r--
implement context-based trace connection
mathieu@2482
     1
#ifndef TRACED_VALUE_H
mathieu@2482
     2
#define TRACED_VALUE_H
tomh@345
     3
mathieu@2482
     4
#include "traced-callback.h"
mathieu@2462
     5
#include "integer.h"
mathieu@2468
     6
#include "uinteger.h"
mathieu@2468
     7
#include "boolean.h"
mathieu@2468
     8
#include "double.h"
mathieu@2468
     9
#include "enum.h"
mathieu@2468
    10
mathieu@2512
    11
#define TRACED_VALUE_DEBUG(x)
tomh@345
    12
tomh@345
    13
namespace ns3 {
tomh@345
    14
mathieu@2468
    15
template <typename T>
mathieu@2482
    16
class TracedValue
mathieu@2462
    17
{
tomh@345
    18
public:
mathieu@2482
    19
  TracedValue ()
mathieu@2468
    20
    : m_v () {}
mathieu@2482
    21
  TracedValue (const TracedValue &o)
mathieu@2468
    22
    : m_v (o.m_v) {}
mathieu@2482
    23
  TracedValue (const T &v)
mathieu@2468
    24
    : m_v (v) {}
mathieu@2468
    25
  operator T () const {
mathieu@2468
    26
    return m_v;
mathieu@2468
    27
  }
mathieu@2482
    28
  TracedValue &operator = (const TracedValue &o) {
mathieu@2512
    29
    TRACED_VALUE_DEBUG ("x=");
mathieu@2468
    30
    Set (o.m_v);
mathieu@2462
    31
    return *this;
tomh@345
    32
  }
mathieu@2482
    33
  TracedValue (const Integer &value) 
mathieu@2468
    34
    : m_v (value.Get ()) {}
mathieu@2468
    35
  operator Integer () const {
mathieu@2468
    36
    return Integer (m_v);
tomh@345
    37
  }
mathieu@2482
    38
  TracedValue (const Uinteger &value)
mathieu@2468
    39
    : m_v (value.Get ()) {}
mathieu@2468
    40
  operator Uinteger () const {
mathieu@2468
    41
    return Uinteger (m_v);
tomh@345
    42
  }
mathieu@2482
    43
  TracedValue (const Boolean &value)
mathieu@2468
    44
    : m_v (value.Get ()) {}
mathieu@2468
    45
  operator Boolean () const {
mathieu@2468
    46
    return Boolean (m_v);
mathieu@2468
    47
  }
mathieu@2482
    48
  TracedValue (const Enum &value)
mathieu@2468
    49
    : m_v (value.Get ()) {}
mathieu@2468
    50
  operator Enum () const {
mathieu@2468
    51
    return Enum (m_v);
mathieu@2468
    52
  }
mathieu@2468
    53
  void Connect (const CallbackBase &cb) {
mathieu@2468
    54
    m_cb.Connect (cb);
mathieu@2468
    55
  }
mathieu@2531
    56
  void ConnectWithContext (const CallbackBase &cb, std::string path) {
mathieu@2531
    57
    m_cb.ConnectWithContext (cb, path);
mathieu@2531
    58
  }
mathieu@2468
    59
  void Disconnect (const CallbackBase &cb) {
mathieu@2468
    60
    m_cb.Disconnect (cb);
mathieu@2468
    61
  }
mathieu@2468
    62
  void Set (const T &v) {
mathieu@2468
    63
    if (m_v != v)
mathieu@2462
    64
      {
mathieu@2468
    65
	m_cb (m_v, v);
mathieu@2468
    66
	m_v = v;
mathieu@2462
    67
      }
tomh@345
    68
  }
mathieu@2468
    69
  T Get (void) const {
mathieu@2468
    70
    return m_v;
mathieu@2468
    71
  }
mathieu@2482
    72
  TracedValue &operator++ () {
mathieu@2512
    73
    TRACED_VALUE_DEBUG ("++x");
mathieu@2468
    74
    T tmp = Get ();
mathieu@2468
    75
    ++tmp;
mathieu@2468
    76
    Set (tmp);
mathieu@2468
    77
    return *this;
mathieu@2468
    78
  }
mathieu@2482
    79
  TracedValue &operator-- () {
mathieu@2512
    80
    TRACED_VALUE_DEBUG ("--x");
mathieu@2468
    81
    T tmp = Get ();
mathieu@2468
    82
    --tmp;
mathieu@2468
    83
    Set (tmp);
mathieu@2468
    84
    return *this;
mathieu@2468
    85
  }
mathieu@2482
    86
  TracedValue operator++ (int) {
mathieu@2512
    87
    TRACED_VALUE_DEBUG ("x++");
mathieu@2482
    88
    TracedValue old (*this);
mathieu@2468
    89
    T tmp = Get ();
mathieu@2468
    90
    tmp++;
mathieu@2468
    91
    Set (tmp);
mathieu@2468
    92
    return old;
mathieu@2468
    93
  }
mathieu@2482
    94
  TracedValue operator-- (int) {
mathieu@2512
    95
    TRACED_VALUE_DEBUG ("x--");
mathieu@2482
    96
    TracedValue old (*this);
mathieu@2468
    97
    T tmp = Get ();
mathieu@2468
    98
    tmp--;
mathieu@2468
    99
    Set (tmp);
mathieu@2468
   100
    return old;
mathieu@2468
   101
  }
tomh@345
   102
private:
mathieu@2468
   103
  T m_v;
mathieu@2482
   104
  TracedCallback<T,T> m_cb;
tomh@345
   105
};
tomh@345
   106
mathieu@2468
   107
template <typename T, typename U>
mathieu@2482
   108
bool operator == (const TracedValue<T> &lhs, const TracedValue<U> &rhs)
mathieu@2468
   109
{
mathieu@2512
   110
  TRACED_VALUE_DEBUG ("x==x");
mathieu@2468
   111
  return lhs.Get () == rhs.Get ();
tomh@345
   112
}
mathieu@2468
   113
template <typename T, typename U>
mathieu@2482
   114
bool operator == (const TracedValue<T> &lhs, const U &rhs)
mathieu@2468
   115
{
mathieu@2512
   116
  TRACED_VALUE_DEBUG ("x==");
mathieu@2468
   117
  return lhs.Get () == rhs;
tomh@345
   118
}
mathieu@2468
   119
template <typename T, typename U>
mathieu@2482
   120
bool operator == (const U &lhs, const TracedValue<T> &rhs)
mathieu@2468
   121
{
mathieu@2512
   122
  TRACED_VALUE_DEBUG ("==x");
mathieu@2468
   123
  return lhs == rhs.Get ();
tomh@345
   124
}
tomh@345
   125
mathieu@2468
   126
template <typename T, typename U>
mathieu@2482
   127
bool operator != (const TracedValue<T> &lhs, const TracedValue<U> &rhs)
mathieu@2468
   128
{
mathieu@2512
   129
  TRACED_VALUE_DEBUG ("x!=x");
mathieu@2468
   130
  return lhs.Get () != rhs.Get ();
mathieu@2468
   131
}
mathieu@2468
   132
template <typename T, typename U>
mathieu@2482
   133
bool operator != (const TracedValue<T> &lhs, const U &rhs)
mathieu@2468
   134
{
mathieu@2512
   135
  TRACED_VALUE_DEBUG ("x!=");
mathieu@2468
   136
  return lhs.Get () != rhs;
mathieu@2468
   137
}
mathieu@2468
   138
template <typename T, typename U>
mathieu@2482
   139
bool operator != (const U &lhs, const TracedValue<T> &rhs)
mathieu@2468
   140
{
mathieu@2512
   141
  TRACED_VALUE_DEBUG ("!=x");
mathieu@2468
   142
  return lhs != rhs.Get ();
mathieu@2468
   143
}
tomh@345
   144
tomh@345
   145
template <typename T, typename U>
mathieu@2482
   146
bool operator <= (const TracedValue<T> &lhs, const TracedValue<U> &rhs)
mathieu@2468
   147
{
mathieu@2512
   148
  TRACED_VALUE_DEBUG ("x<=x");
mathieu@2468
   149
  return lhs.Get () <= rhs.Get ();
mathieu@2468
   150
}
mathieu@2468
   151
template <typename T, typename U>
mathieu@2482
   152
bool operator <= (const TracedValue<T> &lhs, const U &rhs)
mathieu@2468
   153
{
mathieu@2512
   154
  TRACED_VALUE_DEBUG ("x<=");
mathieu@2468
   155
  return lhs.Get () <= rhs;
mathieu@2468
   156
}
mathieu@2468
   157
template <typename T, typename U>
mathieu@2482
   158
bool operator <= (const U &lhs, const TracedValue<T> &rhs)
mathieu@2468
   159
{
mathieu@2512
   160
  TRACED_VALUE_DEBUG ("<=x");
mathieu@2468
   161
  return lhs <= rhs.Get ();
mathieu@2468
   162
}
mathieu@2468
   163
template <typename T, typename U>
mathieu@2482
   164
bool operator >= (const TracedValue<T> &lhs, const TracedValue<U> &rhs)
mathieu@2468
   165
{
mathieu@2512
   166
  TRACED_VALUE_DEBUG ("x>=x");
mathieu@2468
   167
  return lhs.Get () >= rhs.Get ();
mathieu@2468
   168
}
mathieu@2468
   169
template <typename T, typename U>
mathieu@2482
   170
bool operator >= (const TracedValue<T> &lhs, const U &rhs)
mathieu@2468
   171
{
mathieu@2512
   172
  TRACED_VALUE_DEBUG ("x>=");
mathieu@2468
   173
  return lhs.Get () >= rhs;
mathieu@2468
   174
}
mathieu@2468
   175
template <typename T, typename U>
mathieu@2482
   176
bool operator >= (const U &lhs, const TracedValue<T> &rhs)
mathieu@2468
   177
{
mathieu@2512
   178
  TRACED_VALUE_DEBUG (">=x");
mathieu@2468
   179
  return lhs >= rhs.Get ();
mathieu@2468
   180
}
mathieu@2468
   181
mathieu@2468
   182
template <typename T, typename U>
mathieu@2482
   183
bool operator < (const TracedValue<T> &lhs, const TracedValue<U> &rhs)
mathieu@2468
   184
{
mathieu@2512
   185
  TRACED_VALUE_DEBUG ("x<x");
mathieu@2468
   186
  return lhs.Get () < rhs.Get ();
mathieu@2468
   187
}
mathieu@2468
   188
template <typename T, typename U>
mathieu@2482
   189
bool operator < (const TracedValue<T> &lhs, const U &rhs)
mathieu@2468
   190
{
mathieu@2512
   191
  TRACED_VALUE_DEBUG ("x<");
mathieu@2468
   192
  return lhs.Get () < rhs;
mathieu@2468
   193
}
mathieu@2468
   194
template <typename T, typename U>
mathieu@2482
   195
bool operator < (const U &lhs, const TracedValue<T> &rhs)
mathieu@2468
   196
{
mathieu@2512
   197
  TRACED_VALUE_DEBUG ("<x");
mathieu@2468
   198
  return lhs < rhs.Get ();
mathieu@2468
   199
}
mathieu@2468
   200
template <typename T, typename U>
mathieu@2482
   201
bool operator > (const TracedValue<T> &lhs, const TracedValue<U> &rhs)
mathieu@2468
   202
{
mathieu@2512
   203
  TRACED_VALUE_DEBUG ("x>x");
mathieu@2468
   204
  return lhs.Get () > rhs.Get ();
mathieu@2468
   205
}
mathieu@2468
   206
template <typename T, typename U>
mathieu@2482
   207
bool operator > (const TracedValue<T> &lhs, const U &rhs)
mathieu@2468
   208
{
mathieu@2512
   209
  TRACED_VALUE_DEBUG ("x>");
mathieu@2468
   210
  return lhs.Get () > rhs;
mathieu@2468
   211
}
mathieu@2468
   212
template <typename T, typename U>
mathieu@2482
   213
bool operator > (const U &lhs, const TracedValue<T> &rhs)
mathieu@2468
   214
{
mathieu@2512
   215
  TRACED_VALUE_DEBUG (">x");
mathieu@2468
   216
  return lhs > rhs.Get ();
mathieu@2468
   217
}
mathieu@2468
   218
template <typename T, typename U>
mathieu@2482
   219
TracedValue<T> &operator += (TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   220
  TRACED_VALUE_DEBUG ("x+=");
mathieu@2468
   221
  T tmp = lhs.Get ();
mathieu@2468
   222
  tmp += rhs;
mathieu@2468
   223
  lhs.Set (tmp);
tomh@345
   224
  return lhs;
tomh@345
   225
}
tomh@345
   226
template <typename T, typename U>
mathieu@2482
   227
TracedValue<T> &operator -= (TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   228
  TRACED_VALUE_DEBUG ("x-=");
mathieu@2468
   229
  T tmp = lhs.Get ();
mathieu@2468
   230
  tmp -= rhs;
mathieu@2468
   231
  lhs.Set (tmp);
tomh@345
   232
  return lhs;
tomh@345
   233
}
tomh@345
   234
template <typename T, typename U>
mathieu@2482
   235
TracedValue<T> &operator *= (TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   236
  TRACED_VALUE_DEBUG ("x*=");
mathieu@2468
   237
  T tmp = lhs.Get ();
mathieu@2468
   238
  tmp *= rhs;
mathieu@2468
   239
  lhs.Set (tmp);
tomh@345
   240
  return lhs;
tomh@345
   241
}
tomh@345
   242
template <typename T, typename U>
mathieu@2482
   243
TracedValue<T> &operator /= (TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   244
  TRACED_VALUE_DEBUG ("x/=");
mathieu@2468
   245
  T tmp = lhs.Get ();
mathieu@2468
   246
  tmp /= rhs;
mathieu@2468
   247
  lhs.Set (tmp);
tomh@345
   248
  return lhs;
tomh@345
   249
}
tomh@345
   250
template <typename T, typename U>
mathieu@2482
   251
TracedValue<T> &operator %= (TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   252
  TRACED_VALUE_DEBUG ("x%=");
mathieu@2468
   253
  T tmp = lhs.Get ();
mathieu@2468
   254
  tmp %= rhs;
mathieu@2468
   255
  lhs.Set (tmp);
tomh@345
   256
  return lhs;
tomh@345
   257
}
tomh@345
   258
template <typename T, typename U>
mathieu@2482
   259
TracedValue<T> &operator <<= (TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   260
  TRACED_VALUE_DEBUG ("x<<=");
mathieu@2468
   261
  T tmp = lhs.Get ();
mathieu@2468
   262
  tmp <<= rhs;
mathieu@2468
   263
  lhs.Set (tmp);
tomh@345
   264
  return lhs;
tomh@345
   265
}
tomh@345
   266
template <typename T, typename U>
mathieu@2482
   267
TracedValue<T> &operator >>= (TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   268
  TRACED_VALUE_DEBUG ("x>>=");
mathieu@2468
   269
  T tmp = lhs.Get ();
mathieu@2468
   270
  tmp >>= rhs;
mathieu@2468
   271
  lhs.Set (tmp);
tomh@345
   272
  return lhs;
tomh@345
   273
}
tomh@345
   274
template <typename T, typename U>
mathieu@2482
   275
TracedValue<T> &operator &= (TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   276
  TRACED_VALUE_DEBUG ("x&=");
mathieu@2468
   277
  T tmp = lhs.Get ();
mathieu@2468
   278
  tmp &= rhs;
mathieu@2468
   279
  lhs.Set (tmp);
tomh@345
   280
  return lhs;
tomh@345
   281
}
tomh@345
   282
template <typename T, typename U>
mathieu@2482
   283
TracedValue<T> &operator |= (TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   284
  TRACED_VALUE_DEBUG ("x|=");
mathieu@2468
   285
  T tmp = lhs.Get ();
mathieu@2468
   286
  tmp |= rhs;
mathieu@2468
   287
  lhs.Set (tmp);
tomh@345
   288
  return lhs;
tomh@345
   289
}
mathieu@2468
   290
template <typename T, typename U>
mathieu@2482
   291
TracedValue<T> &operator ^= (TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   292
  TRACED_VALUE_DEBUG ("x^=");
mathieu@2468
   293
  T tmp = lhs.Get ();
mathieu@2468
   294
  tmp ^= rhs;
mathieu@2468
   295
  lhs.Set (tmp);
mathieu@2468
   296
  return lhs;
mathieu@2468
   297
}
mathieu@2468
   298
template <typename T, typename U>
mathieu@2482
   299
TracedValue<T> operator + (const TracedValue<T> &lhs, const TracedValue<U> &rhs) {
mathieu@2512
   300
  TRACED_VALUE_DEBUG ("x+x");
mathieu@2482
   301
  return TracedValue<T> (lhs.Get () + rhs.Get ());
mathieu@2468
   302
}
mathieu@2468
   303
template <typename T, typename U>
mathieu@2482
   304
TracedValue<T> operator + (const TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   305
  TRACED_VALUE_DEBUG ("x+");
mathieu@2482
   306
  return TracedValue<T> (lhs.Get () + rhs);
mathieu@2468
   307
}
mathieu@2468
   308
template <typename T, typename U>
mathieu@2482
   309
TracedValue<T> operator + (const U &lhs, const TracedValue<T> &rhs) {
mathieu@2512
   310
  TRACED_VALUE_DEBUG ("+x");
mathieu@2482
   311
  return TracedValue<T> (lhs + rhs.Get ());
mathieu@2468
   312
}
mathieu@2468
   313
mathieu@2468
   314
template <typename T, typename U>
mathieu@2482
   315
TracedValue<T> operator - (const TracedValue<T> &lhs, const TracedValue<U> &rhs) {
mathieu@2512
   316
  TRACED_VALUE_DEBUG ("x-x");
mathieu@2482
   317
  return TracedValue<T> (lhs.Get () - rhs.Get ());
mathieu@2468
   318
}
mathieu@2468
   319
template <typename T, typename U>
mathieu@2482
   320
TracedValue<T> operator - (const TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   321
  TRACED_VALUE_DEBUG ("x-");
mathieu@2482
   322
  return TracedValue<T> (lhs.Get () - rhs);
mathieu@2468
   323
}
mathieu@2468
   324
template <typename T, typename U>
mathieu@2482
   325
TracedValue<T> operator - (const U &lhs, const TracedValue<T> &rhs) {
mathieu@2512
   326
  TRACED_VALUE_DEBUG ("-x");
mathieu@2482
   327
  return TracedValue<T> (lhs - rhs.Get ());
mathieu@2468
   328
}
mathieu@2468
   329
mathieu@2468
   330
template <typename T, typename U>
mathieu@2482
   331
TracedValue<T> operator * (const TracedValue<T> &lhs, const TracedValue<U> &rhs) {
mathieu@2512
   332
  TRACED_VALUE_DEBUG ("x*x");
mathieu@2482
   333
  return TracedValue<T> (lhs.Get () * rhs.Get ());
mathieu@2468
   334
}
mathieu@2468
   335
template <typename T, typename U>
mathieu@2482
   336
TracedValue<T> operator * (const TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   337
  TRACED_VALUE_DEBUG ("x*");
mathieu@2482
   338
  return TracedValue<T> (lhs.Get () * rhs);
mathieu@2468
   339
}
mathieu@2468
   340
template <typename T, typename U>
mathieu@2482
   341
TracedValue<T> operator * (const U &lhs, const TracedValue<T> &rhs) {
mathieu@2512
   342
  TRACED_VALUE_DEBUG ("*x");
mathieu@2482
   343
  return TracedValue<T> (lhs - rhs.Get ());
mathieu@2468
   344
}
mathieu@2468
   345
mathieu@2468
   346
template <typename T, typename U>
mathieu@2482
   347
TracedValue<T> operator / (const TracedValue<T> &lhs, const TracedValue<U> &rhs) {
mathieu@2512
   348
  TRACED_VALUE_DEBUG ("x/x");
mathieu@2482
   349
  return TracedValue<T> (lhs.Get () / rhs.Get ());
mathieu@2468
   350
}
mathieu@2468
   351
template <typename T, typename U>
mathieu@2482
   352
TracedValue<T> operator / (const TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   353
  TRACED_VALUE_DEBUG ("x/");
mathieu@2482
   354
  return TracedValue<T> (lhs.Get () / rhs);
mathieu@2468
   355
}
mathieu@2468
   356
template <typename T, typename U>
mathieu@2482
   357
TracedValue<T> operator / (const U &lhs, const TracedValue<T> &rhs) {
mathieu@2512
   358
  TRACED_VALUE_DEBUG ("/x");
mathieu@2482
   359
  return TracedValue<T> (lhs / rhs.Get ());
mathieu@2468
   360
}
mathieu@2468
   361
mathieu@2468
   362
template <typename T, typename U>
mathieu@2482
   363
TracedValue<T> operator % (const TracedValue<T> &lhs, const TracedValue<U> &rhs) {
mathieu@2512
   364
  TRACED_VALUE_DEBUG ("x%x");
mathieu@2482
   365
  return TracedValue<T> (lhs.Get () % rhs.Get ());
mathieu@2468
   366
}
mathieu@2468
   367
template <typename T, typename U>
mathieu@2482
   368
TracedValue<T> operator % (const TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   369
  TRACED_VALUE_DEBUG ("x%");
mathieu@2482
   370
  return TracedValue<T> (lhs.Get () % rhs);
mathieu@2468
   371
}
mathieu@2468
   372
template <typename T, typename U>
mathieu@2482
   373
TracedValue<T> operator % (const U &lhs, const TracedValue<T> &rhs) {
mathieu@2512
   374
  TRACED_VALUE_DEBUG ("%x");
mathieu@2482
   375
  return TracedValue<T> (lhs % rhs.Get ());
mathieu@2468
   376
}
mathieu@2468
   377
mathieu@2468
   378
template <typename T, typename U>
mathieu@2482
   379
TracedValue<T> operator ^ (const TracedValue<T> &lhs, const TracedValue<U> &rhs) {
mathieu@2512
   380
  TRACED_VALUE_DEBUG ("x^x");
mathieu@2482
   381
  return TracedValue<T> (lhs.Get () ^ rhs.Get ());
mathieu@2468
   382
}
mathieu@2468
   383
template <typename T, typename U>
mathieu@2482
   384
TracedValue<T> operator ^ (const TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   385
  TRACED_VALUE_DEBUG ("x^");
mathieu@2482
   386
  return TracedValue<T> (lhs.Get () ^ rhs);
mathieu@2468
   387
}
mathieu@2468
   388
template <typename T, typename U>
mathieu@2482
   389
TracedValue<T> operator ^ (const U &lhs, const TracedValue<T> &rhs) {
mathieu@2512
   390
  TRACED_VALUE_DEBUG ("^x");
mathieu@2482
   391
  return TracedValue<T> (lhs ^ rhs.Get ());
mathieu@2468
   392
}
mathieu@2468
   393
mathieu@2468
   394
template <typename T, typename U>
mathieu@2482
   395
TracedValue<T> operator | (const TracedValue<T> &lhs, const TracedValue<U> &rhs) {
mathieu@2512
   396
  TRACED_VALUE_DEBUG ("x|x");
mathieu@2482
   397
  return TracedValue<T> (lhs.Get () | rhs.Get ());
mathieu@2468
   398
}
mathieu@2468
   399
template <typename T, typename U>
mathieu@2482
   400
TracedValue<T> operator | (const TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   401
  TRACED_VALUE_DEBUG ("x|");
mathieu@2482
   402
  return TracedValue<T> (lhs.Get () | rhs);
mathieu@2468
   403
}
mathieu@2468
   404
template <typename T, typename U>
mathieu@2482
   405
TracedValue<T> operator | (const U &lhs, const TracedValue<T> &rhs) {
mathieu@2512
   406
  TRACED_VALUE_DEBUG ("|x");
mathieu@2482
   407
  return TracedValue<T> (lhs | rhs.Get ());
mathieu@2468
   408
}
mathieu@2468
   409
mathieu@2468
   410
template <typename T, typename U>
mathieu@2482
   411
TracedValue<T> operator & (const TracedValue<T> &lhs, const TracedValue<U> &rhs) {
mathieu@2512
   412
  TRACED_VALUE_DEBUG ("x&x");
mathieu@2482
   413
  return TracedValue<T> (lhs.Get () & rhs.Get ());
mathieu@2468
   414
}
mathieu@2468
   415
template <typename T, typename U>
mathieu@2482
   416
TracedValue<T> operator & (const TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   417
  TRACED_VALUE_DEBUG ("x&");
mathieu@2482
   418
  return TracedValue<T> (lhs.Get () & rhs);
mathieu@2468
   419
}
mathieu@2468
   420
template <typename T, typename U>
mathieu@2482
   421
TracedValue<T> operator & (const U &lhs, const TracedValue<T> &rhs) {
mathieu@2512
   422
  TRACED_VALUE_DEBUG ("&x");
mathieu@2482
   423
  return TracedValue<T> (lhs & rhs.Get ());
mathieu@2468
   424
}
mathieu@2468
   425
mathieu@2468
   426
template <typename T, typename U>
mathieu@2482
   427
TracedValue<T> operator << (const TracedValue<T> &lhs, const TracedValue<U> &rhs) {
mathieu@2512
   428
  TRACED_VALUE_DEBUG ("x<<x");
mathieu@2482
   429
  return TracedValue<T> (lhs.Get () << rhs.Get ());
mathieu@2468
   430
}
mathieu@2468
   431
template <typename T, typename U>
mathieu@2482
   432
TracedValue<T> operator << (const TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   433
  TRACED_VALUE_DEBUG ("x<<");
mathieu@2482
   434
  return TracedValue<T> (lhs.Get () << rhs);
mathieu@2468
   435
}
mathieu@2468
   436
template <typename T, typename U>
mathieu@2482
   437
TracedValue<T> operator << (const U &lhs, const TracedValue<T> &rhs) {
mathieu@2512
   438
  TRACED_VALUE_DEBUG ("<<x");
mathieu@2482
   439
  return TracedValue<T> (lhs << rhs.Get ());
mathieu@2468
   440
}
mathieu@2468
   441
mathieu@2468
   442
template <typename T, typename U>
mathieu@2482
   443
TracedValue<T> operator >> (const TracedValue<T> &lhs, const TracedValue<U> &rhs) {
mathieu@2512
   444
  TRACED_VALUE_DEBUG ("x>>x");
mathieu@2482
   445
  return TracedValue<T> (lhs.Get () >> rhs.Get ());
mathieu@2468
   446
}
mathieu@2468
   447
template <typename T, typename U>
mathieu@2482
   448
TracedValue<T> operator >> (const TracedValue<T> &lhs, const U &rhs) {
mathieu@2512
   449
  TRACED_VALUE_DEBUG ("x>>");
mathieu@2482
   450
  return TracedValue<T> (lhs.Get () >> rhs);
mathieu@2468
   451
}
mathieu@2468
   452
template <typename T, typename U>
mathieu@2482
   453
TracedValue<T> operator >> (const U &lhs, const TracedValue<T> &rhs) {
mathieu@2512
   454
  TRACED_VALUE_DEBUG (">>x");
mathieu@2482
   455
  return TracedValue<T> (lhs >> rhs.Get ());
mathieu@2468
   456
}
mathieu@2468
   457
mathieu@2468
   458
mathieu@2468
   459
template <typename T>
mathieu@2482
   460
TracedValue<T> operator + (const TracedValue<T> &lhs) {
mathieu@2512
   461
  TRACED_VALUE_DEBUG ("(+x)");
mathieu@2482
   462
  return TracedValue<T> (+lhs.Get ());
mathieu@2468
   463
}
mathieu@2468
   464
template <typename T>
mathieu@2482
   465
TracedValue<T> operator - (const TracedValue<T> &lhs) {
mathieu@2512
   466
  TRACED_VALUE_DEBUG ("(-x)");
mathieu@2482
   467
  return TracedValue<T> (-lhs.Get ());
mathieu@2468
   468
}
mathieu@2468
   469
template <typename T>
mathieu@2482
   470
TracedValue<T> operator ~ (const TracedValue<T> &lhs) {
mathieu@2512
   471
  TRACED_VALUE_DEBUG ("(~x)");
mathieu@2482
   472
  return TracedValue<T> (~lhs.Get ());
mathieu@2468
   473
}
mathieu@2468
   474
template <typename T>
mathieu@2482
   475
TracedValue<T> operator ! (const TracedValue<T> &lhs) {
mathieu@2512
   476
  TRACED_VALUE_DEBUG ("(!x)");
mathieu@2482
   477
  return TracedValue<T> (!lhs.Get ());
mathieu@2468
   478
}
mathieu@2468
   479
tomh@345
   480
mathieu@2462
   481
} // namespace ns3
tomh@345
   482
mathieu@2482
   483
#endif /* TRACED_VALUE_H */