FastLED 3.9.15
Loading...
Searching...
No Matches

◆ registerMethod()

template<class Sig>
bool fl::Rpc::registerMethod ( const char * name,
RpcFn< Sig > fn,
const fl::vector< fl::string > & paramNames,
const fl::string & description,
const fl::vector< fl::string > & tags,
fl::RpcMode mode = fl::RpcMode::SYNC )
inline

Definition at line 346 of file rpc.h.

350 {
351 fl::string key(name);
352 auto it = mRegistry.find(key);
353 if (it != mRegistry.end()) {
354 if (it->second.mTypeTag != detail::TypeTag<Sig>::id()) {
355 return false;
356 }
357 }
358
359 detail::RpcEntry entry;
360 entry.mTypeTag = detail::TypeTag<Sig>::id();
361 entry.mInvoker = fl::make_shared<detail::TypedInvoker<Sig>>(fn);
362 entry.mTypedCallable = fl::make_shared<detail::TypedCallableHolder<Sig>>(fn);
363#if FL_PLATFORM_HAS_LARGE_MEMORY
364 // Schema generator construction gated on Low-memory targets per
365 // FastLED #3081 / #3079. The schema generator is only consumed by
366 // `rpc.discover` (also gated). Skipping it on Low-memory drops
367 // `TypedSchemaGenerator<Sig>::params()` (~800 B per signature).
368 entry.mSchemaGenerator = fl::make_shared<detail::TypedSchemaGenerator<Sig>>();
369#endif
370 entry.mDescription = description;
371 entry.mTags = tags;
372 entry.mMode = mode;
373
374#if FL_PLATFORM_HAS_LARGE_MEMORY
375 if (!paramNames.empty()) {
376 entry.mSchemaGenerator->setParamNames(paramNames);
377 }
378#else
379 (void)paramNames;
380#endif
381
382 mRegistry[key] = fl::move(entry);
383 return true;
384 }
fl::UIDescription description("Demo of the Animatrix effects. @author of fx is StefanPetrick")
fl::unordered_map< fl::string, detail::RpcEntry > mRegistry
Definition rpc.h:387
fl::vector< fl::string > tags() const
Returns list of unique tags used across all methods.
Definition rpc.cpp.hpp:219
bool empty() const FL_NOEXCEPT
constexpr remove_reference< T >::type && move(T &&t) FL_NOEXCEPT
Definition s16x16x4.h:28
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT
Definition shared_ptr.h:414
static const void * id()

References description, fl::vector_basic::empty(), fl::detail::TypeTag< Sig >::id(), fl::make_shared(), fl::detail::RpcEntry::mDescription, fl::detail::RpcEntry::mInvoker, fl::detail::RpcEntry::mMode, fl::fl::move(), mRegistry, fl::detail::RpcEntry::mSchemaGenerator, fl::detail::RpcEntry::mTags, fl::detail::RpcEntry::mTypedCallable, fl::detail::RpcEntry::mTypeTag, fl::SYNC, and tags().

Referenced by bind().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: