Consolix
Toggle main menu visibility
Loading...
Searching...
No Matches
ModuleHubComponent.hpp
Go to the documentation of this file.
1
#pragma once
2
#ifndef _CONSOLIX_MODULE_HUB_COMPONENT_HPP_INCLUDED
3
#define _CONSOLIX_MODULE_HUB_COMPONENT_HPP_INCLUDED
4
8
9
#if CONSOLIX_USE_EVENT_HUB == 1
10
11
#include <cstddef>
12
13
#include <event_hub.hpp>
14
15
namespace
consolix
{
16
23
class
ModuleHubComponent :
24
public
IAppComponent,
25
public
IShutdownable {
26
public
:
28
ModuleHubComponent() =
default
;
29
32
explicit
ModuleHubComponent(event_hub::ModuleHub* module_hub) :
33
m_module_hub(module_hub) {
34
}
35
38
void
set_module_hub(event_hub::ModuleHub* module_hub) {
39
m_module_hub = module_hub;
40
}
41
44
std::size_t last_work_count()
const
{
45
return
m_last_work_count;
46
}
47
48
protected
:
49
bool
initialize()
override
{
50
if
(m_module_hub) {
51
m_module_hub->initialize();
52
}
53
m_is_init =
true
;
54
return
true
;
55
}
56
57
bool
is_initialized()
const override
{
58
return
m_is_init;
59
}
60
61
void
process()
override
{
62
if
(!m_module_hub) {
63
m_last_work_count = 0;
64
return
;
65
}
66
67
m_last_work_count = m_module_hub->process();
68
}
69
70
void
shutdown(
int
/*signal*/
)
override
{
71
if
(m_module_hub) {
72
m_module_hub->request_stop();
73
m_module_hub->shutdown();
74
}
75
}
76
77
private
:
78
event_hub::ModuleHub* m_module_hub{
nullptr
};
79
std::size_t m_last_work_count{0};
80
bool
m_is_init{
false
};
81
};
82
83
}
// namespace consolix
84
85
#endif
// CONSOLIX_USE_EVENT_HUB == 1
86
87
#endif
// _CONSOLIX_MODULE_HUB_COMPONENT_HPP_INCLUDED
consolix
< Utility modules and helpers.
Definition
BaseLoopComponent.hpp:13
include
consolix
components
ModuleHubComponent.hpp
Generated by
1.17.0