bool.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2019-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Primitive
28  bool
29 
30 Description
31  System bool
32 
33 SourceFiles
34  bool.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef bool_H
39 #define bool_H
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 // Forward Declarations
47 class Istream;
48 class Ostream;
49 
50 // IOstream Operators
51 
52 //- Read bool from stream using Foam::Switch(Istream&)
53 Istream& operator>>(Istream& is, bool& b);
54 
55 //- Write bool to a stream as an label (integer) value
56 Ostream& operator<<(Ostream& os, const bool b);
57 
58 //- Read bool from stream using Foam::Switch(Istream&)
59 bool readBool(Istream& is);
60 
61 } // End namespace Foam
62 
63 
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
65 
66 #include "pTraits.H"
67 #include "direction.H"
68 
69 namespace Foam
70 {
71 
72 // Template specialisation for pTraits<bool>
73 template<>
74 class pTraits<bool>
75 {
76  bool p_;
77 
78 public:
79 
80  // Typedefs
81 
82  //- Component type
83  typedef bool cmptType;
84 
85  //- Magnitude type
86  typedef bool magType;
87 
88 
89  // Member Constants
90 
91  //- Dimensionality of space
92  static constexpr direction dim = 3;
93 
94  //- Rank of bool is 0
95  static constexpr direction rank = 0;
96 
97  //- Number of components in bool is 1
98  static constexpr direction nComponents = 1;
99 
100 
101  // Static Data Members
102 
103  static const char* const typeName;
104  static const char* const componentNames[];
105  static const bool zero;
106  static const bool one;
107 
108 
109  // Constructors
110 
111  //- Copy construct from primitive
112  explicit pTraits(const bool& p) noexcept;
113 
114  //- Read construct from Istream
115  explicit pTraits(Istream& is);
116 
117 
118  // Member Functions
119 
120  //- Access to the value
121  operator bool() const noexcept
122  {
123  return p_;
124  }
125 
126  //- Access to the value
127  operator bool&() noexcept
128  {
129  return p_;
130  }
131 };
132 
133 
134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
135 
136 } // End namespace Foam
137 
138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139 
140 #endif
141 
142 // ************************************************************************* //
Foam::pTraits::pTraits
pTraits(const Base &obj)
Copy construct from base class.
Definition: pTraits.H:65
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::pTraits< bool >::zero
static const bool zero
Definition: bool.H:105
Foam::pTraits< bool >::cmptType
bool cmptType
Component type.
Definition: bool.H:83
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:230
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::readBool
bool readBool(Istream &is)
Read bool from stream using Foam::Switch(Istream&)
Definition: bool.C:75
os
OBJstream os(runTime.globalPath()/outputName)
pTraits.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::pTraits< bool >::magType
bool magType
Magnitude type.
Definition: bool.H:86
Foam::pTraits< bool >::typeName
static const char *const typeName
Definition: bool.H:103
direction.H
Direction is an 8-bit unsigned integer type used to represent Cartesian directions,...
Foam::pTraits
A traits class, which is primarily used for primitives.
Definition: pTraits.H:56
bool
bool
Definition: EEqn.H:20
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::pTraits< bool >::one
static const bool one
Definition: bool.H:106