23 #ifndef ICL_CORE_CONFIG_MEMBER_ENUM_H_INCLUDED 24 #define ICL_CORE_CONFIG_MEMBER_ENUM_H_INCLUDED 36 #include <boost/function.hpp> 37 #include <boost/lambda/bind.hpp> 39 #define MEMBER_ENUM_1(suffix, cls, member1, descriptions) \ 40 (new icl_core::config::MemberEnum< \ 41 icl_core::RemoveMemberPointer<ICL_CORE_CONFIG_TYPEOF(&cls::member1)>::Type, cls>( \ 43 boost::lambda::bind(&cls::member1, boost::lambda::_1), descriptions)) 45 #define MEMBER_ENUM_2(suffix, cls, member1, member2, descriptions) \ 46 (new icl_core::config::MemberEnum< \ 47 icl_core::RemoveMemberPointer<ICL_CORE_CONFIG_TYPEOF( \ 48 &icl_core::RemoveMemberPointer<ICL_CORE_CONFIG_TYPEOF( \ 49 &cls::member1)>::Type::member2)>::Type, cls>( \ 51 boost::lambda::bind( \ 52 &icl_core::RemoveMemberPointer<ICL_CORE_CONFIG_TYPEOF(&cls::member1)>::Type::member2, \ 53 boost::lambda::bind(&cls::member1, boost::lambda::_1)), descriptions)) 55 #define MEMBER_ENUM_3(suffix, cls, member1, member2, member3, descriptions) \ 56 (new icl_core::config::MemberEnum< \ 57 icl_core::RemoveMemberPointer<ICL_CORE_CONFIG_TYPEOF( \ 58 &icl_core::RemoveMemberPointer<ICL_CORE_CONFIG_TYPEOF( \ 59 &icl_core::RemoveMemberPointer<ICL_CORE_CONFIG_TYPEOF( \ 60 &cls::member1)>::Type::member2)>::Type::member3)>::Type, cls>( \ 62 boost::lambda::bind( \ 63 &icl_core::RemoveMemberPointer<ICL_CORE_CONFIG_TYPEOF( \ 64 &icl_core::RemoveMemberPointer<ICL_CORE_CONFIG_TYPEOF( \ 65 &cls::member1)>::Type::member2)>::Type::member3, \ 66 boost::lambda::bind( \ 67 &icl_core::RemoveMemberPointer<ICL_CORE_CONFIG_TYPEOF(&cls::member1)>::Type::member2, \ 68 boost::lambda::bind(&cls::member1, boost::lambda::_1))), descriptions)) 73 template<
typename T,
typename Q,
typename V =
int32_t>
78 boost::function<T&(Q&)> accessor,
79 char const *
const * descriptions,
80 char const * end_marker = NULL)
84 if (descriptions != NULL)
87 ((end_marker == NULL) && (descriptions[i] != NULL)) ||
88 ((end_marker != NULL) && (::strcmp(descriptions[i], end_marker) != 0));
96 boost::function<T&(Q&)> accessor,
97 std::vector<std::string>
const & descriptions)
101 std::copy(descriptions.begin(), descriptions.end(), std::back_inserter(
m_descriptions));
105 virtual bool get(std::string
const & key,
Helper definitions for template programming.
virtual std::string getStringValue() const
MemberEnum(std::string const &config_suffix, boost::function< T &(Q &)> accessor, std::vector< std::string > const &descriptions)
static ConfigManager & instance()
std::string m_config_suffix
bool string2Enum(const String &str, int32_t &value, const char *const *descriptions, const char *end_marker)
virtual std::string getSuffix() const
MemberEnum(std::string const &config_suffix, boost::function< T &(Q &)> accessor, char const *const *descriptions, char const *end_marker=NULL)
bool get(const String &key, typename ConvertToRef< T >::ToRef value) const
boost::function< T &(Q &)> m_accessor
std::vector< std::string > m_descriptions