STAPL API Reference          
Overview   Containers   Algorithms   Views   Skeletons   Run-Time System
Modules     Classes    
Classes | Namespaces | Macros
proxy_macros.hpp File Reference
+ Include dependency graph for proxy_macros.hpp:

Classes

struct  stapl::container_traits< Container >
 Metafunction to retrieve associated types for containers. This class is similar in spirit to the STL's iterator_traits. More...
 
struct  stapl::member_referencer< Accessor, bool >
 Functor creates a reference either as a proxy or a view for a member of another proxy, based on is_container metafunction. More...
 

Namespaces

 stapl
 

Macros

#define STAPL_PROXY_HEADER(TYPE)
 Boilerplate for writing proxies. When writing a simple proxy for some type T, the skeleton would be of the form: More...
 
#define STAPL_PROXY_HEADER_TEMPLATE(...)
 
#define STAPL_PROXY_HEADER_TEMPLATE_1(TYPE, A0)
 
#define STAPL_PROXY_HEADER_TEMPLATE_2(TYPE, A0, A1)
 
#define STAPL_PROXY_HEADER_TEMPLATE_3(TYPE, A0, A1, A2)
 
#define STAPL_PROXY_DEFINES(TYPE)
 
#define STAPL_PROXY_TYPES(TYPE, ACC)
 If customization of the boilerplate proxy is needed, the following macros are defined. For example, if a custom constructor is needed, one would need to write: More...
 
#define STAPL_PROXY_CONSTRUCTOR(TYPE, ACC)
 
#define STAPL_PROXY_METHODS(TYPE, ACC)
 
#define STAPL_PROXY_CONCAT(...)   __VA_ARGS__
 Concat complex typenames. For example, when writing a proxy for pair<T, U>, the type will be interpreted as two arguments. In order to pass it to the following macros, one would have to do: More...
 
#define STAPL_PROXY_IMPORT_TYPES(...)
 Helper to import nested types from the proxy's target type. More...
 
#define STAPL_PROXY_METHOD_RETURN(...)
 Helper to create methods for proxies. More...
 
#define STAPL_PROXY_METHOD(...)
 
#define STAPL_PROXY_MEMBER(NAME, TYPE)
 Helper to create member references for proxies. More...
 
#define STAPL_PROXY_REFLECT_TYPE(T)   typedef typename target_t::T T;
 Define the nested type T from the target.
 
#define STAPL_PROXY_SELECTOR_MEMBER(NAME)
 Selector generator for creating selectors for nested proxies. Generates selectors in which the selection scheme is retrieving a member of the outer proxy. More...
 
#define STAPL_PROXY_REFERENCE_METHOD(NAME, TYPE)   STAPL_PROXY_REFERENCE_METHOD_0
 
#define STAPL_PROXY_REFERENCE_METHOD_0(NAME, TYPE)
 
#define STAPL_PROXY_REFERENCE_METHOD_1(NAME, FN, TYPE, A0)
 
#define STAPL_PROXY_REFERENCE_METHOD_VARIADIC_ONLY(NAME, FN, TYPE)
 Create a method in an outer proxy that returns proxy to the element in the inner (multidimensional) container wrapped by that outer proxy. More...
 
#define STAPL_PROXY_REFERENCE_METHOD_VARIADIC_AND_SINGLE(NAME, FNV, FN1, TYPE)
 Create methods in an outer proxy that return proxy to the element in the inner (multidimensional) container wrapped by that outer proxy. Creates two methods allowing access to the inner element using either variadic index pack or index tuple. More...
 
#define GET_MACRO(_1, _2, _3, _4, NAME, ...)   NAME
 
#define STAPL_PROXY_REFERENCE_METHOD_VARIADIC(...)
 
#define STAPL_PROXY_VARIADIC_SIZE(...)
 
#define STAPL_PROXY_VARIADIC_SIZE_I(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63, size, ...)   size
 
#define STAPL_PROXY_METHOD_RETURN_0(NAME, RTN)
 
#define STAPL_PROXY_METHOD_RETURN_1(NAME, RTN, A0)
 
#define STAPL_PROXY_METHOD_RETURN_2(NAME, RTN, A0, A1)
 
