objectHit.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) 2011 OpenFOAM Foundation
9  Copyright (C) 2017 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::objectHit
29 
30 Description
31  This class describes a combination of target object index and success flag.
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef objectHit_H
36 #define objectHit_H
37 
38 #include "bool.H"
39 #include "label.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class objectHit Declaration
48 \*---------------------------------------------------------------------------*/
49 
50 class objectHit
51 {
52  // Private data
53 
54  //- Hit success
55  bool hit_;
56 
57  //- Object of hit
58  label hitObject_;
59 
60 
61 public:
62 
63  // Constructors
64 
65  //- Construct null
66  objectHit()
67  :
68  hit_(false),
69  hitObject_(-1)
70  {}
71 
72  //- Construct from components
73  objectHit(const bool success, const label obj)
74  :
75  hit_(success),
76  hitObject_(obj)
77  {}
78 
79  //- Construct from Istream
80  objectHit(Istream& is)
81  :
82  hit_(readBool(is)),
83  hitObject_(readLabel(is))
84  {}
85 
86 
87  // Member Functions
88 
89  // Access
90 
91  //- Is there a hit
92  inline bool hit() const
93  {
94  return hit_;
95  }
96 
97  //- Return hit object
98  inline label hitObject() const
99  {
100  return hitObject_;
101  }
102 
103 
104  // Edit
105 
106  void setHit()
107  {
108  hit_ = true;
109  }
110 
111  void setMiss()
112  {
113  hit_ = false;
114  }
115 
116 
117  // Ostream operator
118 
119  inline friend Ostream& operator<<(Ostream& os, const objectHit& obj)
120  {
121  return os << obj.hit() << token::SPACE << obj.hitObject();
122  }
123 };
124 
125 
126 // Global Operators
127 
128 inline bool operator==(const objectHit& a, const objectHit& b)
129 {
130  return a.hit() == b.hit() && a.hitObject() == b.hitObject();
131 }
132 
133 
134 inline bool operator!=(const objectHit& a, const objectHit& b)
135 {
136  return !(a == b);
137 }
138 
139 
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 
142 } // End namespace Foam
143 
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 
146 #endif
147 
148 // ************************************************************************* //
success
bool success
Definition: LISASMDCalcMethod1.H:16
Foam::objectHit::objectHit
objectHit(Istream &is)
Construct from Istream.
Definition: objectHit.H:79
Foam::objectHit::setHit
void setHit()
Definition: objectHit.H:105
Foam::objectHit::setMiss
void setMiss()
Definition: objectHit.H:110
Foam::operator!=
bool operator!=(const eddy &a, const eddy &b)
Definition: eddy.H:235
Foam::objectHit::objectHit
objectHit()
Construct null.
Definition: objectHit.H:65
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
Foam::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::readBool
bool readBool(Istream &is)
Definition: bool.C:70
Foam::objectHit::hit
bool hit() const
Is there a hit.
Definition: objectHit.H:91
bool.H
System bool.
Foam::objectHit::operator<<
friend Ostream & operator<<(Ostream &os, const objectHit &obj)
Definition: objectHit.H:118
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
label.H
Foam::readLabel
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
Definition: label.H:70
Foam::objectHit::objectHit
objectHit(const bool success, const label obj)
Construct from components.
Definition: objectHit.H:72
Foam::token::SPACE
Space [isspace].
Definition: token.H:112
Foam::objectHit::hitObject
label hitObject() const
Return hit object.
Definition: objectHit.H:97
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::objectHit
This class describes a combination of target object index and success flag.
Definition: objectHit.H:49