"ScL Feature"/
ScL Feature 0.0.1
C++20 composable proxy wrapper with pluggable executor strategy
Loading...
Searching...
No Matches
method.h File Reference

Compile-time method reflection macros for wrapper types. More...

Go to the source code of this file.

Macros

#define SCL_REFLECT_METHOD(name)
 Generates proxy methods that reflect method from the wrapped object through the executor, for all 8 cv-ref qualifier combinations.

Detailed Description

Compile-time method reflection macros for wrapper types.

Provides macros to automatically generate proxy methods that forward calls from a wrapper class to the held object through an executor, preserving cv-ref qualifiers exactly.

Every generated overload dispatches through Executor::execute so that executor strategies (e.g. locking executors) can intercept every call.

The executor is located at runtime via scl::feature::executor_trait, which must be specialized for each wrapper type.

Requirements on the enclosing class
  1. Declare the wrapper type with SCL_REFLECT_TYPE(Type,Member) (after the executor member declaration).
  2. Specialize scl::feature::executor_trait for the wrapper type.
  3. The executor type must provide:
    • a static access(exec) method that returns a reference to the wrapped object; and
    • a static execute(exec, callable, args...) method that invokes callable(args...) in the executor's context and returns its result.
Example
struct MyWrapper;
template <>
struct scl::feature::executor_trait<MyWrapper> {
template <typename Self>
static constexpr decltype(auto) executor(Self && self)
{ return ::scl::forward_like<Self>(self.m_exec); }
};
struct MyWrapper {
Executor m_exec;
SCL_REFLECT_TYPE(MyWrapper, m_exec);
};
#define SCL_REFLECT_TYPE(type, executor)
Declares the wrapper and executor types for use by SCL_REFLECT_METHOD.
Definition type.h:27
#define SCL_REFLECT_METHOD(name)
Generates proxy methods that reflect method from the wrapped object through the executor,...
Definition method.h:427
Trait that provides access to the executor inside a wrapper.
Definition executor.h:39