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_Item& 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_Item>& Setup::configs() {
49void Setup::extract(Entity* entity, ExtractSettings config) {
50 ExtractVisitor collector(*
this, config);
51 collector.visit(entity, config.recursive);
54void Setup::set(
const pb_Module &
setup) {
59void Setup::get(pb_Module &
setup)
const {
60 setup.items_count = m_items.size();
62 std::copy(m_items.begin(), m_items.end(),
setup.items);
66void Setup::extend(
const pb_Item* begin,
const pb_Item* end) {
67 m_items.reserve(m_items.size() + std::distance(begin, end));
68 for (
auto it = begin ; it != end ; ++it) {
69 m_items.push_back(*it);
73UnitResult Setup::apply(Entity *entity,
bool write_hardware)
const {
74 for (
auto& config : m_items) {
76 path.push(config.entity.path);
78 auto resolved_entity = entity->resolve_child_entity(path);
80 if (resolved_entity ==
nullptr)
continue;
81 if (!resolved_entity) {
82 return UnitResult::err(
"Could not resolve entity to apply config to");
86 if (config.which_kind == 0)
89 if (!TRY(resolved_entity->config(config))) {
90 LOG4(
"unhandled config in ", resolved_entity->get_entity_id().c_str(),
" with config id ", config.which_kind);
96 if (!write_hardware)
return UnitResult::ok();
97 return entity->write_to_hardware();
100pb_Item& Setup::add_config(){
101 return m_items.emplace_back();