QualityControl  1.5.1
O2 Data Quality Control Framework
Quality.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_QUALITY_H
17 #define QC_CORE_QUALITY_H
18 
19 #include <Rtypes.h>
20 #include <string>
21 #include <map>
22 
24 {
25 
29 class Quality
30 {
31  public:
33  Quality(unsigned int level = Quality::NullLevel, std::string name = "");
35  virtual ~Quality() = default;
36  // Copy constructor
37  Quality(const Quality& q);
38 
40  Quality(Quality&& other) /*noexcept*/ = default;
42  Quality& operator=(const Quality& other) = default;
44  Quality& operator=(Quality&& other) /*noexcept*/ = default;
45 
46  unsigned int getLevel() const;
47  const std::string& getName() const;
48 
49  static const Quality Null;
50  static const Quality Good;
51  static const Quality Medium;
52  static const Quality Bad;
53  static const unsigned int NullLevel;
54 
55  friend bool operator==(const Quality& lhs, const Quality& rhs)
56  {
57  return (lhs.getName() == rhs.getName() && lhs.getLevel() == rhs.getLevel());
58  }
59  friend bool operator!=(const Quality& lhs, const Quality& rhs) { return !operator==(lhs, rhs); }
60  friend std::ostream& operator<<(std::ostream& out, const Quality& q); // output
61 
68  bool isWorseThan(const Quality& quality) const { return this->mLevel > quality.getLevel(); }
75  bool isBetterThan(const Quality& quality) const { return this->mLevel < quality.getLevel(); }
76 
80  void addMetadata(std::string key, std::string value);
84  void addMetadata(std::map<std::string, std::string> pairs);
87  void updateMetadata(std::string key, std::string value);
89  const std::map<std::string, std::string>& getMetadataMap() const;
91  void overwriteMetadata(std::map<std::string, std::string> pairs);
95  const std::string getMetadata(std::string key);
96 
97  private:
98  unsigned int mLevel;
99  std::string mName;
100  std::map<std::string, std::string> mUserMetadata;
101 
102  ClassDef(Quality, 2);
103 };
104 
105 } // namespace o2::quality_control::core
106 
107 #endif // QC_CORE_QUALITY_H
virtual ~Quality()=default
Destructor.
Quality(unsigned int level=Quality::NullLevel, std::string name="")
Default constructor.
bool isWorseThan(const Quality &quality) const
Checks whether this quality object is worse than another one. If compared to Null it returns false...
Definition: Quality.h:68
Class representing the quality of a MonitorObject.
Definition: Quality.h:29
void updateMetadata(std::string key, std::string value)
Update the value of metadata. If the key does not exist it will ignore it.
bool isBetterThan(const Quality &quality) const
Checks whether this quality object is better than another one. If compared to Null it returns false...
Definition: Quality.h:75
const std::string getMetadata(std::string key)
Get a metadata.
void overwriteMetadata(std::map< std::string, std::string > pairs)
Overwrite the existing metadata.
Quality & operator=(const Quality &other)=default
Copy assignment operator.
These methods can be used to build a complex processing topology. It spawns 3 separate dummy processi...
Definition: Activity.h:19
const std::map< std::string, std::string > & getMetadataMap() const
Get the full map of user&#39;s metadata.
void addMetadata(std::string key, std::string value)
Add key value pair that will end up in the database Add a metadata (key value pair) to the QualityObj...