Loading...
Searching...
No Matches
boolVector.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2020-2023 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::boolVector
28
29Description
30 Specialized bundling of boolean values as a vector of 3 components,
31 element access using x(), y() and z() member functions.
32 It also has some methods similar to bitSet.
33
34Note
35 The boolVector is not derived from Vector or VectorSpace since
36 it does not share very many vector-like characteristics.
37
38SourceFiles
39 boolVectorI.H
40
41\*---------------------------------------------------------------------------*/
42
43#ifndef Foam_boolVector_H
44#define Foam_boolVector_H
45
46#include "FixedList.H"
47
48// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49
50namespace Foam
51{
53/*---------------------------------------------------------------------------*\
54 Class boolVector Declaration
55\*---------------------------------------------------------------------------*/
56
57class boolVector
58:
59 public FixedList<bool, 3>
60{
61public:
62
63 // Typedefs
64
65 //- The component type is bool
66 typedef bool cmptType;
67
68
69 // Member Constants
70
71 //- Rank of a vector is 1
72 static constexpr direction rank = 1;
73
74 //- Number of components in this vector space
75 static constexpr direction nComponents = 3;
77 //- Component labeling enumeration
78 enum components { X, Y, Z };
79
80
81 // Generated Methods
82
83 //- Copy construct
84 boolVector(const boolVector&) = default;
85
86 //- Copy assignment
87 boolVector& operator=(const boolVector&) = default;
88
89 //- Move construct
90 boolVector(boolVector&&) = default;
91
92 //- Move assignment
93 boolVector& operator=(boolVector&&) = default;
95 //- The front() accessor (from FixedList) has no purpose
96 void front() = delete;
97
98 //- The back() accessor (from FixedList) has no purpose
99 void back() = delete;
100
101
102 // Constructors
103
104 //- Default construct, zero-initialized (ie, false)
105 inline boolVector();
106
107 //- Uniform construct with specified value
108 inline explicit boolVector(const bool val);
110 //- Construct from three components
111 inline boolVector(const bool vx, const bool vy, const bool vz);
112
113 //- Construct from Istream
114 inline explicit boolVector(Istream& is);
115
116
117 // Member Functions
118
119 // Query
120
121 //- True if all components are set
122 //
123 // \note Method name compatibility with bitSet
124 inline bool all() const noexcept;
125
126 //- True if any components are set
127 //
128 // \note Method name compatibility with bitSet
129 inline bool any() const noexcept;
130
131 //- True if no components are set
132 //
133 // \note Method name compatibility with bitSet
134 inline bool none() const noexcept;
135
136 //- Count number of items set.
137 // \param on can be set to false to count the number of unset bits
138 // instead.
139 //
140 // \note Method name compatibility with bitSet
141 inline unsigned int count(const bool on=true) const;
142
143
144 // Component Access
145
146 //- The x component
147 bool x() const noexcept { return get<0>(); }
148
149 //- The y component
150 bool y() const noexcept { return get<1>(); }
151
152 //- The z component
153 bool z() const noexcept { return get<2>(); }
154
155 //- The x component
156 bool& x() noexcept { return get<0>(); }
157
158 //- The y component
159 bool& y() noexcept { return get<1>(); }
160
161 //- The z component
162 bool& z() noexcept { return get<2>(); }
163
164
165 // Edit
166
167 //- Invert all values
168 //
169 // \note Method name compatibility with bitSet
170 inline void flip();
171
172
173 // Operators
174
175 //- Assignment of all entries to the given value
176 inline void operator=(const bool value);
177};
178
179// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
180
181//- A boolVector is contiguous (FixedList of bool)
182template<> struct is_contiguous<boolVector> : std::true_type {};
183
185/*---------------------------------------------------------------------------*\
186 Specialization pTraits<boolVector>
187\*---------------------------------------------------------------------------*/
188
189//- A boolVector has bool data components.
190template<>
191struct pTraits_cmptType<boolVector> { typedef bool type; };
192
193//- A boolVector has three data components
194template<>
196:
197 std::integral_constant<Foam::direction, 3>
198{};
200
201// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202
203} // End namespace Foam
205// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206
207#include "boolVectorI.H"
208
209// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210
211#endif
212
213// ************************************************************************* //
bool & get() noexcept
Definition FixedListI.H:152
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
Specialized bundling of boolean values as a vector of 3 components, element access using x(),...
Definition boolVector.H:55
unsigned int count(const bool on=true) const
Count number of items set.
Definition boolVectorI.H:74
bool none() const noexcept
True if no components are set.
Definition boolVectorI.H:68
void flip()
Invert all values.
Definition boolVectorI.H:93
void back()=delete
The back() accessor (from FixedList) has no purpose.
void front()=delete
The front() accessor (from FixedList) has no purpose.
components
Component labeling enumeration.
Definition boolVector.H:81
bool & z() noexcept
The z component.
Definition boolVector.H:209
boolVector(const boolVector &)=default
Copy construct.
bool z() const noexcept
The z component.
Definition boolVector.H:194
bool & x() noexcept
The x component.
Definition boolVector.H:199
static constexpr direction nComponents
Number of components in this vector space.
Definition boolVector.H:76
static constexpr direction rank
Rank of a vector is 1.
Definition boolVector.H:71
boolVector(boolVector &&)=default
Move construct.
boolVector & operator=(const boolVector &)=default
Copy assignment.
bool x() const noexcept
The x component.
Definition boolVector.H:184
bool any() const noexcept
True if any components are set.
Definition boolVectorI.H:62
boolVector & operator=(boolVector &&)=default
Move assignment.
boolVector()
Default construct, zero-initialized (ie, false).
Definition boolVectorI.H:23
bool y() const noexcept
The y component.
Definition boolVector.H:189
bool & y() noexcept
The y component.
Definition boolVector.H:204
bool all() const noexcept
True if all components are set.
Definition boolVectorI.H:56
bool cmptType
The component type is bool.
Definition boolVector.H:63
Namespace for OpenFOAM.
uint8_t direction
Definition direction.H:49
const direction noexcept
Definition scalarImpl.H:265
A template class to specify that a data type can be considered as being contiguous in memory.
Definition contiguous.H:70
The underlying component data type: default is pass-through.
Definition pTraits.H:116
The vector-space number of components: default is 1.
Definition pTraits.H:140