Sen API
Sen Libraries
Loading...
Searching...
No Matches
gen.h File Reference

Go to the source code of this file.

Macros

#define SEN_IMPL_GEN_NATIVE_MEMBERS
#define SEN_IMPL_GEN_BASE_CLASS(classname)
 Used by the generated code for simplicity NOLINTNEXTLINE.
#define SEN_IMPL_GEN_REMOTE_CLASS(classname)
 Used by the code generator NOLINTNEXTLINE.
#define SEN_IMPL_GEN_LOCAL_PROXY_CLASS(classname)
 Used by the code generator NOLINTNEXTLINE.
#define SEN_IMPL_GEN_UNBOUNDED_SEQUENCE(classname, elementtype)
 Used by the code generator NOLINTNEXTLINE.
#define SEN_IMPL_GEN_BOUNDED_SEQUENCE(classname, element, maxSize)
 Used by the code generator NOLINTNEXTLINE.
#define SEN_IMPL_GEN_FIXED_SEQUENCE(classname, element, size)
 Used by the code generator NOLINTNEXTLINE.
#define SEN_IMPL_GEN_STRUCT_OPERATORS(classname, doExport)
 Used by the code generator NOLINTNEXTLINE.
#define SEN_IMPL_GEN_OPTIONAL(classname, elementtype, doExport)
 Used by the code generator NOLINTNEXTLINE.
#define SEN_IMPL_GEN_OPTIONAL_TRAITS(classname, doExport)
 Used by the code generator NOLINTNEXTLINE.
#define SEN_IMPL_GEN_ENUM_TRAITS(classname, doExport)
 Used by the code generator NOLINTNEXTLINE.
#define SEN_IMPL_GEN_SEQUENCE_TRAITS(classname, doExport)
 Used by the code generator NOLINTNEXTLINE.
#define SEN_IMPL_GEN_ARRAY_TRAITS(classname, doExport)
 Used by the code generator NOLINTNEXTLINE.
#define SEN_IMPL_GEN_STRUCT_TRAITS(classname, doExport)
 Used by the code generator NOLINTNEXTLINE.
#define SEN_IMPL_GEN_VARIANT_TRAITS(classname, doExport)
 Used by the code generator NOLINTNEXTLINE.
#define SEN_IMPL_GEN_CLASS_META_TRAITS(classname, doExport)
 Used by the code generator NOLINTNEXTLINE.
#define SEN_IMPL_GEN_CLASS_TRAITS_TEMPLATE(interfaceName, remoteProxy, localProxy, baseName)
 Used by the code generator NOLINTNEXTLINE.
#define SEN_IMPL_GEN_CLASS_TRAITS_NORMAL(interfaceName, remoteProxy, localProxy, baseName)
 Used by the code generator NOLINTNEXTLINE.
#define SEN_IMPL_GEN_QUANTITY_TRAITS(classname, maxVal, minVal, doExport)
 Used by the code generator NOLINTNEXTLINE.

Macro Definition Documentation

◆ SEN_IMPL_GEN_NATIVE_MEMBERS

