FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

scalarRange.H

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