src/core/boolean-value.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 30 Jan 2008 19:13:06 +0100
changeset 2372 bf4efb9359c6
parent 2371 2118204a86e6
child 2374 570f3c6c6142
permissions -rw-r--r--
attempt to perform correctly automatic conversions.
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.h"
mathieu@2371
     6
#include "param-spec-helper.h"
mathieu@2371
     7
#include "ptr.h"
mathieu@2371
     8
mathieu@2371
     9
namespace ns3 {
mathieu@2371
    10
mathieu@2371
    11
class BooleanValue : public Value
mathieu@2371
    12
{
mathieu@2371
    13
public:
mathieu@2371
    14
  BooleanValue (bool value);
mathieu@2371
    15
  void Set (bool value);
mathieu@2371
    16
  bool Get (void) const;
mathieu@2371
    17
mathieu@2371
    18
  virtual Ptr<Value> Copy (void) const;
mathieu@2371
    19
  virtual std::string SerializeToString (Ptr<const ParamSpec> spec) const;
mathieu@2371
    20
  virtual bool DeserializeFromString (std::string value, Ptr<const ParamSpec> spec);
mathieu@2372
    21
mathieu@2372
    22
  BooleanValue (Ptr<const Value> value);
mathieu@2372
    23
  operator Ptr<Value> () const;
mathieu@2372
    24
  operator Ptr<const Value> () const;
mathieu@2371
    25
private:
mathieu@2371
    26
  bool m_value;
mathieu@2371
    27
};
mathieu@2371
    28
mathieu@2371
    29
mathieu@2371
    30
template <typename T>
mathieu@2371
    31
Ptr<ParamSpec> MakeBooleanParamSpec (bool T::*v, bool initialValue);
mathieu@2371
    32
mathieu@2371
    33
template <typename T>
mathieu@2371
    34
Ptr<ParamSpec> MakeBooleanParamSpec (bool (T::*getter) (void) const, 
mathieu@2371
    35
				     bool initialValue);
mathieu@2371
    36
mathieu@2371
    37
template <typename T>
mathieu@2371
    38
Ptr<ParamSpec> MakeBooleanParamSpec (bool (T::*getter) (void) const,
mathieu@2371
    39
				     void (T::*setter) (bool),
mathieu@2371
    40
				     bool initialValue);
mathieu@2371
    41
template <typename T>
mathieu@2371
    42
Ptr<ParamSpec> MakeBooleanParamSpec (void (T::*setter) (bool),
mathieu@2371
    43
				     bool initialValue);
mathieu@2371
    44
mathieu@2371
    45
} // namespace ns3
mathieu@2371
    46
mathieu@2371
    47
mathieu@2371
    48
// Implementation of template functions below.
mathieu@2371
    49
namespace ns3 {
mathieu@2371
    50
mathieu@2371
    51
template <typename T>
mathieu@2371
    52
Ptr<ParamSpec> MakeBooleanParamSpec (bool T::*v, bool initialValue)
mathieu@2371
    53
{
mathieu@2371
    54
  return Create<MemberVariableParamSpecHelper<T,BooleanValue,bool> > (v, initialValue);
mathieu@2371
    55
}
mathieu@2371
    56
mathieu@2371
    57
template <typename T>
mathieu@2371
    58
Ptr<ParamSpec> MakeBooleanParamSpec (void (T::*setter) (bool),
mathieu@2371
    59
				     bool (T::*getter) (void) const,
mathieu@2371
    60
				     bool initialValue)
mathieu@2371
    61
{
mathieu@2371
    62
  return Create<MemberMethodParamSpecHelper<T,BooleanValue,bool> > (setter, getter, initialValue);
mathieu@2371
    63
}
mathieu@2371
    64
mathieu@2371
    65
template <typename T>
mathieu@2371
    66
Ptr<ParamSpec> MakeBooleanParamSpec (bool (T::*getter) (void) const,
mathieu@2371
    67
				     bool initialValue)
mathieu@2371
    68
{
mathieu@2371
    69
  return Create<MemberMethodGetterParamSpecHelper<T,BooleanValue,bool> > (getter, initialValue);
mathieu@2371
    70
}
mathieu@2371
    71
mathieu@2371
    72
template <typename T>
mathieu@2371
    73
Ptr<ParamSpec> MakeBooleanParamSpec (void (T::*setter) (bool),
mathieu@2371
    74
				     bool initialValue)
mathieu@2371
    75
{
mathieu@2371
    76
  return Create<MemberMethodSetterParamSpecHelper<T,BooleanValue,bool> > (setter, initialValue);
mathieu@2371
    77
}
mathieu@2371
    78
mathieu@2371
    79
} // namespace ns3
mathieu@2371
    80
mathieu@2371
    81
#endif /* BOOLEAN_PARAMETER_H */