Changeset 130:9fde47d5dec3 in finroc_plugins_structure


Ignore:
Timestamp:
25.02.2020 07:23:05 (2 years ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
17.03
Phase:
public
Message:

Adds convenience functions IsComponent and SetParameterConfigEntries to tComponent

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tComponent.cpp

    r123 r130  
    210210} 
    211211 
     212bool tComponent::IsComponent(const core::tFrameworkElement* element) 
     213{ 
     214  return core::tFrameworkElementTags::IsTagged(*element, "group") || core::tFrameworkElementTags::IsTagged(*element, "module"); 
     215} 
     216 
     217void tComponent::SetParameterConfigEntries(const std::string& prefix) 
     218{ 
     219  for (auto parameter_interface = this->ChildrenBegin(); parameter_interface != this->ChildrenEnd(); ++parameter_interface) 
     220  { 
     221    if ((!parameter_interface->IsPort()) && parameter_interface->GetFlag(tFlag::PARAMETER_INTERFACE)) 
     222    { 
     223      auto parameter_interface_path = parameter_interface->GetPath(); 
     224      for (auto parameter = parameter_interface->SubElementsBegin(); parameter != parameter_interface->SubElementsEnd(); ++parameter) 
     225      { 
     226        auto info = parameter->GetAnnotation<parameters::internal::tParameterInfo>(); 
     227        if (info) 
     228        { 
     229          auto parameter_path = parameter->GetPath(); 
     230          rrlib::uri::tPath relative(false, parameter_path.Begin() + parameter_interface_path.Size(), parameter_path.End()); 
     231          std::stringstream stream; 
     232          stream << prefix << relative; 
     233          info->SetConfigEntry(stream.str()); 
     234        } 
     235      } 
     236      return; 
     237    } 
     238  } 
     239} 
     240 
    212241void tComponent::SetComponentVisualizationEnabled(bool enabled) 
    213242{ 
  • tComponent.h

    r129 r130  
    161161 
    162162  /*! 
     163   * \param element Element to check 
     164   * \return Returns whether provided element is a component 
     165   */ 
     166  static bool IsComponent(const core::tFrameworkElement* element); 
     167 
     168  /*! 
    163169   * Components may have a std::vector of ports in their interfaces. 
    164170   * This is a convenience method for adjusting the number of ports in such vectors. 
     
    199205    parameters::tConfigNode::SetConfigNode(*this, node); 
    200206  } 
     207 
     208  /*! 
     209   * Sets config entries for all of the component's parameters to prefix + name 
     210   * (convenience function) 
     211   * 
     212   * \param prefix Prefix to use 
     213   */ 
     214  void SetParameterConfigEntries(const std::string& prefix); 
    201215 
    202216  /*! 
Note: See TracChangeset for help on using the changeset viewer.