#define STAPL_PROXY_METHOD_RETURN_3(NAME, RTN, A0, A1, A2)
 
#define STAPL_PROXY_METHOD_0(NAME)
 
#define STAPL_PROXY_METHOD_1(NAME, A0)
 
#define STAPL_PROXY_METHOD_2(NAME, A0, A1)
 
#define STAPL_PROXY_METHOD_3(NAME, A0, A1, A2)
 
Nested proxy selectors

Generators for creating selectors for nested proxies. Generate selectors in which the selection scheme is invoking a method on the outer proxy.

#define STAPL_PROXY_SELECTOR_METHOD(NAME)
 
#define STAPL_PROXY_SELECTOR_METHOD_ARGS_1(NAME, FN, A0)
 

Detailed Description

Macro Definition Documentation

◆ STAPL_PROXY_HEADER

#define STAPL_PROXY_HEADER (   TYPE)
Value:
template <typename Accessor> \
class proxy<TYPE, Accessor> \
: public Accessor

Boilerplate for writing proxies. When writing a simple proxy for some type T, the skeleton would be of the form:

{
STAPL_PROXY_DEFINES(T)
// user defined functions
};

◆ STAPL_PROXY_HEADER_TEMPLATE

#define STAPL_PROXY_HEADER_TEMPLATE (   ...)
Value:
BOOST_PP_CAT( \
STAPL_PROXY_HEADER_TEMPLATE_, \
BOOST_PP_SUB(STAPL_PROXY_VARIADIC_SIZE(__VA_ARGS__), 1))(__VA_ARGS__)

◆ STAPL_PROXY_HEADER_TEMPLATE_1

#define STAPL_PROXY_HEADER_TEMPLATE_1 (   TYPE,
  A0 
)
Value:
template <typename A0, typename Accessor> \
class proxy<TYPE<A0>, Accessor> \
: public Accessor

◆ STAPL_PROXY_HEADER_TEMPLATE_2

#define STAPL_PROXY_HEADER_TEMPLATE_2 (   TYPE,
  A0,
  A1 
)
Value:
template <typename A0, typename A1, typename Accessor> \
class proxy<TYPE<A0, A1>, Accessor> \
: public Accessor

◆ STAPL_PROXY_HEADER_TEMPLATE_3

#define STAPL_PROXY_HEADER_TEMPLATE_3 (   TYPE,
  A0,
  A1,
  A2 
)
Value:
template <typename A0, typename A1, typename A2, typename Accessor> \
class proxy<TYPE<A0, A1, A2>, Accessor> \
: public Accessor

◆ STAPL_PROXY_DEFINES

#define STAPL_PROXY_DEFINES (   TYPE)
Value:
STAPL_PROXY_TYPES(TYPE, Accessor) \
STAPL_PROXY_CONSTRUCTOR(TYPE, Accessor) \
STAPL_PROXY_METHODS(TYPE, Accessor)
#define STAPL_PROXY_TYPES(TYPE, ACC)
If customization of the boilerplate proxy is needed, the following macros are defined. For example, if a custom constructor is needed, one would need to write:
Definition: proxy_macros.hpp:168

◆ STAPL_PROXY_TYPES

#define STAPL_PROXY_TYPES (   TYPE,
  ACC 
)
Value:
private: \
friend class proxy_core_access; \
typedef TYPE target_t;

If customization of the boilerplate proxy is needed, the following macros are defined. For example, if a custom constructor is needed, one would need to write:

{
STAPL_PROXY_METHODS(T)
proxy(U const& u)
{ ... }
};

◆ STAPL_PROXY_CONSTRUCTOR

#define STAPL_PROXY_CONSTRUCTOR (   TYPE,
  ACC 
)
Value:
public: \
explicit proxy(ACC const& acc) \
: ACC(acc) \
{ } \

◆ STAPL_PROXY_METHODS

#define STAPL_PROXY_METHODS (   TYPE,
  ACC 
)
Value:
public: \
operator target_t() const \
{ \
return ACC::read(); \
} \
proxy const& operator=(proxy const& rhs) \
{ \
ACC::write(rhs); return *this; \
} \
proxy const& operator=(target_t const& rhs) \
{ \
ACC::write(rhs); \
return *this; \
} \
proxy const& operator=(target_t&& rhs) \
{ \
ACC::write(std::move(rhs)); \
return *this; \
} \

◆ STAPL_PROXY_CONCAT

#define STAPL_PROXY_CONCAT (   ...)    __VA_ARGS__

Concat complex typenames. For example, when writing a proxy for pair<T, U>, the type will be interpreted as two arguments. In order to pass it to the following macros, one would have to do:

STAPL_PROXY_CONCAT(pair<T, U>)

◆ STAPL_PROXY_IMPORT_TYPES

#define STAPL_PROXY_IMPORT_TYPES (   ...)
Value:
public: \
BOOST_PP_CAT(STAPL_IMPORT_TYPES_, STAPL_PROXY_VARIADIC_SIZE(__VA_ARGS__))( \
typename target_t, __VA_ARGS__)

Helper to import nested types from the proxy's target type.

If there are nested types in a class of the form:

typedef int foo;
typedef float bar;

the following would automatically import the types:

◆ STAPL_PROXY_METHOD_RETURN

#define STAPL_PROXY_METHOD_RETURN (   ...)
Value:
BOOST_PP_CAT(STAPL_PROXY_METHOD_RETURN_,\
BOOST_PP_SUB(STAPL_PROXY_VARIADIC_SIZE(__VA_ARGS__), 2))(__VA_ARGS__)

Helper to create methods for proxies.

If there is a method in a class with the signature

void foo(int x, int y)

the following would automatically generate the method in the proxy:

STAPL_PROXY_METHOD(foo, int, int)

If the function has a return, such as

string bar(char c)

the following would automatically generate the method in the proxy:

STAPL_PROXY_METHOD_RETURN(bar, string, char)

◆ STAPL_PROXY_METHOD

#define STAPL_PROXY_METHOD (   ...)
Value:
BOOST_PP_CAT(STAPL_PROXY_METHOD_, \
BOOST_PP_SUB(STAPL_PROXY_VARIADIC_SIZE(__VA_ARGS__), 1))(__VA_ARGS__)

◆ STAPL_PROXY_MEMBER

#define STAPL_PROXY_MEMBER (   NAME,
  TYPE 
)
Value:
\
typedef member_accessor<get_ ## NAME<TYPE>> NAME ## _accessor; \
typedef typename member_referencer< \
NAME ## _accessor \
>::result_type NAME ## _reference; \
\
NAME ## _reference NAME;
#define STAPL_PROXY_SELECTOR_MEMBER(NAME)
Selector generator for creating selectors for nested proxies. Generates selectors in which the select...
Definition: proxy_macros.hpp:290

Helper to create member references for proxies.

If there is a member in a class named foo with the type T, the following would automatically create the nested proxy:

◆ STAPL_PROXY_SELECTOR_MEMBER

#define STAPL_PROXY_SELECTOR_MEMBER (   NAME)
Value:
template<typename __Tp> \
struct get_ ## NAME \
{ \
using result_type = __Tp; \
using accessor_type = Accessor; \
\
template<typename Outer> \
result_type operator()(Outer const& v) const \
{ \
return v. NAME; \
} \
template<typename Outer> \
result_type& operator()(Outer& v) const \
{ \
return v. NAME; \
} \
};

Selector generator for creating selectors for nested proxies. Generates selectors in which the selection scheme is retrieving a member of the outer proxy.

◆ STAPL_PROXY_SELECTOR_METHOD

#define STAPL_PROXY_SELECTOR_METHOD (   NAME)
Value:
template<typename __Tp> \
struct get_ ## NAME \
{ \
using result_type = __Tp; \
using accessor_type = Accessor; \
\
template<typename Outer> \
result_type operator()(Outer const& v) const \
{ \
return v. NAME(); \
} \
template<typename Outer> \
result_type& operator()(Outer& v) const \
{ \
return v. NAME(); \
} \
};

◆ STAPL_PROXY_REFERENCE_METHOD_0

