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 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 class Istream;
47 class Ostream;
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 Istream& operator>>(Istream& is, bool& b);
52 Ostream& operator<<(Ostream& os, const bool b);
53 
54 bool readBool(Istream& is);
55 
56 } // End namespace Foam
57 
58 
59 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 
61 #include "pTraits.H"
62 #include "direction.H"
63 
64 namespace Foam
65 {
66 
67 // Template specialisation for pTraits<bool>
68 template<>
69 class pTraits<bool>
70 {
71  bool p_;
72 
73 public:
74 
75  //- Component type
76  typedef bool cmptType;
77 
78  //- Magnitude type
79  typedef bool magType;
80 
81 
82  // Member constants
83 
84  //- Dimensionality of space
85  static constexpr direction dim = 3;
86 
87  //- Rank of bool is 0
88  static constexpr direction rank = 0;
89 
90  //- Number of components in bool is 1
91  static constexpr direction nComponents = 1;
92 
93 
94  // Static data members
95 
96  static const char* const typeName;
97  static const char* const componentNames[];
98  static const bool zero;
99  static const bool one;
100 
101 
102  // Constructors
103 
104  //- Construct from primitive
105  explicit pTraits(const bool& p);
106 
107  //- Construct from Istream
108  pTraits(Istream& is);
109 
110 
111  // Member Functions
112 
113  //- Access to the value
114  operator bool() const
115  {
116  return p_;
117  }
118 
119  //- Access to the value
120  operator bool&()
121  {
122  return p_;
123  }
124 };
125 
126 
127 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128 
129 } // End namespace Foam
130 
131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132 
133 #endif
134 
135 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::pTraits< bool >::zero
static const bool zero
Definition: bool.H:98
Foam::pTraits< bool >::cmptType
bool cmptType
Component type.
Definition: bool.H:76
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:228
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)
Definition: bool.C:70
Foam::pTraits::pTraits
pTraits(const PrimitiveType &p)
Construct from primitive.
Definition: pTraits.H:62
pTraits.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::pTraits< bool >::magType
bool magType
Magnitude type.
Definition: bool.H:79
Foam::pTraits< bool >::typeName
static const char *const typeName
Definition: bool.H:96
direction.H
Direction is an 8-bit unsigned integer type used to represent the Cartesian directions etc.
Foam::pTraits
Traits class for primitives.
Definition: pTraits.H:52
bool
bool
Definition: EEqn.H:20
Foam::direction
uint8_t direction
Definition: direction.H:47
Foam::pTraits< bool >::one
static const bool one
Definition: bool.H:99
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &)
Definition: boundaryPatch.C:102