src/core/value-helper.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Fri, 15 Feb 2008 05:38:29 +0100
changeset 2422 6cbcb8fe4551
child 2424 217a447122a6
permissions -rw-r--r--
macro-ify

#ifndef VALUE_HELPER_H
#define VALUE_HELPER_H

#include "class-value-helper.h"

#define VALUE_HELPER_HEADER_1(type) \
  type (PValue value); \
  operator PValue () const;

#define VALUE_HELPER_HEADER_2(type)				\
  class type##Value : public Value {};				\
  class type##ParamSpec : public ParamSpec {};			\
  template <typename T1>					\
  Ptr<ParamSpec> Make##type##ParamSpec (T1 a1,			\
					type initialValue)	\
  {								\
    return MakeClassValueHelperParamSpec< type ,		\
      type##Value, type##ParamSpec> (a1, initialValue);		\
  }								\
  template <typename T1, typename T2>				\
    Ptr<ParamSpec> Make##type##ParamSpec (T1 a1, T2 a2,		\
					  type initialValue)	\
  {								\
    return MakeClassValueHelperParamSpec<type,			\
      type##Value,type##ParamSpec> (a1, a2, initialValue);	\
  }

#define VALUE_HELPER_CPP(type)						\
  type::type (PValue value)						\
  {									\
    *this = ClassValueHelperExtractFrom<type,type##Value> (value);	\
  }									\
  type::operator PValue () const					\
  {									\
    return ClassValueHelperConvertTo<type,type##Value> (this);		\
  }

#endif /* VALUE_HELPER_H */