11pb_OverloadStatus_Element& OverloadVisitor::create(){
12 auto& elem = m_elements.emplace_back();
13 copy_entity(elem.entity);
17void OverloadVisitor::to(pb_OverloadStatus&
status){
18 status.global_overload = mode::is_global_overload_active();
19 status.elements_count = m_elements.size();
20 status.elements =
new pb_OverloadStatus_Element[
status.elements_count];
21 std::copy(m_elements.begin(), m_elements.end(),
status.elements);
24void OverloadVisitor::handle_visit(Entity* entity) {
25 if (entity->is_entity_class(blocks::MMulBlock::CLASS_)) {
26 auto *mblock =
static_cast<blocks::MBlock *
>(entity);
27 mblock->collect_overloads(*
this);
33pb_Config& ExtractVisitor::create(
int config_type)
const{
34 auto& config = m_setup.add_config();
35 config.which_kind = config_type;
36 config.has_entity =
true;
37 copy_entity(config.entity);
45std::vector<pb_Config>& Setup::configs() {
49void Setup::extract(Entity* entity,
bool recursive) {
50 ExtractVisitor collector(*
this);
51 collector.visit(entity, recursive);
54void Setup::set(
const pb_ConfigBundle &
setup) {
59void Setup::get(pb_ConfigBundle &
setup)
const {
60 setup.configs_count = m_configs.size();
61 setup.configs =
new pb_Config[
setup.configs_count];
62 std::copy(m_configs.begin(), m_configs.end(),
setup.configs);
66void Setup::extend(
const pb_Config* begin,
const pb_Config* end) {
67 m_configs.reserve(m_configs.size() + std::distance(begin, end));
68 for (
auto it = begin ; it != end ; ++it) {
69 m_configs.push_back(*it);
73utils::status Setup::apply(Entity* entity,
bool write_hardware)
const{
74 for (
auto& config : m_configs) {
76 path.push(config.entity.path);
78 auto resolved_entity = entity->resolve_child_entity(path);
80 if (!resolved_entity) {
81 return utils::status(4,
"Could not resolve entity to apply config to");
85 if (config.which_kind == 0)
88 auto apply_res = resolved_entity->config(config);
89 if (apply_res.is_err())
90 return utils::status{apply_res.err_value()};
92 if (!apply_res.ok_value()) {
93 LOG4(
"unhandled config in ", resolved_entity->get_entity_id().c_str(),
" with config id ", config.which_kind);
99 if (!write_hardware)
return {};
100 return entity->write_to_hardware();
103pb_Config& Setup::add_config(){
104 return m_configs.emplace_back();