Changeset 23:fd4a129a8417 in finroc_plugins_network_transport


Ignore:
Timestamp:
26.05.2017 20:03:58 (22 months ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
17.03
Phase:
public
Message:

Adds support for different data encodings in connectors established via generic protocol's CONNECT_PORTS opcode

Location:
generic_protocol
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • generic_protocol/tNetworkPortInfo.cpp

    r19 r23  
    7979  deleted(false), 
    8080  last_update(rrlib::time::cNO_TIME), 
    81   desired_encoding(message_flags::tDataEncoding::cBINARY_ENCODING), 
     81  desired_encoding(rrlib::serialization::tDataEncoding::BINARY), 
    8282  served_port_handle(served_port_handle) 
    8383{ 
  • generic_protocol/tNetworkPortInfo.h

    r19 r23  
    178178   * \param encoding Desired data encoding 
    179179   */ 
    180   inline void SerializeBuffer(rrlib::serialization::tOutputStream& stream, data_ports::tPortDataPointer<const rrlib::rtti::tGenericObject>& buffer, message_flags::tDataEncoding encoding) 
    181   { 
    182     buffer->Serialize(stream, static_cast<rrlib::serialization::tDataEncoding>(encoding)); 
     180  inline void SerializeBuffer(rrlib::serialization::tOutputStream& stream, data_ports::tPortDataPointer<const rrlib::rtti::tGenericObject>& buffer, rrlib::serialization::tDataEncoding encoding) 
     181  { 
     182    buffer->Serialize(stream, encoding); 
     183  } 
     184 
     185  /*! 
     186   * Sets desired network encoding of network partner 
     187   */ 
     188  void SetDesiredEncoding(rrlib::serialization::tDataEncoding desired_encoding) 
     189  { 
     190    this->desired_encoding = desired_encoding; 
    183191  } 
    184192 
    185193  /*! 
    186194   * Sets subscription data of server ports to specified values 
     195   * 
     196   * \param data Dynamic connection data 
    187197   */ 
    188198  void SetServerSideDynamicConnectionData(const tDynamicConnectionData& data); 
     
    200210      bool express_data = current_dynamic_connection_data.high_priority; 
    201211      bool legacy = stream.GetTargetInfo().revision == 0; 
    202       uint8_t message_flags = desired_encoding | ((!legacy) && client_info ? message_flags::cTO_SERVER : 0); 
     212      uint8_t message_flags = static_cast<uint8_t>(desired_encoding) | ((!legacy) && client_info ? message_flags::cTO_SERVER : 0); 
    203213      int handle = stream.GetTargetInfo().revision == 0 ? remote_port_handle : connection_handle; 
    204214      if (express_data && values_to_send.Size() == 0) 
     
    275285 
    276286  /*! Desired encoding of network partner */ 
    277   message_flags::tDataEncoding desired_encoding; 
     287  rrlib::serialization::tDataEncoding desired_encoding; 
    278288 
    279289  /*! In case this is a server port: Local handle of served port - otherwise 0 */ 
  • generic_protocol/tRemoteRuntime.cpp

    r19 r23  
    664664          data_ports::tGenericPort created_port(rrlib::uri::tURI(port->GetPath()).ToString(), &GetServerPortsElement(), &GetServerPortsElement(), port_to_connect_to->GetDataType(), flags); 
    665665          tNetworkPortInfo* network_port_info = new tNetworkPortInfo(*this, message.Get<0>(), message.Get<0>(), dynamic_connection_data.strategy, *created_port.GetWrapped(), port->GetHandle()); 
     666          network_port_info->SetDesiredEncoding(static_subscription_parameters.server_side_conversion.encoding); 
    666667          network_port_info->SetServerSideDynamicConnectionData(dynamic_connection_data); 
    667668          created_port.AddPortListenerForPointer(*network_port_info); 
  • generic_protocol/tServerSideConversionInfo.h

    r19 r23  
    7272  std::string operation_1, operation_2, operation_1_parameter, operation_2_parameter, intermediate_type, destination_type; 
    7373 
     74  /*! Data encoding to use */ 
     75  rrlib::serialization::tDataEncoding encoding = rrlib::serialization::tDataEncoding::BINARY; 
     76 
    7477  bool NoConversion() const 
    7578  { 
     
    8285{ 
    8386  return lhs.operation_1 == rhs.operation_1 && lhs.operation_2 == rhs.operation_2 && lhs.operation_1_parameter == rhs.operation_1_parameter && 
    84          lhs.operation_2_parameter == rhs.operation_2_parameter && lhs.intermediate_type == rhs.intermediate_type && lhs.destination_type == rhs.destination_type; 
     87         lhs.operation_2_parameter == rhs.operation_2_parameter && lhs.intermediate_type == rhs.intermediate_type && lhs.destination_type == rhs.destination_type && 
     88         lhs.encoding == rhs.encoding; 
    8589} 
    8690 
     
    9296inline rrlib::serialization::tOutputStream& operator << (rrlib::serialization::tOutputStream& stream, const tServerSideConversionInfo& info) 
    9397{ 
    94   stream << info.operation_1 << info.operation_1_parameter << info.operation_2 << info.operation_2_parameter << info.intermediate_type << info.destination_type; 
     98  stream << info.destination_type << info.operation_1 << info.operation_1_parameter << info.operation_2 << info.operation_2_parameter << info.intermediate_type << info.encoding; 
    9599  return stream; 
    96100} 
     
    98102inline rrlib::serialization::tInputStream& operator >> (rrlib::serialization::tInputStream& stream, tServerSideConversionInfo& info) 
    99103{ 
    100   stream >> info.operation_1 >> info.operation_1_parameter >> info.operation_2 >> info.operation_2_parameter >> info.intermediate_type >> info.destination_type; 
     104  stream >> info.destination_type >> info.operation_1 >> info.operation_1_parameter >> info.operation_2 >> info.operation_2_parameter >> info.intermediate_type >> info.encoding; 
    101105  return stream; 
    102106} 
Note: See TracChangeset for help on using the changeset viewer.