3DRadSpace 0.1.0Alpha
3DRadSpace is a free, simple to use, rapid application development game engine.
Loading...
Searching...
No Matches
Engine3DRadSpace.Reflection::Event Class Reference

Like MultiEvent, an Event can be bound to multiple function, but this class is also serializable in the editor. More...

#include <Event.hpp>

Inheritance diagram for Engine3DRadSpace.Reflection::Event:
Collaboration diagram for Engine3DRadSpace.Reflection::Event:

Classes

class  ConstIterator
 Wraps the vector iterator with a const iterator to prevent modification of the bound functions. More...

Public Types

using Iterator = std::vector<MemberFunctionInvoker>::iterator

Public Member Functions

 Event ()
 Constructs a empty Event.
template<typename R, typename O, typename F, typename ... Args>
 Event (O *object, O::F fn)
 Constructs a Event with the given method.
 Event (const Event &other)
 Deep clone Event ctor.
 Event (Event &&other)=default
 Move constructor for this Event.
Event & operator= (const Event &other)
 Creates a deep clone of the Event.
Event & operator= (Event &&)=default
template<typename R, typename F, typename ... Args>
void Bind (F fn)
 Binds the given function to this event.
template<typename R, typename O, typename F, typename ... Args>
void Bind (O *object, F fn)
 Binds a member function to this event.
void Bind (std::unique_ptr< IReflectedFunction > &&fn, size_t objID, size_t fnID)
 Binds an typeless function to this event.
void BindIncomplete (size_t objID, size_t fnID)
 Binds an function by finding it in the ObjectList and reflection metadata.
template<typename R, typename ... Args>
R operator() (int index, Args &&...args)
 Calls the index-th bound function.
template<typename R>
std::vector< R > InvokeAll (std::span< Any > args)
 Invokes all functions.
void InvokeAll (std::span< Any > args=std::span< Any >())
 Invokes all functions ignoring the return value.
void Unbind (void *fnPtr)
 Unbinds the given function pointer.
void Unbind (size_t idx)
 Unbinds the idx-th function.
void Bind (std::function< Any(std::vector< Any >)> fn) override
 Binds the given function pointer to this event.
Any operator() (std::vector< Any > &args) override
 Calls all the functions with the specified argument pack.
void Reset () noexcept override
 Clears all the bound functions.
const void * operator[] (size_t i) const
 Returns an raw pointer to the i-th bound function.
const MemberFunctionInvoker & At (size_t i) const
 Returns an invoker at the specified index.
size_t Count () const noexcept
 Returns the number of bound functions.
ConstIterator cbegin () const
 Const begin iterator for this event.
ConstIterator cend () const
 Const end iterator for this event.
Iterator begin ()
 Begin iterator for this event.
Iterator end ()
 End iterator for this event.
const Reflection::IReflectedFunction * ReflFnAt (size_t index)
 Returns the metadata of the index-th function bound in this Event instance.
Event Clone () const
 Same as Event e = other..
 ~Event ()=default
Public Member Functions inherited from Engine3DRadSpace.Reflection::IEvent
virtual ~IEvent ()=default

Additional Inherited Members

Protected Member Functions inherited from Engine3DRadSpace.Reflection::IEvent
 IEvent ()=default

Detailed Description

Like MultiEvent, an Event can be bound to multiple function, but this class is also serializable in the editor.

Member Typedef Documentation

◆ Iterator

using Engine3DRadSpace.Reflection::Event::Iterator = std::vector<MemberFunctionInvoker>::iterator

Constructor & Destructor Documentation

◆ Event() [1/4]

Event::Event ( )

Constructs a empty Event.

◆ Event() [2/4]

template<typename R, typename O, typename F, typename ... Args>
Engine3DRadSpace.Reflection::Event::Event ( O * object,
O::F fn )
inline

Constructs a Event with the given method.

Template Parameters
RReturn type
OClass type of the method
FMethod type
...ArgsArgument pack for the method
Parameters
objectobject instance
fnmember function pointer

◆ Event() [3/4]

Event::Event ( const Event & other)

Deep clone Event ctor.

Parameters
otherFrom

◆ Event() [4/4]

Engine3DRadSpace.Reflection::Event::Event ( Event && other)
default

Move constructor for this Event.

Parameters
other

◆ ~Event()

Engine3DRadSpace.Reflection::Event::~Event ( )
default

Member Function Documentation

◆ At()

const Event::MemberFunctionInvoker & Event::At ( size_t i) const

Returns an invoker at the specified index.

Parameters
iindex
Returns
Structure containing function metadata

◆ begin()

Event::Iterator Event::begin ( )

Begin iterator for this event.

