Lumiera  0.pre.03
»edit your freedom«
VerbPack< REC, RET, arg_storage > Class Template Reference

#include "lib/verb-visitor.hpp"

Description

template<class REC, class RET, size_t arg_storage>
class lib::VerbPack< REC, RET, arg_storage >

A self-contained token to embody a specific yet abstracted operation, together with a concrete set of suitable arguments.

The concrete operation is suppled on invocation, when the VerbPack is combined with an actual receiver object, implementing the interface REC and thus providing the function implementation. VerbPack represents a kind of double-dispatch, flexible both on the actual operation (embodied into the given VerbPack object) and also flexible in the concrete receiver.

Template Parameters
RECthe "visitor interface" to invoke operations on
RETexpected (common) return value of the bound operations (can be void)
arg_storagemaximum storage size to reserve as buffer for actual function parameters.
Remarks
  • binding an operation with arguments exceeding arg_storage triggers a static assertion
  • the resulting VerbPack object has value semantics and is copyable, to the extent any embedded function arguments are copyable by themselves.

Definition at line 196 of file verb-visitor.hpp.

Public Member Functions

template<typename FUN , typename... ARGS>
 VerbPack (FUN handler, Literal verbID, ARGS &&... args)
 setup a VerbPack for a given operation on the interface REC More...
 
template<typename ARG >
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. More...
 
 operator string () const
 
- Public Member Functions inherited from PolymorphicValue< VerbInvoker< REC, RET >, storageOverhead(arg_storage)>
 PolymorphicValue (PolymorphicValue const &o)
 
InterfacegetPayload ()
 
 operator Interface & ()
 
 operator Interface const & () const
 
Interfaceoperator-> () const
 
PolymorphicValueoperator= (PolymorphicValue const &o)
 

Classes

struct  HandlerTypeDetector
 
struct  HandlerTypeDetector< RET(REC::*)(ARGS...)>
 

Private Types

using Dispatcher = VerbInvoker< REC, RET >
 
template<typename FUN >
using PayloadType = typename HandlerTypeDetector< FUN >::Payload *
 
using PolyHolder = PolymorphicValue< Dispatcher, storageOverhead(arg_storage)>
 

Additional Inherited Members

- Public Types inherited from PolymorphicValue< VerbInvoker< REC, RET >, storageOverhead(arg_storage)>
typedef VerbInvoker< REC, RET > Interface
 
- Static Public Member Functions inherited from PolymorphicValue< VerbInvoker< REC, RET >, storageOverhead(arg_storage)>
static PolymorphicValue build (ARGS &&... args)
 
- Protected Member Functions inherited from PolymorphicValue< VerbInvoker< REC, RET >, storageOverhead(arg_storage)>
 PolymorphicValue (IMP *, ARGS &&... args)
 

Class Documentation

◆ lib::VerbPack::HandlerTypeDetector

struct lib::VerbPack::HandlerTypeDetector
+ Collaboration diagram for VerbPack< REC, RET, arg_storage >::HandlerTypeDetector< FUN >:

◆ lib::VerbPack::HandlerTypeDetector< RET(REC::*)(ARGS...)>

struct lib::VerbPack::HandlerTypeDetector< RET(REC::*)(ARGS...)>
Class Members
Verb
Payload
+ Collaboration diagram for VerbPack< REC, RET, arg_storage >::HandlerTypeDetector< RET(REC::*)(ARGS...)>:

Constructor & Destructor Documentation

◆ VerbPack()

VerbPack ( FUN  handler,
Literal  verbID,
ARGS &&...  args 
)
inline

setup a VerbPack for a given operation on the interface REC

Parameters
handlerfunction member-pointer to define the operation
verbIDunique ID to designate the token; equality is based on this verbID, all tokens with same ID count as equal
argsarbitrary (yet suitable) arguments to pre-bind and use later when actually invoking the operation on a concrete receiver

Definition at line 227 of file verb-visitor.hpp.

Member Function Documentation

◆ applyTo()

RET applyTo ( REC &  receiver)
inline

Core operation: invoke the operation for this "verb" with the pre-bound parameters.

Parameters
receivera subclass of REC, providing the function to invoke
Returns
result of performing the actual operation

Definition at line 237 of file verb-visitor.hpp.

+ Inheritance diagram for VerbPack< REC, RET, arg_storage >:
+ Collaboration diagram for VerbPack< REC, RET, arg_storage >:

The documentation for this class was generated from the following file: