ad_physics
Distance2D.hpp
Go to the documentation of this file.
1 /*
2  * ----------------- BEGIN LICENSE BLOCK ---------------------------------
3  *
4  * Copyright (C) 2018-2020 Intel Corporation
5  *
6  * SPDX-License-Identifier: MIT
7  *
8  * ----------------- END LICENSE BLOCK -----------------------------------
9  */
10 
18 #pragma once
19 
20 #include <iostream>
21 #include <limits>
22 #include <memory>
23 #include <sstream>
24 #include "ad/physics/Distance.hpp"
28 namespace ad {
32 namespace physics {
33 
39 struct Distance2D
40 {
44  typedef std::shared_ptr<Distance2D> Ptr;
45 
49  typedef std::shared_ptr<Distance2D const> ConstPtr;
50 
54  Distance2D() = default;
55 
59  ~Distance2D() = default;
60 
64  Distance2D(const Distance2D &other) = default;
65 
69  Distance2D(Distance2D &&other) = default;
70 
78  Distance2D &operator=(const Distance2D &other) = default;
79 
87  Distance2D &operator=(Distance2D &&other) = default;
88 
96  bool operator==(const Distance2D &other) const
97  {
98  return (x == other.x) && (y == other.y);
99  }
100 
108  bool operator!=(const Distance2D &other) const
109  {
110  return !operator==(other);
111  }
112 
115 };
116 
117 } // namespace physics
118 } // namespace ad
119 
123 #ifndef GEN_GUARD_AD_PHYSICS_DISTANCE2D
124 #define GEN_GUARD_AD_PHYSICS_DISTANCE2D
125 
128 namespace ad {
132 namespace physics {
133 
143 inline std::ostream &operator<<(std::ostream &os, Distance2D const &_value)
144 {
145  os << "Distance2D(";
146  os << "x:";
147  os << _value.x;
148  os << ",";
149  os << "y:";
150  os << _value.y;
151  os << ")";
152  return os;
153 }
154 
155 } // namespace physics
156 } // namespace ad
157 
158 namespace std {
162 inline std::string to_string(::ad::physics::Distance2D const &value)
163 {
164  stringstream sstream;
165  sstream << value;
166  return sstream.str();
167 }
168 } // namespace std
169 #endif // GEN_GUARD_AD_PHYSICS_DISTANCE2D
ad
namespace ad
Definition: Acceleration.hpp:30
ad::physics::Distance2D::operator=
Distance2D & operator=(const Distance2D &other)=default
standard assignment operator
ad::physics::Distance
DataType Distance.
Definition: Distance.hpp:67
ad::physics::Distance2D::operator!=
bool operator!=(const Distance2D &other) const
standard comparison operator
Definition: Distance2D.hpp:108
ad::physics::Distance2D::~Distance2D
~Distance2D()=default
standard destructor
ad::physics::Distance2D
DataType Distance2D.
Definition: Distance2D.hpp:39
ad::physics::Distance2D::Ptr
std::shared_ptr< Distance2D > Ptr
Smart pointer on Distance2D.
Definition: Distance2D.hpp:44
ad::physics::Distance2D::ConstPtr
std::shared_ptr< Distance2D const > ConstPtr
Smart pointer on constant Distance2D.
Definition: Distance2D.hpp:49
Distance.hpp
std::to_string
std::string to_string(::ad::physics::Acceleration const &value)
overload of the std::to_string for Acceleration
Definition: Acceleration.hpp:559
ad::physics::Distance2D::operator==
bool operator==(const Distance2D &other) const
standard comparison operator
Definition: Distance2D.hpp:96
ad::physics::operator<<
std::ostream & operator<<(std::ostream &os, Acceleration const &_value)
standard ostream operator
Definition: Acceleration.hpp:547
ad::physics::Distance2D::Distance2D
Distance2D()=default
standard constructor