evio  6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HeaderType.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_HEADERTYPE_H
12 #define EVIO_6_0_HEADERTYPE_H
13 
14 
15 #include <string>
16 
17 
18 namespace evio {
19 
20 
32  class HeaderType {
33 
34  public:
35 
36  static const HeaderType EVIO_RECORD;
37  static const HeaderType EVIO_FILE;
39  static const HeaderType EVIO_TRAILER;
40  static const HeaderType HIPO_RECORD;
41  static const HeaderType HIPO_FILE;
43  static const HeaderType HIPO_TRAILER;
44  static const HeaderType UNKNOWN;
45 
46  private:
47 
49  static HeaderType intToType[16];
50 
52  static std::string names[16];
53 
55  uint32_t value;
56 
58  std::string name;
59 
60 
61  private:
62 
68  HeaderType(uint32_t val, std::string name) : value(val), name(std::move(name)) {}
69 
70  public:
71 
76  std::string getName() const {return name;}
77 
82  uint32_t getValue() const {return value;}
83 
88  bool isEvioFileHeader() const {return (*this == EVIO_FILE || *this == EVIO_FILE_EXTENDED);}
89 
94  bool isHipoFileHeader() const {return (*this == HIPO_FILE || *this == HIPO_FILE_EXTENDED);}
95 
100  bool isFileHeader() const {return (isEvioFileHeader() | isHipoFileHeader());}
101 
106  bool isTrailer() const {return (*this == EVIO_TRAILER || *this == HIPO_TRAILER);}
107 
113  static const HeaderType & getHeaderType(uint32_t val) {
114  if (val > 7) return UNKNOWN;
115  return intToType[val];
116  }
117 
123  static std::string getName(uint32_t val) {
124  if (val > 7) return "UNKNOWN";
125  return getHeaderType(val).names[val];
126  }
127 
128  bool operator==(const HeaderType &rhs) const;
129 
130  bool operator!=(const HeaderType &rhs) const;
131  };
132 
133 }
134 
135 
136 #endif //EVIO_6_0_HEADERTYPE_H
static const HeaderType HIPO_FILE
Header for an hipo file.
Definition: HeaderType.h:41
static const HeaderType UNKNOWN
Unknown header.
Definition: HeaderType.h:44
static const HeaderType EVIO_RECORD
Header for a general evio record.
Definition: HeaderType.h:36
static const HeaderType & getHeaderType(uint32_t val)
Get the object from the integer value.
Definition: HeaderType.h:113
bool isHipoFileHeader() const
Is this a HIPO file header?
Definition: HeaderType.h:94
static const HeaderType EVIO_TRAILER
Header for an evio trailer record.
Definition: HeaderType.h:39
static std::string getName(uint32_t val)
Get the name from the integer value.
Definition: HeaderType.h:123
uint32_t getValue() const
Get the integer value associated with this header type.
Definition: HeaderType.h:82
static const HeaderType EVIO_FILE_EXTENDED
Header for an extended evio file.
Definition: HeaderType.h:38
static const HeaderType HIPO_TRAILER
Header for an hipo trailer record.
Definition: HeaderType.h:43
static const HeaderType HIPO_FILE_EXTENDED
Header for an extended hipo file.
Definition: HeaderType.h:42
static const HeaderType EVIO_FILE
Header for an evio file.
Definition: HeaderType.h:37
bool isFileHeader() const
Is this a file header?
Definition: HeaderType.h:100
std::string getName() const
Get the object name.
Definition: HeaderType.h:76
static const HeaderType HIPO_RECORD
Header for a general hipo record.
Definition: HeaderType.h:40
bool operator!=(const HeaderType &rhs) const
Definition: HeaderType.cpp:21
bool isEvioFileHeader() const
Is this an evio file header?
Definition: HeaderType.h:88
bool isTrailer() const
Is this a trailer?
Definition: HeaderType.h:106
Numerical values associated with types of a file or record header.
Definition: HeaderType.h:32
bool operator==(const HeaderType &rhs) const
Definition: HeaderType.cpp:17