Skip to content

Commit

Permalink
The interface is just a binding wrapper.
Browse files Browse the repository at this point in the history
  • Loading branch information
billyquith committed Nov 28, 2020
1 parent 1d053f0 commit f76fae4
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions include/ponder/detail/propertyfactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace detail {
* Access traits for an exposed type T.
* - I.e. how we use an instance to access the bound property data using the correct interface.
* Traits:
* - ReadOnlyInterface & ReadWriteInterface : RO (const) or RW data.
* - ReadOnlyBinder & ReadWriteBinder : RO (const) or RW data.
* - Impl : which specialise property impl to use.
*/
template <typename T, typename E = void>
Expand All @@ -54,14 +54,14 @@ struct AccessTraits
static constexpr PropertyAccessKind kind = PropertyAccessKind::Simple;

template <class B>
class ReadOnlyInterface
class ReadOnlyBinder
{
public:
typedef B Binding;
typedef typename Binding::ClassType ClassType;
typedef typename Binding::AccessAdapter::InputType InputType;

ReadOnlyInterface(const Binding& a) : m_bound(a) {}
ReadOnlyBinder(const Binding& a) : m_bound(a) {}

typename Binding::AccessAdapter::OutputType getter(ClassType& c) const {return m_bound.access(c);}

Expand All @@ -72,12 +72,12 @@ struct AccessTraits
};

template <class B>
class ReadWriteInterface : public ReadOnlyInterface<B>
class ReadWriteBinder : public ReadOnlyBinder<B>
{
public:
typedef ReadOnlyInterface<B> Base;
typedef ReadOnlyBinder<B> Base;

ReadWriteInterface(const typename Base::Binding& a) : ReadOnlyInterface<B>(a) {}
ReadWriteBinder(const typename Base::Binding& a) : Base(a) {}

bool setter(typename Base::ClassType& c, const typename Base::InputType& v) const {
return this->m_bound.access(c) = v, true;
Expand All @@ -100,14 +100,14 @@ struct AccessTraits<T, typename std::enable_if<std::is_enum<T>::value>::type>
static constexpr PropertyAccessKind kind = PropertyAccessKind::Enum;

template <class B>
class ReadOnlyInterface
class ReadOnlyBinder
{
public:
typedef B Binding;
typedef typename Binding::ClassType ClassType;
typedef typename Binding::AccessAdapter::InputType InputType;

ReadOnlyInterface(const Binding& a) : m_bound(a) {}
ReadOnlyBinder(const Binding& a) : m_bound(a) {}

typename Binding::AccessAdapter::OutputType getter(ClassType& c) const {return m_bound.access(c);}

Expand All @@ -118,12 +118,12 @@ struct AccessTraits<T, typename std::enable_if<std::is_enum<T>::value>::type>
};

template <class B>
class ReadWriteInterface : public ReadOnlyInterface<B>
class ReadWriteBinder : public ReadOnlyBinder<B>
{
public:
typedef ReadOnlyInterface<B> Base;
typedef ReadOnlyBinder<B> Base;

ReadWriteInterface(const typename Base::Binding& a) : ReadOnlyInterface<B>(a) {}
ReadWriteBinder(const typename Base::Binding& a) : ReadOnlyBinder<B>(a) {}

bool setter(typename Base::ClassType& c, const typename Base::InputType& v) const {
return this->m_bound.access(c) = v, true;
Expand All @@ -147,15 +147,15 @@ struct AccessTraits<T, typename std::enable_if<ponder_ext::ArrayMapper<T>::isArr
typedef ponder_ext::ArrayMapper<T> ArrayTraits;

template <typename B>
class ReadOnlyInterface : public ArrayTraits
class ReadOnlyBinder : public ArrayTraits
{
public:
typedef B Binding;
typedef T ArrayType;
typedef typename Binding::ClassType ClassType;
typedef typename Binding::AccessAdapter::InputType InputType;

ReadOnlyInterface(const Binding& a) : m_bound(a) {}
ReadOnlyBinder(const Binding& a) : m_bound(a) {}

ArrayType& array(ClassType& c) const {return m_bound.access(c);}
const ArrayType& array(const ClassType& c) const {return m_bound.access(c);}
Expand All @@ -164,12 +164,12 @@ struct AccessTraits<T, typename std::enable_if<ponder_ext::ArrayMapper<T>::isArr
};

template <class B>
class ReadWriteInterface : public ReadOnlyInterface<B>
class ReadWriteBinder : public ReadOnlyBinder<B>
{
public:
typedef ReadOnlyInterface<B> Base;
typedef ReadOnlyBinder<B> Base;

ReadWriteInterface(const typename Base::Binding& a) : ReadOnlyInterface<B>(a) {}
ReadWriteBinder(const typename Base::Binding& a) : ReadOnlyBinder<B>(a) {}
};

template <typename A>
Expand All @@ -188,14 +188,14 @@ struct AccessTraits<T,
static constexpr PropertyAccessKind kind = PropertyAccessKind::User;

template <class B>
class ReadOnlyInterface
class ReadOnlyBinder
{
public:
typedef B Binding;
typedef typename Binding::ClassType ClassType;
typedef typename Binding::AccessAdapter::InputType InputType;

ReadOnlyInterface(const Binding& a) : m_bound(a) {}
ReadOnlyBinder(const Binding& a) : m_bound(a) {}

T& getter(ClassType& c) const {return m_bound.access(c);}
const T& getter(const ClassType& c) const {return m_bound.access(c);}
Expand All @@ -207,12 +207,12 @@ struct AccessTraits<T,
};

template <class B>
class ReadWriteInterface : public ReadOnlyInterface<B>
class ReadWriteBinder : public ReadOnlyBinder<B>
{
public:
typedef ReadOnlyInterface<B> Base;
typedef ReadOnlyBinder<B> Base;

ReadWriteInterface(const typename Base::Binding& a) : ReadOnlyInterface<B>(a) {}
ReadWriteBinder(const typename Base::Binding& a) : ReadOnlyBinder<B>(a) {}

bool setter(typename Base::ClassType& c, const typename Base::InputType& v) const {
return this->m_bound.access(c) = v, true;
Expand Down Expand Up @@ -275,7 +275,7 @@ class GetSet1
typedef typename AccessAdapter<typename TypeTraits::DereferencedType, PropTraits::isWritable> AA;

typedef typename Interface::template
ReadOnlyInterface<typename PropTraits::template Binding<ClassType, AA>>
ReadOnlyBinder<typename PropTraits::template Binding<ClassType, AA>>
InterfaceType;

InterfaceType m_interface;
Expand Down Expand Up @@ -304,7 +304,7 @@ class GetSet1<C, TRAITS, typename std::enable_if<TRAITS::isWritable>::type>
typedef typename AccessAdapter<typename TypeTraits::DereferencedType, PropTraits::isWritable> AA;

typedef typename Interface::template
ReadWriteInterface<typename PropTraits::template Binding<ClassType, AA>>
ReadWriteBinder<typename PropTraits::template Binding<ClassType, AA>>
InterfaceType;

InterfaceType m_interface;
Expand Down

0 comments on commit f76fae4

Please sign in to comment.