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

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