Changeset 64:dd01256b2f43 in finroc_plugins_parameters


Ignore:
Timestamp:
18.02.2019 08:11:57 (3 years ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
17.03
Children:
65:2cd40bc34978, 66:3700e332142e
Parents:
62:ce83028b0122 (diff), 63:68b843441c71 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Phase:
public
Message:

Merge with 14.08

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • internal/tParameterInfo.cpp

    r59 r64  
    261261    if (has_entry) 
    262262    { 
    263       // Does port contain default value? 
    264       const rrlib::rtti::tGenericObject* default_value = port.GetDefaultValue(); 
    265       bool is_default = false; 
    266       if (default_value) 
    267       { 
    268         std::unique_ptr<rrlib::rtti::tGenericObject> current_value(default_value->GetType().CreateGenericObject()); 
    269         port.Get(*current_value); 
    270         if (current_value->Equals(*default_value)) 
    271         { 
    272           is_default = true; 
    273         } 
    274       } 
    275  
    276       if (!is_default) 
    277       { 
    278263#ifdef _LIB_RRLIB_XML_PRESENT_ 
    279         rrlib::xml::tNode& node = cf->GetEntry(config_entry, true); 
    280         std::unique_ptr<rrlib::rtti::tGenericObject> current_value(port.GetDataType().CreateGenericObject()); 
    281         port.Get(*current_value); 
    282         current_value->Serialize(node); 
     264      rrlib::xml::tNode& node = cf->GetEntry(config_entry, true); 
     265      std::unique_ptr<rrlib::rtti::tGenericObject> current_value(port.GetDataType().CreateGenericObject()); 
     266      port.Get(*current_value); 
     267      current_value->Serialize(node); 
    283268#endif 
    284       } 
    285269    } 
    286270  } 
     
    292276 
    293277#ifdef _LIB_RRLIB_XML_PRESENT_ 
    294 void tParameterInfo::Serialize(rrlib::xml::tNode& node, bool finstruct_context, bool include_command_line) const 
     278void tParameterInfo::Serialize(rrlib::xml::tNode & node, bool finstruct_context, bool include_command_line) const 
    295279{ 
    296280  assert(!(node.HasAttribute("default") || node.HasAttribute("cmdline") || node.HasAttribute("config"))); 
     
    313297#endif 
    314298 
    315 void tParameterInfo::SetConfigEntry(const std::string& config_entry, bool finstruct_set) 
     299void tParameterInfo::SetConfigEntry(const std::string & config_entry, bool finstruct_set) 
    316300{ 
    317301  if (this->config_entry.compare(config_entry) != 0) 
     
    331315 
    332316 
    333 rrlib::serialization::tOutputStream& operator << (rrlib::serialization::tOutputStream& stream, const tParameterInfo& parameter_info) 
     317rrlib::serialization::tOutputStream& operator << (rrlib::serialization::tOutputStream & stream, const tParameterInfo & parameter_info) 
    334318{ 
    335319  stream.WriteBoolean(parameter_info.IsConfigEntrySetFromFinstruct()); 
     
    340324} 
    341325 
    342 rrlib::serialization::tInputStream& operator >> (rrlib::serialization::tInputStream& stream, tParameterInfo& parameter_info) 
     326rrlib::serialization::tInputStream& operator >> (rrlib::serialization::tInputStream & stream, tParameterInfo & parameter_info) 
    343327{ 
    344328  parameter_info.entry_set_from_finstruct = stream.ReadBoolean(); 
  • internal/tParameterInfo.cpp

    r61 r64  
    8585{} 
    8686 
    87 void tParameterInfo::AnnotatedObjectInitialized() 
    88 { 
    89   try 
    90   { 
    91     LoadValue(true); 
    92   } 
    93   catch (const std::exception& e) 
    94   { 
    95     FINROC_LOG_PRINT(ERROR, e); 
    96   } 
    97 } 
    98  
    9987#ifdef _LIB_RRLIB_XML_PRESENT_ 
    10088void tParameterInfo::Deserialize(const rrlib::xml::tNode& node, bool finstruct_context, bool include_commmand_line) 
     
    133121bool tParameterInfo::IsFinstructableGroupResponsibleForConfigFileConnections(const core::tFrameworkElement& finstructable_group, const core::tFrameworkElement& ap) 
    134122{ 
    135   tConfigFile* cf = tConfigFile::Find(ap); 
    136   if (cf == NULL) 
    137   { 
    138     return finstructable_group.GetParentWithFlags(core::tFrameworkElement::tFlag::FINSTRUCTABLE_GROUP) == NULL; 
    139   } 
    140   core::tFrameworkElement* config_element = cf->GetAnnotated<core::tFrameworkElement>(); 
    141   const core::tFrameworkElement* responsible = config_element->GetFlag(core::tFrameworkElement::tFlag::FINSTRUCTABLE_GROUP) ? 
    142       config_element : config_element->GetParentWithFlags(core::tFrameworkElement::tFlag::FINSTRUCTABLE_GROUP); 
    143   if (!responsible) 
    144   { 
    145     // ok, config file is probably attached to runtime. Choose outer-most finstructable group. 
    146     responsible = &finstructable_group; 
    147     const core::tFrameworkElement* tmp; 
    148     while ((tmp = responsible->GetParentWithFlags(core::tFrameworkElement::tFlag::FINSTRUCTABLE_GROUP)) != NULL) 
    149     { 
    150       responsible = tmp; 
    151     } 
    152   } 
     123  core::tFrameworkElement* responsible = ap.GetParentWithFlags(core::tFrameworkElement::tFlag::FINSTRUCTABLE_GROUP | core::tFrameworkElement::tFlag::MANAGES_PARAMETER_CONFIGURATION); 
    153124  return responsible == &finstructable_group; 
    154125} 
     
    170141          { 
    171142            rrlib::serialization::tStringInputStream sis(arg); 
    172             data_ports::tGenericPort port = data_ports::tGenericPort::Wrap(*ann, true); 
     143            data_ports::tGenericPort port = data_ports::tGenericPort::Wrap(*ann); 
    173144            data_ports::tPortDataPointer<rrlib::rtti::tGenericObject> buffer = port.GetUnusedBuffer(); 
    174145            try 
     
    178149              if (error.size() > 0) 
    179150              { 
    180                 FINROC_LOG_PRINT(WARNING, "Failed to load parameter '", ann->GetQualifiedName(), "' from command line argument '", arg, "': ", error); 
     151                FINROC_LOG_PRINT(WARNING, "Failed to load parameter '", ann, "' from command line argument '", arg, "': ", error); 
    181152              } 
    182153              return; 
     
    184155            catch (const std::exception& e) 
    185156            { 
    186               FINROC_LOG_PRINT(ERROR, "Failed to load parameter '", ann->GetQualifiedName(), "' from command line argument '", arg, "': ", e); 
     157              FINROC_LOG_PRINT(ERROR, "Failed to load parameter '", ann, "' from command line argument '", arg, "': ", e); 
    187158            } 
    188159          } 
     
    205176          if (data_ports::IsDataFlowType(ann->GetDataType())) 
    206177          { 
    207             data_ports::tGenericPort port = data_ports::tGenericPort::Wrap(*ann, true); 
     178            data_ports::tGenericPort port = data_ports::tGenericPort::Wrap(*ann); 
    208179            data_ports::tPortDataPointer<rrlib::rtti::tGenericObject> buffer = port.GetUnusedBuffer(); 
    209180 
     
    214185              if (error.size() > 0) 
    215186              { 
    216                 FINROC_LOG_PRINT(WARNING, "Failed to load parameter '", ann->GetQualifiedName(), "' from config entry '", full_config_entry, "': ", error); 
     187                FINROC_LOG_PRINT(WARNING, "Failed to load parameter '", ann, "' from config entry '", full_config_entry, "': ", error); 
    217188              } 
    218189              return; 
     
    220191            catch (const std::exception& e) 
    221192            { 
    222               FINROC_LOG_PRINT(ERROR, "Failed to load parameter '", ann->GetQualifiedName(), "' from config entry '", full_config_entry, "': ", e); 
     193              FINROC_LOG_PRINT(ERROR, "Failed to load parameter '", ann, "' from config entry '", full_config_entry, "': ", e); 
    223194            } 
    224195          } 
     
    237208        { 
    238209          rrlib::serialization::tStringInputStream sis(finstruct_default); 
    239           data_ports::tGenericPort port = data_ports::tGenericPort::Wrap(*ann, true); 
     210          data_ports::tGenericPort port = data_ports::tGenericPort::Wrap(*ann); 
    240211          data_ports::tPortDataPointer<rrlib::rtti::tGenericObject> buffer = port.GetUnusedBuffer(); 
    241212 
     
    246217            if (error.size() > 0) 
    247218            { 
    248               FINROC_LOG_PRINT(WARNING, "Failed to load parameter '", ann->GetQualifiedName(), "' from finstruct default '", finstruct_default, "': ", error); 
     219              FINROC_LOG_PRINT(WARNING, "Failed to load parameter '", ann, "' from finstruct default '", finstruct_default, "': ", error); 
    249220            } 
    250221            return; 
     
    252223          catch (const std::exception& e) 
    253224          { 
    254             FINROC_LOG_PRINT(ERROR, "Failed to load parameter '", ann->GetQualifiedName(), "' from finstruct default '", finstruct_default, "': ", e); 
     225            FINROC_LOG_PRINT(ERROR, "Failed to load parameter '", ann, "' from finstruct default '", finstruct_default, "': ", e); 
    255226          } 
    256227        } 
     
    264235} 
    265236 
     237void tParameterInfo::OnInitialization() 
     238{ 
     239  try 
     240  { 
     241    LoadValue(true); 
     242  } 
     243  catch (const std::exception& e) 
     244  { 
     245    FINROC_LOG_PRINT(ERROR, e); 
     246  } 
     247} 
     248 
    266249void tParameterInfo::SaveValue() 
    267250{ 
     
    275258  if (data_ports::IsDataFlowType(ann->GetDataType())) 
    276259  { 
    277     data_ports::tGenericPort port = data_ports::tGenericPort::Wrap(*ann, true); 
     260    data_ports::tGenericPort port = data_ports::tGenericPort::Wrap(*ann); 
    278261    if (has_entry) 
    279262    { 
    280263#ifdef _LIB_RRLIB_XML_PRESENT_ 
    281264      rrlib::xml::tNode& node = cf->GetEntry(config_entry, true); 
    282       std::unique_ptr<rrlib::rtti::tGenericObject> current_value(port.GetDataType().CreateInstanceGeneric()); 
     265      std::unique_ptr<rrlib::rtti::tGenericObject> current_value(port.GetDataType().CreateGenericObject()); 
    283266      port.Get(*current_value); 
    284267      current_value->Serialize(node); 
     
    293276 
    294277#ifdef _LIB_RRLIB_XML_PRESENT_ 
    295 void tParameterInfo::Serialize(rrlib::xml::tNode& node, bool finstruct_context, bool include_command_line) const 
     278void tParameterInfo::Serialize(rrlib::xml::tNode & node, bool finstruct_context, bool include_command_line) const 
    296279{ 
    297280  assert(!(node.HasAttribute("default") || node.HasAttribute("cmdline") || node.HasAttribute("config"))); 
     
    314297#endif 
    315298 
    316 void tParameterInfo::SetConfigEntry(const std::string& config_entry, bool finstruct_set) 
     299void tParameterInfo::SetConfigEntry(const std::string & config_entry, bool finstruct_set) 
    317300{ 
    318301  if (this->config_entry.compare(config_entry) != 0) 
     
    332315 
    333316 
    334 rrlib::serialization::tOutputStream& operator << (rrlib::serialization::tOutputStream& stream, const tParameterInfo& parameter_info) 
     317rrlib::serialization::tOutputStream& operator << (rrlib::serialization::tOutputStream & stream, const tParameterInfo & parameter_info) 
    335318{ 
    336319  stream.WriteBoolean(parameter_info.IsConfigEntrySetFromFinstruct()); 
     
    341324} 
    342325 
    343 rrlib::serialization::tInputStream& operator >> (rrlib::serialization::tInputStream& stream, tParameterInfo& parameter_info) 
     326rrlib::serialization::tInputStream& operator >> (rrlib::serialization::tInputStream & stream, tParameterInfo & parameter_info) 
    344327{ 
    345328  parameter_info.entry_set_from_finstruct = stream.ReadBoolean(); 
     
    362345    catch (std::exception& e) 
    363346    { 
    364       FINROC_LOG_PRINT(ERROR, e); 
     347      FINROC_LOG_PRINT_STATIC(ERROR, e); 
    365348    } 
    366349  } 
  • tConfigFile.cpp

    r57 r64  
    211211    std::string name = result[0]->GetStringAttribute("name"); 
    212212    tXMLNode& parent = result[0]->Parent(); 
     213    tXMLNode& new_node = result[0]->AddNextSibling(cXML_LEAF_NAME); 
     214    new_node.SetAttribute("name", name); 
    213215    parent.RemoveChildNode(*result[0]); 
    214     tXMLNode& new_node = parent.AddChildNode(cXML_LEAF_NAME); 
    215     new_node.SetAttribute("name", name); 
    216216    return new_node; 
    217217  } 
     
    337337} 
    338338 
     339void tConfigFile::Reload() 
     340{ 
     341  if (core::FinrocFileExists(filename)) 
     342  { 
     343    try 
     344    { 
     345      wrapped = core::GetFinrocXMLDocument(filename, false); // false = do not validate with dtd 
     346      return; 
     347    } 
     348    catch (const std::exception& e) 
     349    { 
     350      FINROC_LOG_PRINT(ERROR, e); 
     351    } 
     352  } 
     353} 
     354 
    339355void tConfigFile::SaveFile(const std::string& new_filename) 
    340356{ 
  • tConfigFile.cpp

    r63 r64  
    419419  catch (const std::exception& e) 
    420420  { 
    421     FINROC_LOG_PRINT(ERROR, e); // Should never occur 
     421    FINROC_LOG_PRINT_STATIC(ERROR, e); // Should never occur 
    422422  } 
    423423#endif 
     
    443443      catch (const std::exception& e) 
    444444      { 
    445         FINROC_LOG_PRINT(ERROR, e); 
     445        FINROC_LOG_PRINT_STATIC(ERROR, e); 
    446446        config_file.wrapped = rrlib::xml::tDocument(); 
    447447        try 
     
    451451        catch (const std::exception& e1) 
    452452        { 
    453           FINROC_LOG_PRINT(ERROR, e1); 
     453          FINROC_LOG_PRINT_STATIC(ERROR, e1); 
    454454        } 
    455455      } 
     
    470470    catch (const std::exception& e) 
    471471    { 
    472       FINROC_LOG_PRINT(ERROR, e); 
     472      FINROC_LOG_PRINT_STATIC(ERROR, e); 
    473473    } 
    474474  } 
  • tConfigFile.h

    r57 r64  
    177177 
    178178  /*! 
     179   * Reloads config file 
     180   */ 
     181  void Reload(); 
     182 
     183  /*! 
    179184   * Saves configuration file back to HDD 
    180185   * 
  • tConfigFile.h

    r63 r64  
    115115   */ 
    116116  rrlib::xml::tNode& GetEntry(const std::string& entry, bool create = false); 
     117 
     118 
     119  /*! 
     120   * Search entry in configuration file via an XML path 
     121   * 
     122   * \param path_to_entry XML path to locate the entry in this config file 
     123   * \return XMLNode representing entry 
     124   * 
     125   * \throw Throws std::runtime_error if entry cannot be found 
     126   */ 
     127  const rrlib::xml::tNode& FindEntry(const std::string& path_to_entry) const 
     128  { 
     129    return wrapped.FindNode(path_to_entry); 
     130  } 
    117131#endif 
    118132 
Note: See TracChangeset for help on using the changeset viewer.