Horizon Official Technical Documentation
Kernel Class Referenceabstract

#include <Server.hpp>

+ Inheritance diagram for Kernel:
+ Collaboration diagram for Kernel:

Public Member Functions

 Kernel (general_server_configuration &config)
 
 ~Kernel ()
 
virtual void initialize ()=0
 
virtual void finalize ()=0
 
virtual void post_initialize ()=0
 
virtual void post_finalize ()=0
 
struct general_server_configurationgeneral_conf ()
 
template<typename T >
std::shared_ptr< T > get_component (std::string uuid)
 
template<typename T >
std::shared_ptr< T > get_component_of_type (Horizon::System::runtime_module_type type, int segment_number=1)
 
template<typename T >
void register_component (Horizon::System::runtime_module_type type, T &&component)
 
template<typename T >
void register_component (Horizon::System::runtime_module_type type, std::shared_ptr< T > component)
 
void deregister_component (Horizon::System::runtime_module_type type, int segment_number=1)
 
int get_registered_component_count_of_type (Horizon::System::runtime_module_type type)
 
template<typename ComponentType , std::size_t Priority, typename Key , typename Value >
int get_segment_number_for_resource (Horizon::System::runtime_module_type module_t, Key resource_key, Value resource_not_found_value)
 
int get_component_count ()
 
KernelComponentsget_components ()
 
void system_routine_queue_push (std::shared_ptr< Horizon::System::RuntimeContext > context)
 
void system_routine_queue_push (std::shared_ptr< Horizon::System::RuntimeContextChain > context)
 
void system_routine_process_queue ()
 
void system_routine_register (Horizon::System::runtime_module_type module_t, Horizon::System::runtime_synchronization_method sync_t, std::shared_ptr< Horizon::System::RuntimeContext > context)
 
Horizon::System::SystemRoutineManagerget_system_routine_manager ()
 
boost::asio::io_context & get_io_context ()
 
void set_signal_interrupt_command_line_loop (bool signal)
 
bool get_signal_interrupt_command_line_loop ()
 

Protected Attributes

boost::asio::io_context _io_context_global
 
KernelComponents _components
 
general_server_configuration _config
 

Private Attributes

Horizon::System::SystemRoutineManager _hsr_manager
 
std::atomic< bool > _signal_interrupt_command_line_loop {false}
 

Constructor & Destructor Documentation

◆ Kernel()

Kernel::Kernel ( general_server_configuration config)
Horizon::System::SystemRoutineManager _hsr_manager
Definition: Server.hpp:548
general_server_configuration _config
Definition: Server.hpp:546
@ RUNTIME_MAIN
Definition: System.hpp:82

◆ ~Kernel()

Kernel::~Kernel ( )
55{
56 for (auto it = _components.begin(); it != _components.end();) {
57 it->second.ptr.reset();
58 it = _components.erase(it);
59 }
60}
KernelComponents _components
Definition: Server.hpp:545

References _components.

Member Function Documentation

◆ deregister_component()

void Kernel::deregister_component ( Horizon::System::runtime_module_type  type,
int  segment_number = 1 
)
inline
494 {
495 for (auto c : _components) {
496 if (c.second.type == type && c.second.segment_number == segment_number) {
497 _components.erase(c.first);
498 break;
499 }
500 }
501 }

References _components.

Referenced by Server::finalize(), and Horizon::Zone::ZoneServer::finalize().

+ Here is the caller graph for this function:

◆ finalize()

virtual void Kernel::finalize ( )
pure virtual

◆ general_conf()

struct general_server_configuration & Kernel::general_conf ( )
inline
450{ return this->_config; }

References _config.

◆ get_component()

template<typename T >
std::shared_ptr< T > Kernel::get_component ( std::string  uuid)
inline
454 {
455 auto it = _components.find(uuid);
456 if (it == _components.end())
457 return nullptr;
458
459 return std::static_pointer_cast<T>(it->second.ptr);
460 }

References _components.

◆ get_component_count()

int Kernel::get_component_count ( )
inline
526{ return _components.size(); }

References _components.

◆ get_component_of_type()

template<typename T >
std::shared_ptr< T > Kernel::get_component_of_type ( Horizon::System::runtime_module_type  type,
int  segment_number = 1 
)
inline
464 {
465 for (auto c : _components) {
466 if (c.second.type == type && c.second.segment_number == segment_number) {
467 return std::static_pointer_cast<T>(c.second.ptr);
468 }
469 }
470
471 return nullptr;
472 }

References _components.

◆ get_components()

KernelComponents & Kernel::get_components ( )
inline
528{ return _components; }

References _components.

Referenced by CommandLineProcess::clicmd_kernel_info().

+ Here is the caller graph for this function:

◆ get_io_context()

◆ get_registered_component_count_of_type()

int Kernel::get_registered_component_count_of_type ( Horizon::System::runtime_module_type  type)
inline
504 {
505 int count = 0;
506 for (auto c : _components) {
507 if (c.second.type == type)
508 count++;
509 }
510 return count;
511 }
size_t count(GridTypeListContainer< SPECIFIC_TYPE > const &elements, SPECIFIC_TYPE *)
Definition: GridReferenceContainer.hpp:100

References _components, and GridTypeListIterator::count().

Referenced by get_segment_number_for_resource(), and register_component().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_segment_number_for_resource()

