YARP
Yet Another Robot Platform
NetUint32.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/NetUint32.h>
8 
9 #ifndef YARP_LITTLE_ENDIAN
10 
11 using namespace yarp;
12 using namespace yarp::os;
13 
14 
15 std::uint32_t NetUint32::swap(std::uint32_t x) const
16 {
17  return (x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24);
18 }
19 
20 std::uint32_t NetUint32::get() const
21 {
22  return (std::uint32_t)swap(raw_value);
23 }
24 
25 void NetUint32::set(std::uint32_t v)
26 {
27  raw_value = (std::uint32_t)swap((std::uint32_t)v);
28 }
29 
31 {
32 }
33 
34 NetUint32::NetUint32(std::uint32_t val)
35 {
36  set(val);
37 }
38 
39 NetUint32::operator std::uint32_t() const
40 {
41  return get();
42 }
43 
44 std::uint32_t NetUint32::operator+(std::uint32_t v) const
45 {
46  return get() + v;
47 }
48 
49 std::uint32_t NetUint32::operator-(std::uint32_t v) const
50 {
51  return get() - v;
52 }
53 
54 std::uint32_t NetUint32::operator*(std::uint32_t v) const
55 {
56  return get() * v;
57 }
58 
59 std::uint32_t NetUint32::operator/(std::uint32_t v) const
60 {
61  return get() / v;
62 }
63 
64 void NetUint32::operator+=(std::uint32_t v)
65 {
66  set(get() + v);
67 }
68 
69 void NetUint32::operator-=(std::uint32_t v)
70 {
71  set(get() - v);
72 }
73 
74 void NetUint32::operator*=(std::uint32_t v)
75 {
76  set(get() * v);
77 }
78 
79 void NetUint32::operator/=(std::uint32_t v)
80 {
81  set(get() / v);
82 }
83 
84 void NetUint32::operator++(int)
85 {
86  set(get() + 1);
87 }
88 
89 void NetUint32::operator--(int)
90 {
91  set(get() - 1);
92 }
93 
94 
95 #endif // YARP_LITTLE_ENDIAN
Vector & operator+=(Vector &a, const double &s)
Addition operator between a scalar and a vector (defined in Math.h).
Definition: math.cpp:38
Vector operator+(const Vector &a, const double &s)
Mathematical operations.
Definition: math.cpp:27
Vector operator-(const Vector &a, const double &s)
Subtraction operator between a vector and a scalar (defined in Math.h).
Definition: math.cpp:82
Vector operator*(double k, const Vector &b)
Scalar-vector product operator (defined in Math.h).
Definition: math.cpp:143
Vector & operator*=(Vector &a, double k)
Vector-scalar product operator (defined in Math.h).
Definition: math.cpp:154
Vector & operator/=(Vector &a, const Vector &b)
Vector-vector element-wise division operator (defined in Math.h).
Definition: math.cpp:266
Vector operator/(const Vector &a, const Vector &b)
Vector-vector element-wise division operator (defined in Math.h).
Definition: math.cpp:260
Vector & operator-=(Vector &a, const double &s)
Subtraction operator between a vector and a scalar (defined in Math.h).
Definition: math.cpp:98
An interface to the operating system, including Port based communication.
std::uint32_t NetUint32
Definition of the NetUint32 type.
Definition: NetUint32.h:30
The main, catch-all namespace for YARP.
Definition: dirs.h:16