evio  6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BaseStructureHeader.h
Go to the documentation of this file.
1 //
2 // Copyright 2020, Jefferson Science Associates, LLC.
3 // Subject to the terms in the LICENSE file found in the top-level directory.
4 //
5 // EPSCI Group
6 // Thomas Jefferson National Accelerator Facility
7 // 12000, Jefferson Ave, Newport News, VA 23606
8 // (757)-269-7100
9 
10 
11 #ifndef EVIO_6_0_BASESTRUCTUREHEADER_H
12 #define EVIO_6_0_BASESTRUCTUREHEADER_H
13 
14 
15 #include <vector>
16 #include <cstring>
17 #include <cstdint>
18 #include <sstream>
19 
20 
21 #include "Util.h"
22 #include "ByteOrder.h"
23 #include "DataType.h"
24 #include "EvioException.h"
25 
26 
27 namespace evio {
28 
40 
41  friend class BaseStructure;
42  friend class CompositeData;
43  friend class EvioReader;
44  friend class EvioReaderV4;
45  friend class EventHeaderParser;
46  friend class StructureTransformer;
47 
48  protected:
49 
54  uint32_t length = 0;
55 
57  uint32_t tag = 0;
58 
61 
67  uint8_t padding = 0;
68 
73  uint8_t number = 0;
74 
75  protected:
76 
77  void setPadding(uint8_t pad);
78  void copy(std::shared_ptr<BaseStructureHeader> const & head);
79 
80  public:
81 
82  BaseStructureHeader() = default;
83  BaseStructureHeader(uint16_t tag, DataType const & dataType, uint8_t num = 0);
84 
85  uint8_t getNumber() const;
86  void setNumber(uint8_t number);
87 
88  uint32_t getDataTypeValue() const;
89  void setDataType(uint32_t type);
90 
91  void setDataType(DataType const & type);
92  DataType getDataType() const;
93 
94  std::string getDataTypeName() const;
95  uint8_t getPadding() const;
96 
97  uint32_t getLength() const;
98  void setLength(uint32_t len);
99 
100  uint16_t getTag() const;
101  void setTag(uint16_t tag);
102 
103  virtual uint32_t getDataLength() {return 0;};
104  virtual uint32_t getHeaderLength() {return 0;};
105  virtual std::string toString() {return "BaseStructureHeader";};
106 
107  virtual size_t write(std::shared_ptr<ByteBuffer> & dest) {return 0;}
108  virtual size_t write(ByteBuffer & dest) {return 0;};
109  virtual size_t write(uint8_t *dest, ByteOrder const & order) {return 0;};
110 
111  };
112 }
113 
114 #endif //EVIO_6_0_BASESTRUCTUREHEADER_H
This class is copied from one of the same name in the Java programming language.
Definition: ByteBuffer.h:42
void setPadding(uint8_t pad)
Set the amount of padding bytes when storing short or byte data.
Definition: BaseStructureHeader.cpp:96
This is the base class for all evio structures: Banks, Segments, and TagSegments. ...
Definition: BaseStructure.h:347
void setNumber(uint8_t number)
Set the number.
Definition: BaseStructureHeader.cpp:51
virtual size_t write(std::shared_ptr< ByteBuffer > &dest)
Definition: BaseStructureHeader.h:107
virtual size_t write(uint8_t *dest, ByteOrder const &order)
Definition: BaseStructureHeader.h:109
Numerical values associated with endian byte order.
Definition: ByteOrder.h:53
std::string getDataTypeName() const
Returns the data type as a string.
Definition: BaseStructureHeader.cpp:82
virtual std::string toString()
Definition: BaseStructureHeader.h:105
The createXXX methods exist is in the EventParser class in the original Java, but must be moved in C+...
Definition: EventHeaderParser.h:40
uint32_t tag
The structure tag.
Definition: BaseStructureHeader.h:57
uint8_t getNumber() const
Get the number.
Definition: BaseStructureHeader.cpp:45
void copy(std::shared_ptr< BaseStructureHeader > const &head)
Method to copy data from the fiven header to this one.
Definition: BaseStructureHeader.cpp:33
uint32_t length
The length of the structure in 32-bit words.
Definition: BaseStructureHeader.h:54
This the header for the base structure (BaseStructure).
Definition: BaseStructureHeader.h:39
uint8_t number
The number represents an unsigned byte.
Definition: BaseStructureHeader.h:73
Definition: CompositeData.h:97
This class contains methods to transform structures from one type to another, for example...
Definition: StructureTransformer.h:38
Numerical values associated with evio data types.
Definition: DataType.h:32
static const DataType UNKNOWN32
Unknown data type.
Definition: DataType.h:36
uint8_t getPadding() const
Get the amount of padding bytes when storing short or byte data.
Definition: BaseStructureHeader.cpp:89
DataType dataType
The data type of the structure.
Definition: BaseStructureHeader.h:60
virtual uint32_t getHeaderLength()
Definition: BaseStructureHeader.h:104
DataType getDataType() const
Returns the data type for data stored in this structure as a DataType enum.
Definition: BaseStructureHeader.cpp:76
void setTag(uint16_t tag)
Set the structure tag.
Definition: BaseStructureHeader.cpp:120
uint8_t padding
The amount of padding bytes when storing short or byte data.
Definition: BaseStructureHeader.h:67
void setDataType(uint32_t type)
Set the numeric data type for the structure.
Definition: BaseStructureHeader.cpp:63
void setLength(uint32_t len)
Set the length of the structure in 32 bit ints, not counting the length word.
Definition: BaseStructureHeader.cpp:108
uint32_t getDataTypeValue() const
Get the data type for the structure.
Definition: BaseStructureHeader.cpp:57
uint16_t getTag() const
Get the structure tag.
Definition: BaseStructureHeader.cpp:114
uint32_t getLength() const
Get the length of the structure in 32 bit ints, not counting the length word.
Definition: BaseStructureHeader.cpp:102
This is a class of interest to the user.
Definition: EvioReaderV4.h:58
virtual size_t write(ByteBuffer &dest)
Definition: BaseStructureHeader.h:108
virtual uint32_t getDataLength()
Definition: BaseStructureHeader.h:103
This is a class of interest to the user.
Definition: EvioReader.h:52