|
|
|
objectHit.HGo 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-2009 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 the 00013 Free Software Foundation; either version 2 of the License, or (at your 00014 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, write to the Free Software Foundation, 00023 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00024 00025 Class 00026 Foam::objectHit 00027 00028 Description 00029 This class describes a combination of target object index and success flag. 00030 00031 \*---------------------------------------------------------------------------*/ 00032 00033 #ifndef objectHit_H 00034 #define objectHit_H 00035 00036 #include "bool.H" 00037 #include "label.H" 00038 00039 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00040 00041 namespace Foam 00042 { 00043 00044 // Forward declaration of friend functions and operators 00045 00046 class objectHit; 00047 inline bool operator==(const objectHit& a, const objectHit& b); 00048 inline bool operator!=(const objectHit& a, const objectHit& b); 00049 inline Ostream& operator<<(Ostream& os, const objectHit& b); 00050 00051 00052 /*---------------------------------------------------------------------------*\ 00053 Class objectHit Declaration 00054 \*---------------------------------------------------------------------------*/ 00055 00056 class objectHit 00057 { 00058 // Private data 00059 00060 //- Hit success 00061 bool hit_; 00062 00063 //- Object of hit 00064 label hitObject_; 00065 00066 00067 public: 00068 00069 // Constructors 00070 00071 //- Construct null 00072 objectHit() 00073 : 00074 hit_(false), 00075 hitObject_(-1) 00076 {} 00077 00078 //- Construct from components 00079 objectHit(const bool success, const label& obj) 00080 : 00081 hit_(success), 00082 hitObject_(obj) 00083 {} 00084 00085 //- Construct from Istream 00086 objectHit(Istream& is) 00087 : 00088 hit_(readBool(is)), 00089 hitObject_(readLabel(is)) 00090 {} 00091 00092 00093 // Member Functions 00094 00095 //- Is there a hit 00096 bool hit() const 00097 { 00098 return hit_; 00099 } 00100 00101 //- Return hit object 00102 label hitObject() const 00103 { 00104 return hitObject_; 00105 } 00106 00107 00108 // Friend Operators 00109 00110 friend bool operator==(const objectHit& a, const objectHit& b) 00111 { 00112 return ((a.hit_ == b.hit_) && (a.hitObject_ == b.hitObject_)); 00113 } 00114 00115 friend bool operator!=(const objectHit& a, const objectHit& b) 00116 { 00117 return (!(a == b)); 00118 } 00119 00120 00121 // Ostream operator 00122 00123 friend Ostream& operator<<(Ostream& os, const objectHit& b) 00124 { 00125 return os << b.hit() << token::SPACE << b.hitObject(); 00126 } 00127 }; 00128 00129 00130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00131 00132 } // End namespace Foam 00133 00134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00135 00136 #endif 00137 00138 // ************************************************************************* // |