YARP
Yet Another Robot Platform
NetInt32.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #include <yarp/os/NetInt32.h>
11 
12 #ifndef YARP_LITTLE_ENDIAN
13 
14 using namespace yarp;
15 using namespace yarp::os;
16 
17 
18 std::uint32_t NetInt32::swap(std::uint32_t x) const
19 {
20  return (x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24);
21 }
22 
23 std::int32_t NetInt32::get() const
24 {
25  return (std::int32_t)swap(raw_value);
26 }
27 
28 void NetInt32::set(std::int32_t v)
29 {
30  raw_value = (std::int32_t)swap((std::uint32_t)v);
31 }
32 
34 {
35 }
36 
37 NetInt32::NetInt32(std::int32_t val)
38 {
39  set(val);
40 }
41 
42 NetInt32::operator std::int32_t() const
43 {
44  return get();
45 }
46 
47 std::int32_t NetInt32::operator+(std::int32_t v) const
48 {
49  return get() + v;
50 }
51 
52 std::int32_t NetInt32::operator-(std::int32_t v) const
53 {
54  return get() - v;
55 }
56 
57 std::int32_t NetInt32::operator*(std::int32_t v) const
58 {
59  return get() * v;
60 }
61 
62 std::int32_t NetInt32::operator/(std::int32_t v) const
63 {
64  return get() / v;
65 }
66 
67 void NetInt32::operator+=(std::int32_t v)
68 {
69  set(get() + v);
70 }
71 
72 void NetInt32::operator-=(std::int32_t v)
73 {
74  set(get() - v);
75 }
76 
77 void NetInt32::operator*=(std::int32_t v)
78 {
79  set(get() * v);
80 }
81 
82 void NetInt32::operator/=(std::int32_t v)
83 {
84  set(get() / v);
85 }
86 
87 void NetInt32::operator++(int)
88 {
89  set(get() + 1);
90 }
91 
92 void NetInt32::operator--(int)
93 {
94  set(get() - 1);
95 }
96 
97 
98 #endif // YARP_LITTLE_ENDIAN
NetInt32.h
operator*=
Vector & operator*=(Vector &a, double k)
Vector-scalar product operator (defined in Math.h).
Definition: math.cpp:148
operator+=
Vector & operator+=(Vector &a, const double &s)
Addition operator between a scalar and a vector (defined in Math.h).
Definition: math.cpp:41
operator/
Vector operator/(const Vector &a, const Vector &b)
Vector-vector element-wise division operator (defined in Math.h).
Definition: math.cpp:250
operator+
Vector operator+(const Vector &a, const double &s)
Mathematical operations.
Definition: math.cpp:30
operator/=
Vector & operator/=(Vector &a, const Vector &b)
Vector-vector element-wise division operator (defined in Math.h).
Definition: math.cpp:256
operator*
Vector operator*(double k, const Vector &b)
Scalar-vector product operator (defined in Math.h).
Definition: math.cpp:137
yarp::os
An interface to the operating system, including Port based communication.
Definition: AbstractCarrier.h:17
operator-=
Vector & operator-=(Vector &a, const double &s)
Subtraction operator between a vector and a scalar (defined in Math.h).
Definition: math.cpp:96
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
operator-
Vector operator-(const Vector &a, const double &s)
Subtraction operator between a vector and a scalar (defined in Math.h).
Definition: math.cpp:81
yarp::os::NetInt32
std::int32_t NetInt32
Definition of the NetInt32 type.
Definition: NetInt32.h:33