src/core/param-spec-helper.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 13 Feb 2008 21:00:33 +0100
changeset 2408 04fe819b3ad1
parent 2403 759adf2fdf98
child 2410 88dc7d4a6731
permissions -rw-r--r--
rework param-spec-helper code to avoid having to deal with pointers to member functions et al.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
#ifndef PARAM_SPEC_HELPER_H
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
#define PARAM_SPEC_HELPER_H
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
namespace ns3 {
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
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: 2403
diff changeset
     6
template <typename T1, typename V>
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
     7
Ptr<ParamSpec>
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: 2403
diff changeset
     8
MakeParamSpecHelper (T1 a1, V initialValue);
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: 2403
diff changeset
     9
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: 2403
diff changeset
    10
template <typename T1, typename T2, typename V>
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: 2403
diff changeset
    11
Ptr<ParamSpec>
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: 2403
diff changeset
    12
MakeParamSpecHelper (T1 a1, T2 a2, V initialValue);
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    13
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: 2403
diff changeset
    14
template <typename T1, typename V, typename CHECKER>
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    15
Ptr<ParamSpec>
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: 2403
diff changeset
    16
MakeParamSpecHelperWithChecker (T1 a1, V initialValue, CHECKER checker);
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    17
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: 2403
diff changeset
    18
template <typename T1, typename T2, typename V, typename CHECKER>
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: 2403
diff changeset
    19
Ptr<ParamSpec>
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: 2403
diff changeset
    20
MakeParamSpecHelperWithChecker (T1 a1, T2 a2, V initialValue, CHECKER checker);
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    21
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    22
} // namespace ns3
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    23
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: 2403
diff changeset
    24
/***************************************************************
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: 2403
diff changeset
    25
 *        The implementation of the above functions.
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: 2403
diff changeset
    26
 ***************************************************************/
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    27
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: 2403
diff changeset
    28
