x
Yes
No
Do you want to visit DriveHQ English website?
Inicio
Características
Precios
Prueba gratuita
Software cliente
Acerca de nosotros
Servidor de archivos
|
Solución de copias de seguridad
|
Servidor FTP
|
Servidor de correo electrónico
|
Alojamiento web
|
Software cliente
Servidor de archivos
Solución de copia de seguridad
Servidor FTP
Servidor de correo electrónico
Alojamiento web
Software cliente
composite.hpp - Hosted on DriveHQ Cloud IT Platform
Arriba
Subir
Descargar
Compartir
Publicar
Nueva carpeta
Nuevo archivo
Copiar
Cortar
Eliminar
Pegar
Clasificación
Actualizar
Ruta de la carpeta: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\spirit\phoenix\composite.hpp
Girar
Efecto
Propiedad
Historial
/*============================================================================= Phoenix V1.2.1 Copyright (c) 2001-2002 Joel de Guzman Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #ifndef PHOENIX_COMPOSITE_HPP #define PHOENIX_COMPOSITE_HPP /////////////////////////////////////////////////////////////////////////////// #include
/////////////////////////////////////////////////////////////////////////////// namespace phoenix { /////////////////////////////////////////////////////////////////////////////// // // composite class // // A composite is an actor base class composed of zero or more // actors (see actor.hpp) and an operation. A composite is itself // an actor superclass and conforms to its conceptual interface. // Its eval member function un-funnels the tupled actual arguments // from the tuple by invoking each of the actors' eval member // function. The results of each are then passed on as arguments to // the operation. Specializations are provided to handle different // numbers of actors. // // Schematically: // // actor0.eval(tupled_args) --> arg0 --> | // actor1.eval(tupled_args) --> arg1 --> | // actor2.eval(tupled_args) --> arg3 --> | --> operation(arg0...argN) // ... | // actorN.eval(tupled_args) --> argN --> | // // The operation can be any suitable functor that can accept the // arguments passed in by the composite. The operation is expected // to have a member operator() that carries out the actual // operation. There should be a one to one correspondence between // actors of the composite and the arguments of the operation's // member operator(). // // The operation is also expected to have a nested template class // result
. The nested template class result should have a // typedef 'type' that reflects the return type of its member // operator(). This is essentially a type computer that answers the // metaprogramming question "Given arguments of type T0...TN, what // will be its operator()'s return type?". // // There is a special case for operations that accept no arguments. // Such nullary operations are only required to define a typedef // result_type that reflects the return type of its operator(). // // Here's an example of a simple operation that squares a number: // // struct square { // // template
// struct result { typedef ArgT type; }; // // template
// ArgT operator()(ArgT n) const { return n * n; } // }; // // As can be seen, operations can be polymorphic. Its arguments and // return type are not fixed to a particular type. The example // above for example, can handle any ArgT type as long as it has a // multiplication operator. // // Composites are not created directly. Instead, there are meta- // programs provided that indirectly create composites. See // operators.hpp, binders.hpp and functions.hpp for examples. // /////////////////////////////////////////////////////////////////////////////// template < typename OperationT , typename A = nil_t , typename B = nil_t , typename C = nil_t #if PHOENIX_LIMIT > 3 , typename D = nil_t , typename E = nil_t , typename F = nil_t #if PHOENIX_LIMIT > 6 , typename G = nil_t , typename H = nil_t , typename I = nil_t #if PHOENIX_LIMIT > 9 , typename J = nil_t , typename K = nil_t , typename L = nil_t #if PHOENIX_LIMIT > 12 , typename M = nil_t , typename N = nil_t , typename O = nil_t #endif #endif #endif #endif , typename NU = nil_t // Not used > struct composite; /////////////////////////////////////////////////////////////////////////////// // // composite <0 actor> class // /////////////////////////////////////////////////////////////////////////////// template
struct composite0_result { typedef typename OperationT::result_type type; }; ////////////////////////////////// template
struct composite
3 nil_t, nil_t, nil_t, #if PHOENIX_LIMIT > 6 nil_t, nil_t, nil_t, #if PHOENIX_LIMIT > 9 nil_t, nil_t, nil_t, #if PHOENIX_LIMIT > 12 nil_t, nil_t, nil_t, #endif #endif #endif #endif nil_t // Unused > { typedef composite
self_t; template
struct result { typedef typename composite0_result< OperationT, TupleT >::type type; }; composite(OperationT const& op_) : op(op_) {} template
typename OperationT::result_type eval(TupleT const& /*args*/) const { return op(); } mutable OperationT op; // operation }; /////////////////////////////////////////////////////////////////////////////// // // composite <1 actor> class // /////////////////////////////////////////////////////////////////////////////// template
struct composite1_result { typedef typename OperationT::template result< typename actor_result
::plain_type >::type type; }; ////////////////////////////////// template
struct composite
3 nil_t, nil_t, nil_t, #if PHOENIX_LIMIT > 6 nil_t, nil_t, nil_t, #if PHOENIX_LIMIT > 9 nil_t, nil_t, nil_t, #if PHOENIX_LIMIT > 12 nil_t, nil_t, nil_t, #endif #endif #endif #endif nil_t // Unused > { typedef composite
self_t; template
struct result { typedef typename composite1_result< OperationT, TupleT, A >::type type; }; composite(OperationT const& op_, A const& a_) : op(op_), a(a_) {} template
typename actor_result
::type eval(TupleT const& args) const { typename actor_result
::type ra = a.eval(args); return op(ra); } mutable OperationT op; // operation A a; // actors }; /////////////////////////////////////////////////////////////////////////////// // // composite <2 actors> class // /////////////////////////////////////////////////////////////////////////////// template
struct composite2_result { typedef typename OperationT::template result< typename actor_result
::plain_type, typename actor_result
::plain_type >::type type; }; ////////////////////////////////// template
struct composite
3 nil_t, nil_t, nil_t, #if PHOENIX_LIMIT > 6 nil_t, nil_t, nil_t, #if PHOENIX_LIMIT > 9 nil_t, nil_t, nil_t, #if PHOENIX_LIMIT > 12 nil_t, nil_t, nil_t, #endif #endif #endif #endif nil_t // Unused > { typedef composite
self_t; template
struct result { typedef typename composite2_result< OperationT, TupleT, A, B >::type type; }; composite(OperationT const& op_, A const& a_, B const& b_) : op(op_), a(a_), b(b_) {} template
typename actor_result
::type eval(TupleT const& args) const { typename actor_result
::type ra = a.eval(args); typename actor_result
::type rb = b.eval(args); return op(ra, rb); } mutable OperationT op; // operation A a; B b; // actors }; /////////////////////////////////////////////////////////////////////////////// // // composite <3 actors> class // /////////////////////////////////////////////////////////////////////////////// template
struct composite3_result { typedef typename OperationT::template result< typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type >::type type; }; ////////////////////////////////// template
struct composite
3 nil_t, nil_t, nil_t, #if PHOENIX_LIMIT > 6 nil_t, nil_t, nil_t, #if PHOENIX_LIMIT > 9 nil_t, nil_t, nil_t, #if PHOENIX_LIMIT > 12 nil_t, nil_t, nil_t, #endif #endif #endif #endif nil_t // Unused > { typedef composite
self_t; template
struct result { typedef typename composite3_result< OperationT, TupleT, A, B, C >::type type; }; composite(OperationT const& op_, A const& a_, B const& b_, C const& c_) : op(op_), a(a_), b(b_), c(c_) {} template
typename actor_result
::type eval(TupleT const& args) const { typename actor_result
::type ra = a.eval(args); typename actor_result
::type rb = b.eval(args); typename actor_result
::type rc = c.eval(args); return op(ra, rb, rc); } mutable OperationT op; // operation A a; B b; C c; // actors }; #if PHOENIX_LIMIT > 3 /////////////////////////////////////////////////////////////////////////////// // // composite <4 actors> class // /////////////////////////////////////////////////////////////////////////////// template
struct composite4_result { typedef typename OperationT::template result< typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type >::type type; }; ////////////////////////////////// template
struct composite
6 nil_t, nil_t, nil_t, #if PHOENIX_LIMIT > 9 nil_t, nil_t, nil_t, #if PHOENIX_LIMIT > 12 nil_t, nil_t, nil_t, #endif #endif #endif nil_t // Unused > { typedef composite
self_t; template
struct result { typedef typename composite4_result< OperationT, TupleT, A, B, C, D >::type type; }; composite(OperationT const& op_, A const& a_, B const& b_, C const& c_, D const& d_) : op(op_), a(a_), b(b_), c(c_), d(d_) {} template
typename actor_result
::type eval(TupleT const& args) const { typename actor_result
::type ra = a.eval(args); typename actor_result
::type rb = b.eval(args); typename actor_result
::type rc = c.eval(args); typename actor_result
::type rd = d.eval(args); return op(ra, rb, rc, rd); } mutable OperationT op; // operation A a; B b; C c; D d; // actors }; /////////////////////////////////////////////////////////////////////////////// // // composite <5 actors> class // /////////////////////////////////////////////////////////////////////////////// template
struct composite5_result { typedef typename OperationT::template result< typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type >::type type; }; ////////////////////////////////// template
struct composite
6 nil_t, nil_t, nil_t, #if PHOENIX_LIMIT > 9 nil_t, nil_t, nil_t, #if PHOENIX_LIMIT > 12 nil_t, nil_t, nil_t, #endif #endif #endif nil_t // Unused > { typedef composite
self_t; template
struct result { typedef typename composite5_result< OperationT, TupleT, A, B, C, D, E >::type type; }; composite(OperationT const& op_, A const& a_, B const& b_, C const& c_, D const& d_, E const& e_) : op(op_), a(a_), b(b_), c(c_), d(d_), e(e_) {} template
typename actor_result
::type eval(TupleT const& args) const { typename actor_result
::type ra = a.eval(args); typename actor_result
::type rb = b.eval(args); typename actor_result
::type rc = c.eval(args); typename actor_result
::type rd = d.eval(args); typename actor_result
::type re = e.eval(args); return op(ra, rb, rc, rd, re); } mutable OperationT op; // operation A a; B b; C c; D d; E e; // actors }; /////////////////////////////////////////////////////////////////////////////// // // composite <6 actors> class // /////////////////////////////////////////////////////////////////////////////// template
struct composite6_result { typedef typename OperationT::template result< typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type >::type type; }; ////////////////////////////////// template
struct composite
6 nil_t, nil_t, nil_t, #if PHOENIX_LIMIT > 9 nil_t, nil_t, nil_t, #if PHOENIX_LIMIT > 12 nil_t, nil_t, nil_t, #endif #endif #endif nil_t // Unused > { typedef composite
self_t; template
struct result { typedef typename composite6_result< OperationT, TupleT, A, B, C, D, E, F >::type type; }; composite(OperationT const& op_, A const& a_, B const& b_, C const& c_, D const& d_, E const& e_, F const& f_) : op(op_), a(a_), b(b_), c(c_), d(d_), e(e_), f(f_) {} template
typename actor_result
::type eval(TupleT const& args) const { typename actor_result
::type ra = a.eval(args); typename actor_result
::type rb = b.eval(args); typename actor_result
::type rc = c.eval(args); typename actor_result
::type rd = d.eval(args); typename actor_result
::type re = e.eval(args); typename actor_result
::type rf = f.eval(args); return op(ra, rb, rc, rd, re, rf); } mutable OperationT op; // operation A a; B b; C c; D d; E e; F f; // actors }; #if PHOENIX_LIMIT > 6 /////////////////////////////////////////////////////////////////////////////// // // composite <7 actors> class // /////////////////////////////////////////////////////////////////////////////// template
struct composite7_result { typedef typename OperationT::template result< typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type >::type type; }; ////////////////////////////////// template
struct composite
9 nil_t, nil_t, nil_t, #if PHOENIX_LIMIT > 12 nil_t, nil_t, nil_t, #endif #endif nil_t // Unused > { typedef composite
self_t; template
struct result { typedef typename composite7_result< OperationT, TupleT, A, B, C, D, E, F, G >::type type; }; composite(OperationT const& op_, A const& a_, B const& b_, C const& c_, D const& d_, E const& e_, F const& f_, G const& g_) : op(op_), a(a_), b(b_), c(c_), d(d_), e(e_), f(f_), g(g_) {} template
typename actor_result
::type eval(TupleT const& args) const { typename actor_result
::type ra = a.eval(args); typename actor_result
::type rb = b.eval(args); typename actor_result
::type rc = c.eval(args); typename actor_result
::type rd = d.eval(args); typename actor_result
::type re = e.eval(args); typename actor_result
::type rf = f.eval(args); typename actor_result
::type rg = g.eval(args); return op(ra, rb, rc, rd, re, rf, rg); } mutable OperationT op; // operation A a; B b; C c; D d; E e; F f; G g; // actors }; /////////////////////////////////////////////////////////////////////////////// // // composite <8 actors> class // /////////////////////////////////////////////////////////////////////////////// template
struct composite8_result { typedef typename OperationT::template result< typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type >::type type; }; ////////////////////////////////// template
struct composite
9 nil_t, nil_t, nil_t, #if PHOENIX_LIMIT > 12 nil_t, nil_t, nil_t, #endif #endif nil_t // Unused > { typedef composite
self_t; template
struct result { typedef typename composite8_result< OperationT, TupleT, A, B, C, D, E, F, G, H >::type type; }; composite(OperationT const& op_, A const& a_, B const& b_, C const& c_, D const& d_, E const& e_, F const& f_, G const& g_, H const& h_) : op(op_), a(a_), b(b_), c(c_), d(d_), e(e_), f(f_), g(g_), h(h_) {} template
typename actor_result
::type eval(TupleT const& args) const { typename actor_result
::type ra = a.eval(args); typename actor_result
::type rb = b.eval(args); typename actor_result
::type rc = c.eval(args); typename actor_result
::type rd = d.eval(args); typename actor_result
::type re = e.eval(args); typename actor_result
::type rf = f.eval(args); typename actor_result
::type rg = g.eval(args); typename actor_result
::type rh = h.eval(args); return op(ra, rb, rc, rd, re, rf, rg, rh); } mutable OperationT op; // operation A a; B b; C c; D d; E e; F f; G g; H h; // actors }; /////////////////////////////////////////////////////////////////////////////// // // composite <9 actors> class // /////////////////////////////////////////////////////////////////////////////// template
struct composite9_result { typedef typename OperationT::template result< typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type >::type type; }; ////////////////////////////////// template
struct composite
9 nil_t, nil_t, nil_t, #if PHOENIX_LIMIT > 12 nil_t, nil_t, nil_t, #endif #endif nil_t // Unused > { typedef composite
self_t; template
struct result { typedef typename composite9_result< OperationT, TupleT, A, B, C, D, E, F, G, H, I >::type type; }; composite(OperationT const& op_, A const& a_, B const& b_, C const& c_, D const& d_, E const& e_, F const& f_, G const& g_, H const& h_, I const& i_) : op(op_), a(a_), b(b_), c(c_), d(d_), e(e_), f(f_), g(g_), h(h_), i(i_) {} template
typename actor_result
::type eval(TupleT const& args) const { typename actor_result
::type ra = a.eval(args); typename actor_result
::type rb = b.eval(args); typename actor_result
::type rc = c.eval(args); typename actor_result
::type rd = d.eval(args); typename actor_result
::type re = e.eval(args); typename actor_result
::type rf = f.eval(args); typename actor_result
::type rg = g.eval(args); typename actor_result
::type rh = h.eval(args); typename actor_result
::type ri = i.eval(args); return op(ra, rb, rc, rd, re, rf, rg, rh, ri); } mutable OperationT op; // operation A a; B b; C c; D d; E e; F f; G g; H h; I i; // actors }; #if PHOENIX_LIMIT > 9 /////////////////////////////////////////////////////////////////////////////// // // composite <10 actors> class // /////////////////////////////////////////////////////////////////////////////// template
struct composite10_result { typedef typename OperationT::template result< typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type >::type type; }; ////////////////////////////////// template
struct composite
12 nil_t, nil_t, nil_t, #endif nil_t // Unused > { typedef composite
self_t; template
struct result { typedef typename composite10_result< OperationT, TupleT, A, B, C, D, E, F, G, H, I, J >::type type; }; composite(OperationT const& op_, A const& a_, B const& b_, C const& c_, D const& d_, E const& e_, F const& f_, G const& g_, H const& h_, I const& i_, J const& j_) : op(op_), a(a_), b(b_), c(c_), d(d_), e(e_), f(f_), g(g_), h(h_), i(i_), j(j_) {} template
typename actor_result
::type eval(TupleT const& args) const { typename actor_result
::type ra = a.eval(args); typename actor_result
::type rb = b.eval(args); typename actor_result
::type rc = c.eval(args); typename actor_result
::type rd = d.eval(args); typename actor_result
::type re = e.eval(args); typename actor_result
::type rf = f.eval(args); typename actor_result
::type rg = g.eval(args); typename actor_result
::type rh = h.eval(args); typename actor_result
::type ri = i.eval(args); typename actor_result
::type rj = j.eval(args); return op(ra, rb, rc, rd, re, rf, rg, rh, ri, rj); } mutable OperationT op; // operation A a; B b; C c; D d; E e; F f; G g; H h; I i; J j; // actors }; /////////////////////////////////////////////////////////////////////////////// // // composite <11 actors> class // /////////////////////////////////////////////////////////////////////////////// template
struct composite11_result { typedef typename OperationT::template result< typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type >::type type; }; ////////////////////////////////// template
struct composite
12 nil_t, nil_t, nil_t, #endif nil_t // Unused > { typedef composite
self_t; template
struct result { typedef typename composite11_result< OperationT, TupleT, A, B, C, D, E, F, G, H, I, J, K >::type type; }; composite(OperationT const& op_, A const& a_, B const& b_, C const& c_, D const& d_, E const& e_, F const& f_, G const& g_, H const& h_, I const& i_, J const& j_, K const& k_) : op(op_), a(a_), b(b_), c(c_), d(d_), e(e_), f(f_), g(g_), h(h_), i(i_), j(j_), k(k_) {} template
typename actor_result
::type eval(TupleT const& args) const { typename actor_result
::type ra = a.eval(args); typename actor_result
::type rb = b.eval(args); typename actor_result
::type rc = c.eval(args); typename actor_result
::type rd = d.eval(args); typename actor_result
::type re = e.eval(args); typename actor_result
::type rf = f.eval(args); typename actor_result
::type rg = g.eval(args); typename actor_result
::type rh = h.eval(args); typename actor_result
::type ri = i.eval(args); typename actor_result
::type rj = j.eval(args); typename actor_result
::type rk = k.eval(args); return op(ra, rb, rc, rd, re, rf, rg, rh, ri, rj, rk); } mutable OperationT op; // operation A a; B b; C c; D d; E e; F f; G g; H h; I i; J j; K k;// actors }; /////////////////////////////////////////////////////////////////////////////// // // composite <12 actors> class // /////////////////////////////////////////////////////////////////////////////// template
struct composite12_result { typedef typename OperationT::template result< typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type, typename actor_result
::plain_type >::type type; }; ////////////////////////////////// template
struct composite
12 nil_t, nil_t, nil_t, #endif nil_t // Unused > { typedef composite
self_t; template
struct result { typedef typename composite12_result< OperationT, TupleT, A, B, C, D, E, F, G, H, I, J, K, L >::type type; }; composite(OperationT const& op_, A const& a_, B const& b_, C const& c_, D const& d_, E const& e_, F const& f_, G const& g_, H const& h_, I const& i_, J const& j_, K const& k_, L const& l_) : op(op_), a(a_), b(b_), c(c_), d(d_), e(e_), f(f_), g(g_), h(h_), i(i_), j(j_), k(k_), l(l_) {} template
typename actor_result
::type eval(TupleT const& args) const { typename actor_result
::type ra = a.eval(args); typename actor_result
::type rb = b.eval(args); typename actor_result
::type rc = c.eval(args); typename actor_result
::type rd = d.eval(args); typename actor_result
::type re = e.eval(args); typename actor_result
::type rf = f.eval(args); typename actor_result
::type rg = g.eval(args); typename actor_result