Returns
std::vector<MemberFunctionInvoker>::iterator::begin()

◆ Bind() [1/4]

template<typename R, typename F, typename ... Args>
void Engine3DRadSpace.Reflection::Event::Bind ( F fn)
inline

Binds the given function to this event.

Template Parameters
RReturn type
FFunction type
...ArgsFunction parameter pack
Parameters
fnFunction pointer

◆ Bind() [2/4]

template<typename R, typename O, typename F, typename ... Args>
void Engine3DRadSpace.Reflection::Event::Bind ( O * object,
F fn )
inline

Binds a member function to this event.

Template Parameters
RReturn type
OObject type
FFunction type
...ArgsArgument pack
Parameters
objectObject pointer
fnMember function pointer

◆ Bind() [3/4]

void Event::Bind ( std::function< Any(std::vector< Any >)> fn)
overridevirtual

Binds the given function pointer to this event.

Parameters
fnType erased function

Implements Engine3DRadSpace.Reflection::IEvent.

◆ Bind() [4/4]

void Event::Bind ( std::unique_ptr< IReflectedFunction > && fn,
size_t objID,
size_t fnID )

Binds an typeless function to this event.

Parameters
fnFunction reflection data
objIDObject ID in the ObjectList.
fnIDFunction ID

◆ BindIncomplete()

void Event::BindIncomplete ( size_t objID,
size_t fnID )

Binds an function by finding it in the ObjectList and reflection metadata.

Parameters
objIDobject ID from an object list
fnIDfunction ID in metadata

◆ cbegin()

Event::ConstIterator Event::cbegin ( ) const

Const begin iterator for this event.

Returns
const begin iterator

◆ cend()

Event::ConstIterator Event::cend ( ) const

Const end iterator for this event.

Returns
const end iterator

◆ Clone()

Event Event::Clone ( ) const

Same as Event e = other..

Returns
Deep clone

◆ Count()

size_t Event::Count ( ) const
noexcept

Returns the number of bound functions.

Returns

◆ end()

Event::Iterator Event::end ( )

End iterator for this event.

Returns
std::vector<MemberFunctionInvoker>::iterator::end()

◆ InvokeAll() [1/2]

template<typename R>
std::vector< R > Engine3DRadSpace.Reflection::Event::InvokeAll ( std::span< Any > args)
inline

Invokes all functions.

Template Parameters
RReturn type
Parameters
argsType erased argument pack
Returns
A list of returned values

◆ InvokeAll() [2/2]

void Engine3DRadSpace.Reflection::Event::InvokeAll ( std::span< Any > args = std::span<Any>())
inline

Invokes all functions ignoring the return value.

Parameters
argsType erased argument pack

◆ operator()() [1/2]

template<typename R, typename ... Args>
R Engine3DRadSpace.Reflection::Event::operator() ( int index,
Args &&... args )
inline

Calls the index-th bound function.

Template Parameters
RReturn type
...ArgsArgument pack
Parameters
indexIndex of the function
...argsArgument pack
Returns
The result of the function

◆ operator()() [2/2]

Any Event::operator() ( std::vector< Any > & args)
overridevirtual

Calls all the functions with the specified argument pack.

Parameters
argstype erased argument pack
Returns
List of return values

Implements Engine3DRadSpace.Reflection::IEvent.

◆ operator=() [1/2]

Event & Event::operator= ( const Event & other)

Creates a deep clone of the Event.

Parameters
otherFrom
Returns
Cloned event

◆ operator=() [2/2]

Event & Engine3DRadSpace.Reflection::Event::operator= ( Event && )
default

◆ operator[]()

const void * Event::operator[] ( size_t i) const

Returns an raw pointer to the i-th bound function.

Parameters
iindex
Returns
type erased function or member function pointer

◆ ReflFnAt()

const IReflectedFunction * Event::ReflFnAt ( size_t index)

Returns the metadata of the index-th function bound in this Event instance.

Parameters
index
Returns

◆ Reset()

void Event::Reset ( )
overridevirtualnoexcept

Clears all the bound functions.

Implements Engine3DRadSpace.Reflection::IEvent.

◆ Unbind() [1/2]

void Event::Unbind ( size_t idx)

Unbinds the idx-th function.

Parameters
idx0 < idx < Count().

◆ Unbind() [2/2]

void Event::Unbind ( void * fnPtr)

Unbinds the given function pointer.

Parameters
fnPtrFunction pointer.

The documentation for this class was generated from the following files:
  • E:/3DRadSpace/Engine3DRadSpace/Reflection/Event.hpp
  • E:/3DRadSpace/Engine3DRadSpace/Reflection/Event.cpp