OpenFOAM logo
Open Source CFD Toolkit

objectHit.H

Go 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-2005 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     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 /*---------------------------------------------------------------------------*\
00045                            Class objectHit Declaration
00046 \*---------------------------------------------------------------------------*/
00047 
00048 class objectHit
00049 {
00050     // Private data
00051 
00052         //- Hit success
00053         bool hit_;
00054 
00055         //- Object of hit
00056         label hitObject_;
00057 
00058 
00059 public:
00060 
00061     // Constructors
00062 
00063         //- Construct null
00064         objectHit()
00065         :
00066             hit_(false),
00067             hitObject_(-1)
00068         {}
00069 
00070         //- Construct from components
00071         objectHit(const bool success, const label& obj)
00072         :
00073             hit_(success),
00074             hitObject_(obj)
00075         {}
00076 
00077         //- Construct from Istream
00078         objectHit(Istream& is)
00079         :
00080             hit_(readBool(is)),
00081             hitObject_(readLabel(is))
00082         {}
00083 
00084 
00085     // Member Functions
00086 
00087         //- Is there a hit
00088         bool hit() const
00089         {
00090             return hit_;
00091         }
00092 
00093         //- Return hit object
00094         label hitObject() const
00095         {
00096             return hitObject_;
00097         }
00098 
00099 
00100     // Friend Operators
00101 
00102         inline friend bool operator==(const objectHit& a, const objectHit& b)
00103         {
00104             return ((a.hit_ == b.hit_) && (a.hitObject_ == b.hitObject_));
00105         }
00106             
00107         inline friend bool operator!=(const objectHit& a, const objectHit& b)
00108         {
00109             return (!(a == b));
00110         }
00111 
00112 
00113     // Ostream operator
00114 
00115         friend Ostream& operator<<(Ostream& os, const objectHit& b)
00116         {
00117              return os << b.hit() << token::SPACE << b.hitObject();
00118         }
00119 };
00120 
00121 
00122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00123 
00124 } // End namespace Foam
00125 
00126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00127 
00128 #endif
00129 
00130 // ************************************************************************* //
For further information go to www.openfoam.org