8#ifndef SEN_CORE_META_CALLABLE_H
9#define SEN_CORE_META_CALLABLE_H
20#include <unordered_map>
48 return lhs.name == rhs.name && lhs.description == rhs.description && lhs.type == rhs.type;
51 friend bool operator!=(
const Arg& lhs,
const Arg& rhs)
noexcept {
return !(lhs == rhs); }
61 [[nodiscard]] uint32_t
getNameHash() const noexcept;
64 mutable uint32_t nameHash_ = 0;
78 return lhs.transportMode == rhs.transportMode && lhs.name == rhs.name && lhs.description == rhs.description &&
102 [[nodiscard]] std::string_view
getName() const noexcept;
122 [[nodiscard]]
bool operator==(const
Callable& other) const noexcept;
124 [[nodiscard]]
bool operator!=(const
Callable& other) const noexcept;
155struct impl::hash<
Arg>
157 inline u32 operator()(
const Arg& spec)
const noexcept
164struct impl::hash<CallableSpec>
166 u32 operator()(
const CallableSpec& spec)
const noexcept
168 auto result =
hashCombine(hashSeed, spec.name, spec.transportMode);
170 for (
const auto& arg: spec.args)
Here we define a set of template meta-programming helpers to let the compiler take some decisions bas...
std::string_view getName() const noexcept
Callable name.
Callable(CallableSpec spec)
Copies the spec into a member.
virtual ~Callable()=default
Span< const Arg > getArgs() const noexcept
Gets the arguments.
std::string_view getDescription() const noexcept
Callable description.
TransportMode getTransportMode() const noexcept
The transport mode of this callable.
static void checkSpec(const CallableSpec &spec)
Throws std::exception if the callable spec is invalid.
const CallableSpec & getCallableSpec() const noexcept
The spec of this callable.
size_t getArgIndexFromNameHash(MemberHash nameHash) const
Get the index in the vector of Args given a name hash.
const Arg * getArgFromName(std::string_view name) const
Get the field data given a name. Nullptr means not found.
Contiguous view of elements of type T. Inspired by http://www.open-std.org/jtc1/sc22/wg21/docs/papers...
Definition span.h:34
constexpr u32 hashSeed
Initial seed for all hashes.
Definition hash32.h:33
u32 hashCombine(u32 seed, const Types &... args) noexcept
Combines the hash of different values into a single 32-bit hash.
Definition hash32.h:214
TypeHandle< const T > ConstTypeHandle
Definition type.h:319
TransportMode
How to transport information.
Definition type.h:56
@ confirmed
Directed to each receiver, reliable, ordered, with congestion control, relatively heavyweight.
Definition type.h:59
uint32_t u32
Definition numbers.h:25
This file contains functions related to hashing and compression. This is mainly used by Sen internals...
Holds the information for an argument in the callable.
Definition callable.h:31
friend bool operator!=(const Arg &lhs, const Arg &rhs) noexcept
Definition callable.h:51
uint32_t getNameHash() const noexcept
Definition callable.h:145
friend bool operator==(const Arg &lhs, const Arg &rhs) noexcept
Definition callable.h:41
ConstTypeHandle type
Definition callable.h:58
Arg(std::string theName, std::string theDescription, ConstTypeHandle<> theType)
Definition callable.h:35
std::string description
Definition callable.h:57
std::string name
Definition callable.h:56
Data of a callable.
Definition callable.h:69
friend bool operator!=(const CallableSpec &lhs, const CallableSpec &rhs) noexcept
Definition callable.h:82
std::vector< Arg > args
Definition callable.h:86
TransportMode transportMode
Definition callable.h:87
std::string name
Definition callable.h:84
friend bool operator==(const CallableSpec &lhs, const CallableSpec &rhs) noexcept
Definition callable.h:71
std::string description
Definition callable.h:85
The hash of a member.
Definition type.h:39