#define STAPL_PROXY_REFERENCE_METHOD_0 (   NAME,
  TYPE 
)
Value:
STAPL_PROXY_SELECTOR_METHOD(NAME) \
\
typedef member_accessor<get_ ## NAME<TYPE>> NAME ## _accessor; \
typedef proxy<TYPE, NAME ## _accessor> NAME ## _reference; \
\
NAME ## _reference NAME() const \
{ \
return NAME ## _reference(*this); \
}

◆ STAPL_PROXY_REFERENCE_METHOD_1

#define STAPL_PROXY_REFERENCE_METHOD_1 (   NAME,
  FN,
  TYPE,
  A0 
)
Value:
STAPL_PROXY_SELECTOR_METHOD_ARGS_1(NAME, FN, A0) \
\
typedef get_ ## NAME<TYPE> NAME ## _selector_type; \
typedef member_accessor<NAME ## _selector_type> NAME ## _accessor; \
typedef proxy<TYPE, NAME ## _accessor> NAME ## _reference; \
\
NAME ## _reference FN(A0 const& a0) const \
{ \
return NAME ## _reference( \
NAME ## _accessor(*this, NAME ## _selector_type(a0)) \
); \
}

◆ STAPL_PROXY_REFERENCE_METHOD_VARIADIC_ONLY

#define STAPL_PROXY_REFERENCE_METHOD_VARIADIC_ONLY (   NAME,
  FN,
  TYPE 
)
Value:
STAPL_PROXY_SELECTOR_METHOD_ARGS_VARIADIC(NAME, FN) \
\
typedef get_ ## NAME<TYPE> NAME ## _selector_type; \
typedef member_accessor<NAME ## _selector_type> NAME ## _accessor; \
typedef proxy<TYPE, NAME ## _accessor> NAME ## _reference; \
\
template<typename... Indices> \
NAME ## _reference FN(Indices... indices) const \
{ \
return NAME ## _reference( \
NAME ## _accessor(*this, NAME ## _selector_type(indices...)) \
); \
} \

Create a method in an outer proxy that returns proxy to the element in the inner (multidimensional) container wrapped by that outer proxy.

Parameters
NAMEBasis for the names of the datatypes introduced into the outer proxy by this macro.
FNName of the variadic method added to the proxy. Method with the same name must be present in the wrapped container class as it is used for the actual data access.
TYPEType of the element proxy of which is being created.

◆ STAPL_PROXY_REFERENCE_METHOD_VARIADIC_AND_SINGLE

#define STAPL_PROXY_REFERENCE_METHOD_VARIADIC_AND_SINGLE (   NAME,
  FNV,
  FN1,
  TYPE 
)
Value:
STAPL_PROXY_SELECTOR_METHOD_ARGS_VARIADIC(NAME, FNV) \
\
typedef get_ ## NAME<TYPE> NAME ## _selector_type; \
typedef member_accessor<NAME ## _selector_type> NAME ## _accessor; \
typedef proxy<TYPE, NAME ## _accessor> NAME ## _reference; \
\
template<typename... Indices> \
NAME ## _reference FNV(Indices... indices) const \
{ \
return NAME ## _reference( \
NAME ## _accessor(*this, NAME ## _selector_type(indices...)) \
); \
} \
\
template<typename... Indices> \
NAME ## _reference FN1(stapl::tuple<Indices...> const& gid) const \
{ \
return NAME ## _reference( \
NAME ## _accessor(*this, NAME ## _selector_type(gid)) \
); \
}

Create methods in an outer proxy that return proxy to the element in the inner (multidimensional) container wrapped by that outer proxy. Creates two methods allowing access to the inner element using either variadic index pack or index tuple.

Parameters
NAMEBasis for the names of the datatypes introduced into the outer proxy by this macro.
FNVName of the method accepting variadic indices. Method with the same name must be present in the wrapped container class as it is used for the actual data access.
FN1Name of the method accepting index tuple. The tuple is unpacked to actually access the data using the variadic method of the underlying container.
TYPEType of the element proxy of which is being created.

◆ STAPL_PROXY_REFERENCE_METHOD_VARIADIC

