OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

instant.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-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::instant
00027 
00028 Description
00029     An instant of time. Contains the time value and name.
00030 
00031 SourceFiles
00032     instant.C
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef instant_H
00037 #define instant_H
00038 
00039 #include "word.H"
00040 #include "scalar.H"
00041 
00042 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00043 
00044 namespace Foam
00045 {
00046 
00047 // Forward declaration of friend functions and operators
00048 
00049 class instant;
00050 
00051 // Friend Operators
00052 
00053 bool operator==(const instant&, const instant&);
00054 bool operator!=(const instant&, const instant&);
00055 
00056 // IOstream Operators
00057 
00058 Istream& operator>>(Istream&, instant&);
00059 Ostream& operator<<(Ostream&, const instant&);
00060 
00061 
00062 /*---------------------------------------------------------------------------*\
00063                            Class instant Declaration
00064 \*---------------------------------------------------------------------------*/
00065 
00066 class instant
00067 {
00068     // Private data
00069 
00070         scalar value_;
00071         word name_;
00072 
00073 public:
00074 
00075     // Public classes
00076 
00077         //- Less function class used in sorting instants
00078         class less
00079         {
00080         public:
00081 
00082             bool operator()(const instant& a, const instant& b) const
00083             {
00084                 return a.value() < b.value();
00085             }
00086         };
00087 
00088 
00089     // Static data members
00090 
00091         static const char* const typeName;
00092 
00093 
00094     // Constructors
00095 
00096         //- Construct null
00097         instant();
00098 
00099         //- Construct from components
00100         instant(const scalar, const word&);
00101 
00102         //- Construct from time value
00103         instant(const scalar);
00104 
00105         //- Construct from word
00106         instant(const word&);
00107 
00108 
00109     // Member Functions
00110 
00111         // Access
00112 
00113             //- Value (const access)
00114             scalar value() const
00115             {
00116                 return value_;
00117             }
00118 
00119             //- Value (non-const access)
00120             scalar& value()
00121             {
00122                 return value_;
00123             }
00124 
00125             //- Name (const access)
00126             const word& name() const
00127             {
00128                 return name_;
00129             }
00130 
00131             //- Name (non-const access)
00132             word& name()
00133             {
00134                 return name_;
00135             }
00136 
00137 
00138     // Friend Operators
00139 
00140         friend bool operator==(const instant&, const instant&);
00141         friend bool operator!=(const instant&, const instant&);
00142 
00143 
00144     // IOstream Operators
00145 
00146         friend Istream& operator>>(Istream&, instant&);
00147         friend Ostream& operator<<(Ostream&, const instant&);
00148 };
00149 
00150 
00151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00152 
00153 } // End namespace Foam
00154 
00155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00156 
00157 #endif
00158 
00159 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd