20#include "Simo/core/InitializationStatus.h"
21#include "Simo/parameter/ParameterTrie.h"
22#include "Simo/port/Port.h"
23#include "Simo/statistics/StatMapper.h"
34 [[nodiscard]] std::string_view name()
const;
36 void name(std::string_view name);
43 [[nodiscard]]
virtual bool check()
const;
49 return trie.add<T>(name, value);
58 const std::string& name)
const {
59 return trie.find<T>(name);
63 return trie.find(name);
71 [[nodiscard]] std::optional<Parameters> get_subtree(
72 const std::string& name)
const;
75 Parameter::ParameterTrie trie;
93 [[nodiscard]] std::string_view name()
const;
95 [[nodiscard]]
Context& sim_ctx()
const;
102 [[nodiscard]]
Port* get_port(std::string_view);
104 template <
typename Stat>
105 Stat* get_statistic(
const std::string_view name) {
106 return statistics.get<Stat>(name);
109 template <
typename Function>
110 void visit_statistics(Function f) {
116 template <
typename T,
typename... Args>
118 T& s = statistics.emplace<T>(std::forward<Args>(args)...);
123 template <
typename T,
typename... Args>
125 auto ptr = std::make_unique<T>(std::forward<Args>(args)...);
127 ports[std::string(name)] = std::move(ptr);
132 std::unordered_map<std::string, std::unique_ptr<Port>> ports;
Definition InitializationStatus.h:30
void record_statistics(Statistics::StatMapper &mapper)
Record a statistic in a StatMapper to dump statistics.
Definition Module.cc:62
T & create_port(const std::string_view name, Args... args)
Create a new port of type T.
Definition Module.h:124
virtual InitializationStatus initialize(Context &sim_ctx_v, const Parameters ¶meters)
Definition Module.cc:49
T & create_statistic(Args... args)
Create a new statistic of type T.
Definition Module.h:117
A Parameter with a type.
Definition Parameter.h:68
Base class for any Parameter.
Definition Parameter.h:31
Collects parameters that are then passed to a Module instance.
Definition Module.h:30
virtual bool check() const
Definition Module.cc:29
Parameter::ParameterTyped< T > * get(const std::string &name) const
Definition Module.h:57
Parameter::ParameterTyped< T > & set(const std::string &name, const T &value)
Create a new parameter with the given type and return a reference to it.
Definition Module.h:48
Generic port. It offers the virtual method connect.
Definition Port.h:28
Definition StatMapper.h:33
Definition StatMapper.h:68