Simo 0.0.1
Loading...
Searching...
No Matches
Simo::Module Class Reference

#include <Module.h>

Inheritance diagram for Simo::Module:
NestedModule PingPongBaseModule RootModule Simo::Examples::FirstModule Simo::Modules::Core::Collector Simo::Tests::FailingInitModule Simo::Tests::InitTrackingModule Simo::Tests::TestModule TestModule

Public Member Functions

virtual InitializationStatus initialize (Context &sim_ctx_v, const Parameters &parameters)
std::string_view name () const
constexpr std::string name_of_child (const std::string_view child) const
Contextsim_ctx () const
void record_statistics (Statistics::StatMapper &mapper)
 Record a statistic in a StatMapper to dump statistics.
Portget_port (std::string_view)
Time current_time () const
template<typename Stat>
Stat * get_statistic (const std::string_view name)
template<typename Function>
void visit_statistics (Function f)
virtual InitializationStatus log_setup (const std::filesystem::path &out_file)
InitializationStatus log_setup ()
 Default log_setup with default path set to Simo.log.
void log_enable (bool new_value)
 Enable/disable logging for the component.
void log_level (size_t level)
void log_level (std::string_view level_name)
template<typename Callable>
void log (size_t level, Callable &&callable)
template<typename Callable>
void log_raw_callable (size_t level, bool print_level, Callable &&callable)
 Log a message with the given level without adding timestamp.
void populate_default_log_levels ()
Log::Loggerget_logger ()
template<typename T, typename... Args>
T & create_statistic (Args... args)
 Create a new statistic of type T.
template<typename T, typename... Args>
T & create_port (const std::string_view name, Args... args)
 Create a new port of type T.
template<typename T, typename... Args>
T & create_child (Args... args)

Protected Attributes

Statistics::StatStorage statistics
std::unordered_map< std::string, std::unique_ptr< Port > > ports
std::vector< std::unique_ptr< Module > > children
Log::Logger logger

Detailed Description

A simulation unit that can schedule events in the context

Every class that inherits from module shall have a default constructor (possibly trivial) and initialize everything in the initialize method.

Member Function Documentation

◆ create_child()

template<typename T, typename... Args>
T & Simo::Module::create_child ( Args... args)
inline

Create a child module of type T. The child is owned by this module instance

◆ initialize()

InitializationStatus Simo::Module::initialize ( Context & sim_ctx_v,
const Parameters & parameters )
nodiscardvirtual

Associate a context to this instance and look at the parameters to initialize the structure. The default implementation is to return true. Derived classes can call <base_class>::initialize to initialize the attributes of the base class

Reimplemented in NestedModule, PingPongBaseModule, RootModule, Simo::Examples::FirstModule, Simo::Modules::Core::Collector, Simo::Tests::FailingInitModule, Simo::Tests::InitTrackingModule, Simo::Tests::TestModule, and TestModule.

◆ log()

template<typename Callable>
void Simo::Module::log ( size_t level,
Callable && callable )
inline

Log a message with the given level. The message is generated by the callable. New-line is added

The callable is evaluated only when the log is enabled and the log level is satisfied

◆ log_setup()

InitializationStatus Simo::Module::log_setup ( const std::filesystem::path & out_file)
virtual

Setup logging for the component

Enable log by default when the operation succeeds. Calling this function will re-initialize the log even if the same out_file is passed


The documentation for this class was generated from the following files:
  • include/Simo/module/Module.h
  • src/module/Module.cc