-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathDataChunk.h
More file actions
48 lines (44 loc) · 2.03 KB
/
DataChunk.h
File metadata and controls
48 lines (44 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#ifndef FRAMEWORK_DATACHUNK_H
#define FRAMEWORK_DATACHUNK_H
#include "MemoryResources/MemoryResources.h"
namespace o2
{
namespace framework
{
/// @class DataChunk A resizable buffer used with DPL's DataAllocator
/// DataChunk derives from std::vector with polymorphic allocator and forbids copying, the underlying
/// buffer is of type char and is through DPL and polymorphic memory resource directly allocated in the
/// message memory.
/// Since MessageContext returns the object by reference, the forbidden copy and assignment makes sure that
/// the code can not accidentally use a copy instead reference.
class DataChunk : public std::vector<char, o2::pmr::polymorphic_allocator<char>>
{
public:
// FIXME: want to have a general forwarding, but then the copy constructor is not deleted any more despite
// it's declared deleted
//template <typename... Args>
//DataChunk(T&& arg, Args&&... args) : std::vector<char, o2::pmr::polymorphic_allocator<char>>(std::forward<Args>(args)...)
//{
//}
// DataChunk is special and for the moment it's enough to declare the constructor with size and allocator
DataChunk(size_t size, const o2::pmr::polymorphic_allocator<char>& allocator) : std::vector<char, o2::pmr::polymorphic_allocator<char>>(size, allocator)
{
}
DataChunk(const DataChunk&) = delete;
DataChunk& operator=(const DataChunk&) = delete;
DataChunk(DataChunk&&) = default;
DataChunk& operator=(DataChunk&&) = default;
};
} // namespace framework
} // namespace o2
#endif // FRAMEWORK_DATACHUNK_H