#define STAPL_PROXY_REFERENCE_METHOD_VARIADIC (   ...)
Value:
GET_MACRO(__VA_ARGS__, \
#define STAPL_PROXY_REFERENCE_METHOD_VARIADIC_AND_SINGLE(NAME, FNV, FN1, TYPE)
Create methods in an outer proxy that return proxy to the element in the inner (multidimensional) con...
Definition: proxy_macros.hpp:450
#define STAPL_PROXY_REFERENCE_METHOD_VARIADIC_ONLY(NAME, FN, TYPE)
Create a method in an outer proxy that returns proxy to the element in the inner (multidimensional) c...
Definition: proxy_macros.hpp:419

◆ STAPL_PROXY_VARIADIC_SIZE

#define STAPL_PROXY_VARIADIC_SIZE (   ...)
Value:
STAPL_PROXY_VARIADIC_SIZE_I(__VA_ARGS__, \
64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, \
45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, \
26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, \
6, 5, 4, 3, 2, 1,)

◆ STAPL_PROXY_METHOD_RETURN_0

#define STAPL_PROXY_METHOD_RETURN_0 (   NAME,
  RTN 
)
Value:
RTN NAME() const \
{ \
return Accessor::const_invoke(&target_t::NAME); \
}

◆ STAPL_PROXY_METHOD_RETURN_1

#define STAPL_PROXY_METHOD_RETURN_1 (   NAME,
  RTN,
  A0 
)
Value:
RTN NAME(A0 const& a0) const \
{ \
return Accessor::const_invoke(&target_t::NAME, a0); \
}

◆ STAPL_PROXY_METHOD_RETURN_2

#define STAPL_PROXY_METHOD_RETURN_2 (   NAME,
  RTN,
  A0,
  A1 
)
Value:
RTN NAME(A0 const& a0, A1 const& a1) const \
{ \
return Accessor::const_invoke(&target_t::NAME, a0, a1); \
}

◆ STAPL_PROXY_METHOD_RETURN_3

#define STAPL_PROXY_METHOD_RETURN_3 (   NAME,
  RTN,
  A0,
  A1,
  A2 
)
Value:
RTN NAME(A0 const& a0, A1 const& a1, A2 const& a2) const \
{ \
return Accessor::const_invoke(&target_t::NAME, a0, a1, a2); \
}

◆ STAPL_PROXY_METHOD_0

#define STAPL_PROXY_METHOD_0 (   NAME)
Value:
void NAME() const \
{ \
Accessor::invoke(&target_t::NAME); \
}
auto invoke(F &&f, Tuple &args, void *const base, index_sequence< I... >) -> decltype(std::forward< F >(f)(std::get< I >(args).get(base)...))
Calls f with the stored objects in args passed as arguments.
Definition: arguments.hpp:217

◆ STAPL_PROXY_METHOD_1

#define STAPL_PROXY_METHOD_1 (   NAME,
  A0 
)
Value:
void NAME(A0 const& a0) const \
{ \
Accessor::invoke(&target_t::NAME, a0); \
}
auto invoke(F &&f, Tuple &args, void *const base, index_sequence< I... >) -> decltype(std::forward< F >(f)(std::get< I >(args).get(base)...))
Calls f with the stored objects in args passed as arguments.
Definition: arguments.hpp:217

◆ STAPL_PROXY_METHOD_2

#define STAPL_PROXY_METHOD_2 (   NAME,
  A0,
  A1 
)
Value:
void NAME(A0 const& a0, A1 const& a1) const \
{ \
Accessor::invoke(&target_t::NAME, a0, a1); \
}
auto invoke(F &&f, Tuple &args, void *const base, index_sequence< I... >) -> decltype(std::forward< F >(f)(std::get< I >(args).get(base)...))
Calls f with the stored objects in args passed as arguments.
Definition: arguments.hpp:217

◆ STAPL_PROXY_METHOD_3

#define STAPL_PROXY_METHOD_3 (   NAME,
  A0,
  A1,
  A2 
)
Value:
void NAME(A0 const& a0, A1 const& a1, A2 const& a2) const \
{ \
Accessor::invoke(&target_t::NAME, a0, a1, a2); \
}
auto invoke(F &&f, Tuple &args, void *const base, index_sequence< I... >) -> decltype(std::forward< F >(f)(std::get< I >(args).get(base)...))
Calls f with the stored objects in args passed as arguments.
Definition: arguments.hpp:217