#define SEN_IMPL_GEN_NATIVE_MEMBERS
Value:
protected: \
[[nodiscard]] inline ::sen::Var senImplGetPropertyImpl(::sen::MemberHash propertyId) const override; \
inline void senImplSetNextPropertyUntyped(::sen::MemberHash propertyId, const ::sen::Var& value) override; \
[[nodiscard]] inline ::sen::Var senImplGetNextPropertyUntyped(::sen::MemberHash propertyId) const override; \
[[nodiscard]] inline uint32_t senImplComputeMaxReliableSerializedPropertySizeImpl() const override; \
inline void senImplStreamCall(::sen::MemberHash methodId, ::sen::InputStream& in, ::sen::StreamCallForwarder&& func) \
override; \
inline void senImplVariantCall( \
::sen::MemberHash methodId, const ::sen::VarList& args, ::sen::VariantCallForwarder&& func) override; \
inline void senImplCommitImpl(::sen::TimeStamp time) override; \
inline void senImplWriteChangedPropertiesToStream( \
::sen::OutputStream& confirmed, ::sen::impl::BufferProvider uni, ::sen::impl::BufferProvider multi) override; \
inline void senImplWriteAllPropertiesToStream(::sen::OutputStream& out) const override; \
inline void senImplWriteStaticPropertiesToStream(::sen::OutputStream& out) const override; \
inline void senImplWriteDynamicPropertiesToStream(::sen::OutputStream& out) const override; \
inline void senImplRemoveTypedConnection(::sen::ConnId id) override; \
[[nodiscard]] inline ::sen::impl::FieldValueGetter senImplGetFieldValueGetter( \
::sen::MemberHash propertyId, ::sen::Span<uint16_t> fields) const override; \
inline void invokeAllPropertyCallbacks() override; \
\
private: \
bool somePropertyIsDirty_ = false;
Contiguous view of elements of type T. Inspired by http://www.open-std.org/jtc1/sc22/wg21/docs/papers...
Definition span.h:34
A point in time.
Definition timestamp.h:26
InputStreamTemplate< LittleEndian > InputStream
Definition input_stream.h:84
sen::std_util::move_only_function< void(StreamCall &&)> StreamCallForwarder
Definition native_object.h:57
sen::std_util::move_only_function< void(VariantCall &&)> VariantCallForwarder
Definition native_object.h:58
OutputStreamTemplate< LittleEndian > OutputStream
Definition output_stream.h:64
The hash of a member.
Definition type.h:39

◆ SEN_IMPL_GEN_BASE_CLASS

#define SEN_IMPL_GEN_BASE_CLASS ( classname)
Value:
SEN_IMPL_GEN_NATIVE_MEMBERS \
public: \
inline classname(std::string name, const ::sen::VarMap& args); \
~classname() override = default; \
[[nodiscard]] inline ::sen::ConstTypeHandle<::sen::ClassType> getClass() const noexcept override; \
[[nodiscard]] static inline ::sen::ConstTypeHandle<::sen::ClassType> meta() noexcept; \
\
private:
Definition assert.h:17

Used by the generated code for simplicity NOLINTNEXTLINE.

◆ SEN_IMPL_GEN_REMOTE_CLASS

#define SEN_IMPL_GEN_REMOTE_CLASS ( classname)
Value:
public: \
explicit classname(::sen::impl::RemoteObjectInfo&& info); \
~classname() override = default; \
\
protected: \
void senImplRemoveTypedConnection(::sen::ConnId id) override; \
void senImplWriteAllPropertiesToStream(::sen::OutputStream& out) const override; \
void senImplWriteStaticPropertiesToStream(::sen::OutputStream& out) const override; \
void senImplWriteDynamicPropertiesToStream(::sen::OutputStream& out) const override; \
[[nodiscard]] ::sen::Var senImplGetPropertyImpl(::sen::MemberHash propertyId) const override; \
[[nodiscard]] bool readPropertyFromStream(::sen::MemberHash id, ::sen::InputStream& in, bool initialState) override; \
[[nodiscard]] ::sen::Var deserializeMethodReturnValueAsVariant(::sen::MemberHash methodId, ::sen::InputStream& in) \
const override; \
void serializeMethodArgumentsFromVariants( \
::sen::MemberHash methodId, const ::sen::VarList& args, ::sen::OutputStream& out) const override; \
void drainInputs() override; \
void eventReceived(::sen::MemberHash eventId, ::sen::TimeStamp creationTime, const ::sen::Span<const uint8_t>& args) \
override; \
void invokeAllPropertyCallbacks() override; \
\
private:
Can hold any supported value type. Wraps std::variant to allow recursion and implements some helpers.
Definition var.h:119

Used by the code generator NOLINTNEXTLINE.

◆ SEN_IMPL_GEN_LOCAL_PROXY_CLASS

#define SEN_IMPL_GEN_LOCAL_PROXY_CLASS ( classname)
Value:
public: \
explicit classname(::sen::NativeObject* owner, const std::string& localPrefix); \
~classname() override = default; \
\
protected: \
void senImplWriteAllPropertiesToStream(::sen::OutputStream& out) const override; \
void senImplWriteStaticPropertiesToStream(::sen::OutputStream& out) const override; \
void senImplWriteDynamicPropertiesToStream(::sen::OutputStream& out) const override; \
void senImplRemoveTypedConnection(::sen::ConnId id) override; \
[[nodiscard]] ::sen::Var senImplGetPropertyImpl(::sen::MemberHash propertyId) const override; \
void drainInputsImpl(::sen::TimeStamp lastCommitTime) override; \
\
private:
An object instantiated in this process. This is the base class for all user-implemented objects.
Definition native_object.h:63

