Belle II Software development
RawDataBlock.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <rawdata/dataobjects/RawDataBlock.h>
10
11using namespace std;
12using namespace Belle2;
13
15{
17
18 m_nwords = 0;
20 m_buffer = NULL;
21 m_num_nodes = 0;
22 m_num_events = 0;
23}
24
26{
27 if (m_access_dblk != NULL) delete m_access_dblk;
28 m_access_dblk = NULL;
29
30 if (!m_use_prealloc_buf && m_buffer != NULL) {
31 delete[] m_buffer;
32 }
33}
34
35void RawDataBlock::SetBuffer(int* bufin, int nwords, int delete_flag, int num_events, int num_nodes)
36{
37
38 if (bufin == NULL) {
39 char err_buf[500];
40 sprintf(err_buf, "[DEBUG] bufin is NULL. Exting...\n");
41 printf("%s", err_buf); fflush(stdout);
42 B2FATAL(err_buf);
43 }
44
45 if (!m_use_prealloc_buf && m_buffer != NULL) delete[] m_buffer;
46
47 if (delete_flag == 0) {
48 m_use_prealloc_buf = true;
49 } else {
50 m_use_prealloc_buf = false;
51 }
52 // m_nwords = bufin[0];
53 m_nwords = nwords;
54 m_buffer = bufin;
55
56 m_num_nodes = num_nodes;
57 m_num_events = num_events;
58
59 // Set to access class
61
62 // Set length at the first word of the buffer
63 //
64 // Assign header and trailer
65 //
66 // m_header.SetBuffer(&(bufin[ 0 ]));
67 // m_trailer.SetBuffer(&(bufin[ m_nwords - m_trailer.GetTrlNwords() ]));
68
69}
The RawDataBlockFormat class Format information for rawdata handling.
virtual void SetBuffer(int *bufin, int nwords, int delete_flag, int num_events, int num_nodes)
set buffer ( delete_flag : m_buffer is freeed( = 0 )/ not freeed( = 1 ) in Destructer )
int m_num_events
number of events in this object
Definition: RawDataBlock.h:151
int m_num_nodes
number of nodes in this object
Definition: RawDataBlock.h:148
int m_use_prealloc_buf
flag for deleting m_buffer in destructer( 0:delete, 1: not delete) When using pre-allocated buffer,...
Definition: RawDataBlock.h:158
int * m_buffer
Buffer.
Definition: RawDataBlock.h:154
virtual void SetBuffer(int *bufin, int nwords, int delete_flag, int num_events, int num_nodes)
set buffer ( delete_flag : m_buffer is freeed( = 0 )/ not freeed( = 1 ) in Destructer )
Definition: RawDataBlock.cc:35
RawDataBlock()
Default constructor.
Definition: RawDataBlock.cc:14
virtual ~RawDataBlock()
Destructor.
Definition: RawDataBlock.cc:25
int m_nwords
do not record
Definition: RawDataBlock.h:145
RawDataBlockFormat * m_access_dblk
class to access
Definition: RawDataBlock.h:141
Abstract base class for different kinds of events.
STL namespace.