YARP
Yet Another Robot Platform
NetInt64.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/NetInt64.h>
11 
12 #ifndef YARP_LITTLE_ENDIAN
13 
14 using namespace yarp;
15 using namespace yarp::os;
16 
17 
18 std::int64_t NetInt64::swap(std::int64_t x) const
19 {
20  UnionNetInt64 in, out;
21  in.d = x;
22  for (int i = 0; i < 8; i++) {
23  out.c[i] = in.c[7 - i];
24  }
25  return out.d;
26 }
27 RawNetInt64 NetInt64::get() const
28 {
29  return (RawNetInt64)swap((RawNetInt64)raw_value);
30 }
31 void NetInt64::set(RawNetInt64 v)
32 {
33  raw_value = (RawNetInt64)swap((RawNetInt64)v);
34 }
36 {
37 }
38 NetInt64::NetInt64(RawNetInt64 val)
39 {
40  set(val);
41 }
42 NetInt64::operator RawNetInt64() const
43 {
44  return get();
45 }
46 RawNetInt64 NetInt64::operator+(RawNetInt64 v) const
47 {
48  return get() + v;
49 }
50 RawNetInt64 NetInt64::operator-(RawNetInt64 v) const
51 {
52  return get() - v;
53 }
54 RawNetInt64 NetInt64::operator*(RawNetInt64 v) const
55 {
56  return get() * v;
57 }
58 RawNetInt64 NetInt64::operator/(RawNetInt64 v) const
59 {
60  return get() / v;
61 }
62 void NetInt64::operator+=(RawNetInt64 v)
63 {
64  set(get() + v);
65 }
66 void NetInt64::operator-=(RawNetInt64 v)
67 {
68  set(get() - v);
69 }
70 void NetInt64::operator*=(RawNetInt64 v)
71 {
72  set(get() * v);
73 }
74 void NetInt64::operator/=(RawNetInt64 v)
75 {
76  set(get() / v);
77 }
78 #endif // YARP_LITTLE_ENDIAN
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
yarp::os::NetInt64
std::int64_t NetInt64
Definition of the NetInt64 type.
Definition: NetInt64.h:33
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
NetInt64.h