Used by the code generator NOLINTNEXTLINE.

◆ SEN_IMPL_GEN_UNBOUNDED_SEQUENCE

#define SEN_IMPL_GEN_UNBOUNDED_SEQUENCE ( classname,
elementtype )
Value:
struct classname final: public std::vector<elementtype> \
{ \
using Parent = std::vector<elementtype>; \
using Parent::Parent; \
using Parent::operator=; \
};

Used by the code generator NOLINTNEXTLINE.

◆ SEN_IMPL_GEN_BOUNDED_SEQUENCE

#define SEN_IMPL_GEN_BOUNDED_SEQUENCE ( classname,
element,
maxSize )
Value:
struct classname final: public ::sen::StaticVector<element, maxSize> \
{ \
using Parent::Parent; \
using Parent::operator=; \
};
Stack-based, exception-free and resizable vector with fixed-capacity.
Definition static_vector.h:571

Used by the code generator NOLINTNEXTLINE.

◆ SEN_IMPL_GEN_FIXED_SEQUENCE

#define SEN_IMPL_GEN_FIXED_SEQUENCE ( classname,
element,
size )
Value:
struct classname final: public std::array<element, size> \
{ \
using Parent = std::array<element, size>; \
using Parent::Parent; \
using Parent::operator=; \
\
template <typename Y, typename = std::enable_if_t<std::is_convertible_v<Y, element>, int>> \
classname(std::initializer_list<Y> elems): Parent() \
{ \
std::size_t i = 0; \
for (auto itr = elems.begin(); itr != elems.end() && i < size; ++itr) \
{ \
(*this)[i] = *itr; \
++i; \
} \
} \
};

Used by the code generator NOLINTNEXTLINE.

◆ SEN_IMPL_GEN_STRUCT_OPERATORS

#define SEN_IMPL_GEN_STRUCT_OPERATORS ( classname,
doExport )
Value:
SEN_MAYBE_EXPORT(doExport) std::ostream& operator<<(std::ostream& out, const classname& val); \
SEN_MAYBE_EXPORT(doExport) bool operator==(const classname& lhs, const classname& rhs); \
SEN_MAYBE_EXPORT(doExport) bool operator!=(const classname& lhs, const classname& rhs);

Used by the code generator NOLINTNEXTLINE.

◆ SEN_IMPL_GEN_OPTIONAL

#define SEN_IMPL_GEN_OPTIONAL ( classname,
elementtype,
doExport )
Value:
struct classname final: public std::optional<elementtype> \
{ \
using Parent = std::optional<elementtype>; \
using Parent::Parent; \
using Parent::operator=; \
using Parent::operator->; \
using Parent::operator*; \
using Parent::operator bool; \
}; \
\
SEN_MAYBE_EXPORT(doExport) bool operator==(const classname& lhs, const classname& rhs); \
SEN_MAYBE_EXPORT(doExport) bool operator!=(const classname& lhs, const classname& rhs);

Used by the code generator NOLINTNEXTLINE.

◆ SEN_IMPL_GEN_OPTIONAL_TRAITS

#define SEN_IMPL_GEN_OPTIONAL_TRAITS ( classname,
doExport )
Value:
template <> \
struct MetaTypeTrait<classname> \
{ \
[[nodiscard]] SEN_MAYBE_EXPORT(doExport) static ConstTypeHandle<OptionalType> meta(); \
}; \
template <> \
struct VariantTraits<classname>: private OptionalTraitsBase<classname> \
{ \
using OptionalTraitsBase<classname>::valueToVariant; \
using OptionalTraitsBase<classname>::variantToValue; \
}; \
template <> \
struct SerializationTraits<classname>: private OptionalTraitsBase<classname> \
{ \
using OptionalTraitsBase<classname>::write; \
using OptionalTraitsBase<classname>::read; \
using OptionalTraitsBase<classname>::serializedSize; \
};

Used by the code generator NOLINTNEXTLINE.

