ATLAS Offline Software
Loading...
Searching...
No Matches
Trigger
TrigAccel
TrigAccelEvent
TrigAccelEvent
DataExportBuffer.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef TRIGACCELEVENT_DATAEXPORTBUFFER_H
6
#define TRIGACCELEVENT_DATAEXPORTBUFFER_H
7
8
9
#include <string>
10
#include <fstream>
11
12
namespace
TrigAccel
{
13
14
typedef
struct
DataExportBuffer
{
15
public
:
16
DataExportBuffer
() :
m_size
(0),
m_buffer
(0) {};
17
DataExportBuffer
(
size_t
s) :
m_size
(s) {
18
m_buffer
=
new
char
[s];
19
}
20
~DataExportBuffer
() {
delete
[]
m_buffer
;}
21
22
// no copy/assign
23
DataExportBuffer
(
const
DataExportBuffer
&) =
delete
;
24
DataExportBuffer
&
operator=
(
const
DataExportBuffer
&) =
delete
;
25
26
inline
bool
fit
(
size_t
s) {
27
return
s<=
m_size
;
28
}
29
30
void
reallocate
(
size_t
s) {
31
delete
[]
m_buffer
;
32
m_buffer
=
new
char
[s];
33
m_size
= s;
34
}
35
36
void
save
(
const
std::string& name)
const
{
37
std::ofstream binFile(name, std::ios::binary);
38
binFile.write(
m_buffer
,
m_size
);
39
binFile.close();
40
}
41
42
size_t
load
(
const
std::string& name) {
43
std::ifstream binFile(name, std::ios::binary);
44
if
(!binFile) {
45
return
0;
46
}
47
binFile.seekg(0, binFile.end);
48
size_t
fileSize = binFile.tellg();
49
binFile.seekg (0, binFile.beg);
50
reallocate
(fileSize);
51
binFile.read(
m_buffer
,
m_size
);
52
binFile.close();
53
return
fileSize;
54
}
55
56
size_t
m_size
;
57
char
*
m_buffer
;
58
}
DATA_EXPORT_BUFFER
;
59
}
60
61
#endif
TrigAccel
Definition
DataExportBuffer.h:12
TrigAccel::DATA_EXPORT_BUFFER
struct TrigAccel::DataExportBuffer DATA_EXPORT_BUFFER
TrigAccel::DataExportBuffer::m_size
size_t m_size
Definition
DataExportBuffer.h:56
TrigAccel::DataExportBuffer::m_buffer
char * m_buffer
Definition
DataExportBuffer.h:57
TrigAccel::DataExportBuffer::~DataExportBuffer
~DataExportBuffer()
Definition
DataExportBuffer.h:20
TrigAccel::DataExportBuffer::load
size_t load(const std::string &name)
Definition
DataExportBuffer.h:42
TrigAccel::DataExportBuffer::reallocate
void reallocate(size_t s)
Definition
DataExportBuffer.h:30
TrigAccel::DataExportBuffer::DataExportBuffer
DataExportBuffer(size_t s)
Definition
DataExportBuffer.h:17
TrigAccel::DataExportBuffer::operator=
DataExportBuffer & operator=(const DataExportBuffer &)=delete
TrigAccel::DataExportBuffer::fit
bool fit(size_t s)
Definition
DataExportBuffer.h:26
TrigAccel::DataExportBuffer::DataExportBuffer
DataExportBuffer(const DataExportBuffer &)=delete
TrigAccel::DataExportBuffer::save
void save(const std::string &name) const
Definition
DataExportBuffer.h:36
TrigAccel::DataExportBuffer::DataExportBuffer
DataExportBuffer()
Definition
DataExportBuffer.h:16
Generated on
for ATLAS Offline Software by
1.14.0