src/core/int-value.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Sun, 17 Feb 2008 04:38:34 +0100
changeset 2424 217a447122a6
parent 2410 88dc7d4a6731
child 2427 9245ec163111
permissions -rw-r--r--
split initial value from ParamSpec.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
#ifndef INT_VALUE_H
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
#define INT_VALUE_H
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
#include "value.h"
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
#include "param-spec-helper.h"
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
#include <stdint.h>
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
namespace ns3 {
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
class IntValue : public Value
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
{
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
public:
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
  IntValue (int64_t value);
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
  void Set (int64_t value);
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
  int64_t Get (void) const;
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
  virtual PValue Copy (void) const;
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
  virtual std::string SerializeToString (Ptr<const ParamSpec> spec) const;
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
  virtual bool DeserializeFromString (std::string value, Ptr<const ParamSpec> spec);
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
  IntValue (PValue value);
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
  operator PValue () const;
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
private:
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
  int64_t m_value;
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
};
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
2410
88dc7d4a6731 introduce top-level ParamSpec for bindings.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2408
diff changeset
    27
class IntParamSpec : public ParamSpec {};
88dc7d4a6731 introduce top-level ParamSpec for bindings.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2408
diff changeset
    28
2408
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    29
template <typename T1>
2424
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2410
diff changeset
    30
Ptr<ParamSpec> MakeIntParamSpec (T1 a1);
2408
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    31
template <typename T1>
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    32
Ptr<ParamSpec> MakeIntParamSpec (T1 a1,
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
				 int64_t minValue,
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
				 int64_t maxValue);
2408
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    35
template <typename T1, typename T2>
2424
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2410
diff changeset
    36
Ptr<ParamSpec> MakeIntParamSpec (T1 a1, T2 a2);
2408
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    37
template <typename T1, typename T2>
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    38
Ptr<ParamSpec> MakeIntParamSpec (T1 a1, T2 a2,
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    39
				 int64_t minValue,
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    40
				 int64_t maxValue);
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    41
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    42
} // namespace ns3
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    43
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    44
namespace ns3 {
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    45
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    46
class IntValueChecker
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    47
{
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
public:
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    49
  IntValueChecker (int64_t minValue, int64_t maxValue);
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    50
  bool Check (const int64_t &value) const;
2408
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    51
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    52
  template <typename T, typename U>
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    53
  static IntValueChecker Create (U T::*) {
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    54
    return IntValueChecker (std::numeric_limits<U>::min (),
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    55
			    std::numeric_limits<U>::max ());
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    56
  }
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    57
  template <typename T, typename U>
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    58
  static IntValueChecker Create (U (T::*) (void) const) {
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    59
    return IntValueChecker (std::numeric_limits<U>::min (),
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    60
			    std::numeric_limits<U>::max ());
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    61
  }
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    62
  template <typename T, typename U>
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    63
  static IntValueChecker Create (void (T::*) (U)) {
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    64
    return IntValueChecker (std::numeric_limits<U>::min (),
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    65
			    std::numeric_limits<U>::max ());
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    66
  }
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    67
private:
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
  int64_t m_minValue;
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    69
  int64_t m_maxValue;
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
};
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
2408
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    72
template <typename T1>
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    73
Ptr<ParamSpec> 
2424
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2410
diff changeset
    74
MakeIntParamSpec (T1 a1)
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    75
{
2424
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2410
diff changeset
    76
  return MakeParamSpecHelperWithChecker<IntParamSpec,IntValue> (a1,
2410
88dc7d4a6731 introduce top-level ParamSpec for bindings.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2408
diff changeset
    77
						       IntValueChecker::Create (a1));
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    78
}
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    79
2408
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    80
template <typename T1>
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    81
Ptr<ParamSpec> MakeIntParamSpec (T1 a1,
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    82
				 int64_t minValue,
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    83
				 int64_t maxValue)
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    84
{
2424
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2410
diff changeset
    85
  return MakeParamSpecHelperWithChecker<IntParamSpec,IntValue> (a1,
2410
88dc7d4a6731 introduce top-level ParamSpec for bindings.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2408
diff changeset
    86
						       IntValueChecker (minValue, maxValue));
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    87
}
2408
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    88
template <typename T1, typename T2>
2424
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2410
diff changeset
    89
Ptr<ParamSpec> MakeIntParamSpec (T1 a1, T2 a2)
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    90
{
2424
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2410
diff changeset
    91
  return MakeParamSpecHelperWithChecker<IntParamSpec,IntValue> (a1, a2,
2410
88dc7d4a6731 introduce top-level ParamSpec for bindings.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2408
diff changeset
    92
						       IntValueChecker::Create (a1));
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    93
}
2408
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    94
template <typename T1, typename T2>
04fe819b3ad1 rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    95
Ptr<ParamSpec> MakeIntParamSpec (T1 a1, T2 a2,
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    96
				 int64_t minValue,
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    97
				 int64_t maxValue)
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    98
{
2424
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2410
diff changeset
    99
  return MakeParamSpecHelperWithChecker<IntParamSpec,IntValue> (a1, a2,
2410
88dc7d4a6731 introduce top-level ParamSpec for bindings.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2408
diff changeset
   100
						       IntValueChecker (minValue, maxValue));
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   101
}
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   102
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   103
} // namespace ns3
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   104
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   105
#endif /* INT_VALUE_H */