Belle II Software  release-05-02-19
FieldProperty.h
1 #ifndef _Belle2_FieldProperty_hh
2 #define _Belle2_FieldProperty_hh
3 
4 #include <string>
5 #include <map>
6 #include <vector>
7 
8 namespace Belle2 {
14  namespace DBField {
15 
16  enum Type {
17  UNKNOWN = 0,
18  BOOL = 1,
19  CHAR,
20  SHORT,
21  INT,
22  LONG,
23  FLOAT,
24  DOUBLE,
25  TEXT,
26  OBJECT
27  };
28 
29  class Property {
30 
31  public:
32  Property(): m_type(), m_length(0), m_offset(0) {}
33  Property(Type type, int length, int offset = 0)
34  : m_type(type), m_length(length), m_offset(offset) {}
35  Property(const Property& pro)
36  : m_type(pro.m_type), m_length(pro.m_length), m_offset(pro.m_offset) {}
37  ~Property() {}
38 
39  public:
40  Type getType() const { return m_type; }
41  int getLength() const { return m_length; }
42  int getOffset() const { return m_offset; }
43  void setType(Type type) { m_type = type; }
44  void setLength(int length) { m_length = length; }
45 
46  int getTypeSize() const
47  {
48  switch (m_type) {
49  case BOOL: return sizeof(bool);
50  case CHAR: return sizeof(char);
51  case SHORT: return sizeof(short);
52  case INT: return sizeof(int);
53  case LONG: return sizeof(long long);
54  case FLOAT: return sizeof(float);
55  case DOUBLE: return sizeof(double);
56  default: break;
57  }
58  return 0;
59  }
60 
61  const std::string getTypeText() const
62  {
63  switch (m_type) {
64  case BOOL: return "bool";
65  case CHAR: return "char";
66  case SHORT: return "short";
67  case INT: return "int";
68  case LONG: return "long";
69  case FLOAT: return "float";
70  case DOUBLE: return "double";
71  case TEXT: return "text";
72  case OBJECT: return "object";
73  default: break;
74  }
75  return "";
76  }
77 
78  private:
79  Type m_type;
80  int m_length;
81  int m_offset;
82 
83  };
84 
85  typedef std::vector<std::string> NameList;
86  typedef std::map<std::string, DBField::Property> PropertyList;
87 
88  }
89 
91 }
92 
93 #endif
Belle2::DBField::Property
Definition: FieldProperty.h:29
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19