QualityControl  1.5.1
O2 Data Quality Control Framework
MonitorObject.h
Go to the documentation of this file.
1 // Copyright CERN and copyright holders of ALICE O2. This software is
2 // distributed under the terms of the GNU General Public License v3 (GPL
3 // Version 3), copied verbatim in the file "COPYING".
4 //
5 // See http://alice-o2.web.cern.ch/license for full licensing information.
6 //
7 // In applying this license CERN does not waive the privileges and immunities
8 // granted to it by virtue of its status as an Intergovernmental Organization
9 // or submit itself to any jurisdiction.
10 
15 
16 #ifndef QC_CORE_MONITOROBJECT_H
17 #define QC_CORE_MONITOROBJECT_H
18 
19 // std
20 #include <string>
21 #include <map>
22 // ROOT
23 #include <Rtypes.h>
24 #include <TObject.h>
25 // O2
26 #include <Common/Exceptions.h>
27 
29 {
30 
32  const char* what() const noexcept override
33  {
34  return "Duplicate object error";
35  }
36 };
37 
41 class MonitorObject : public TObject
42 {
43  public:
45  MonitorObject();
46  MonitorObject(TObject* object, const std::string& taskName, const std::string& detectorName = "DET");
48  ~MonitorObject() override;
49 
51  MonitorObject(const MonitorObject& other) = default;
53  MonitorObject(MonitorObject&& other) /*noexcept*/ = default;
55  MonitorObject& operator=(const MonitorObject& other) = default;
57  MonitorObject& operator=(MonitorObject&& other) /*noexcept*/ = default;
58 
61  const std::string getName() const;
62 
65  const char* GetName() const override;
66 
69  const std::string getFullName() const { return getTaskName() + "/" + getName(); }
70 
71  TObject* getObject() const { return mObject; }
72 
73  void setObject(TObject* object) { mObject = object; }
74 
75  bool isIsOwner() const { return mIsOwner; }
76 
77  void setIsOwner(bool isOwner) { mIsOwner = isOwner; }
78 
79  const std::string& getTaskName() const { return mTaskName; }
80  void setTaskName(const std::string& taskName) { mTaskName = taskName; }
81 
82  const std::string& getDetectorName() const { return mDetectorName; }
83  void setDetectorName(const std::string& detectorName) { mDetectorName = detectorName; }
84 
88  void addMetadata(std::string key, std::string value);
92  void addMetadata(std::map<std::string, std::string> pairs);
95  void updateMetadata(std::string key, std::string value);
97  const std::map<std::string, std::string>& getMetadataMap() const;
99  void addOrUpdateMetadata(std::string key, std::string value);
100 
101  void Draw(Option_t* option) override;
102  TObject* DrawClone(Option_t* option) const override;
103 
107  std::string getPath() const;
108 
109  const std::string& getDescription() const;
110  void setDescription(const std::string& description);
111 
112  private:
113  TObject* mObject;
114  std::string mTaskName;
115  std::string mDetectorName;
116  std::map<std::string, std::string> mUserMetadata;
117  std::string mDescription;
118 
119  // indicates that we are the owner of mObject. It is the case by default. It is not the case when a task creates the
120  // object.
121  // TODO : maybe we should always be the owner ?
122  bool mIsOwner;
123 
124  ClassDefOverride(MonitorObject, 7);
125 };
126 
127 } // namespace o2::quality_control::core
128 
129 #endif // QC_CORE_MONITOROBJECT_H
const std::string getFullName() const
Return joined task name and name of the encapsulated object (if any).
Definition: MonitorObject.h:69
These methods can be used to build a complex processing topology. It spawns 3 separate dummy processi...
Definition: Activity.h:19
This class keeps the meta data about one published object.
Definition: MonitorObject.h:41