Skip to content

Commit

Permalink
[format] refactor away from camel_case
Browse files Browse the repository at this point in the history
  - except for some type aliases, template params, and defs
  • Loading branch information
ricejasonf committed Mar 19, 2016
1 parent 3fcf1f0 commit e8a0800
Show file tree
Hide file tree
Showing 94 changed files with 1,306 additions and 1,316 deletions.
4 changes: 2 additions & 2 deletions include/nbdl/concepts/DownstreamMessage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ namespace nbdl
struct DownstreamMessage<T, hana::when<hana::Sequence<T>::value>>
{
static constexpr bool value = std::is_same<
decltype(message::getChannel(std::declval<T>())),
message::channel::Downstream
decltype(message::get_channel(std::declval<T>())),
message::channel::downstream
>::value;
};
} // nbdl
Expand Down
4 changes: 2 additions & 2 deletions include/nbdl/concepts/UpstreamMessage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ namespace nbdl
struct UpstreamMessage<T, hana::when<hana::Sequence<T>::value>>
{
static constexpr bool value = std::is_same<
decltype(message::getChannel(std::declval<T>())),
message::channel::Upstream
decltype(message::get_channel(std::declval<T>())),
message::channel::upstream
>::value;
};
} // nbdl
Expand Down
24 changes: 12 additions & 12 deletions src/Bind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,62 +18,62 @@ namespace nbdl {
namespace hana = boost::hana;

template<typename T1, typename T2, typename = void>
struct BindImpl
struct bind_impl
{
template<typename Binder, typename X>
static void apply(Binder&& binder, X&& x)
{
//use this?
// std::forward<Binder>(binder).bindMember(std::forward<decltype(X)>(x));
binder.bindMember(std::forward<X>(x));
// std::forward<Binder>(binder).bind_member(std::forward<X>(x));
binder.bind_member(std::forward<X>(x));
}
};

template<typename T1, typename T2>
struct BindImpl<T1, T2, EnableIfVariant<T2>>
struct bind_impl<T1, T2, enable_if_variant<T2>>
{
template<typename Binder, typename V>
static void apply(Binder&& binder, V&& variant)
{
binder.bindVariant(std::forward<V>(variant));
binder.bind_variant(std::forward<V>(variant));
}
};

template<typename T1, typename T2>
struct BindImpl<T1, T2, EnableIfEntity<T2>>
struct bind_impl<T1, T2, enable_if_entity<T2>>
{
template<typename Binder, typename E>
static void apply(Binder&& binder, E&& entity)
{
hana::unpack(
hana::transform(entityMembers<E>(),
hana::transform(entity_members<E>(),
[&](auto member_type) {
return entityMember(entity, member_type);
return entity_member(entity, member_type);
}),
[&](auto&&... members) {
binder.bindSequence(std::forward<decltype(members)>(members)...);
binder.bind_sequence(std::forward<decltype(members)>(members)...);
});
}
};

template<typename T1, typename T2>
struct BindImpl<T1, T2,
struct bind_impl<T1, T2,
std::enable_if_t<hana::Foldable<T2>::value>>
{
template<typename Binder, typename Xs>
static void apply(Binder&& binder, Xs&& xs)
{
hana::unpack(std::forward<Xs>(xs),
[&](auto&&... members) {
binder.bindSequence(std::forward<decltype(members)>(members)...);
binder.bind_sequence(std::forward<decltype(members)>(members)...);
});
}
};

template<typename Binder, typename Xs>
void bind(Binder&& binder, Xs&& xs)
{
BindImpl<typename std::decay<Binder>::type, typename std::decay<Xs>::type>::apply(
bind_impl<typename std::decay<Binder>::type, typename std::decay<Xs>::type>::apply(
std::forward<Binder>(binder),
std::forward<Xs>(xs));
}
Expand Down
58 changes: 29 additions & 29 deletions src/Context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ template<
typename ConsumerLookup,
typename MakeContextCells,
typename StoreMap>
class Context
class context
{
// calling the push functions after
// the context is destroyed will result
// in undefined behaviour
struct PushUpstreamFn
struct push_upstream_fn
{
Context& ctx;
context& ctx;

PushUpstreamFn(Context& c) : ctx(c) { }
push_upstream_fn(context& c) : ctx(c) { }

template<typename Message>
void operator()(Message&& m)
Expand All @@ -46,11 +46,11 @@ class Context
}
};

struct PushDownstreamFn
struct push_downstream_fn
{
Context& ctx;
context& ctx;

PushDownstreamFn(Context& c) : ctx(c) { }
push_downstream_fn(context& c) : ctx(c) { }

template<typename Message>
void operator()(Message&& m)
Expand All @@ -62,8 +62,8 @@ class Context
};

using Cells = typename decltype(MakeContextCells{}(
hana::type_c<PushUpstreamFn>,
hana::type_c<PushDownstreamFn>
hana::type_c<push_upstream_fn>,
hana::type_c<push_downstream_fn>
))::type;

Cells cells;
Expand All @@ -81,34 +81,34 @@ class Context
) + hana::size_c<1>)::value;

template<typename Cell, typename PushFn, bool>
struct MakeCellHelper;
struct make_cell_helper;

template<std::size_t i, typename... Args>
auto makeCell(Args&& ...args)
auto make_cell(Args&& ...args)
{
using Cell = std::decay_t<decltype(hana::at_c<i>(std::declval<Cells>()))>;
using PushFn = typename decltype(
hana::if_(hana::bool_c<(i < provider_count)>, // is provider?
hana::type_c<PushDownstreamFn>,
hana::type_c<PushUpstreamFn>
hana::type_c<push_downstream_fn>,
hana::type_c<push_upstream_fn>
)
)::type;

return Cell(PushFn(*this), std::forward<Args>(args)...);
}

template<typename Message>
void propagate_message(Message&& m, message::channel::Upstream)
void propagate_message(Message&& m, message::channel::upstream)
{
using Index = decltype(hana::at_key(ProviderLookup{}, hana::decltype_(message::getPath(m))));
using Index = decltype(hana::at_key(ProviderLookup{}, hana::decltype_(message::get_path(m))));
constexpr Index index{};
nbdl::receive_message(cells[index], std::forward<Message>(m));
}

template<typename Message>
void propagate_message(Message&& m, message::channel::Downstream)
void propagate_message(Message&& m, message::channel::downstream)
{
using Index = decltype(hana::at_key(ConsumerLookup{}, hana::decltype_(message::getPath(m))));
using Index = decltype(hana::at_key(ConsumerLookup{}, hana::decltype_(message::get_path(m))));
constexpr Index index{};
nbdl::receive_message(cells[index], std::forward<Message>(m));
}
Expand All @@ -117,8 +117,8 @@ class Context
template<typename Message>
void push_message(Message&& m)
{
constexpr auto path_type = hana::decltype_(message::getPath(m));
constexpr auto channel = decltype(message::getChannel(m)){};
constexpr auto path_type = hana::decltype_(message::get_path(m));
constexpr auto channel = decltype(message::get_channel(m)){};
propagate_message(
nbdl::dispatch(
stores[path_type],
Expand All @@ -132,15 +132,15 @@ class Context
template<std::size_t ...i, typename ...Args,
typename = std::enable_if_t<(sizeof...(Args) > 0)>
>
Context(std::index_sequence<i...>, Args&& ...args)
: cells(makeCell<i>(args)...)
context(std::index_sequence<i...>, Args&& ...args)
: cells(make_cell<i>(args)...)
, stores()
{ }

// default constructor helper
template<std::size_t ...i>
explicit Context(std::index_sequence<i...>)
: cells(makeCell<i>()...)
explicit context(std::index_sequence<i...>)
: cells(make_cell<i>()...)
, stores()
{ }

Expand All @@ -149,28 +149,28 @@ class Context
template<typename Arg1, typename ...Args,
typename = std::enable_if_t<(
(sizeof...(Args) + 1 == cell_count)
&& !std::is_same<std::decay_t<Arg1>, Context>::value
&& !std::is_same<std::decay_t<Arg1>, context>::value
&& !hana::is_a<hana::ext::std::integer_sequence_tag, Arg1>
)>
>
explicit Context(Arg1&& arg1, Args&& ...args)
: Context(
explicit context(Arg1&& arg1, Args&& ...args)
: context(
std::make_index_sequence<sizeof...(Args) + 1>{},
std::forward<Arg1>(arg1),
std::forward<Args>(args)...
)
{ }

// default constructor
Context()
: Context(std::make_index_sequence<cell_count>{})
context()
: context(std::make_index_sequence<cell_count>{})
{ }

// Push functions contain references to self
// another option is to use shared_from_this,
// but that responsibility should be on the
// Providers.
Context(Context const&) = delete;
context(context const&) = delete;
};

}//nbdl
Expand Down
4 changes: 2 additions & 2 deletions src/Make.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace nbdl {

//general high order make function
template<template<class...> class T>
struct Make
struct make_fn
{
template<typename... X>
constexpr auto operator()(X... x) const
Expand All @@ -24,7 +24,7 @@ struct Make
}
};
template<template<class...> class T>
constexpr Make<T> make{};
constexpr make_fn<T> make{};

}//nbdl

Expand Down
48 changes: 24 additions & 24 deletions src/Member.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,71 +10,71 @@
namespace nbdl {

template<class Owner, typename T, T Owner::*p>
struct Member
struct member
{
using OwnerType = Owner;
using MemberType = T;
static constexpr T Owner::*ptr = p;
};
template<class M>
struct MemberId;
struct member_id;

template<typename T>
struct MemberTraits;
struct member_traits;
template<class Owner, typename T>
struct MemberTraits<T Owner::*>
struct member_traits<T Owner::*>
{
using OwnerType = Owner;
using MemberType = T;
};

template<class M>
struct MemberName;
struct member_name;

template<class M>
struct MemberDefault;
struct member_default;

template<class M>
struct MemberHasDefault
struct member_has_default
{
static const bool value = false;
};

template<class M>
struct MemberStringMaxLength
struct member_string_max_length
{
//default max length of 50 for all strings
static const int value = 50;
};

template<class M>
struct MemberStringMinLength
struct member_string_min_length
{
static const int value = 0;
};

template<class M>
struct MemberMatch
struct member_match
{
static constexpr const char *value = nullptr;
};

//allow a string to have zero length
template<class M>
struct MemberAllowBlank
struct member_allow_blank
{
static const bool value = false;
};

//string treated as buffer and does no trim filtering
template<class M>
struct MemberRawBuffer
struct member_raw_buffer
{
static const bool value = false;
};

template<class M>
struct MemberCustomValidator
struct member_custom_validator
{
template<typename T, typename AddError>
static void validate(T&, AddError) {}
Expand All @@ -85,31 +85,31 @@ struct MemberCustomValidator
/*
* MACROS
*/
#define NBDL_MEMBER(mptr) ::nbdl::Member<typename ::nbdl::MemberTraits<decltype(mptr)>::OwnerType, typename ::nbdl::MemberTraits<decltype(mptr)>::MemberType, mptr>
#define NBDL_MEMBER(mptr) ::nbdl::member<typename ::nbdl::member_traits<decltype(mptr)>::OwnerType, typename ::nbdl::member_traits<decltype(mptr)>::MemberType, mptr>

#define NBDL_MEMBER_ID(mptr, v) template<> struct MemberId<NBDL_MEMBER(mptr)> \
#define NBDL_MEMBER_ID(mptr, v) template<> struct member_id<NBDL_MEMBER(mptr)> \
{ static const uint8_t value = v; };

#define NBDL_MEMBER_NAME(Owner, member_name) \
#define NBDL_MEMBER_NAME(Owner, MemberName) \
template<> \
struct MemberName<NBDL_MEMBER(&Owner::member_name)> \
{ static constexpr const char *value = #member_name; };
struct member_name<NBDL_MEMBER(&Owner::MemberName)> \
{ static constexpr const char *value = #MemberName; };

#define NBDL_MEMBER_DEFAULT(mptr, val) template<> struct MemberDefault<NBDL_MEMBER(mptr)> \
#define NBDL_MEMBER_DEFAULT(mptr, val) template<> struct member_default<NBDL_MEMBER(mptr)> \
{ static constexpr decltype(val) value = val; }; \
template<> struct MemberHasDefault<NBDL_MEMBER(mptr)> \
template<> struct member_has_default<NBDL_MEMBER(mptr)> \
{ static const bool value = true; };

#define NBDL_MEMBER_MAXLENGTH(mptr, v) template<> struct MemberStringMaxLength<NBDL_MEMBER(mptr)> \
#define NBDL_MEMBER_MAXLENGTH(mptr, v) template<> struct member_string_max_length<NBDL_MEMBER(mptr)> \
{ static const unsigned value = v; };

#define NBDL_MEMBER_MINLENGTH(mptr, v) template<> struct MemberStringMinLength<NBDL_MEMBER(mptr)> \
#define NBDL_MEMBER_MINLENGTH(mptr, v) template<> struct member_string_min_length<NBDL_MEMBER(mptr)> \
{ static const unsigned value = v; };

#define NBDL_MEMBER_MATCH(mptr, reg) template<> struct MemberMatch<NBDL_MEMBER(mptr)> \
#define NBDL_MEMBER_MATCH(mptr, reg) template<> struct member_match<NBDL_MEMBER(mptr)> \
{ static constexpr const char *value = reg; };

#define NBDL_MEMBER_ALLOWBLANK(mptr) template<> struct MemberAllowBlank<NBDL_MEMBER(mptr)> \
#define NBDL_MEMBER_ALLOWBLANK(mptr) template<> struct member_allow_blank<NBDL_MEMBER(mptr)> \
{ static const bool value = true; };


Expand Down
Loading

0 comments on commit e8a0800

Please sign in to comment.