initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / global / clock / clock.H
blobed74dc01810d9089cc8602ed3143ebf677fbeb03
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::clock
28 Description
29     Read access to the system clock with formatting.
31 SourceFiles
32     clock.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef clock_H
37 #define clock_H
39 #include <ctime>
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 namespace Foam
46 class string;
48 /*---------------------------------------------------------------------------*\
49                            Class clock Declaration
50 \*---------------------------------------------------------------------------*/
52 class clock
54     // Private data
56         //- Start time in seconds
57         time_t startTime_;
59         //- Time when clockTimeIncrement() was last called
60         mutable time_t lastTime_;
62         //- Latest time from either elapsedClockTime() or clockTimeIncrement()
63         mutable time_t newTime_;
65         //- Names of the months
66         static const char *monthNames[];
69 public:
71     // Constructors
73         //- Null constructor which stores the start time
74         clock();
77     // Member Functions
79         //- Get the current clock time in seconds
80         static time_t getTime();
82         //- Return the current wall-clock date as a raw struct
83         static const struct tm rawDate();
85         //- Return the current wall-clock date/time as a string
86         //  format according to ISO-8601 (yyyy-mm-ddThh:mm:ss)
87         static string dateTime();
89         //- Return the current wall-clock date as a string
90         static string date();
92         //- Return the current wall-clock time as a string
93         static string clockTime();
95         //- Returns wall-clock time from clock instantiation
96         time_t elapsedClockTime() const;
98         //- Returns wall-clock time from last call of clockTimeIncrement()
99         time_t clockTimeIncrement() const;
103 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
105 } // End namespace Foam
107 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
109 #endif
111 // ************************************************************************* //