DABC (Data Acquisition Backbone Core)  2.9.9
TextInput.h
Go to the documentation of this file.
1 // $Id: TextInput.h 4479 2020-04-15 14:30:52Z linev $
2 
3 /************************************************************
4  * The Data Acquisition Backbone Core (DABC) *
5  ************************************************************
6  * Copyright (C) 2009 - *
7  * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
8  * Planckstr. 1, 64291 Darmstadt, Germany *
9  * Contact: http://dabc.gsi.de *
10  ************************************************************
11  * This software can be used under the GPL license *
12  * agreements as stated in LICENSE.txt file *
13  * which is part of the distribution. *
14  ************************************************************/
15 
16 #ifndef MBS_TextInput
17 #define MBS_TextInput
18 
19 #ifndef DABC_DataIO
20 #include "dabc/DataIO.h"
21 #endif
22 
23 #include <fstream>
24 
25 #include <cstdint>
26 
27 namespace mbs {
28 
33  class TextInput : public dabc::FileInput {
34  protected:
35  std::string fDataFormat; // int32_t, uint32_t, float
36  int fNumData; // number of data entries in line
37  int fNumHeaderLines; // number of lines in header
38  int fCharBufferLength; // buffer for single string
39 
40  std::ifstream fFile;
41  char* fCharBuffer;
42  uint32_t fEventCounter;
43  int fFormatId; // 0 - float, 1 - int32_t, 2 - uint32_t
44  unsigned fDataUnitSize; // sizeof of single binary entry
45 
46  bool CloseFile();
47  bool OpenNextFile();
48 
49  public:
50  TextInput(const dabc::Url& url);
51  virtual ~TextInput();
52 
53  virtual bool Read_Init(const dabc::WorkerRef& wrk, const dabc::Command& cmd);
54 
55  virtual unsigned Read_Size();
56  virtual unsigned Read_Complete(dabc::Buffer& buf);
57 
58  virtual unsigned RawDataSize();
59  virtual unsigned FillRawData(const char* str, void* rawdata, unsigned maxsize);
60 
61  };
62 
63 }
64 
65 #endif
Reference on memory from memory pool.
Definition: Buffer.h:135
Represents command with its arguments.
Definition: Command.h:99
Interface for implementing file inputs.
Definition: DataIO.h:246
Uniform Resource Locator interpreter.
Definition: Url.h:33
Reference on dabc::Worker
Definition: Worker.h:466
Text LMD input.
Definition: TextInput.h:33
bool OpenNextFile()
Definition: TextInput.cxx:73
int fCharBufferLength
Definition: TextInput.h:38
std::ifstream fFile
Definition: TextInput.h:40
virtual unsigned Read_Complete(dabc::Buffer &buf)
Complete reading of the buffer from source,.
Definition: TextInput.cxx:110
uint32_t fEventCounter
Definition: TextInput.h:42
virtual unsigned RawDataSize()
Definition: TextInput.cxx:171
virtual bool Read_Init(const dabc::WorkerRef &wrk, const dabc::Command &cmd)
Initialize data input, using port and command.
Definition: TextInput.cxx:49
virtual unsigned FillRawData(const char *str, void *rawdata, unsigned maxsize)
Definition: TextInput.cxx:178
std::string fDataFormat
Definition: TextInput.h:35
unsigned fDataUnitSize
Definition: TextInput.h:44
char * fCharBuffer
Definition: TextInput.h:41
bool CloseFile()
Definition: TextInput.cxx:93
virtual ~TextInput()
Definition: TextInput.cxx:42
int fNumHeaderLines
Definition: TextInput.h:37
virtual unsigned Read_Size()
Defines required buffer size for next operation.
Definition: TextInput.cxx:100
TextInput(const dabc::Url &url)
Definition: TextInput.cxx:24
Support for MBS - standard GSI DAQ.
Definition: api.h:36