15 #ifndef _ENTITY_COMPONENT_ZIP_H_INCLUDED_
16 #define _ENTITY_COMPONENT_ZIP_H_INCLUDED_
18 #include <boost/fusion/algorithm/iteration/fold.hpp>
19 #include <boost/fusion/algorithm/query/count.hpp>
20 #include <boost/fusion/algorithm/transformation/transform.hpp>
21 #include <boost/fusion/container/vector/convert.hpp>
22 #include <boost/fusion/sequence/intrinsic/at.hpp>
23 #include <boost/fusion/sequence/intrinsic/value_at.hpp>
24 #include <boost/mpl/aux_/preprocessed/gcc/placeholders.hpp>
25 #include <boost/mpl/transform.hpp>
28 #include <type_traits>
30 #include "entity/config.hpp"
36 namespace entity {
namespace component
40 template<
typename ComponentPool>
49 template<
typename ComponentPoolTuple>
53 boost::mpl::transform<
65 template<
typename ComponentPoolWindow>
66 std::size_t
operator()(std::size_t result, ComponentPoolWindow& view)
const
68 return view.increment(
target_) ? result + 1 : result;
80 template<
typename ComponentPoolWindow>
81 std::size_t
operator()(std::size_t result, ComponentPoolWindow& view)
const
83 return view.advance(
target_) ? result + 1 : result;
92 template<
typename ComponentPoolTuple>
98 boost::fusion::result_of::as_vector<
106 windows_ = boost::fusion::as_vector(
107 boost::fusion::transform(
116 return boost::fusion::count(windows_);
121 return boost::fusion::fold(
130 return boost::fusion::fold(
137 windows_type
get()
const
144 windows_type windows_;
155 template<
typename ComponentTuple>
163 template<std::
size_t idx,
typename ZippedComponentWindows>
164 typename std::enable_if<
166 typename boost::fusion::result_of::value_at_c<
167 typename ZippedComponentWindows::windows_type, idx
169 >::type
get(ZippedComponentWindows
const& windows)
171 return boost::fusion::at_c<idx>(windows.get()).
get();
174 template<
typename ComponentPoolTuple>
184 #if ENTITY_SUPPORT_VARIADICS
185 template<
typename... Pools>
191 template<
typename Pool>
197 template<
typename Pool1,
typename Pool2>
203 template<
typename Pool1,
typename Pool2,
typename Pool3>
204 auto zip(Pool1& pool_1, Pool2& pool_2, Pool3& pool_3) -> decltype(
zip_from_tuple(
tie(pool_1, pool_2, pool_3)))
211 #endif // _ENTITY_COMPONENT_ZIP_H_INCLUDED_
boost::fusion::result_of::as_vector< typename detail::component_windows_type< ComponentPoolTuple >::type >::type windows_type
std::size_t increment(entity e)
boost::mpl::transform< ComponentPoolTuple, component_window_type< boost::mpl::_1 > >::type type
std::decay< ComponentPool >::type::window type
auto zip(Pools &...pools) -> decltype(zip_from_tuple(tie(pools...)))
std::size_t operator()(std::size_t result, ComponentPoolWindow &view) const
sized_increment_window(entity target)
std::size_t operator()(std::size_t result, ComponentPoolWindow &view) const
zipped_component_windows(ComponentPoolTuple &&pools)
std::size_t advance(entity e)
boost::fusion::vector< Pools &...> tie(Pools &...pools)
sized_advance_window(entity target)
zipped_component_windows< ComponentPoolTuple > zip_from_tuple(ComponentPoolTuple pools)