Belle II Software  release-08-01-10
FieldProperty.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 #ifndef _Belle2_FieldProperty_hh
9 #define _Belle2_FieldProperty_hh
10 
11 #include <string>
12 #include <map>
13 #include <vector>
14 
15 namespace Belle2 {
21  namespace DBField {
22 
23  enum Type {
24  UNKNOWN = 0,
25  BOOL = 1,
26  CHAR,
27  SHORT,
28  INT,
29  LONG,
30  FLOAT,
31  DOUBLE,
32  TEXT,
33  OBJECT
34  };
35 
36  class Property {
37 
38  public:
39  Property(): m_type(), m_length(0), m_offset(0) {}
40  Property(Type type, int length, int offset = 0)
41  : m_type(type), m_length(length), m_offset(offset) {}
42  Property(const Property& pro)
43  : m_type(pro.m_type), m_length(pro.m_length), m_offset(pro.m_offset) {}
44  ~Property() {}
45 
46  public:
47  Type getType() const { return m_type; }
48  int getLength() const { return m_length; }
49  int getOffset() const { return m_offset; }
50  void setType(Type type) { m_type = type; }
51  void setLength(int length) { m_length = length; }
52 
53  int getTypeSize() const
54  {
55  switch (m_type) {
56  case BOOL: return sizeof(bool);
57  case CHAR: return sizeof(char);
58  case SHORT: return sizeof(short);
59  case INT: return sizeof(int);
60  case LONG: return sizeof(long long);
61  case FLOAT: return sizeof(float);
62  case DOUBLE: return sizeof(double);
63  default: break;
64  }
65  return 0;
66  }
67 
68  const std::string getTypeText() const
69  {
70  switch (m_type) {
71  case BOOL: return "bool";
72  case CHAR: return "char";
73  case SHORT: return "short";
74  case INT: return "int";
75  case LONG: return "long";
76  case FLOAT: return "float";
77  case DOUBLE: return "double";
78  case TEXT: return "text";
79  case OBJECT: return "object";
80  default: break;
81  }
82  return "";
83  }
84 
85  private:
86  Type m_type;
87  int m_length;
88  int m_offset;
89 
90  };
91 
92  typedef std::vector<std::string> NameList;
93  typedef std::map<std::string, DBField::Property> PropertyList;
94 
95  }
96 
98 }
99 
100 #endif
Abstract base class for different kinds of events.