Changeset 5:ea3cb2f0499b in finroc_plugins_network_transport for tNetworkConnection.cpp


Ignore:
Timestamp:
29.11.2013 18:48:56 (8 years ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
13.10
Phase:
public
Message:

Implemented more required functionality

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tNetworkConnection.cpp

    r3 r5  
    6969tNetworkConnection::tNetworkConnection() : 
    7070  encoding(tDestinationEncoding::NONE), 
     71  destination_is_source(false), 
    7172  uuid(), 
    7273  port_handle(0) 
    7374{} 
     75 
     76tNetworkConnection::tNetworkConnection(const std::string& uuid, core::tFrameworkElement::tHandle handle, bool destination_is_source) : 
     77  encoding(tDestinationEncoding::UUID_AND_HANDLE), 
     78  destination_is_source(destination_is_source), 
     79  uuid(uuid), 
     80  port_handle(handle) 
     81{} 
     82 
     83bool tNetworkConnection::operator==(const tNetworkConnection& other) const 
     84{ 
     85  if (encoding != other.encoding) 
     86  { 
     87    return false; 
     88  } 
     89  switch (encoding) 
     90  { 
     91  case tDestinationEncoding::NONE: 
     92    return true; 
     93  case tDestinationEncoding::UUID_AND_HANDLE: 
     94    return uuid == other.uuid && port_handle == other.port_handle && destination_is_source == other.destination_is_source; 
     95  default: 
     96    FINROC_LOG_PRINT(ERROR, "Unsupported encoding"); 
     97    return false; 
     98  } 
     99} 
    74100 
    75101rrlib::serialization::tOutputStream& operator << (rrlib::serialization::tOutputStream& stream, const tNetworkConnection& connection) 
     
    81107    break; 
    82108  case tDestinationEncoding::UUID_AND_HANDLE: 
    83     stream << connection.uuid << connection.port_handle; 
     109    stream << connection.uuid << connection.port_handle << connection.destination_is_source; 
    84110    break; 
    85111  default: 
     
    97123    break; 
    98124  case tDestinationEncoding::UUID_AND_HANDLE: 
    99     stream >> connection.uuid >> connection.port_handle; 
     125    stream >> connection.uuid >> connection.port_handle >> connection.destination_is_source; 
    100126    break; 
    101127  default: 
Note: See TracChangeset for help on using the changeset viewer.