qb::Main Class Reference

Core main class. More...

#include <qb/main.h>

Classes

class  CoreBuilder
 Helper to build Actors in VirtualCore. More...
 

Public Member Functions

 Main (CoreSet const &core_set)
 
 Main (std::unordered_set< uint8_t > const &core_set)
 
void start (bool async=true) const
 Start the engine. More...
 
void join () const
 Wait until engine terminates. More...
 
template<typename _Actor , typename ... _Args>
ActorId addActor (std::size_t index, _Args &&...args)
 Create new _Actor. More...
 
CoreBuilder core (uint16_t const index)
 Get CoreBuilder from index. More...
 

Static Public Member Functions

static bool hasError ()
 
static void stop ()
 Stop the engine. More...
 

Detailed Description

Core main class.

This is the Main engine class, initialized with desired CoreSet.

Member Function Documentation

◆ start()

void qb::Main::start ( bool  async = true) const

Start the engine.

Parameters
asynchas blocking execution
Note
If async = false the main thread will by used by a VirtualCore engine.

◆ stop()

static void qb::Main::stop ( )
static

Stop the engine.

Note
Same effect as receiving SIGINT Signal.

◆ join()

void qb::Main::join ( ) const

Wait until engine terminates.

Note
You can not avoid calling this function even if main has started with async=false.

◆ addActor()

template<typename _Actor , typename ... _Args>
ActorId qb::Main::addActor ( std::size_t  index,
_Args &&...  args 
)

Create new _Actor.

Template Parameters
_ActorDerivedActor type
Parameters
indexVirtualCore index
argsarguments to forward to the constructor of the _Actor
Returns
ActorId of the created _Actor

create new _Actor on VirtualCore index.
example:

auto id = addActor<MyActor>(0, param1, param2);
Attention
This function is not available when the engine is running.

◆ core()

CoreBuilder qb::Main::core ( uint16_t const  index)

Get CoreBuilder from index.

Parameters
indexVirtualCore index
Returns
CoreBuilder
Attention
auto builder1 = main.core(0);
auto builder2 = main.core(0);
// even both elements build the same VirtualCore
// builder1 != builder2