-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
116 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,179 +1,100 @@ | ||
#ifndef PH_BITMASK_HPP | ||
#define PH_BITMASK_HPP | ||
|
||
#include "phproperty.hpp" | ||
#include "bitmask.hpp" | ||
|
||
#include <cstring> | ||
|
||
namespace PhWidgets | ||
{ | ||
struct IPhWidgetsProperty | ||
{ | ||
template<class ReturnT, class WidgetClassT, class ArgumentT, ArgumentT ArgumentID> | ||
inline ReturnT getArgument() const | ||
{ | ||
return static_cast<const WidgetClassT*>(this)->resource.argument[ArgumentID].get(); | ||
} | ||
|
||
template<class ValueT, class WidgetClassT, class ArgumentT, ArgumentT ArgumentID> | ||
inline void setArgument(ValueT val) | ||
{ | ||
static_cast<const WidgetClassT*>(this)->resource.argument[ArgumentID].set(val); | ||
} | ||
}; | ||
|
||
template<class ValueT = void, | ||
const cppproperties::detail::property_flag::e_property_flag Flag = (const cppproperties::detail::property_flag::e_property_flag)(cppproperties::detail::flag_chooser<ValueT>::flag)> | ||
class phbitmask {}; | ||
|
||
//phbitmask<void>: | ||
template<> | ||
class phbitmask<void, cppproperties::detail::property_flag::ro> : | ||
public cppproperties::detail::property_flag | ||
template<class MaskT, class FlagT> | ||
class phbitmask | ||
{ | ||
public: | ||
typedef cppproperties::detail::property_flag flags; | ||
}; | ||
|
||
template<> | ||
class phbitmask<void, cppproperties::detail::property_flag::wo> : | ||
public cppproperties::detail::property_flag | ||
{ | ||
public: | ||
typedef cppproperties::detail::property_flag flags; | ||
}; | ||
|
||
template<> | ||
class phbitmask<void, cppproperties::detail::property_flag::rw> : | ||
public cppproperties::detail::property_flag | ||
{ | ||
public: | ||
typedef cppproperties::detail::property_flag flags; | ||
}; | ||
|
||
//phbitmask<Value>: | ||
template<typename ValueT> | ||
class phbitmask<ValueT, cppproperties::detail::property_flag::ro>//ValueT == const... | ||
{ | ||
typedef cppproperties::property<ValueT, cppproperties::detail::property_flag::ro> cpp_property_t; | ||
|
||
template<class WidgetClassT, typename cppproperties::detail::get_parent_func<ValueT, WidgetClassT>::getter_t Getter> | ||
struct bind_internal : | ||
public cpp_property_t::template bind<WidgetClassT, Getter> | ||
{ | ||
bind_internal(WidgetClassT *parent) : | ||
cpp_property_t::template bind<WidgetClassT, Getter>(parent) | ||
{} | ||
|
||
private: | ||
inline bind_internal &operator=(ValueT const &); | ||
inline bind_internal &operator=(bind_internal const &); | ||
}; | ||
|
||
public: | ||
template<class WidgetClassT, class ArgumentT, ArgumentT ArgumentID> | ||
class bind : | ||
public bind_internal< | ||
IPhWidgetsProperty, | ||
&IPhWidgetsProperty::getArgument<ValueT, WidgetClassT, ArgumentT, ArgumentID> | ||
> | ||
class bind_internal : | ||
private phproperty<MaskT>::template bind<WidgetClassT, ArgumentT, ArgumentID> | ||
{ | ||
typedef bind_internal< | ||
IPhWidgetsProperty, | ||
&IPhWidgetsProperty::getArgument<ValueT, WidgetClassT, ArgumentT, ArgumentID> | ||
> cpp_bind_t; | ||
typedef cppbitmasks::bitmask<MaskT, FlagT> value_t; | ||
typedef phproperty<MaskT> ph_property_t; | ||
typedef typename ph_property_t::template bind<WidgetClassT, ArgumentT, ArgumentID> ph_bind_t; | ||
|
||
public: | ||
bind(WidgetClassT *parent) : | ||
cpp_bind_t(parent) | ||
bind_internal(WidgetClassT *parent) : | ||
ph_bind_t(parent) | ||
{} | ||
|
||
private: | ||
inline bind &operator=(ValueT const &); | ||
inline bind &operator=(bind const &); | ||
}; | ||
inline void set(value_t value) | ||
{ | ||
static_cast<ph_bind_t*>(this)->set(value); | ||
} | ||
|
||
}; | ||
inline value_t get() const | ||
{ | ||
value_t bm; | ||
MaskT mask = static_cast<ph_bind_t*>(this)->get(); | ||
std::memcpy(&bm, &mask, sizeof(MaskT)); | ||
return bm; | ||
} | ||
|
||
inline operator value_t() const { return get(); } | ||
|
||
template<typename ValueT> | ||
class phbitmask<ValueT, cppproperties::detail::property_flag::rw>//ValueT != const... | ||
{ | ||
typedef cppproperties::property<ValueT, cppproperties::detail::property_flag::rw> cpp_property_t; | ||
inline bind_internal &operator=(value_t value) { set(value); return *this; } | ||
|
||
template<class WidgetClassT, typename cppproperties::detail::get_parent_func<ValueT, WidgetClassT>::getter_t Getter, typename cppproperties::detail::get_parent_func<ValueT, WidgetClassT>::setter_t Setter> | ||
struct bind_internal : | ||
public cpp_property_t::template bind<WidgetClassT, Getter, Setter> | ||
{ | ||
bind_internal(WidgetClassT *parent) : | ||
cpp_property_t::template bind<WidgetClassT, Getter, Setter>(parent) | ||
{} | ||
inline value_t operator()(void) const { return get(); } | ||
|
||
using cpp_property_t::template bind<WidgetClassT, Getter, Setter>::operator=; | ||
inline void operator()(value_t value) { set(value); return *this; } | ||
}; | ||
|
||
public: | ||
|
||
template<class WidgetClassT, class ArgumentT, ArgumentT ArgumentID> | ||
class bind : | ||
public bind_internal< | ||
IPhWidgetsProperty, | ||
&IPhWidgetsProperty::getArgument<ValueT, WidgetClassT, ArgumentT, ArgumentID>, | ||
&IPhWidgetsProperty::setArgument<ValueT, WidgetClassT, ArgumentT, ArgumentID> | ||
> | ||
public bind_internal<WidgetClassT, ArgumentT, ArgumentID> | ||
{ | ||
typedef bind_internal< | ||
IPhWidgetsProperty, | ||
&IPhWidgetsProperty::getArgument<ValueT, WidgetClassT, ArgumentT, ArgumentID>, | ||
&IPhWidgetsProperty::setArgument<ValueT, WidgetClassT, ArgumentT, ArgumentID> | ||
> cpp_bind_t; | ||
typedef bind_internal<WidgetClassT, ArgumentT, ArgumentID> internal_bind_t; | ||
|
||
public: | ||
bind(WidgetClassT *parent) : | ||
cpp_bind_t(parent) | ||
internal_bind_t(parent) | ||
{} | ||
|
||
using cpp_bind_t::operator=; | ||
using internal_bind_t::operator=; | ||
}; | ||
|
||
}; | ||
|
||
template<typename ValueT> | ||
class phbitmask<ValueT, cppproperties::detail::property_flag::wo>//ValueT != const... | ||
/*template<class MaskT, class FlagT> | ||
class phbitmask<const MaskT, FlagT> | ||
{ | ||
typedef cppproperties::property<ValueT, cppproperties::detail::property_flag::wo> cpp_property_t; | ||
|
||
template<class WidgetClassT, typename cppproperties::detail::get_parent_func<ValueT, WidgetClassT>::setter_t Setter> | ||
struct bind_internal : | ||
public cpp_property_t::template bind<WidgetClassT, Setter> | ||
{ | ||
bind_internal(WidgetClassT *parent) : | ||
cpp_property_t::template bind<WidgetClassT, Setter>(parent) | ||
{} | ||
|
||
using cpp_property_t::template bind<WidgetClassT, Setter>::operator=; | ||
}; | ||
|
||
public: | ||
template<class WidgetClassT, class ArgumentT, ArgumentT ArgumentID> | ||
class bind : | ||
public bind_internal< | ||
IPhWidgetsProperty, | ||
&IPhWidgetsProperty::setArgument<ValueT, WidgetClassT, ArgumentT, ArgumentID> | ||
> | ||
private phproperty<const MaskT>::template bind<WidgetClassT, ArgumentT, ArgumentID> | ||
{ | ||
typedef bind_internal< | ||
IPhWidgetsProperty, | ||
&IPhWidgetsProperty::setArgument<ValueT, WidgetClassT, ArgumentT, ArgumentID> | ||
> cpp_bind_t; | ||
typedef cppbitmasks::bitmask<MaskT, FlagT> value_t; | ||
typedef phproperty<const MaskT>::template bind<WidgetClassT, ArgumentT, ArgumentID> ph_bind_t; | ||
public: | ||
bind(WidgetClassT *parent) : | ||
cpp_bind_t(parent) | ||
ph_bind_t(parent) | ||
{} | ||
using cpp_bind_t::operator=; | ||
}; | ||
inline value_t get() const | ||
{ | ||
value_t bm; | ||
MaskT mask = static_cast<ph_bind_t*>(this)->get(); | ||
std::memcpy(&bm, &mask, sizeof(MaskT)); | ||
return bm; | ||
} | ||
}; | ||
inline operator value_t() const { return get(); } | ||
inline value_t operator()(void) const { return get(); } | ||
private: | ||
inline bind &operator=(value_t const &); | ||
inline bind &operator=(bind const &); | ||
}; | ||
};*/ | ||
} | ||
|
||
#endif |
Oops, something went wrong.