Changeset 137:4cb8c22f878d in finroc_plugins_structure


Ignore:
Timestamp:
17.05.2020 07:55:23 (3 weeks ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
17.03
Phase:
public
Message:

Adapts to change in finroc_plugins_parameters: config entries can now also be set for whole port interfaces and composite ports (parameter info is now also auto-attached)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tComponent.cpp

    r131 r137  
    7676{ 
    7777public: 
     78 
     79  typedef core::tFrameworkElementFlag tFlag; 
     80 
    7881  tInternalRuntimeListener() 
    7982  { 
     
    8992  { 
    9093    // Ensure that all parameters are fully set up 
    91     if (change_type == tEvent::PRE_INIT && element.GetParent() && element.IsPort() && data_ports::IsDataFlowType(static_cast<core::tAbstractPort&>(element).GetDataType()) && (!element.GetParent()->IsPort()) && element.GetParent()->GetFlag(core::tFrameworkElementFlag::PARAMETER_INTERFACE)) 
     94    if (change_type == tEvent::PRE_INIT && element.GetParent()) 
    9295    { 
    93       data_ports::common::tAbstractDataPort& port = static_cast<data_ports::common::tAbstractDataPort&>(element); 
    94  
    95       // Ensure that parameter info annotation is attached 
    96       auto parameter_info = port.GetAnnotation<parameters::internal::tParameterInfo>(); 
    97       if (!parameter_info) 
     96      bool parameter_interface = (!element.IsPort()) && element.GetFlag(tFlag::INTERFACE) && element.GetFlag(tFlag::PARAMETER_INTERFACE); 
     97      data_ports::common::tAbstractDataPort* parameter_data_port = nullptr; 
     98      if ((!parameter_interface) && element.IsPort()) 
    9899      { 
    99         port.EmplaceAnnotation<parameters::internal::tParameterInfo>(); 
     100        core::tAbstractPort& port = static_cast<core::tAbstractPort&>(element); 
     101        auto edge_aggregator = core::tEdgeAggregator::GetAggregator(port); 
     102        if (edge_aggregator && edge_aggregator->GetFlag(tFlag::PARAMETER_INTERFACE)) 
     103        { 
     104          if (element.GetFlag(tFlag::COMPOSITE_PORT)) 
     105          { 
     106            parameter_interface = true; 
     107          } 
     108          else if (data_ports::IsDataFlowType(port.GetDataType())) 
     109          { 
     110            parameter_data_port = &static_cast<data_ports::common::tAbstractDataPort&>(element); 
     111          } 
     112        } 
    100113      } 
    101114 
    102       // Ensure that listener is set up 
    103       tModuleBase* module_base = dynamic_cast<tModuleBase*>(element.GetParent()->GetParent()); 
    104       if (module_base) 
     115      if (parameter_interface || parameter_data_port) 
    105116      { 
    106         data_ports::tGenericPort generic_port = data_ports::tGenericPort::Wrap(port); 
    107         data_ports::tChangeContext change_context(port, rrlib::time::cNO_TIME, data_ports::tChangeStatus::CHANGED_INITIAL); 
    108         module_base->parameters_changed.OnPortChange(change_context); 
    109         generic_port.AddPortListenerSimple(module_base->parameters_changed); 
     117        // Ensure that parameter info annotation is attached 
     118        auto parameter_info = element.GetAnnotation<parameters::internal::tParameterInfo>(); 
     119        if (!parameter_info) 
     120        { 
     121          element.EmplaceAnnotation<parameters::internal::tParameterInfo>(); 
     122        } 
     123 
     124        // Ensure that listener is set up 
     125        tModuleBase* module_base = dynamic_cast<tModuleBase*>(element.GetParent()->GetParent()); 
     126        if (module_base && parameter_data_port) 
     127        { 
     128          data_ports::tGenericPort generic_port = data_ports::tGenericPort::Wrap(*parameter_data_port); 
     129          data_ports::tChangeContext change_context(*parameter_data_port, rrlib::time::cNO_TIME, data_ports::tChangeStatus::CHANGED_INITIAL); 
     130          module_base->parameters_changed.OnPortChange(change_context); 
     131          generic_port.AddPortListenerSimple(module_base->parameters_changed); 
     132        } 
    110133      } 
    111134    } 
Note: See TracChangeset for help on using the changeset viewer.