Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
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 187 of file verb-visitor.hpp.

Classes

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

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
 
RET applyTo (REC &receiver)
 Core operation: invoke the operation for this "verb" with the pre-bound parameters.
 
 operator string () const
 
template<typename ARG >
ARG & accessArg ()
 unsafe downcast and access to an embedded payload argument value
 
- 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
 
 ~PolymorphicValue ()
 
PolymorphicValueoperator= (PolymorphicValue const &o)
 

Private Types

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

Additional Inherited Members

- Public Types inherited from PolymorphicValue< VerbInvoker< REC, RET >, storageOverhead(arg_storage)>
using Interface = VerbInvoker< REC, RET >
 
- 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)
 

Constructor & Destructor Documentation

◆ VerbPack()

template<class REC , class RET , size_t arg_storage>
template<typename FUN , typename... ARGS>
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 218 of file verb-visitor.hpp.


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
typedef VerbToken< REC, RET(ARGS...)> Verb
typedef VerbHolder< REC, RET(ARGS...)> Payload
+ Collaboration diagram for VerbPack< REC, RET, arg_storage >::HandlerTypeDetector< RET(REC::*)(ARGS...)>:

Member Typedef Documentation

◆ Dispatcher

template<class REC , class RET , size_t arg_storage>
using Dispatcher = VerbInvoker<REC,RET>
private

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

◆ PolyHolder

template<class REC , class RET , size_t arg_storage>
using PolyHolder = PolymorphicValue<Dispatcher, storageOverhead(arg_storage)>
private

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

◆ PayloadType

template<class REC , class RET , size_t arg_storage>
template<typename FUN >
using PayloadType = HandlerTypeDetector<FUN>::Payload *
private

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

Member Function Documentation

◆ applyTo()

template<class REC , class RET , size_t arg_storage>
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 228 of file verb-visitor.hpp.

◆ operator string()

template<class REC , class RET , size_t arg_storage>
operator string ( ) const
inline

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

References util::unConst().

+ Here is the call graph for this function:

◆ accessArg()

template<class REC , class RET , size_t arg_storage>
template<typename ARG >
ARG & accessArg ( )
inline

unsafe downcast and access to an embedded payload argument value

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

References PolymorphicValue< VerbInvoker< REC, RET >, storageOverhead(arg_storage)>::getPayload(), and INSTANCEOF.

+ Here is the call graph for this function:
+ 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: