BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
ArchiveDescriptor.h
Go to the documentation of this file.
1// Copyright 2013 Jan de Cuveland <cmail@cuveland.de>
2/// \file
3/// \brief Defines the fles::ArchiveDescriptor class.
4#ifndef FLES_ARCHIVEDESCRIPTOR_H
5#define FLES_ARCHIVEDESCRIPTOR_H
6
7#include "System.h"
8
9#include <boost/serialization/access.hpp>
10#include <boost/serialization/version.hpp>
11#include <chrono>
12#include <string>
13
14namespace fles
15{
16
17/// The archive type enum (e.g., timeslice, microslice)
23
24template<class Base, class Derived, ArchiveType archive_type>
26
27/**
28 * \brief The ArchiveDescriptor class contains metadata on an archive.
29 *
30 * This class class precedes a stream of serialized StorableTimeslice or
31 * StorableMicroslice objects.
32 */
34{
35 public:
36 /**
37 * \brief Public constructor.
38 *
39 * \param archive_type The type of archive (e.g., timeslice, microslice).
40 */
43 {
44 time_created_ = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
47 }
48
49 /// Retrieve the type of archive.
51
52 /// Retrieve the time of creation of the archive.
53 std::time_t time_created() const { return time_created_; }
54
55 /// Retrieve the hostname of the machine creating the archive.
56 std::string hostname() const { return hostname_; }
57
58 /// Retrieve the hostname of the machine creating the archive.
59 std::string username() const { return username_; }
60
61 private:
63 /// Provide boost serialization access.
64 template<class Base, class Derived, ArchiveType archive_type>
65 friend class InputArchive;
66 template<class Base, class Derived, ArchiveType archive_type>
67 friend class InputArchiveLoop;
68
70
71 template<class Archive>
72 void serialize(Archive& ar, const unsigned int version)
73 {
74 if (version > 0) {
75 ar & archive_type_;
76 } else {
78 };
79 ar & time_created_;
80 ar & hostname_;
81 ar & username_;
82 }
83
85 std::time_t time_created_ = std::time_t();
86 std::string hostname_;
87 std::string username_;
88};
89
90} // namespace fles
91
92#pragma GCC diagnostic push
93#pragma GCC diagnostic ignored "-Wold-style-cast"
94BOOST_CLASS_VERSION(fles::ArchiveDescriptor, 1)
95#pragma GCC diagnostic pop
96
97#endif // FLES_ARCHIVEDESCRIPTOR_H
The ArchiveDescriptor class contains metadata on an archive.
void serialize(Archive &ar, const unsigned int version)
std::string hostname() const
Retrieve the hostname of the machine creating the archive.
friend class boost::serialization::access
std::string username() const
Retrieve the hostname of the machine creating the archive.
friend class InputArchive
Provide boost serialization access.
ArchiveType archive_type() const
Retrieve the type of archive.
ArchiveDescriptor(ArchiveType archive_type)
Public constructor.
std::time_t time_created() const
Retrieve the time of creation of the archive.
Defines utility functions in the fles::system namespace.
std::string current_hostname()
Retrieve current host name.
std::string current_username()
Retrieve current user name.
Main FLES namespace.
ArchiveType
The archive type enum (e.g., timeslice, microslice).