fieldInfo.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) 2019 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::functionObjects::fieldInfo
28 
29 Description
30  Helper class to store a wordRe and label used by
31  Foam::functionObjects::fieldSelection
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef functionObjects_fieldInfo_H
36 #define functionObjects_fieldInfo_H
37 
38 #include "wordRe.H"
39 #include "label.H"
40 #include "Switch.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 namespace functionObjects
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class fieldInfo Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 class fieldInfo;
54 Istream& operator>>(Istream&, fieldInfo&);
55 Ostream& operator<<(Ostream&, const fieldInfo&);
56 
57 class fieldInfo
58 {
59  // Pivate data
60 
61  //- Pattern for the field name
62  wordRe name_;
63 
64  //- Field component
65  label component_;
66 
67  //- Found
68  mutable Switch found_;
69 
70 
71 public:
72 
73  // Constructors
74 
75  //- Null constructor
76  fieldInfo()
77  :
78  name_(word::null),
79  component_(-1),
80  found_(false)
81  {}
82 
83 
84  //- Construct from components
85  fieldInfo(const wordRe& name, const label component = -1)
86  :
87  name_(name),
88  component_(component),
89  found_(false)
90  {}
91 
92  //- Construct from stream
93  fieldInfo(Istream& is)
94  :
95  name_(is),
96  component_(readLabel(is)),
97  found_(false)
98  {}
99 
100 
101  //- Destructor
102  ~fieldInfo() = default;
103 
104 
105  // Member Functions
106 
107  const wordRe& name() const
108  {
109  return name_;
110  }
111 
112  label component() const
113  {
114  return component_;
115  }
116 
117  Switch& found() const
118  {
119  return found_;
120  }
121 
122  friend bool operator==(const fieldInfo& a, const fieldInfo& b)
123  {
124  return
125  a.name_ == b.name_
126  && a.component_ == b.component_
127  && a.found_ == b.found_;
128  }
129 
130  friend bool operator!=(const fieldInfo& a, const fieldInfo& b)
131  {
132  return !(a == b);
133  }
134 
135 
136  // IOstream Operators
137 
138  friend Istream& operator>>(Istream& is, fieldInfo& fi)
139  {
140  is >> fi.name_ >> fi.component_ >> fi.found_;
141  return is;
142  }
143  friend Ostream& operator<<(Ostream& os, const fieldInfo& fi)
144  {
145  os << fi.name_ << ' ' << fi.component_ << ' ' << fi.found_;
146  return os;
147  }
148 };
149 
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 } // End namespace functionObjects
154 } // End namespace Foam
155 
156 
157 #endif
158 
159 // ************************************************************************* //
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:77
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::functionObjects::fieldInfo::~fieldInfo
~fieldInfo()=default
Destructor.
Foam::functionObjects::fieldInfo::name
const wordRe & name() const
Definition: fieldInfo.H:106
Foam::functionObjects::fieldInfo::fieldInfo
fieldInfo(const wordRe &name, const label component=-1)
Construct from components.
Definition: fieldInfo.H:84
Foam::functionObjects::fieldInfo
Helper class to store a wordRe and label used by Foam::functionObjects::fieldSelection.
Definition: fieldInfo.H:56
Foam::functionObjects::fieldInfo::fieldInfo
fieldInfo(Istream &is)
Construct from stream.
Definition: fieldInfo.H:92
Foam::functionObjects::operator<<
Ostream & operator<<(Ostream &, const fieldInfo &)
Definition: fieldInfo.H:142
Foam::wordRe
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:72
Foam::functionObjects::operator>>
Istream & operator>>(Istream &, fieldInfo &)
Definition: fieldInfo.H:137
Foam::functionObjects::fieldInfo::fieldInfo
fieldInfo()
Null constructor.
Definition: fieldInfo.H:75
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::functionObjects::fieldInfo::operator!=
friend bool operator!=(const fieldInfo &a, const fieldInfo &b)
Definition: fieldInfo.H:129
wordRe.H
Switch.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::fieldInfo::found
Switch & found() const
Definition: fieldInfo.H:116
Foam::functionObjects::fieldInfo::operator<<
friend Ostream & operator<<(Ostream &os, const fieldInfo &fi)
Definition: fieldInfo.H:142
label.H
Foam::readLabel
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
Definition: label.H:66
Foam::functionObjects::fieldInfo::component
label component() const
Definition: fieldInfo.H:111
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::functionObjects::fieldInfo::operator==
friend bool operator==(const fieldInfo &a, const fieldInfo &b)
Definition: fieldInfo.H:121
Foam::functionObjects::fieldInfo::operator>>
friend Istream & operator>>(Istream &is, fieldInfo &fi)
Definition: fieldInfo.H:137