olp-cpp-sdk 1.24.0
Loading...
Searching...
No Matches
Size.h
1/*
2 * Copyright (C) 2019 HERE Europe B.V.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * SPDX-License-Identifier: Apache-2.0
17 * License-Filename: LICENSE
18 */
19
20#pragma once
21
22#include <olp/core/math/Vector.h>
23
24namespace olp {
25namespace math {
27template <typename T>
28class Size2 {
29 public:
31 using Value = T;
32
34 Size2();
35
41 template <typename U>
42 Size2(const Size2<U>& size);
43
49 template <typename U>
50 explicit Size2(const Vector2<U>& vector);
51
59
65 template <typename U>
66 explicit operator Vector2<U>() const;
67
74 bool empty() const;
75
81 Value Width() const;
82
88 Value Height() const;
89
90 private:
91 Vector2<Value> size_;
92};
93
95
96template <typename T>
97Size2<T>::Size2() : size_(0, 0) {}
98
99template <typename T>
100template <typename U>
102
103template <typename T>
104template <typename U>
106
107template <typename T>
109
110template <typename T>
111template <typename U>
113 return Vector2<U>(size_.x, size_.y);
114}
115
116template <typename T>
117bool Size2<T>::empty() const {
118 return size_.x == T() || size_.y == T();
119}
120
121template <typename T>
123 return size_.x;
124}
125
126template <typename T>
128 return size_.y;
129}
130
131template <typename T>
132bool operator==(const Size2<T>& lhs, const Size2<T>& rhs) {
133 return lhs.width() == rhs.width() && lhs.height() == rhs.height();
134}
135
136template <typename T>
137bool operator!=(const Size2<T>& lhs, const Size2<T>& rhs) {
138 return !(lhs == rhs);
139}
140
141} // namespace math
142} // namespace olp
Represents the 2D size.
Definition Size.h:28
T Value
An alias for the value type.
Definition Size.h:31
Value Width() const
Gets the width of the Size2 object.
Definition Size.h:122
Value Height() const
Gets the height of the Size2 object.
Definition Size.h:127
bool empty() const
Checks whether the size is empty.
Definition Size.h:117
Size2()
Creates an uninitialized Size2 instance.
Definition Size.h:97
Rules all the other namespaces.
Definition AppleSignInProperties.h:24
Represents 3D vectors and points.
Definition Vector.h:86
T y
The Y component of the vector.
Definition Vector.h:149
T x
The X component of the vector.
Definition Vector.h:147