Changeset 21:f564c2b6f60b in finroc_plugins_network_transport


Ignore:
Timestamp:
14.05.2017 13:25:11 (20 months ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
17.03
Phase:
public
Message:

Adds options to tFrameworkElementInfo to also serialize owned connectors (required in TCP plugin)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • runtime_info/tFrameworkElementInfo.h

    r18 r21  
    4949//---------------------------------------------------------------------- 
    5050#include "plugins/network_transport/runtime_info/definitions.h" 
     51#include "plugins/network_transport/runtime_info/tConnectorInfo.h" 
    5152#include "plugins/network_transport/runtime_info/tRemoteType.h" 
     53#include "plugins/network_transport/runtime_info/tUriConnectorInfo.h" 
    5254 
    5355//---------------------------------------------------------------------- 
     
    232234   * \param stream Binary stream to serialize to 
    233235   * \param framework_element Framework element to serialize info of 
     236   * \param serialize_owned_connectors Whether to serialize connectors owned by framework element 
    234237   * 
    235238   * TODO: avoid frequent reallocation of (typically one) tPath 
    236239   */ 
    237240  template < bool ENABLE = !Tremote > 
    238   static void Serialize(typename std::enable_if<ENABLE, rrlib::serialization::tOutputStream>::type& stream, const core::tFrameworkElement& framework_element) 
     241  static void Serialize(typename std::enable_if<ENABLE, rrlib::serialization::tOutputStream>::type& stream, const core::tFrameworkElement& framework_element, bool serialize_owned_connectors = false) 
    239242  { 
    240243    rrlib::uri::tURI uri; 
     
    269272      stream << tDynamicInfo(framework_element); 
    270273    } 
     274 
     275    enum tNextConnector { NONE, PLAIN, URI }; 
     276 
     277    if (serialize_owned_connectors && framework_element.IsPort()) 
     278    { 
     279      const core::tAbstractPort& port = static_cast<const core::tAbstractPort&>(framework_element); 
     280      for (auto it = port.OutgoingConnectionsBegin(); it != port.OutgoingConnectionsEnd(); ++it) 
     281      { 
     282        runtime_info::tConnectorInfo info(*it); 
     283        stream.WriteByte(static_cast<uint8_t>(PLAIN)); 
     284        stream << it->Destination().GetHandle() << info.static_info; 
     285      } 
     286      for (auto & connector : port.UriConnectors()) 
     287      { 
     288        if (connector) 
     289        { 
     290          tUriConnectorInfo info(*connector); 
     291          stream.WriteByte(static_cast<uint8_t>(URI)); 
     292          stream << info.id.index << info.static_info << info.dynamic_info; 
     293        } 
     294      } 
     295      stream.WriteByte(static_cast<uint8_t>(NONE)); 
     296    } 
    271297  } 
    272298 
Note: See TracChangeset for help on using the changeset viewer.