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