#include "type-traits.h"
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    29
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    30
namespace ns3 {
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    31
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    32
template <typename T, typename U, typename CHECKER>
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
class ParamSpecHelper : public ParamSpec
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
{
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
public:
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    36
  ParamSpecHelper (PValue initialValue, CHECKER checker);
2374
570f3c6c6142 make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2372
diff changeset
    37
  virtual bool Set (ObjectBase * object, PValue value) const;
570f3c6c6142 make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2372
diff changeset
    38
  virtual bool Get (const ObjectBase * object, PValue value) const;
570f3c6c6142 make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2372
diff changeset
    39
  virtual bool Check (PValue value) const;
2380
64dbfb5cf589 split ParamSpec::CreateInitialValue -> ParamSpec::GetInitialValue + ParamSpec::CreateValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    40
  virtual PValue GetInitialValue (void) const;
64dbfb5cf589 split ParamSpec::CreateInitialValue -> ParamSpec::GetInitialValue + ParamSpec::CreateValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
    41
  virtual PValue CreateValue (void) const;
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    42
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    43
private:
2403
759adf2fdf98 report more get/set errors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2398
diff changeset
    44
  virtual bool DoSet (T *object, const U *v) const = 0;
759adf2fdf98 report more get/set errors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2398
diff changeset
    45
  virtual bool DoGet (const T *object, U *v) const = 0;
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    46
  PValue m_initialValue;
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    47
  CHECKER m_checker;
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
};
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    49
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    50
template <typename T>
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    51
class ParamSpecHelperSimpleChecker
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    52
{
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    53
public:
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    54
  bool Check (const T &value) const {return true;}
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    55
};
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    56
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    57
template <typename T, typename U, typename V, typename CHECKER>
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    58
Ptr<ParamSpec>
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: 2403
diff changeset
    59
DoMakeParamSpecHelperOne (U T::*memberVariable, V initialValue, CHECKER checker)
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    60
{
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    61
  class MemberVariable : public ParamSpecHelper<T,V,CHECKER>
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    62
    {
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    63
    public:
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    64
      MemberVariable (U T::*memberVariable, V initialValue, CHECKER checker)
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    65
	: ParamSpecHelper<T,V,CHECKER> (initialValue, checker),
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    66
	m_memberVariable (memberVariable)
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    67
	{}
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    68
    private:
2403
759adf2fdf98 report more get/set errors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2398
diff changeset
    69
      virtual bool DoSet (T *object, const V *v) const {
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    70
	(object->*m_memberVariable) = v->Get ();
2403
759adf2fdf98 report more get/set errors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2398
diff changeset
    71
	return true;
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    72
      }
2403
759adf2fdf98 report more get/set errors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2398
diff changeset
    73
      virtual bool DoGet (const T *object, V *v) const {
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    74
	v->Set (object->*m_memberVariable);
2403
759adf2fdf98 report more get/set errors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2398
diff changeset
    75
	return true;
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    76
      }
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    77
      
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    78
      U T::*m_memberVariable;
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    79
    };
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    80
  return Ptr<ParamSpec> (new MemberVariable (memberVariable, initialValue, checker), false);
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
    81
}
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: 2403
diff changeset
    82
template <typename T, typename U, typename V>
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: 2403
diff changeset
    83
Ptr<ParamSpec>
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: 2403
diff changeset
    84
DoMakeParamSpecHelperOne (U T::*memberVariable, V initialValue)
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: 2403
diff changeset
    85
{
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: 2403
diff changeset
    86
  return DoMakeParamSpecHelperOne (memberVariable, initialValue, ParamSpecHelperSimpleChecker<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: 2403
diff changeset
    87
}
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: 2403
diff changeset
    88
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: 2403
diff changeset
    89
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: 2403
diff changeset
    90
template <typename T, typename U, typename V, typename CHECKER>
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: 2403
diff changeset
    91
Ptr<ParamSpec>
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: 2403
diff changeset
    92
DoMakeParamSpecHelperOne (U (T::*getter) (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: 2403
diff changeset
    93
			  V initialValue, CHECKER checker)
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: 2403
diff changeset
    94
{
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: 2403
diff changeset
    95
  class MemberMethod : public ParamSpecHelper<T,V,CHECKER>
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: 2403
diff changeset
    96
    {
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: 2403
diff changeset
    97
    public:
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: 2403
diff changeset
    98
      MemberMethod (U (T::*getter) (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: 2403
diff changeset
    99
		    V initialValue, CHECKER checker)
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: 2403
diff changeset
   100
	: ParamSpecHelper<T,V,CHECKER> (initialValue, checker),
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: 2403
diff changeset
   101
	m_getter (getter)
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: 2403
diff changeset
   102
	{}
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: 2403
diff changeset
   103
    private:
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: 2403
diff changeset
   104
      virtual bool DoSet (T *object, const V *v) 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: 2403
diff changeset
   105
	return false;
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: 2403
diff changeset
   106
      }
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: 2403
diff changeset
   107
      virtual bool DoGet (const T *object, V *v) 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: 2403
diff changeset
   108
	v->Set ((object->*m_getter) ());
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: 2403
diff changeset
   109
	return true;
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: 2403
diff changeset
   110
      }
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: 2403
diff changeset
   111
      U (T::*m_getter) (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: 2403
diff changeset
   112
    };
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: 2403
diff changeset
   113
  return Ptr<ParamSpec> (new MemberMethod (getter, initialValue, checker), false);
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: 2403
diff changeset
   114
}
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   115
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   116
template <typename T, typename U, typename V>
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   117
Ptr<ParamSpec>
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: 2403
diff changeset
   118
DoMakeParamSpecHelperOne (U (T::*getter) (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: 2403
diff changeset
   119
			  V initialValue)
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: 2403
diff changeset
   120
{
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: 2403
diff changeset
   121
  return DoMakeParamSpecHelperOne (getter, initialValue, ParamSpecHelperSimpleChecker<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: 2403
diff changeset
   122
}
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: 2403
diff changeset
   123
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: 2403
diff changeset
   124
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: 2403
diff changeset
   125
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: 2403
diff changeset
   126
template <typename T, typename U, typename V, typename CHECKER>
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: 2403
diff changeset
   127
Ptr<ParamSpec>
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: 2403
diff changeset
   128
DoMakeParamSpecHelperOne (void (T::*setter) (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: 2403
diff changeset
   129
			  V initialValue, CHECKER checker)
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   130
{
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: 2403
diff changeset
   131
  class MemberMethod : public ParamSpecHelper<T,V,CHECKER>
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: 2403
diff changeset
   132
    {
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: 2403
diff changeset
   133
    public:
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: 2403
diff changeset
   134
      MemberMethod (void (T::*setter) (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: 2403
diff changeset
   135
		    V initialValue, CHECKER checker)
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: 2403
diff changeset
   136
	: ParamSpecHelper<T,V,CHECKER> (initialValue, checker),
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: 2403
diff changeset
   137
	m_setter (setter)
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: 2403
diff changeset
   138
	{}
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: 2403
diff changeset
   139
    private:
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: 2403
diff changeset
   140
      virtual bool DoSet (T *object, const V *v) 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: 2403
diff changeset
   141
	(object->*m_setter) (v->Get ());
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: 2403
diff changeset
   142
	return true;
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: 2403
diff changeset
   143
      }
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: 2403
diff changeset
   144
      virtual void DoGet (const T *object, V *v) 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: 2403
diff changeset
   145
	return false;
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: 2403
diff changeset
   146
      }
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: 2403
diff changeset
   147
      void (T::*m_setter) (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: 2403
diff changeset
   148
    };
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: 2403
diff changeset
   149
  return Ptr<ParamSpec> (new MemberMethod (setter, initialValue, checker), false);
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   150
}
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   151
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: 2403
diff changeset
   152
template <typename T, typename U, typename V>
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: 2403
diff changeset
   153
Ptr<ParamSpec>
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: 2403
diff changeset
   154
DoMakeParamSpecHelperOne (void (T::*setter) (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: 2403
diff changeset
   155
			  V initialValue)
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: 2403
diff changeset
   156
{
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: 2403
diff changeset
   157
  return DoMakeParamSpecHelperOne (setter, initialValue, 
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: 2403
diff changeset
   158
				   ParamSpecHelperSimpleChecker<typename TypeTraits<U>::ReferencedType> ());
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: 2403
diff changeset
   159
}
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: 2403
diff changeset
   160
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: 2403
diff changeset
   161
2393
025986c8b400 untested templates rarely work.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   162
template <typename T, typename U, typename V, typename W, typename CHECKER>
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   163
Ptr<ParamSpec>
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: 2403
diff changeset
   164
DoMakeParamSpecHelperTwo (void (T::*setter) (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: 2403
diff changeset
   165
			  V (T::*getter) (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: 2403
diff changeset
   166
			  W initialValue, 
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: 2403
diff changeset
   167
			  CHECKER checker = ParamSpecHelperSimpleChecker<V> ())
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   168
{
2393
025986c8b400 untested templates rarely work.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   169
  class MemberMethod : public ParamSpecHelper<T,W,CHECKER>
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   170
    {
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   171
    public:
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   172
      MemberMethod (void (T::*setter) (U), 
2393
025986c8b400 untested templates rarely work.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   173
		    V (T::*getter) (void) const,
025986c8b400 untested templates rarely work.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   174
		    W initialValue, CHECKER checker)
025986c8b400 untested templates rarely work.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   175
	: ParamSpecHelper<T,W,CHECKER> (initialValue, checker),
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   176
	m_setter (setter),
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   177
	m_getter (getter)
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   178
	{}
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   179
    private:
2403
759adf2fdf98 report more get/set errors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2398
diff changeset
   180
      virtual bool DoSet (T *object, const W *v) const {
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   181
	(object->*m_setter) (v->Get ());
2403
759adf2fdf98 report more get/set errors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2398
diff changeset
   182
	return true;
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   183
      }
2403
759adf2fdf98 report more get/set errors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2398
diff changeset
   184
      virtual bool DoGet (const T *object, W *v) const {
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   185
	v->Set ((object->*m_getter) ());
2403
759adf2fdf98 report more get/set errors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2398
diff changeset
   186
	return true;
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   187
      }
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   188
      void (T::*m_setter) (U);
2393
025986c8b400 untested templates rarely work.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   189
      V (T::*m_getter) (void) const;
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   190
    };
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   191
  return Ptr<ParamSpec> (new MemberMethod (setter, getter, initialValue, checker), false);
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   192
}
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   193
2393
025986c8b400 untested templates rarely work.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   194
template <typename T, typename U, typename V, typename W>
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   195
Ptr<ParamSpec>
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: 2403
diff changeset
   196
DoMakeParamSpecHelperTwo (void (T::*setter) (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: 2403
diff changeset
   197
		      V (T::*getter) (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: 2403
diff changeset
   198
		      W initialValue)
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   199
{
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: 2403
diff changeset
   200
  return DoMakeParamSpecHelperTwo (setter, getter, initialValue, ParamSpecHelperSimpleChecker<V> ());
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   201
}
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   202
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: 2403
diff changeset
   203
template <typename T, typename U, typename V, typename W, typename CHECKER>
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   204
Ptr<ParamSpec>
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: 2403
diff changeset
   205
DoMakeParamSpecHelperTwo (V (T::*getter) (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: 2403
diff changeset
   206
			  void (T::*setter) (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: 2403
diff changeset
   207
			  W initialValue, 
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: 2403
diff changeset
   208
			  CHECKER checker)
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   209
{
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: 2403
diff changeset
   210
  return DoMakeParamSpecHelperTwo (setter, getter, initialValue, checker);
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   211
}
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   212
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: 2403
diff changeset
   213
template <typename T, typename U, typename V, typename W, typename CHECKER>
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   214
Ptr<ParamSpec>
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: 2403
diff changeset
   215
DoMakeParamSpecHelperTwo (V (T::*getter) (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: 2403
diff changeset
   216
			  void (T::*setter) (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: 2403
diff changeset
   217
			  W initialValue)
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   218
{
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: 2403
diff changeset
   219
  return DoMakeParamSpecHelperTwo (setter, getter, initialValue);
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   220
}
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   221
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   222
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   223
template <typename T, typename U, typename CHECKER>
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   224
ParamSpecHelper<T,U,CHECKER>::ParamSpecHelper (PValue initialValue, CHECKER checker)
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   225
  : m_initialValue (initialValue),
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   226
    m_checker (checker)
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   227
{}
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   228
template <typename T, typename U, typename CHECKER>
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   229
bool 
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   230
ParamSpecHelper<T,U,CHECKER>::Set (ObjectBase * object, PValue val) const
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   231
{
2374
570f3c6c6142 make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2372
diff changeset
   232
  const U *value = val.DynCast<const U*> ();
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   233
  if (value == 0)
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   234
    {
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   235
      return false;
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   236
    }
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   237
  T *obj = dynamic_cast<T *> (object);
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   238
  if (obj == 0)
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   239
    {
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   240
      return false;
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   241
    }
2403
759adf2fdf98 report more get/set errors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2398
diff changeset
   242
  return DoSet (obj, value);
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   243
}
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   244
template <typename T, typename U, typename CHECKER>
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   245
bool 
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   246
ParamSpecHelper<T,U,CHECKER>::Get (const ObjectBase * object, PValue val) const
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   247
{
2374
570f3c6c6142 make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2372
diff changeset
   248
  U *value = val.DynCast<U*> ();
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   249
  if (value == 0)
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   250
    {
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   251
      return false;
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   252
    }
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   253
  const T *obj = dynamic_cast<const T *> (object);
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   254
  if (obj == 0)
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   255
    {
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   256
      return false;
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   257
    }
2403
759adf2fdf98 report more get/set errors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2398
diff changeset
   258
  return DoGet (obj, value);
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   259
}
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   260
template <typename T, typename U, typename CHECKER>
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   261
bool 
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   262
ParamSpecHelper<T,U,CHECKER>::Check (PValue value) const
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   263
{
2374
570f3c6c6142 make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2372
diff changeset
   264
  const U *val = value.DynCast<const U*> ();
570f3c6c6142 make Ptr<T> convertible to a Value.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2372
diff changeset
   265
  if (val == 0)
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   266
    {
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   267
      return false;
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   268
    }
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   269
  return m_checker.Check (val->Get ());
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   270
}
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   271
template <typename T, typename U, typename CHECKER>
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   272
PValue
2380
64dbfb5cf589 split ParamSpec::CreateInitialValue -> ParamSpec::GetInitialValue + ParamSpec::CreateValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
   273
ParamSpecHelper<T,U,CHECKER>::GetInitialValue (void) const
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   274
{
2375
6f8733409b3b add back IntValue support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2374
diff changeset
   275
  return m_initialValue;
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   276
}
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   277
2380
64dbfb5cf589 split ParamSpec::CreateInitialValue -> ParamSpec::GetInitialValue + ParamSpec::CreateValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
   278
template <typename T, typename U, typename CHECKER>
64dbfb5cf589 split ParamSpec::CreateInitialValue -> ParamSpec::GetInitialValue + ParamSpec::CreateValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
   279
PValue
64dbfb5cf589 split ParamSpec::CreateInitialValue -> ParamSpec::GetInitialValue + ParamSpec::CreateValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
   280
ParamSpecHelper<T,U,CHECKER>::CreateValue (void) const
64dbfb5cf589 split ParamSpec::CreateInitialValue -> ParamSpec::GetInitialValue + ParamSpec::CreateValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
   281
{
64dbfb5cf589 split ParamSpec::CreateInitialValue -> ParamSpec::GetInitialValue + ParamSpec::CreateValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
   282
  return m_initialValue.Copy ();
64dbfb5cf589 split ParamSpec::CreateInitialValue -> ParamSpec::GetInitialValue + ParamSpec::CreateValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
   283
}
64dbfb5cf589 split ParamSpec::CreateInitialValue -> ParamSpec::GetInitialValue + ParamSpec::CreateValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2375
diff changeset
   284
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: 2403
diff changeset
   285
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: 2403
diff changeset
   286
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: 2403
diff changeset
   287
template <typename T1, typename V>
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: 2403
diff changeset
   288
Ptr<ParamSpec>
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: 2403
diff changeset
   289
MakeParamSpecHelper (T1 a1, V initialValue)
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: 2403
diff changeset
   290
{
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: 2403
diff changeset
   291
  return DoMakeParamSpecHelperOne (a1, initialValue);
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: 2403
diff changeset
   292
}
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: 2403
diff changeset
   293
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: 2403
diff changeset
   294
template <typename T1, typename T2, typename V>
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: 2403
diff changeset
   295
Ptr<ParamSpec>
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: 2403
diff changeset
   296
MakeParamSpecHelper (T1 a1, T2 a2, V initialValue)
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: 2403
diff changeset
   297
{
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: 2403
diff changeset
   298
  return DoMakeParamSpecHelperTwo (a1, a2, initialValue);
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: 2403
diff changeset
   299
}
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: 2403
diff changeset
   300
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: 2403
diff changeset
   301
template <typename T1, typename V, typename CHECKER>
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: 2403
diff changeset
   302
Ptr<ParamSpec>
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: 2403
diff changeset
   303
MakeParamSpecHelperWithChecker (T1 a1, V initialValue, CHECKER checker)
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: 2403
diff changeset
   304
{
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: 2403
diff changeset
   305
  return DoMakeParamSpecHelperOne (a1, initialValue, checker);
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: 2403
diff changeset
   306
}
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: 2403
diff changeset
   307
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: 2403
diff changeset
   308
template <typename T1, typename T2, typename V, typename CHECKER>
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: 2403
diff changeset
   309
Ptr<ParamSpec>
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: 2403
diff changeset
   310
MakeParamSpecHelperWithChecker (T1 a1, T2 a2, V initialValue, CHECKER checker)
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: 2403
diff changeset
   311
{
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: 2403
diff changeset
   312
  return DoMakeParamSpecHelperTwo (a1, a2, initialValue, checker);
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: 2403
diff changeset
   313
}
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: 2403
diff changeset
   314
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   315
} // namespace ns3
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   316
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   317
#endif /* PARAM_SPEC_HELPER_H */