OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
Timestamp.h
Go to the documentation of this file.
1//
2// Class Timestamp
3//
4// Copyright (c) 2010 - 2013, Yves Ineichen, ETH Zürich
5// All rights reserved
6//
7// Implemented as part of the PhD thesis
8// "Toward massively parallel multi-objective optimization with application to
9// particle accelerators" (https://doi.org/10.3929/ethz-a-009792359)
10//
11// This file is part of OPAL.
12//
13// OPAL is free software: you can redistribute it and/or modify
14// it under the terms of the GNU General Public License as published by
15// the Free Software Foundation, either version 3 of the License, or
16// (at your option) any later version.
17//
18// You should have received a copy of the GNU General Public License
19// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
20//
21#ifndef __TIMESTAMP_H__
22#define __TIMESTAMP_H__
23
24#include <sstream>
25#include <boost/chrono.hpp>
26#include <ctime>
27
29
30#include "mpi.h"
31
32class Timestamp : public TraceComponent {
33
34public:
35
36
38 : TraceComponent("Timestamp")
39 {}
40
41 void execute(std::ostringstream &dump) {
42
43 boost::chrono::time_point<boost::chrono::system_clock> now;
44 now = boost::chrono::system_clock::now();
45 std::time_t now_time = boost::chrono::system_clock::to_time_t(now);
46
47 std::ostringstream timestamp;
48 timestamp << std::ctime(&now_time);
49
50 prepend(dump, timestamp);
51 }
52
53 virtual ~Timestamp()
54 {}
55
56};
57
58#endif
Timestamp()
Definition: Timestamp.h:37
void execute(std::ostringstream &dump)
Definition: Timestamp.h:41
virtual ~Timestamp()
Definition: Timestamp.h:53
void prepend(std::ostringstream &dump, std::ostringstream &prepender)