src/core/boolean-value.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 13 Feb 2008 23:37:46 +0100
changeset 2410 88dc7d4a6731
parent 2408 04fe819b3ad1
child 2424 217a447122a6
permissions -rw-r--r--
introduce top-level ParamSpec for bindings.
mathieu@2371
     1
#ifndef BOOLEAN_VALUE_H
mathieu@2371
     2
#define BOOLEAN_VALUE_H
mathieu@2371
     3
mathieu@2371
     4
#include "value.h"
mathieu@2371
     5
#include "param-spec-helper.h"
mathieu@2371
     6
#include "ptr.h"
mathieu@2371
     7
mathieu@2371
     8
namespace ns3 {
mathieu@2371
     9
mathieu@2371
    10
class BooleanValue : public Value
mathieu@2371
    11
{
mathieu@2371
    12
public:
mathieu@2371
    13
  BooleanValue (bool value);
mathieu@2371
    14
  void Set (bool value);
mathieu@2371
    15
  bool Get (void) const;
mathieu@2371
    16
mathieu@2374
    17
  virtual PValue Copy (void) const;
mathieu@2371
    18
  virtual std::string SerializeToString (Ptr<const ParamSpec> spec) const;
mathieu@2371
    19
  virtual bool DeserializeFromString (std::string value, Ptr<const ParamSpec> spec);
mathieu@2372
    20
mathieu@2374
    21
  BooleanValue (PValue value);
mathieu@2374
    22
  operator PValue () const;
mathieu@2371
    23
private:
mathieu@2371
    24
  bool m_value;
mathieu@2371
    25
};
mathieu@2371
    26
mathieu@2410
    27
class BooleanParamSpec : public ParamSpec {};
mathieu@2410
    28
mathieu@2371
    29
mathieu@2408
    30
template <typename T1>
mathieu@2408
    31
Ptr<ParamSpec> MakeBooleanParamSpec (T1 a1, bool initialValue);
mathieu@2371
    32
mathieu@2408
    33
template <typename T1, typename T2>
mathieu@2408
    34
Ptr<ParamSpec> MakeBooleanParamSpec (T1 a1, T2 a2, bool initialValue);
mathieu@2371
    35
mathieu@2371
    36
} // namespace ns3
mathieu@2371
    37
mathieu@2371
    38
mathieu@2371
    39
// Implementation of template functions below.
mathieu@2371
    40
namespace ns3 {
mathieu@2371
    41
mathieu@2408
    42
template <typename T1>
mathieu@2408
    43
Ptr<ParamSpec> MakeBooleanParamSpec (T1 a1, bool initialValue)
mathieu@2371
    44
{
mathieu@2410
    45
  return MakeParamSpecHelper<BooleanParamSpec> (a1, BooleanValue (initialValue));
mathieu@2371
    46
}
mathieu@2371
    47
mathieu@2408
    48
template <typename T1, typename T2>
mathieu@2408
    49
Ptr<ParamSpec> MakeBooleanParamSpec (T1 a1, T2 a2, bool initialValue)
mathieu@2371
    50
{
mathieu@2410
    51
  return MakeParamSpecHelper<BooleanParamSpec> (a1, a2, BooleanValue (initialValue));
mathieu@2371
    52
}
mathieu@2371
    53
mathieu@2371
    54
mathieu@2371
    55
mathieu@2371
    56
} // namespace ns3
mathieu@2371
    57
mathieu@2371
    58
#endif /* BOOLEAN_PARAMETER_H */