template<typename ComponentType , std::size_t Priority, typename Key , typename Value >
int Kernel::get_segment_number_for_resource ( Horizon::System::runtime_module_type  module_t,
Key  resource_key,
Value  resource_not_found_value 
)
inline
515 {
516
517 for (int i = 0; i < get_registered_component_count_of_type(module_t); i++) {
518 auto component = get_component_of_type<ComponentType>(module_t, i + 1);
519 if (component->get_resource_manager().template get_resource<Priority, Key, Value>(resource_key, resource_not_found_value) != resource_not_found_value)
520 return i + 1;
521 }
522
523 return 0;
524 }
int get_registered_component_count_of_type(Horizon::System::runtime_module_type type)
Definition: Server.hpp:503

References get_registered_component_count_of_type().

+ Here is the call graph for this function:

◆ get_signal_interrupt_command_line_loop()

bool Kernel::get_signal_interrupt_command_line_loop ( )
inline
std::atomic< bool > _signal_interrupt_command_line_loop
Definition: Server.hpp:550

References _signal_interrupt_command_line_loop.

◆ get_system_routine_manager()

Horizon::System::SystemRoutineManager & Kernel::get_system_routine_manager ( )
inline
535{ return _hsr_manager; }

References _hsr_manager.

◆ initialize()

virtual void Kernel::initialize ( )
pure virtual

◆ post_finalize()

void Kernel::post_finalize ( )
pure virtual

Implemented in Server.

89{
90
91}

Referenced by Server::post_finalize().

+ Here is the caller graph for this function:

◆ post_initialize()

void Kernel::post_initialize ( )
pure virtual

Implemented in Server.

84{
85
86}

Referenced by Server::post_initialize().

+ Here is the caller graph for this function:

◆ register_component() [1/2]

template<typename T >
void Kernel::register_component ( Horizon::System::runtime_module_type  type,
std::shared_ptr< T >  component 
)
inline
485 {
488 holder.type = type;
489 holder.ptr = std::static_pointer_cast<KernelComponent>(component);
490 _components.insert(std::pair(component->get_uuid_string(), holder));
491 }
Definition: Server.hpp:430
int segment_number
Definition: Server.hpp:434
Horizon::System::runtime_module_type type
Definition: Server.hpp:432
std::shared_ptr< KernelComponent > ptr
Definition: Server.hpp:433

References _components, get_registered_component_count_of_type(), kernel_component_state_holder::ptr, kernel_component_state_holder::segment_number, and kernel_component_state_holder::type.

+ Here is the call graph for this function:

◆ register_component() [2/2]

template<typename T >
void Kernel::register_component ( Horizon::System::runtime_module_type  type,
T &&  component 
)
inline
475 {
478 holder.type = type;
479 holder.ptr = std::make_shared<T>(std::move(component));
480 _components.insert(std::pair(component.get_uuid_string(), holder));
481 }

References _components, get_registered_component_count_of_type(), kernel_component_state_holder::ptr, kernel_component_state_holder::segment_number, and kernel_component_state_holder::type.

Referenced by Server::initialize(), Horizon::Zone::ZoneServer::initialize(), and Server::parse_common_configs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_signal_interrupt_command_line_loop()

void Kernel::set_signal_interrupt_command_line_loop ( bool  signal)
inline
540{ _signal_interrupt_command_line_loop.exchange(signal); }

References _signal_interrupt_command_line_loop.

Referenced by CommandLineProcess::clicmd_kernel_info().

+ Here is the caller graph for this function:

◆ system_routine_process_queue()

void Kernel::system_routine_process_queue ( )
void process_queue()
Definition: System.hpp:676

References _hsr_manager, and Horizon::System::SystemRoutineManager::process_queue().

+ Here is the call graph for this function:

◆ system_routine_queue_push() [1/2]

void Kernel::system_routine_queue_push ( std::shared_ptr< Horizon::System::RuntimeContext context)
62{ _hsr_manager.push(context); }
void push(std::shared_ptr< RuntimeContextChain > chain)
Definition: System.hpp:644

References _hsr_manager, and Horizon::System::SystemRoutineManager::push().

+ Here is the call graph for this function:

◆ system_routine_queue_push() [2/2]

void Kernel::system_routine_queue_push ( std::shared_ptr< Horizon::System::RuntimeContextChain context)
63{ _hsr_manager.push(context); }

References _hsr_manager, and Horizon::System::SystemRoutineManager::push().

+ Here is the call graph for this function:

◆ system_routine_register()

void Kernel::system_routine_register ( Horizon::System::runtime_module_type  module_t,
Horizon::System::runtime_synchronization_method  sync_t,
std::shared_ptr< Horizon::System::RuntimeContext context 
)
66{
67 _hsr_manager.register_(module_t, sync_t, context);
68}
virtual void register_(runtime_module_type module_t, runtime_synchronization_method sync_t, std::shared_ptr< RuntimeContext > context)
Definition: System.hpp:619

References _hsr_manager, and Horizon::System::SystemRoutineManager::register_().

+ Here is the call graph for this function:

Member Data Documentation

◆ _components

◆ _config

general_server_configuration Kernel::_config
protected

Referenced by general_conf().

◆ _hsr_manager

◆ _io_context_global

boost::asio::io_context Kernel::_io_context_global
protected

Referenced by get_io_context().

◆ _signal_interrupt_command_line_loop

std::atomic<bool> Kernel::_signal_interrupt_command_line_loop {false}
private

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