76#ifndef LIB_VERB_VISITOR_H
77#define LIB_VERB_VISITOR_H
106 template<
class REC,
class RET>
120 template<
class REC,
class SIG>
127 template<
class REC,
class RET,
typename... ARGS>
133 using Args = std::tuple<ARGS...>;
141 template<
typename...PARS>
143 :
Verb{handlerRef, verbID}
144 , args_{
std::forward<PARS> (args)...}
150 return Verb::getID();
161 template<
size_t...idx>
165 return (receiver.*Verb::handler_) (std::get<idx> (args_)...);
186 template<
class REC,
class RET,
size_t arg_storage>
188 :
public PolymorphicValue<VerbInvoker<REC,RET>, storageOverhead(arg_storage)>
193 template<
typename FUN>
196 static_assert (!
sizeof(FUN),
"handler must be a function member pointer for the given receiver");
198 template<
typename...ARGS>
205 template<
typename FUN>
217 template<
typename FUN,
typename...ARGS>
230 return PolyHolder::getPayload().applyTo (receiver);
233 operator string()
const
241 template<
typename ARG>
247 EmbeddedPayload& embedded =
static_cast<EmbeddedPayload&
>(this->
getPayload());
248 return std::get<0> (embedded.args_);
Template to build polymorphic value objects.
A self-contained token to embody a specific yet abstracted operation, together with a concrete set of...
VerbPack(FUN handler, Literal verbID, ARGS &&... args)
setup a VerbPack for a given operation on the interface REC
PolymorphicValue< Dispatcher, storageOverhead(arg_storage)> PolyHolder
HandlerTypeDetector< FUN >::Payload * PayloadType
VerbInvoker< REC, RET > Dispatcher
ARG & accessArg()
unsafe downcast and access to an embedded payload argument value
RET applyTo(REC &receiver)
Core operation: invoke the operation for this "verb" with the pre-bound parameters.
A variation for limited copy support.
struct{} JustSomeIrrelvantType
constexpr size_t storageOverhead(size_t argStorage)
const size_t VERB_TOKEN_SIZE
Implementation namespace for support and library code.
Action token implemented by double dispatch to a handler function, as defined in the "receiver" inter...
OBJ * unConst(const OBJ *)
shortcut to save some typing when having to define const and non-const variants of member functions
A mechanism to allow for opaque polymorphic value objects.
Building block: actual storage for a "verb" (function pointer), together with the pre-bound invocatio...
RET invokeVerb(REC &receiver, meta::IndexSeq< idx... >)
Literal getID() const override
meta::BuildIdxIter< ARGS... >::Ascending SequenceIterator
meta-sequence to pick argument values from the storage tuple
Args args_
Storage for the argument tuple.
VerbHolder(Verb::Handler handlerRef, Literal verbID, PARS &&... args)
std::tuple< ARGS... > Args
RET applyTo(REC &receiver) override
Building block: the Interface to cause the invocation.
virtual Literal getID() const =0
bool operator!=(VerbInvoker const &o) const
virtual RET applyTo(REC &)=0
bool operator==(VerbInvoker const &o) const
Marker types to indicate a literal string and a Symbol.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
#define INSTANCEOF(CLASS, EXPR)
shortcut for subclass test, intended for assertions only.
Metaprogramming with type sequences based on variadic template parameters.
Building blocks for a simple DSL using double dispatch to a handler function.