Changeset 20:55a45f0de4a0 in finroc_plugins_composite_ports


Ignore:
Timestamp:
05.09.2020 16:00:43 (4 weeks ago)
Author:
Max Reichardt <max.reichardt@…>
Branch:
default
Phase:
public
Tags:
tip
Message:

Adds SetConfigEntry function to port composite interfaces

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tInterfaceBase.cpp

    r19 r20  
    240240  const internal::tInterfaceTypeInfo& info = static_cast<const internal::tInterfaceTypeInfo&>(interface_type.SharedTypeInfo()); 
    241241  return parent ? new tInterfaceBase::tBackend(info.GetPartialType(), convience_port_type ? parent->parent_component : parent, parent, primary_relation_id, name, convience_port_type, custom_connect_function, nullptr, parent->PrimaryPortType(), true) : nullptr; 
     242} 
     243 
     244void tInterfaceBase::SetConfigEntry(const rrlib::uri::tPath& config_entry) 
     245{ 
     246  bool interface_count = 0; 
     247  auto primary_backend = this->Backend(); 
     248  if (primary_backend) 
     249  { 
     250    for (auto backend : primary_backend->primary_backend.all_backends) 
     251    { 
     252      auto aggregator = GetAggregator(*backend); 
     253      if (aggregator && (!aggregator->IsPort()) && aggregator->GetFlag(tFlag::INTERFACE) && aggregator->GetFlag(tFlag::PARAMETER_INTERFACE)) 
     254      { 
     255        auto parameter_info = backend->GetAnnotation<parameters::internal::tParameterInfo>(); 
     256        if (!parameter_info) 
     257        { 
     258          parameter_info = &backend->EmplaceAnnotation<parameters::internal::tParameterInfo>(); 
     259        } 
     260        std::stringstream temp;  // Temporary solution until tParameterInfo class accepts paths 
     261        temp << config_entry; 
     262        parameter_info->SetConfigEntry(temp.str(), false); 
     263        interface_count++; 
     264      } 
     265    } 
     266    if (!interface_count) 
     267    { 
     268      FINROC_LOG_PRINT(WARNING, "No parameters backend in interface ", *primary_backend); 
     269    } 
     270  } 
     271  else 
     272  { 
     273    FINROC_LOG_PRINT(WARNING, "Called on empty interface wrapper"); 
     274  } 
    242275} 
    243276 
  • tInterfaceBase.h

    r19 r20  
    187187  } 
    188188 
     189  /*! 
     190   * Sets config entries for any parameters (backend) in this interface 
     191   * 
     192   * \param config_entry Parent node in configuration tree that parameters are configured from 
     193   */ 
     194  void SetConfigEntry(const rrlib::uri::tPath& config_entry); 
     195 
    189196  class tBackend : public core::tAbstractPort 
    190197  { 
Note: See TracChangeset for help on using the changeset viewer.