◆ SEN_IMPL_GEN_ENUM_TRAITS

#define SEN_IMPL_GEN_ENUM_TRAITS ( classname,
doExport )
Value:
template <> \
struct MetaTypeTrait<classname> \
{ \
[[nodiscard]] SEN_MAYBE_EXPORT(doExport) static ConstTypeHandle<EnumType> meta(); \
}; \
template <> \
struct SEN_MAYBE_EXPORT(doExport) VariantTraits<classname>: private EnumTraitsBase<classname> \
{ \
using EnumTraitsBase<classname>::valueToVariant; \
using EnumTraitsBase<classname>::variantToValue; \
}; \
template <> \
struct SEN_MAYBE_EXPORT(doExport) SerializationTraits<classname>: private EnumTraitsBase<classname> \
{ \
using EnumTraitsBase<classname>::write; \
using EnumTraitsBase<classname>::read; \
using EnumTraitsBase<classname>::serializedSize; \
}; \
template <> \
struct SEN_MAYBE_EXPORT(doExport) StringConversionTraits<classname> \
{ \
[[nodiscard]] static std::string_view toString(classname val); \
[[nodiscard]] static classname fromString(std::string_view val); \
}; \
\
[[nodiscard]] SEN_MAYBE_EXPORT(doExport) std::string_view toString(classname value);
std::string toString(const StlToken &token)

Used by the code generator NOLINTNEXTLINE.

◆ SEN_IMPL_GEN_SEQUENCE_TRAITS

#define SEN_IMPL_GEN_SEQUENCE_TRAITS ( classname,
doExport )
Value:
template <> \
struct MetaTypeTrait<classname> \
{ \
[[nodiscard]] SEN_MAYBE_EXPORT(doExport) static sen::ConstTypeHandle<SequenceType> meta(); \
}; \
template <> \
struct SEN_MAYBE_EXPORT(doExport) VariantTraits<classname>: private SequenceTraitsBase<classname> \
{ \
using SequenceTraitsBase<classname>::valueToVariant; \
using SequenceTraitsBase<classname>::variantToValue; \
}; \
template <> \
struct SEN_MAYBE_EXPORT(doExport) SerializationTraits<classname>: private SequenceTraitsBase<classname> \
{ \
using SequenceTraitsBase<classname>::write; \
using SequenceTraitsBase<classname>::read; \
using SequenceTraitsBase<classname>::serializedSize; \
};
TypeHandle< const T > ConstTypeHandle
Definition type.h:319

Used by the code generator NOLINTNEXTLINE.

◆ SEN_IMPL_GEN_ARRAY_TRAITS

#define SEN_IMPL_GEN_ARRAY_TRAITS ( classname,
doExport )
Value:
template <> \
struct MetaTypeTrait<classname> \
{ \
[[nodiscard]] SEN_MAYBE_EXPORT(doExport) static ConstTypeHandle<SequenceType> meta(); \
}; \
template <> \
struct SEN_MAYBE_EXPORT(doExport) VariantTraits<classname>: private ArrayTraitsBase<classname> \
{ \
using ArrayTraitsBase<classname>::valueToVariant; \
using ArrayTraitsBase<classname>::variantToValue; \
}; \
template <> \
struct SEN_MAYBE_EXPORT(doExport) SerializationTraits<classname>: private ArrayTraitsBase<classname> \
{ \
using ArrayTraitsBase<classname>::write; \
using ArrayTraitsBase<classname>::read; \
using ArrayTraitsBase<classname>::serializedSize; \
};

Used by the code generator NOLINTNEXTLINE.

◆ SEN_IMPL_GEN_STRUCT_TRAITS

#define SEN_IMPL_GEN_STRUCT_TRAITS ( classname,
doExport )
Value:
template <> \
struct MetaTypeTrait<classname> \
{ \
[[nodiscard]] SEN_MAYBE_EXPORT(doExport) static ConstTypeHandle<StructType> meta(); \
}; \
template <> \
struct SEN_MAYBE_EXPORT(doExport) VariantTraits<classname>: protected StructTraitsBase \
{ \
static void valueToVariant(const classname& val, Var& var); \
static void variantToValue(const Var& var, classname& val); \
static std::function<lang::Value(const void*)> getFieldValueGetterFunction(Span<uint16_t> fields); \
}; \
template <> \
struct SEN_MAYBE_EXPORT(doExport) SerializationTraits<classname>: protected StructTraitsBase \
{ \
static void write(OutputStream& out, const classname& val); \
static void read(InputStream& in, classname& val); \
[[nodiscard]] static uint32_t serializedSize(const classname& val) noexcept; \
};
void write(T &&data, FILE *file)
Definition db/src/util.h:71

