FastLED 3.9.15
Loading...
Searching...
No Matches
rpc_handle.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/stl/function.h"
5#include "fl/stl/noexcept.h"
6
7namespace fl {
8
9// =============================================================================
10// RpcFn - Type alias for typed RPC callables
11// =============================================================================
12
13template<class Sig>
15
16// =============================================================================
17// RpcHandle - Callable handle returned from method() for immediate use
18// =============================================================================
19
20template<typename Sig>
22
23// Specialization for function signatures
24template<typename R, typename... Args>
25class RpcHandle<R(Args...)> {
26public:
27 using signature = R(Args...);
28 using function_type = fl::function<R(Args...)>;
29
30 // Default constructor - creates invalid handle
32
33 // Constructor from function (internal use by RpcFactory)
34 explicit RpcHandle(function_type fn) : mFn(fn), mValid(true) {}
35
36 // Call operator - invoke the underlying function
37 template<typename... CallArgs>
38 R operator()(CallArgs&&... args) const {
39 return mFn(fl::forward<CallArgs>(args)...);
40 }
41
42 // Validity check
43 explicit operator bool() const { return mValid && static_cast<bool>(mFn); }
44
45 // Get underlying function
46 function_type get() const { return mFn; }
47
48 // Implicit conversion to fl::function
49 operator function_type() const { return mFn; }
50
51private:
53 bool mValid;
54};
55
56} // namespace fl
R operator()(CallArgs &&... args) const
Definition rpc_handle.h:38
function_type get() const
Definition rpc_handle.h:46
RpcHandle(function_type fn)
Definition rpc_handle.h:34
fl::function< R(Args...)> function_type
Definition rpc_handle.h:28
constexpr T && forward(typename remove_reference< T >::type &t) FL_NOEXCEPT
Definition s16x16x4.h:234
fl::function< Sig > RpcFn
Definition rpc_handle.h:14
Base definition for an LED controller.
Definition crgb.hpp:179
corkscrew_args args
Definition old.h:149
#define FL_NOEXCEPT