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 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 boolVector_H
44#define boolVector_H
45
46#include "FixedList.H"
47
48// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49
50namespace Foam
51{
52
53/*---------------------------------------------------------------------------*\
54 Class boolVector Declaration
55\*---------------------------------------------------------------------------*/
57class boolVector
58:
59 public FixedList<bool, 3>
60{
61public:
62
63 // Member Constants
64
65 //- Rank of a vector is 1
66 static constexpr direction rank = 1;
67
68 //- Component labeling enumeration
69 enum components { X, Y, Z };
70
71
72 // Generated Methods
73
74 //- Copy construct
75 boolVector(const boolVector&) = default;
76
77 //- Copy assignment
78 boolVector& operator=(const boolVector&) = default;
79
80 //- Move construct
81 boolVector(boolVector&&) = default;
82
83 //- Move assignment
84 boolVector& operator=(boolVector&&) = default;
85
86
87 // Constructors
88
89 //- Default construct, zero-initialized (ie, false)
90 inline boolVector();
91
92 //- Uniform construct with specified value
93 inline explicit boolVector(const bool val);
94
95 //- Construct from three components
96 inline boolVector(const bool vx, const bool vy, const bool vz);
97
98 //- Construct from Istream
99 inline explicit boolVector(Istream& is);
100
101
102 // Member Functions
103
104 // Query
105
106 //- True if all components are set
107 //
108 // \note Method name compatibility with bitSet
109 inline bool all() const;
110
111 //- True if any components are set
112 //
113 // \note Method name compatibility with bitSet
114 inline bool any() const;
115
116 //- True if no components are set
117 //
118 // \note Method name compatibility with bitSet
119 inline bool none() const;
120
121 //- Count number of items set.
122 // \param on can be set to false to count the number of unset bits
123 // instead.
124 //
125 // \note Method name compatibility with bitSet
126 inline unsigned int count(const bool on=true) const;
127
128
129 // Access
130
131 //- The x component
132 inline bool x() const;
133
134 //- The y component
135 inline bool y() const;
136
137 //- The z component
138 inline bool z() const;
139
140 //- The x component
141 inline bool& x();
142
143 //- The y component
144 inline bool& y();
145
146 //- The z component
147 inline bool& z();
148
149
150 // Edit
151
152 //- Invert all values
153 //
154 // \note Method name compatibility with bitSet
155 inline void flip();
156
157
158 // Operators
159
160 //- Assignment of all entries to the given value
161 inline void operator=(const bool value);
162};
163
164// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
165
166//- A boolVector is contiguous (FixedList of bool)
167template<> struct is_contiguous<boolVector> : std::true_type {};
168
169
170// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171
172} // End namespace Foam
173
174// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175
176#include "boolVectorI.H"
177
178// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179
180#endif
181
182// ************************************************************************* //
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: FixedList.H:81
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
Specialized bundling of boolean values as a vector of 3 components, element access using x(),...
Definition: boolVector.H:59
unsigned int count(const bool on=true) const
Count number of items set.
Definition: boolVectorI.H:91
void flip()
Invert all values.
Definition: boolVectorI.H:119
components
Component labeling enumeration.
Definition: boolVector.H:68
boolVector(const boolVector &)=default
Copy construct.
bool none() const
True if no components are set.
Definition: boolVectorI.H:85
static constexpr direction rank
Rank of a vector is 1.
Definition: boolVector.H:65
boolVector(boolVector &&)=default
Move construct.
boolVector & operator=(const boolVector &)=default
Copy assignment.
bool & z()
The z component.
Definition: boolVectorI.H:116
bool all() const
True if all components are set.
Definition: boolVectorI.H:65
boolVector & operator=(boolVector &&)=default
Move assignment.
boolVector()
Default construct, zero-initialized (ie, false)
Definition: boolVectorI.H:30
bool & y()
The y component.
Definition: boolVectorI.H:115
bool any() const
True if any components are set.
Definition: boolVectorI.H:75
bool & x()
The x component.
Definition: boolVectorI.H:114
Namespace for OpenFOAM.
uint8_t direction
Definition: direction.H:56
A template class to specify that a data type can be considered as being contiguous in memory.
Definition: contiguous.H:78