14#ifndef RUNTIME_CONTAINER_H
15#define RUNTIME_CONTAINER_H
44#include <boost/mpl/equal.hpp>
45#include <boost/mpl/minus.hpp>
46#include <boost/mpl/less.hpp>
47#include <boost/mpl/fold.hpp>
48#include <boost/mpl/lambda.hpp>
49#include <boost/mpl/vector.hpp>
50#include <boost/mpl/push_back.hpp>
51#include <boost/mpl/protect.hpp>
52#include <boost/mpl/begin.hpp>
53#include <boost/mpl/end.hpp>
54#include <boost/mpl/next.hpp>
55#include <boost/mpl/deref.hpp>
56#include <boost/mpl/at.hpp>
57#include <boost/mpl/range_c.hpp>
58#include <boost/mpl/size.hpp>
60using namespace boost::mpl::placeholders;
126template<
bool recursive = true>
131 std::cout <<
"RC mixin level "
133 <<
level <<
": " <<
v << std::endl;
254 static typename F::return_type
apply( _ContainerT&
c, _IndexT position, F&
f )
256 if ( position == _Index ) {
261 typedef typename boost::mpl::deref< _Iterator >::type stagetype;
262 stagetype& stage =
static_cast<stagetype&
>(
c);
269 ,
typename boost::mpl::next< _Iterator >::type
295 static typename F::return_type
apply( _ContainerT&
c, _IndexT position, F&
f )
299 return typename F::return_type(0);
308template<
typename _ContainerT
313 typedef typename _ContainerT::types
types;
314 static typename F::return_type
apply(_ContainerT&
c, _IndexT , F&
f)
316 return f(
static_cast<_StageT&
>(
c));
328template<
typename _ContainerT
330 ,
typename Position = boost::mpl::size<typename _ContainerT::types>
331 ,
typename _IndexT =
int
334 typedef typename _ContainerT::types
types;
335 typedef typename boost::mpl::if_<
336 boost::mpl::less<Position, boost::mpl::size<types> >
341 ,
typename boost::mpl::begin<types>::type
342 ,
typename boost::mpl::end<types>::type
348 static typename F::return_type
apply(_ContainerT&
c, _IndexT position, F&
f) {
349 return type::apply(
c, position,
f);
363template<
typename InterfacePolicy = DefaultInterface
364 ,
typename InitializerPolicy = default_initializer
365 ,
typename PrinterPolicy = default_printer>
371 typedef boost::mpl::vector<>::type
types;
374 constexpr std::size_t
size()
const {
return 0;}
377 const char*
string =
"base";
399template <
typename BASE,
typename T>
403 rc_mixin() : mMember() {BASE::_initializer(mMember);}
410 typedef typename boost::mpl::push_back<typename BASE::types, mixin_type>::type
types;
412 typedef typename boost::mpl::plus< typename BASE::level, boost::mpl::int_<1> >
::type level;
416 if (BASE::_printer(mMember, level::value)) {
422 constexpr std::size_t
size()
const {
return level::value + 1;}
446 template<
typename _T>
448 return mFunctor(*me);
482 ,
bool unroll =
false
522:
boost::mpl::bool_<(T::level::value < boost::mpl::minus<N, boost::mpl::int_<1>>::value) > {};
524template< typename T, typename N > struct rtc_equal
525: boost::mpl::bool_<boost::mpl::equal<typename T::wrapped_type, N>::type> {};
534template<typename Types, typename Base, typename N = boost::mpl::size<Types>>
537 typedef typename boost::mpl::lambda<
544 typename boost::mpl::fold<
554 , boost::mpl::apply2< boost::mpl::protect<apply_rc_mixin>::type, _1, _2 >
556 , boost::mpl::identity<_1>
570template<typename Types, typename Base, typename N = boost::mpl::size<Types>>
571struct create_rtc_types
573 typedef typename boost::mpl::fold<
574 boost::mpl::range_c<int, 0, N::value>
575 , boost::mpl::vector< >
576 , boost::mpl::push_back<_1, create_rtc<Types , Base , boost::mpl::plus<_2, boost::mpl::int_<1>>>>
The default interface for the RuntimeContainer.
return_type operator()(T &t)
Getter functor, forwards to the container mixin's get function.
return_type operator()(T &t)
F::return_type return_type
F::return_type operator()(_T &me)
Mixin component is used with different data types.
wrapped_type & operator*()
get wrapped object reference
wrapped_type get() const
get wrapped object
wrapped_type operator+(const wrapped_type &v)
operator
rc_mixin< BASE, wrapped_type > mixin_type
this is the self type
constexpr std::size_t size() const
get size at this stage
T wrapped_type
each stage of the mixin class wraps one type
boost::mpl::push_back< typenameBASE::types, mixin_type >::type types
a vector of all mixin stage types so far
void set(wrapped_type v)
set member wrapped object
wrapped_type & operator+=(const wrapped_type &v)
operator
F::return_type apply(int index, F f)
boost::mpl::plus< typenameBASE::level, boost::mpl::int_< 1 > >::type level
increment the level counter
wrapped_type & operator=(const wrapped_type &v)
assignment operator to wrapped type
Setter functor, forwards to the container mixin's set function.
return_type operator()(T &t)
GLint GLint GLsizei GLint GLenum GLenum type
recursive_printer verbose_printer
boost::mpl::lambda< rc_mixin< _1, _2 > >::type apply_rc_mixin
Applying rc_mixin with the template parameters as placeholders The wrapping into an mpl lambda is nec...
the technical base of the mixin class
boost::mpl::int_<-1 > level
constexpr std::size_t size() const
get size which is 0 at this level
InitializerPolicy _initializer
boost::mpl::vector ::type types
Default initializer does nothing.
Default printer prints nothing.
bool operator()(const T &v, int level=-1)
An initializer for simple types The initializer makes use of truncation for non-float types,...
static F::return_type apply(_ContainerT &c, _IndexT position, F &f)
static F::return_type apply(_ContainerT &c, _IndexT position, F &f)
static F::return_type apply(_ContainerT &c, _IndexT, F &f)
static F::return_type apply(_ContainerT &c, _IndexT position, F &f)
boost::mpl::if_< boost::mpl::less< Position, boost::mpl::size< types > >, rc_apply< _ContainerT, typenameboost::mpl::at< types, Position >::type, _IndexT, F >, rc_apply_at< _ContainerT, _IndexT, typenameboost::mpl::begin< types >::type, typenameboost::mpl::end< types >::type, 0, F > >::type type
Verbose printer to print levels recursively.
check the mixin level to be below specified level
Verbose printer to print a single level.
Verbose printer prints level and content.
bool operator()(const T &v, int level=-1)