Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
Orientation.h
1// trax track library
2// AD 2015
3//
4// "the resolution of all the fruitless searches"
5//
6// Peter Gabriel
7//
8// Copyright (c) 2025 Trend Redaktions- und Verlagsgesellschaft mbH
9// Copyright (c) 2019 Marc-Michael Horstmann
10//
11// Permission is hereby granted to any person obtaining a copy of this software
12// and associated source code (the "Software"), to use, view, and study the
13// Software for personal or internal business purposes, subject to the following
14// conditions:
15//
16// 1. Redistribution, modification, sublicensing, or commercial use of the
17// Software is NOT permitted without prior written consent from the copyright
18// holder.
19//
20// 2. The Software is provided "AS IS", without warranty of any kind, express
21// or implied.
22//
23// 3. All copies of the Software must retain this license notice.
24//
25// For further information, please contact: horstmann.marc@trendverlag.de
26
27#pragma once
28
29#include "Configuration.h"
30
31#include <ostream>
32#include <string>
33
34namespace trax{
35
38
40 enum class Value : char{
41 none = -1,
42 anti = 0,
43 para = 1
44 };
45
46
51 //{@
52 Orientation() noexcept
53 : m_Value{ Value::para }
54 {}
55
56 Orientation( Value value ) noexcept
57 : m_Value{ value }
58 {}
59
60 explicit Orientation( bool bvalue ) noexcept
61 : m_Value{ bvalue ? Value::para : Value::anti }
62 {}
63
64 explicit Orientation( int ivalue ) noexcept
65 : m_Value{ ivalue == 0 ? Value::anti : Value::para }
66 {}
67
68
69 void Flip() noexcept{
70 m_Value = m_Value == Value::para ? Value::anti : Value::para;
71 }
72
74 bool operator==( Value value ) const noexcept{
75 return m_Value == value;
76 }
77
79 bool operator!=( Value value ) const noexcept{
80 return m_Value != value;
81 }
82
87 Value operator!() const noexcept{
88 return m_Value == Value::para ? Value::anti : Value::para;
89 }
90
91 operator bool() const noexcept{
92 return m_Value == Value::para;
93 }
94
95 operator int() const noexcept{
96 return m_Value == Value::para ? +1 : -1;
97 }
98
99 private:
100 Value m_Value;
101
102 friend bool operator==( const Orientation& a, const Orientation& b ) noexcept;
103 friend bool operator!=( const Orientation& a, const Orientation& b ) noexcept;
104 friend bool operator==( const Orientation::Value& a, const Orientation& b ) noexcept;
105 friend bool operator!=( const Orientation::Value& a, const Orientation& b ) noexcept;
106 };
107
108
110 inline bool operator==( const Orientation& a, const Orientation& b ) noexcept;
111
112
114 inline bool operator!=( const Orientation& a, const Orientation& b ) noexcept;
115
116
118 inline bool operator==( const Orientation::Value& a, const Orientation& b ) noexcept;
119
120
122 inline bool operator!=( const Orientation::Value& a, const Orientation& b ) noexcept;
123
124
126 inline Orientation operator+( const Orientation& a, const Orientation& b ) noexcept;
127
128
131 inline Orientation& operator+=( Orientation& a, const Orientation& b ) noexcept;
132
133
134 dclspc std::string ToString( Orientation orient );
135
136 dclspc Orientation ToOrientation( const std::string& orient );
137
138
139//inlines:
140 inline bool operator==( const Orientation& a, const Orientation& b ) noexcept{
141 return a.m_Value == b.m_Value;
142 }
143
144 inline bool operator!=( const Orientation& a, const Orientation& b ) noexcept{
145 return a.m_Value != b.m_Value;
146 }
147
148 inline bool operator==( const Orientation::Value& a, const Orientation& b ) noexcept{
149 return a == b.m_Value;
150 }
151
152 inline bool operator!=( const Orientation::Value& a, const Orientation& b ) noexcept{
153 return a != b.m_Value;
154 }
155
156 Orientation operator+( const Orientation& a, const Orientation& b ) noexcept{
158 }
159
161 a = a + b;
162 return a;
163 }
164}
Value type, dependend from dimensions.
Definition DimensionedValues.h:233
constexpr bool operator!=(const Interval< Valtype > &i1, const Interval< Valtype > &i2) noexcept
Interval operator.
Definition Interval.h:701
void operator+=(Interval< Valtype > &i1, const Interval< Valtype > &i2) noexcept
Interval operator.
Definition Interval.h:586
constexpr bool operator==(const Interval< Valtype > &i1, const Interval< Valtype > &i2) noexcept
Interval operator.
Definition Interval.h:696
constexpr Interval< Valtype > operator+(const Interval< Valtype > &i1, const Interval< Valtype > &i2) noexcept
Interval operator.
Definition Interval.h:591
Namespace of all the trax track libraries classes and methods.
Definition Collection.h:17
Provides two values for orientation.
Definition Orientation.h:37
Value
Values for orientation.
Definition Orientation.h:40
@ none
Denoting the unknown orientation.
Definition Orientation.h:41
@ para
Denoting the aligned, parallel orientation.
Definition Orientation.h:43
@ anti
Denoting the non parallel or opposite orientation.
Definition Orientation.h:42
Orientation(bool bvalue) noexcept
Test for equality of value.
Definition Orientation.h:60
Orientation(Value value) noexcept
Test for equality of value.
Definition Orientation.h:56
Orientation() noexcept
Test for equality of value.
Definition Orientation.h:52
bool operator==(Value value) const noexcept
Test for equality of value.
Definition Orientation.h:74
Value operator!() const noexcept
Definition Orientation.h:87
void Flip() noexcept
Test for equality of value.
Definition Orientation.h:69
bool operator!=(Value value) const noexcept
Test for inequality of value.
Definition Orientation.h:79
Orientation(int ivalue) noexcept
Test for equality of value.
Definition Orientation.h:64