scalarRanges.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) 2018-2020 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::scalarRanges
28 
29 Description
30  A collection of scalar bounds to be used as a unary predicate.
31 
32 SeeAlso
33  Foam::predicates::scalars
34 
35 SourceFiles
36  scalarRanges.C
37  scalarRangesI.H
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef Foam_scalarRanges_H
42 #define Foam_scalarRanges_H
43 
44 #include "scalarRange.H"
45 #include "List.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class scalarRanges Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class scalarRanges
57 :
58  public List<scalarRange>
59 {
60 public:
61 
62  // Constructors
63 
64  //- Inherit constructors from List of scalarRange
66 
67  //- Default construct
68  constexpr scalarRanges() noexcept = default;
69 
70  //- Construct by parsing string using the parse() static method
71  inline explicit scalarRanges
72  (
73  const std::string& str,
74  bool report = true
75  );
76 
77 
78  // Static Constructors
79 
80  //- Construct by parsing string for scalar ranges
81  // The individual items are space, comma or semicolon delimited.
82  static scalarRanges parse
83  (
84  const std::string& str,
85  bool report = true
86  );
87 
88 
89  // Member Functions
90 
91  //- True if the value is contained by any of the sub-ranges
92  inline bool contains(const scalar value) const;
93 
94  //- True if the value is matched by any of the sub-ranges
95  bool match(const scalar value) const { return contains(value); }
96 
97 
98  // Member Operators
99 
100  //- For use as a predicate, same as contains()
101  bool operator()(const scalar value) const { return contains(value); }
102 };
104 
105 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106 
107 } // End namespace Foam
108 
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110 
111 #include "scalarRangesI.H"
112 
113 #endif
114 
115 // ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
constexpr scalarRanges() noexcept=default
Default construct.
bool match(const scalar value) const
True if the value is matched by any of the sub-ranges.
Definition: scalarRanges.H:103
const direction noexcept
Definition: Scalar.H:258
static scalarRanges parse(const std::string &str, bool report=true)
Construct by parsing string for scalar ranges.
Definition: scalarRanges.C:27
A collection of scalar bounds to be used as a unary predicate.
Definition: scalarRanges.H:51
bool contains(const scalar value) const
True if the value is contained by any of the sub-ranges.
Definition: scalarRangesI.H:31
bool operator()(const scalar value) const
For use as a predicate, same as contains()
Definition: scalarRanges.H:111
Namespace for OpenFOAM.