source: finroc_plugins_network_transport/tNetworkConnection.cpp @ 0:fd1f1542e677

Last change on this file since 0:fd1f1542e677 was 0:fd1f1542e677, checked in by Max Reichardt <mreichardt@…>, 8 years ago

Some initial files

File size: 3.7 KB
Line 
1//
2// You received this file as part of Finroc
3// A Framework for intelligent robot control
4//
5// Copyright (C) Finroc GbR (finroc.org)
6//
7// This program is free software; you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation; either version 2 of the License, or
10// (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License along
18// with this program; if not, write to the Free Software Foundation, Inc.,
19// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20//
21//----------------------------------------------------------------------
22/*!\file    plugins/network_transport/tNetworkConnection.cpp
23 *
24 * \author  Max Reichardt
25 *
26 * \date    2013-11-28
27 *
28 */
29//----------------------------------------------------------------------
30#include "plugins/network_transport/tNetworkConnection.h"
31
32//----------------------------------------------------------------------
33// External includes (system with <>, local with "")
34//----------------------------------------------------------------------
35
36//----------------------------------------------------------------------
37// Internal includes with ""
38//----------------------------------------------------------------------
39
40//----------------------------------------------------------------------
41// Debugging
42//----------------------------------------------------------------------
43#include <cassert>
44
45//----------------------------------------------------------------------
46// Namespace usage
47//----------------------------------------------------------------------
48
49//----------------------------------------------------------------------
50// Namespace declaration
51//----------------------------------------------------------------------
52namespace finroc
53{
54namespace network_transport
55{
56
57//----------------------------------------------------------------------
58// Forward declarations / typedefs / enums
59//----------------------------------------------------------------------
60
61//----------------------------------------------------------------------
62// Const values
63//----------------------------------------------------------------------
64
65//----------------------------------------------------------------------
66// Implementation
67//----------------------------------------------------------------------
68
69tNetworkConnection::tNetworkConnection() :
70  encoding(tDestinationEncoding::NONE),
71  uuid(),
72  port_handle(0)
73{}
74
75rrlib::serialization::tOutputStream& operator << (rrlib::serialization::tOutputStream& stream, const tNetworkConnection& connection)
76{
77  stream << connection.encoding;
78  switch (connection.encoding)
79  {
80  case tDestinationEncoding::NONE:
81    break;
82  case tDestinationEncoding::UUID_AND_HANDLE:
83    stream << connection.uuid << connection.port_handle;
84    break;
85  default:
86    FINROC_LOG_PRINT(ERROR, "Unsupported encoding");
87  }
88  return stream;
89}
90
91rrlib::serialization::tInputStream& operator >> (rrlib::serialization::tInputStream& stream, tNetworkConnection& connection)
92{
93  stream >> connection.encoding;
94  switch (connection.encoding)
95  {
96  case tDestinationEncoding::NONE:
97    break;
98  case tDestinationEncoding::UUID_AND_HANDLE:
99    stream >> connection.uuid >> connection.port_handle;
100    break;
101  default:
102    FINROC_LOG_PRINT(ERROR, "Unsupported encoding");
103  }
104  return stream;
105}
106
107
108//----------------------------------------------------------------------
109// End of namespace declaration
110//----------------------------------------------------------------------
111}
112}
Note: See TracBrowser for help on using the repository browser.