|
|
|
scalarRange.HGo to the documentation of this file.00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2009 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 the 00013 Free Software Foundation; either version 2 of the License, or (at your 00014 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, write to the Free Software Foundation, 00023 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00024 00025 Class 00026 Foam::scalarRange 00027 00028 Description 00029 A scalar range specifier. 00030 00031 The range selector can be specified as an "LOWER:UPPER" range, as a 00032 "LOWER:" bound, as an ":UPPER" bound or simply as an "EXACT" value. 00033 The read constructor uses a colon (:) as a range marker and a comma (,) 00034 to delimit the next possible range selector. 00035 00036 SourceFiles 00037 scalarRange.C 00038 00039 \*---------------------------------------------------------------------------*/ 00040 #ifndef scalarRange_H 00041 #define scalarRange_H 00042 00043 #include "scalar.H" 00044 00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00046 00047 namespace Foam 00048 { 00049 00050 // Forward declaration of classes 00051 class Istream; 00052 class Ostream; 00053 00054 // Forward declaration of friend functions and operators 00055 class scalarRange; 00056 Istream& operator>>(Istream&, scalarRange&); 00057 Ostream& operator<<(Ostream&, const scalarRange&); 00058 00059 00060 /*---------------------------------------------------------------------------*\ 00061 Class scalarRange Declaration 00062 \*---------------------------------------------------------------------------*/ 00063 00064 class scalarRange 00065 { 00066 //- Enumeration defining the types of token 00067 enum rangeType 00068 { 00069 EMPTY = 0, 00070 EXACT, 00071 LOWER, 00072 UPPER, 00073 RANGE 00074 }; 00075 00076 00077 // Private data 00078 00079 enum rangeType type_; 00080 scalar value_; 00081 scalar value2_; 00082 00083 00084 public: 00085 00086 static int debug; 00087 00088 00089 // Constructors 00090 00091 //- Construct Null 00092 scalarRange(); 00093 00094 //- Construct a Range 00095 scalarRange(const scalar& lower, const scalar& upper); 00096 00097 //- Construct from Istream. 00098 // Since commas can be used as list delimiters, 00099 // leading and trailing commas are ignored. 00100 scalarRange(Istream&); 00101 00102 00103 // Member Functions 00104 00105 //- Is the range non-empty? 00106 bool isDefined() const; 00107 00108 //- Is the range 'EXACT'? 00109 bool isExact() const; 00110 00111 //- The value constituting an 'EXACT' match 00112 // or the values for 'UPPER' or 'LOWER' limits 00113 scalar value() const; 00114 00115 //- The lower limit 00116 scalar lower() const; 00117 00118 //- The upper limit 00119 scalar upper() const; 00120 00121 //- Return true if the value is within the range 00122 bool selected(const scalar&) const; 00123 00124 00125 // Member Operators 00126 00127 bool operator==(const scalarRange&) const; 00128 bool operator!=(const scalarRange&) const; 00129 00130 00131 // IOstream Operators 00132 00133 friend Istream& operator>>(Istream&, scalarRange&); 00134 friend Ostream& operator<<(Ostream&, const scalarRange&); 00135 }; 00136 00137 00138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00139 00140 } // End namespace Foam 00141 00142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00143 00144 #endif 00145 00146 // ************************************************************************* // |