BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
StorableMicroslice.h
Go to the documentation of this file.
1// Copyright 2015 Jan de Cuveland <cmail@cuveland.de>
2/// \file
3/// \brief Defines the fles::StorableMicroslice class.
4#ifndef FLES_STORABLEMICROSLICE_H
5#define FLES_STORABLEMICROSLICE_H
6
7#include "ArchiveDescriptor.h"
8#include "Microslice.h"
10
11#include <boost/serialization/access.hpp>
12#include <boost/serialization/vector.hpp>
13#include <fstream>
14#include <vector>
15// Note: <fstream> has to precede boost/serialization includes for non-obvious
16// reasons to avoid segfault similar to
17// http://lists.debian.org/debian-hppa/2009/11/msg00069.html
18
19namespace fles
20{
21
22template<class Base, class Derived, ArchiveType archive_type>
23class InputArchive;
24template<class Base, class Derived, ArchiveType archive_type>
26
27/**
28 * \brief The StorableMicroslice class contains the data of a single microslice.
29 *
30 * Both metadata and content are stored within the object.
31 */
33{
34 public:
35 /// Copy constructor.
37 /// Delete assignment operator (not implemented).
38 void operator=(const StorableMicroslice&) = delete;
39 /// Move constructor.
41
42 /// Construct by copying from given Microslice object.
44
45 /**
46 * \brief Construct by copying from given data array.
47 *
48 * Copy the descriptor and the data pointed to by `content` into the
49 * StorableMicroslice. The `size` field of the descriptor must already
50 * be valid and will not be modified.
51 */
52 StorableMicroslice(MicrosliceDescriptor d, const uint8_t* content_p);
53
54 /**
55 * \brief Construct by copying from given data vector.
56 *
57 * Copy the descriptor and copy or move the data contained in
58 * `content` into the StorableMicroslice. The descriptor will be
59 * updated to match the size of the `content` vector.
60 *
61 * Copying the vector is avoided if it is passed as an rvalue,
62 * like in:
63 *
64 * StorableMicroslice {..., std::move(some_vector)}
65 * StorableMicroslice {..., {1, 2, 3, 4, 5}}
66 * StorableMicroslice {..., create_some_vector()}
67 */
68 StorableMicroslice(MicrosliceDescriptor d, std::vector<uint8_t> content_v);
69
70 /// Retrieve non-const microslice descriptor reference
72
73 /// Retrieve a non-const pointer to the microslice data
74 uint8_t* content() { return content_ptr_; }
75
77
78 private:
81 friend class InputArchiveLoop<Microslice, StorableMicroslice, ArchiveType::MicrosliceArchive>;
82
84
85 template<class Archive>
86 void serialize(Archive& ar, const unsigned int /* version */)
87 {
88 ar & desc_;
89 ar & content_;
90
92 }
93
95 {
97 content_ptr_ = content_.data();
98 }
99
101 std::vector<uint8_t> content_;
102};
103
104} // namespace fles
105
106#endif // FLES_STORABLEMICROSLICE_H
Microslice()=default
uint8_t * content_ptr_
Pointer to the microslice data content.
Definition Microslice.h:55
MicrosliceDescriptor * desc_ptr_
Pointer to the microslice descriptor.
Definition Microslice.h:52
StorableMicroslice(const StorableMicroslice &ms)
Copy constructor.
MicrosliceDescriptor desc_
MicrosliceDescriptor & desc()
Retrieve non-const microslice descriptor reference.
friend class boost::serialization::access
void operator=(const StorableMicroslice &)=delete
Delete assignment operator (not implemented).
void serialize(Archive &ar, const unsigned int)
StorableMicroslice(StorableMicroslice &&ms) noexcept
Move constructor.
std::vector< uint8_t > content_
uint8_t * content()
Retrieve a non-const pointer to the microslice data.
StorableMicroslice(MicrosliceDescriptor d, std::vector< uint8_t > content_v)
Construct by copying from given data vector.
StorableMicroslice(MicrosliceDescriptor d, const uint8_t *content_p)
Construct by copying from given data array.
StorableMicroslice(const Microslice &ms)
Construct by copying from given Microslice object.
Defines the fles::ArchiveDescriptor class.
Defines the fles::MicrosliceDescriptor struct and corresponding enums.
Defines the fles::Microslice abstract base class.
Main FLES namespace.
ArchiveType
The archive type enum (e.g., timeslice, microslice).
Microslice descriptor struct.