evio  6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StructureType.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_STRUCTUREYPE_H
12 #define EVIO_6_0_STRUCTUREYPE_H
13 
14 
15 #include <string>
16 
17 
18 namespace evio {
19 
20 
34  class StructureType {
35 
36  public:
37 
41  static const StructureType STRUCT_BANK;
42 
43  private:
44 
46  uint32_t value;
47 
49  uint32_t value2 = 0;
50 
52  std::string name;
53 
55  static StructureType intToType[33]; // 0x20 + 1 = 33
56 
58  static std::string names[33];
59 
66  StructureType(std::string name, uint32_t val, uint32_t val2=0) : name(std::move(name)), value(val), value2(val2) {}
67 
68  public:
69 
75  static const StructureType & getStructureType(uint32_t val) {
76  if (val > 0x20) return STRUCT_UNKNOWN32;
77  return intToType[val];
78  }
79 
85  static std::string getName(uint32_t val) {
86  if (val > 0x20) return "UNKNOWN32";
87  return getStructureType(val).names[val];
88  }
89 
95  static bool isBank(uint32_t type) {return (STRUCT_BANK.value == type || STRUCT_BANK.value2 == type);}
96 
102  static bool isSegment(uint32_t type) {return (STRUCT_SEGMENT.value == type || STRUCT_SEGMENT.value2 == type);}
103 
109  static bool isTagSegment(uint32_t type) {return (STRUCT_TAGSEGMENT.value == type);}
110 
111 
112 
117  const std::string & getName() const {return name;}
118 
123  uint32_t getValue() const {return value;}
124 
132  std::string toString() {return name;}
133 
138  bool isBank() {return (*this == STRUCT_BANK);}
139 
144  bool isSegment() {return (*this == STRUCT_SEGMENT);}
145 
150  bool isTagSegment() {return (*this == STRUCT_TAGSEGMENT);}
151 
152 
153  bool operator==(const StructureType &rhs) const;
154 
155  bool operator!=(const StructureType &rhs) const;
156  };
157 
158 }
159 
160 
161 #endif //EVIO_6_0_STRUCTUREYPE_H
static const StructureType & getStructureType(uint32_t val)
Get the object from the integer value.
Definition: StructureType.h:75
bool isTagSegment()
Convenience routine to see if &quot;this&quot; structure type is a tagsegment structure.
Definition: StructureType.h:150
static const StructureType STRUCT_TAGSEGMENT
Tag segment.
Definition: StructureType.h:39
static const StructureType STRUCT_BANK
Bank.
Definition: StructureType.h:41
bool operator!=(const StructureType &rhs) const
Definition: StructureType.cpp:21
bool isSegment()
Convenience routine to see if &quot;this&quot; structure type is a segment structure.
Definition: StructureType.h:144
static bool isTagSegment(uint32_t type)
Convenience method to see if the given integer arg represents a TAGSEGMENT.
Definition: StructureType.h:109
static const StructureType STRUCT_UNKNOWN32
Unknown data type.
Definition: StructureType.h:38
static bool isBank(uint32_t type)
Convenience method to see if the given integer arg represents a BANK.
Definition: StructureType.h:95
static const StructureType STRUCT_SEGMENT
Segment.
Definition: StructureType.h:40
const std::string & getName() const
Get the name associated with this structure type.
Definition: StructureType.h:117
bool operator==(const StructureType &rhs) const
Definition: StructureType.cpp:17
uint32_t getValue() const
Get the integer value associated with this structure type.
Definition: StructureType.h:123
static std::string getName(uint32_t val)
Get the name from the integer value.
Definition: StructureType.h:85
bool isBank()
Convenience routine to see if &quot;this&quot; structure type is a bank structure.
Definition: StructureType.h:138
Numerical values associated with evio structure types.
Definition: StructureType.h:34
std::string toString()
Return a string which is usually the same as the name of the enumerated value, except in the cases of...
Definition: StructureType.h:132
static bool isSegment(uint32_t type)
Convenience method to see if the given integer arg represents a SEGMENT.
Definition: StructureType.h:102