Belle II Software  release-08-01-10
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 
11 using namespace std;
12 using namespace Belle2;
13 
14 RawDataBlock::RawDataBlock()
15 {
16  m_access_dblk = new RawDataBlockFormat;
17 
18  m_nwords = 0;
19  m_use_prealloc_buf = 0;
20  m_buffer = NULL;
21  m_num_nodes = 0;
22  m_num_events = 0;
23 }
24 
25 RawDataBlock::~RawDataBlock()
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 
35 void 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
60  m_access_dblk->SetBuffer(m_buffer, m_nwords, 0, m_num_events, m_num_nodes);
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.
Abstract base class for different kinds of events.