YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
NetInt16.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <yarp/os/NetInt16.h>
8
9#ifndef YARP_LITTLE_ENDIAN
10
11using namespace yarp;
12using namespace yarp::os;
13
14
15std::uint16_t NetInt16::swap(std::uint16_t x) const
16{
17 return (x >> 8) | ((x << 8) & 0xff00);
18}
19
20std::int16_t NetInt16::get() const
21{
22 return (std::int16_t)swap(raw_value);
23}
24
25void NetInt16::set(std::int16_t v)
26{
27 raw_value = (std::int16_t)swap((std::uint16_t)v);
28}
29
30NetInt16::NetInt16()
31{
32}
33
34NetInt16::NetInt16(std::int16_t val)
35{
36 set(val);
37}
38
39NetInt16::operator std::int16_t() const
40{
41 return get();
42}
43
44std::int16_t NetInt16::operator+(std::int16_t v) const
45{
46 return get() + v;
47}
48
49std::int16_t NetInt16::operator-(std::int16_t v) const
50{
51 return get() - v;
52}
53
54std::int16_t NetInt16::operator*(std::int16_t v) const
55{
56 return get() * v;
57}
58
59std::int16_t NetInt16::operator/(std::int16_t v) const
60{
61 return get() / v;
62}
63
64void NetInt16::operator+=(std::int16_t v)
65{
66 set(get() + v);
67}
68
69void NetInt16::operator-=(std::int16_t v)
70{
71 set(get() - v);
72}
73
74void NetInt16::operator*=(std::int16_t v)
75{
76 set(get() * v);
77}
78
79void NetInt16::operator/=(std::int16_t v)
80{
81 set(get() / v);
82}
83
84void NetInt16::operator++(int)
85{
86 set(get() + 1);
87}
88
89void NetInt16::operator--(int)
90{
91 set(get() - 1);
92}
93
94#endif // YARP_LITTLE_ENDIAN
A mini-server for performing network communication in the background.
An interface to the operating system, including Port based communication.
The main, catch-all namespace for YARP.
Definition dirs.h:16