FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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