00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software: you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. 00023 00024 Primitive 00025 bool 00026 00027 Description 00028 System bool 00029 00030 SourceFiles 00031 boolIO.C 00032 00033 \*---------------------------------------------------------------------------*/ 00034 00035 #ifndef bool_H 00036 #define bool_H 00037 00038 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00039 00040 namespace Foam 00041 { 00042 00043 class Istream; 00044 class Ostream; 00045 00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00047 00048 Istream& operator>>(Istream&, bool&); 00049 Ostream& operator<<(Ostream&, const bool); 00050 00051 bool readBool(Istream&); 00052 00053 } // End namespace Foam 00054 00055 00056 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00057 00058 #include <OpenFOAM/pTraits.H> 00059 00060 namespace Foam 00061 { 00062 00063 // template specialisation for pTraits<bool> 00064 template<> 00065 class pTraits<bool> 00066 { 00067 bool p_; 00068 00069 public: 00070 00071 //- Component type 00072 typedef bool cmptType; 00073 00074 // Member constants 00075 00076 enum 00077 { 00078 dim = 3, // Dimensionality of space 00079 rank = 0, // Rank of bool is 0 00080 nComponents = 1 // Number of components in bool is 1 00081 }; 00082 00083 00084 // Static data members 00085 00086 static const char* const typeName; 00087 static const char* componentNames[]; 00088 static const bool zero; 00089 static const bool one; 00090 00091 00092 // Constructors 00093 00094 //- Construct from bool 00095 pTraits(const bool b) 00096 { 00097 p_ = b; 00098 } 00099 00100 //- Construct from Istream 00101 pTraits(Istream&); 00102 00103 00104 // Member Functions 00105 00106 operator bool() const 00107 { 00108 return p_; 00109 } 00110 00111 operator bool&() 00112 { 00113 return p_; 00114 } 00115 }; 00116 00117 00118 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00119 00120 } // End namespace Foam 00121 00122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00123 00124 #endif 00125 00126 // ************************ vim: set sw=4 sts=4 et: ************************ //