Used by the code generator NOLINTNEXTLINE.

◆ SEN_IMPL_GEN_VARIANT_TRAITS

#define SEN_IMPL_GEN_VARIANT_TRAITS ( classname,
doExport )
Value:
template <> \
struct SEN_MAYBE_EXPORT(doExport) MetaTypeTrait<classname> \
{ \
[[nodiscard]] static ConstTypeHandle<VariantType> meta(); \
}; \
template <> \
struct SEN_MAYBE_EXPORT(doExport) VariantTraits<classname>: protected VariantTraitsBase<classname> \
{ \
static void valueToVariant(const classname& val, Var& var); \
static void variantToValue(const Var& var, classname& val); \
static std::function<lang::Value(const void*)> getFieldValueGetterFunction(Span<uint16_t> fields); \
using VariantTraitsBase<classname>::tryPrintField; \
}; \
template <> \
struct SEN_MAYBE_EXPORT(doExport) SerializationTraits<classname>: protected VariantTraitsBase<classname> \
{ \
static void write(OutputStream& out, const classname& val); \
static void read(InputStream& in, classname& val); \
[[nodiscard]] static uint32_t serializedSize(const classname& val) noexcept; \
};

Used by the code generator NOLINTNEXTLINE.

◆ SEN_IMPL_GEN_CLASS_META_TRAITS

#define SEN_IMPL_GEN_CLASS_META_TRAITS ( classname,
doExport )
Value:
template <> \
struct MetaTypeTrait<classname> \
{ \
[[nodiscard]] SEN_MAYBE_EXPORT(doExport) static ConstTypeHandle<ClassType> meta(); \
};

Used by the code generator NOLINTNEXTLINE.

◆ SEN_IMPL_GEN_CLASS_TRAITS_TEMPLATE

#define SEN_IMPL_GEN_CLASS_TRAITS_TEMPLATE ( interfaceName,
remoteProxy,
localProxy,
baseName )

Used by the code generator NOLINTNEXTLINE.

◆ SEN_IMPL_GEN_CLASS_TRAITS_NORMAL

#define SEN_IMPL_GEN_CLASS_TRAITS_NORMAL ( interfaceName,
remoteProxy,
localProxy,
baseName )

Used by the code generator NOLINTNEXTLINE.

◆ SEN_IMPL_GEN_QUANTITY_TRAITS

#define SEN_IMPL_GEN_QUANTITY_TRAITS ( classname,
maxVal,
minVal,
doExport )
Value:
template <> \
struct MetaTypeTrait<classname> \
{ \
[[nodiscard]] SEN_MAYBE_EXPORT(doExport) static ConstTypeHandle<QuantityType> meta(); \
}; \
template <> \
struct SEN_MAYBE_EXPORT(doExport) VariantTraits<classname>: private QuantityTraitsBase<classname> \
{ \
using QuantityTraitsBase<classname>::valueToVariant; \
using QuantityTraitsBase<classname>::variantToValue; \
}; \
template <> \
struct SEN_MAYBE_EXPORT(doExport) SerializationTraits<classname>: private QuantityTraitsBase<classname> \
{ \
using QuantityTraitsBase<classname>::write; \
using QuantityTraitsBase<classname>::read; \
using QuantityTraitsBase<classname>::serializedSize; \
}; \
template <> \
struct SEN_MAYBE_EXPORT(doExport) QuantityTraits<classname> \
{ \
using ValueType = typename classname::ValueType; \
\
static constexpr ValueType max = maxVal; \
static constexpr ValueType min = minVal; \
\
[[nodiscard]] static ::std::optional<const sen::Unit*> unit() noexcept; \
[[nodiscard]] static const sen::Unit& unit(sen::Unit::EnsureTag); \
};

Used by the code generator NOLINTNEXTLINE.