Kouta
A small application framework based on Boost
kouta::base::Root Class Reference

Root component. More...

#include <root.hpp>

Inheritance diagram for kouta::base::Root:
Collaboration diagram for kouta::base::Root:

Public Member Functions

 Root ()
 Default constructor. More...
 
 Root (Component *parent)
 Construct from a parent. More...
 
 Root (const Root &)=delete
 
Rootoperator= (const Root &)=delete
 
 Root (Root &&)=delete
 
Rootoperator= (Root &&)=delete
 
virtual ~Root ()=default
 
boost::asio::io_context & context () override
 Obtain a reference to the underlying I/O context. More...
 
virtual void run ()
 Run the event loop. More...
 
virtual void stop ()
 Stop the event loop and exit. More...
 
- Public Member Functions inherited from kouta::base::Component
 Component ()=delete
 
 Component (Component *parent)
 Constructor. More...
 
 Component (const Component &)=delete
 
Componentoperator= (const Component &)=delete
 
 Component (Component &&)=delete
 
Componentoperator= (Component &&)=delete
 
virtual ~Component ()
 Component destructor. More...
 
void add_child (Component *component)
 Add a child component to the list. More...
 
void remove_child (Component *component)
 Remove a child component from the list. More...
 
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. More...
 
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. More...
 
template<class TFunctor >
void post (TFunctor &&functor)
 Post a functor call to the event loop for deferred execution. More...
 

Private Attributes

boost::asio::io_context m_context
 

Detailed Description

Root component.

As opposed to a regular Component, the Root does own the event loop and is in charge of running it and acting as the entry-point to the rest of the application.

Constructor & Destructor Documentation

◆ Root() [1/4]

kouta::base::Root::Root ( )
inline

Default constructor.

This constructor assumes that the Root object will not have a parent (e.g. it is the main object of the tree), meaning that it will not attempt to register itself with the parent, nor remove itself from its list when being destroyed.

◆ Root() [2/4]

kouta::base::Root::Root ( Component parent)
inlineexplicit

Construct from a parent.

This constructor will register the Root object with the parent only to manage the memory deallocation in case the object was allocated on the heap. Regardless of having a parent, the Root owns its event loop.

◆ Root() [3/4]

kouta::base::Root::Root ( const Root )
delete

◆ Root() [4/4]

kouta::base::Root::Root ( Root &&  )
delete

◆ ~Root()

virtual kouta::base::Root::~Root ( )
virtualdefault

Member Function Documentation

◆ context()

boost::asio::io_context& kouta::base::Root::context ( )
inlineoverridevirtual

Obtain a reference to the underlying I/O context.

Note
The I/O context is owned by the root.

Reimplemented from kouta::base::Component.

◆ operator=() [1/2]

Root& kouta::base::Root::operator= ( const Root )
delete

◆ operator=() [2/2]

Root& kouta::base::Root::operator= ( Root &&  )
delete

◆ run()

virtual void kouta::base::Root::run ( )
inlinevirtual

Run the event loop.

Note
This method blocks until the event loop is terminated.

Reimplemented in kouta::base::Branch< TWrapped >.

◆ stop()

virtual void kouta::base::Root::stop ( )
inlinevirtual

Stop the event loop and exit.

Note
Under normal circumstances, this would only be called when terminating the application.

Member Data Documentation

◆ m_context

boost::asio::io_context kouta::base::Root::m_context
private

The documentation for this class was generated from the following file: