QualityControl  1.5.1
O2 Data Quality Control Framework
TaskInterface.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 
16 
17 #ifndef QC_CORE_TASKINTERFACE_H
18 #define QC_CORE_TASKINTERFACE_H
19 
20 #include <map>
21 #include <memory>
22 #include <string>
23 #include <unordered_map>
24 // O2
25 #include <Framework/InitContext.h>
26 #include <Framework/ProcessingContext.h>
27 #include <CCDB/CcdbApi.h>
28 // QC
32 
33 namespace o2::ccdb
34 {
35 class CcdbApi;
36 }
37 
38 class TObject;
39 
41 {
42 
54 {
55  public:
59  explicit TaskInterface(ObjectsManager* objectsManager);
60 
62  TaskInterface() = default;
63 
65  virtual ~TaskInterface() noexcept = default;
67  TaskInterface(const TaskInterface& other) = default;
69  TaskInterface(TaskInterface&& other) noexcept = default;
71  TaskInterface& operator=(const TaskInterface& other) = default;
73  TaskInterface& operator=(TaskInterface&& other) /* noexcept */ = default; // error with gcc if noexcept
74 
75  virtual void loadCcdb(std::string url) final;
76 
77  // Definition of the methods for the template method pattern
78  virtual void initialize(o2::framework::InitContext& ctx) = 0;
79  virtual void startOfActivity(Activity& activity) = 0;
80  virtual void startOfCycle() = 0;
81  virtual void monitorData(o2::framework::ProcessingContext& ctx) = 0;
82  virtual void endOfCycle() = 0;
83  virtual void endOfActivity(Activity& activity) = 0;
84  virtual void reset() = 0;
85 
86  // Setters and getters
87  void setObjectsManager(std::shared_ptr<ObjectsManager> objectsManager);
88  void setName(const std::string& name);
89  void setCustomParameters(const std::unordered_map<std::string, std::string>& parameters);
90  const std::string& getName() const;
91 
92  protected:
93  std::shared_ptr<ObjectsManager> getObjectsManager();
94  TObject* retrieveCondition(std::string path, std::map<std::string, std::string> metadata = {}, long timestamp = -1);
95  template <typename T>
96  T* retrieveConditionAny(std::string const& path, std::map<std::string, std::string> const& metadata = {},
97  long timestamp = -1) const;
98 
99  std::unordered_map<std::string, std::string> mCustomParameters;
100 
101  private:
102  // TODO should we rather have a global/singleton for the objectsManager ?
103  std::shared_ptr<ObjectsManager> mObjectsManager;
104  std::string mName;
105  std::shared_ptr<o2::ccdb::CcdbApi> mCcdbApi;
106 };
107 
108 template <typename T>
109 T* TaskInterface::retrieveConditionAny(std::string const& path, std::map<std::string, std::string> const& metadata,
110  long timestamp) const
111 {
112  if (mCcdbApi) {
113  return mCcdbApi->retrieveFromTFileAny<T>(path, metadata, timestamp);
114  } else {
115  ILOG(Error, Support) << "Trying to retrieve a condition, but CCDB API is not constructed." << ENDM;
116  return nullptr;
117  }
118 }
119 
120 } // namespace o2::quality_control::core
121 
122 #endif // QC_CORE_TASKINTERFACE_H
Keeps the list of encapsulated objects to publish and does the actual publication.
Definition: ObjectsManager.h:41
Skeleton of a QC task.
Definition: TaskInterface.h:53
Definition: TaskInterface.h:33
Dummy class that should be removed when there is the official one. This corresponds to a Run1/2 "run"...
Definition: Activity.h:25
These methods can be used to build a complex processing topology. It spawns 3 separate dummy processi...
Definition: Activity.h:19