BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
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
14
namespace
fles
15
{
16
17
/// The archive type enum (e.g., timeslice, microslice)
18
enum class
ArchiveType
19
{
20
TimesliceArchive
,
21
MicrosliceArchive
22
};
23
24
template
<
class
Base,
class
Derived, ArchiveType archive_type>
25
class
InputArchive;
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
*/
33
class
ArchiveDescriptor
34
{
35
public
:
36
/**
37
* \brief Public constructor.
38
*
39
* \param archive_type The type of archive (e.g., timeslice, microslice).
40
*/
41
explicit
ArchiveDescriptor
(
ArchiveType
archive_type
)
42
:
archive_type_
(
archive_type
)
43
{
44
time_created_
= std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
45
hostname_
=
fles::system::current_hostname
();
46
username_
=
fles::system::current_username
();
47
}
48
49
/// Retrieve the type of archive.
50
ArchiveType
archive_type
()
const
{
return
archive_type_
; }
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
:
62
friend
class
boost::serialization::access;
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
69
ArchiveDescriptor
() {};
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
{
77
archive_type_
=
ArchiveType::TimesliceArchive
;
78
};
79
ar &
time_created_
;
80
ar &
hostname_
;
81
ar &
username_
;
82
}
83
84
ArchiveType
archive_type_
;
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"
94
BOOST_CLASS_VERSION(
fles::ArchiveDescriptor
, 1)
95
#pragma GCC diagnostic pop
96
97
#endif
// FLES_ARCHIVEDESCRIPTOR_H
fles::ArchiveDescriptor
The ArchiveDescriptor class contains metadata on an archive.
Definition
ArchiveDescriptor.h:34
fles::ArchiveDescriptor::serialize
void serialize(Archive &ar, const unsigned int version)
Definition
ArchiveDescriptor.h:72
fles::ArchiveDescriptor::username_
std::string username_
Definition
ArchiveDescriptor.h:87
fles::ArchiveDescriptor::hostname
std::string hostname() const
Retrieve the hostname of the machine creating the archive.
Definition
ArchiveDescriptor.h:56
fles::ArchiveDescriptor::InputArchiveLoop
friend class InputArchiveLoop
Definition
ArchiveDescriptor.h:67
fles::ArchiveDescriptor::username
std::string username() const
Retrieve the hostname of the machine creating the archive.
Definition
ArchiveDescriptor.h:59
fles::ArchiveDescriptor::ArchiveDescriptor
ArchiveDescriptor()
Definition
ArchiveDescriptor.h:69
fles::ArchiveDescriptor::InputArchive
friend class InputArchive
Provide boost serialization access.
Definition
ArchiveDescriptor.h:65
fles::ArchiveDescriptor::archive_type_
ArchiveType archive_type_
Definition
ArchiveDescriptor.h:84
fles::ArchiveDescriptor::hostname_
std::string hostname_
Definition
ArchiveDescriptor.h:86
fles::ArchiveDescriptor::archive_type
ArchiveType archive_type() const
Retrieve the type of archive.
Definition
ArchiveDescriptor.h:50
fles::ArchiveDescriptor::ArchiveDescriptor
ArchiveDescriptor(ArchiveType archive_type)
Public constructor.
Definition
ArchiveDescriptor.h:41
fles::ArchiveDescriptor::time_created_
std::time_t time_created_
Definition
ArchiveDescriptor.h:85
fles::ArchiveDescriptor::time_created
std::time_t time_created() const
Retrieve the time of creation of the archive.
Definition
ArchiveDescriptor.h:53
System.h
Defines utility functions in the fles::system namespace.
fles::system::current_hostname
std::string current_hostname()
Retrieve current host name.
fles::system::current_username
std::string current_username()
Retrieve current user name.
fles
Main FLES namespace.
Definition
ArchiveDescriptor.h:15
fles::ArchiveType
ArchiveType
The archive type enum (e.g., timeslice, microslice).
Definition
ArchiveDescriptor.h:19
fles::ArchiveType::TimesliceArchive
@ TimesliceArchive
Definition
ArchiveDescriptor.h:20
fles::ArchiveType::MicrosliceArchive
@ MicrosliceArchive
Definition
ArchiveDescriptor.h:21
install
include
ArchiveDescriptor.h
Generated on
for BmnRoot by
1.17.0