|
| | Component ()=delete |
| |
| | Component (Component *parent) |
| | Constructor.
|
| |
| | Component (const Component &)=delete |
| |
| Component & | operator= (const Component &)=delete |
| |
| | Component (Component &&)=delete |
| |
| Component & | operator= (Component &&)=delete |
| |
| virtual | ~Component () |
| | Component destructor.
|
| |
| virtual asio::io_context & | context () |
| | Obtain a reference to the underlying I/O context.
|
| |
| void | add_child (Component *component) |
| | Add a child component to the list.
|
| |
| void | remove_child (Component *component) |
| | Remove a child component from the list.
|
| |
| template<class TClass , class... TMethodArgs, class... TArgs> |
| void | post (void(TClass::*method)(TMethodArgs...), TArgs... args) |
| | Post a method call to the event loop for deferred execution.
|
| |
| template<class... TFuncArgs, class... TArgs> |
| void | post (const std::function< void(TFuncArgs...)> &functor, TArgs... args) |
| | Post a function call to the event loop for deferred execution.
|
| |
| template<class TFunctor > |
| void | post (TFunctor &&functor) |
| | Post a functor call to the event loop for deferred execution.
|
| |
Base class for asynchronous components.
A component provies access to the underlying event loop which, by default, belongs to the parent component. Moreover, specifying a parent will add the component to its children list and make sure that the component is deleted when the parent is destroyed (if the component was allocated on the heap).
| virtual kouta::base::Component::~Component |
( |
| ) |
|
|
inlinevirtual |
Component destructor.
The component will go through its list of children and delete them one at a time. This is only useful if the components were allocated in the heap, as stack-allocated ones will probably have been deleted automatically prior to calling this destructor.
In addition, once a component has deleted its children, it will remove itself from its parent.
- Note
- Child deletion happens in reverse order.
template<class... TFuncArgs, class... TArgs>
| void kouta::base::Component::post |
( |
const std::function< void(TFuncArgs...)> & |
functor, |
|
|
TArgs... |
args |
|
) |
| |
|
inline |
Post a function call to the event loop for deferred execution.
This allows other components, even those residing in another thread/event loop, to post a function to this specific component.
- Warning
- Arguments are copied before being passed to the event loop.
- Template Parameters
-
| TFuncArgs | Types of the arguments that the function accepts. |
| TArgs | Types of the arguments provided to the invocation. |
- Parameters
-
| [in] | functor | Functor to invoke. Its signature must match void(TArgs...) |
| [in] | args | Arguments to invoke the functor with. |
template<class TFunctor >
| void kouta::base::Component::post |
( |
TFunctor && |
functor | ) |
|
|
inline |
Post a functor call to the event loop for deferred execution.
This allows other components, even those residing in another thread/event loop, to post a functor to this specific component, for example a lambda.
- Template Parameters
-
- Parameters
-
| [in] | functor | Functor to invoke.s |
template<class TClass , class... TMethodArgs, class... TArgs>
| void kouta::base::Component::post |
( |
void(TClass::*)(TMethodArgs...) |
method, |
|
|
TArgs... |
args |
|
) |
| |
|
inline |
Post a method call to the event loop for deferred execution.
This allows other components, even those residing in another thread/event loop, to post a call to this specific component.
- Warning
- Arguments are copied before being passed to the event loop.
- Template Parameters
-
| TClass | Child class whose method is going to be invoked. |
| TMethodArgs | Types of the arguments that the method accepts. |
| TArgs | Types of the arguments provided to the invocation. |
- Parameters
-
| [in] | method | Method to invoke. Its signature must match void(TArgs...) |
| [in] | args | Arguments to invoke the method with. |