YARP
Yet Another Robot Platform
NetInt64.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/NetInt64.h>
8
9#ifndef YARP_LITTLE_ENDIAN
10
11using namespace yarp;
12using namespace yarp::os;
13
14
15std::int64_t NetInt64::swap(std::int64_t x) const
16{
17 UnionNetInt64 in, out;
18 in.d = x;
19 for (int i = 0; i < 8; i++) {
20 out.c[i] = in.c[7 - i];
21 }
22 return out.d;
23}
24RawNetInt64 NetInt64::get() const
25{
26 return (RawNetInt64)swap((RawNetInt64)raw_value);
27}
28void NetInt64::set(RawNetInt64 v)
29{
30 raw_value = (RawNetInt64)swap((RawNetInt64)v);
31}
33{
34}
35NetInt64::NetInt64(RawNetInt64 val)
36{
37 set(val);
38}
39NetInt64::operator RawNetInt64() const
40{
41 return get();
42}
43RawNetInt64 NetInt64::operator+(RawNetInt64 v) const
44{
45 return get() + v;
46}
47RawNetInt64 NetInt64::operator-(RawNetInt64 v) const
48{
49 return get() - v;
50}
51RawNetInt64 NetInt64::operator*(RawNetInt64 v) const
52{
53 return get() * v;
54}
55RawNetInt64 NetInt64::operator/(RawNetInt64 v) const
56{
57 return get() / v;
58}
59void NetInt64::operator+=(RawNetInt64 v)
60{
61 set(get() + v);
62}
63void NetInt64::operator-=(RawNetInt64 v)
64{
65 set(get() - v);
66}
67void NetInt64::operator*=(RawNetInt64 v)
68{
69 set(get() * v);
70}
71void NetInt64::operator/=(RawNetInt64 v)
72{
73 set(get() / v);
74}
75#endif // YARP_LITTLE_ENDIAN
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, const double &s)
Subtraction operator between a vector and a scalar (defined in Math.h).
Definition: math.cpp:98
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/=(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, double k)
Vector-scalar product operator (defined in Math.h).
Definition: math.cpp:154
An interface to the operating system, including Port based communication.
std::int64_t NetInt64
Definition of the NetInt64 type.
Definition: NetInt64.h:29
The main, catch-all namespace for YARP.
Definition: dirs.h:16