Belle II Software  release-05-02-19
DBObject.h
1 #ifndef _Belle2_DBObject_hh
2 #define _Belle2_DBObject_hh
3 
4 #include <daq/slc/base/AbstractDBObject.h>
5 #include <daq/slc/base/StringUtil.h>
6 #include <daq/slc/base/Date.h>
7 
8 namespace Belle2 {
14  class DBObject : public AbstractDBObject {
15 
16  public:
17  typedef std::vector<DBObject> DBObjectList;
18  typedef std::map<std::string, void*> FieldValueList;
19  typedef std::map<std::string, std::string> FieldTextList;
20  typedef std::map<std::string, DBObjectList> FieldObjectList;
21 
22  public:
23  struct NameValue {
24  std::string name;
25  std::string value;
26  void* buf;
27  DBField::Type type;
28  };
29  typedef std::vector<NameValue> NameValueList;
30 
31  public:
32  DBObject();
33  DBObject(const std::string& path);
34  DBObject(const DBObject& obj);
35  virtual ~DBObject();
36  const DBObject& operator=(const DBObject& obj);
37 
38  public:
39  int getNObjects(const std::string& name) const;
40  DBObjectList& getObjects(const std::string& name);
41  const DBObjectList& getObjects(const std::string& name) const;
42  DBObject& getObject(const std::string& name, int i = 0);
43  const DBObject& getObject(const std::string& name, int i = 0) const;
44  void addObjects(const std::string& name, const DBObjectList& obj);
45  void addObject(const std::string& name, const DBObject& obj);
46 
47  public:
48  DBObject& operator()(const std::string& name, int index = 0)
49  {
50  return getObject(name, index);
51  }
52  const DBObject& operator()(const std::string& name, int index = 0) const
53  {
54  return getObject(name, index);
55  }
56 
57  public:
58  StringList getNameList(bool isfull) const;
59  void print(bool isfull = true) const;
60  const std::string sprint(bool isfull) const;
61  void printHTML(bool isfull = true) const;
62  const std::string printSQL(const std::string& table, int id) const;
63  void search(NameValueList& map, const std::string& name = "", bool isfull = true) const;
64  int getDate() const { return m_date; }
65  void setDate(const Date& date) { m_date = date.get(); }
66  void setDate(int date) { m_date = date; }
67 
68  public:
69  virtual const void* getValue(const std::string& name) const;
70  virtual const std::string& getText(const std::string& name) const;
71  virtual void addText(const std::string& name, const std::string& value);
72  virtual void addValue(const std::string& name, const void* value,
73  DBField::Type type, int length);
74  virtual void setValue(const std::string& name, const void* value, int length);
75 
76  public:
77  virtual void readObject(Reader& reader);
78  virtual void writeObject(Writer& writer) const;
79 
80  private:
81  FieldValueList m_value_m;
82  FieldTextList m_text_m;
83  FieldObjectList m_obj_v_m;
84  std::string m_empty;
85  int m_date;
86 
87  protected:
88  virtual void reset();
89 
90  private:
91  void copy(const DBObject& obj);
92 
93  };
94 
95  typedef std::vector<DBObject> DBObjectList;
96 
98 }
99 
100 #endif
Belle2::DBObject
Definition: DBObject.h:14
Belle2::AbstractDBObject
Definition: AbstractDBObject.h:18
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::DBObject::NameValue
Definition: DBObject.h:23