|
|
|
clock.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::clock 00027 00028 Description 00029 Read access to the system clock with formatting. 00030 00031 SourceFiles 00032 clock.C 00033 00034 \*---------------------------------------------------------------------------*/ 00035 00036 #ifndef clock_H 00037 #define clock_H 00038 00039 #include <ctime> 00040 00041 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00042 00043 namespace Foam 00044 { 00045 00046 class string; 00047 00048 /*---------------------------------------------------------------------------*\ 00049 Class clock Declaration 00050 \*---------------------------------------------------------------------------*/ 00051 00052 class clock 00053 { 00054 // Private data 00055 00056 //- Start time in seconds 00057 time_t startTime_; 00058 00059 //- Time when clockTimeIncrement() was last called 00060 mutable time_t lastTime_; 00061 00062 //- Latest time from either elapsedClockTime() or clockTimeIncrement() 00063 mutable time_t newTime_; 00064 00065 //- Names of the months 00066 static const char *monthNames[]; 00067 00068 00069 public: 00070 00071 // Constructors 00072 00073 //- Null constructor which stores the start time 00074 clock(); 00075 00076 00077 // Member Functions 00078 00079 //- Get the current clock time in seconds 00080 static time_t getTime(); 00081 00082 //- Return the current wall-clock date as a raw struct 00083 static const struct tm rawDate(); 00084 00085 //- Return the current wall-clock date/time as a string 00086 // format according to ISO-8601 (yyyy-mm-ddThh:mm:ss) 00087 static string dateTime(); 00088 00089 //- Return the current wall-clock date as a string 00090 static string date(); 00091 00092 //- Return the current wall-clock time as a string 00093 static string clockTime(); 00094 00095 //- Returns wall-clock time from clock instantiation 00096 time_t elapsedClockTime() const; 00097 00098 //- Returns wall-clock time from last call of clockTimeIncrement() 00099 time_t clockTimeIncrement() const; 00100 }; 00101 00102 00103 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00104 00105 } // End namespace Foam 00106 00107 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00108 00109 #endif 00110 00111 // ************************************************************************* // |