QualityControl  1.5.1
O2 Data Quality Control Framework
Triggers.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 QUALITYCONTROL_TRIGGERS_H
17 #define QUALITYCONTROL_TRIGGERS_H
18 
19 #include <string>
20 #include <functional>
21 #include <iosfwd>
22 
24 {
25 
26 // todo: implement the rest
29  No = 0, // casts to boolean false
30  Once, // triggers only first time it is asked
31  Always, // triggers always
32  StartOfRun,
33  EndOfRun,
34  StartOfFill,
35  EndOfFill,
36  Periodic,
37  NewObject,
38  UserOrControl, // reacts start and stop transitions (not an update trigger).
39  INVALID
40 };
41 
42 struct Trigger {
43 
45  Trigger(TriggerType triggerType) : triggerType(triggerType), timestamp(msSinceEpoch()){};
47  Trigger(TriggerType triggerType, uint64_t timestamp) : triggerType(triggerType), timestamp(timestamp){};
48 
49  operator bool() const { return triggerType != TriggerType::No && triggerType != TriggerType::INVALID; }
50  friend std::ostream& operator<<(std::ostream& out, const Trigger& t);
51  bool operator==(TriggerType other) const
52  {
53  return triggerType == other;
54  }
55 
56  static uint64_t msSinceEpoch();
57 
58  TriggerType triggerType;
59  uint64_t timestamp;
60 };
61 
62 using TriggerFcn = std::function<Trigger()>;
63 
64 namespace triggers
65 {
66 
68 TriggerFcn StartOfRun();
70 TriggerFcn EndOfRun();
72 TriggerFcn StartOfFill();
74 TriggerFcn EndOfFill();
76 TriggerFcn Periodic(double seconds);
78 TriggerFcn NewObject(std::string databaseUrl, std::string objectPath);
80 TriggerFcn Once();
82 TriggerFcn Always();
84 TriggerFcn Never();
85 
86 } // namespace triggers
87 
88 } // namespace o2::quality_control::postprocessing
89 
90 #endif //QUALITYCONTROL_TRIGGERS_H
TriggerType
Possible triggers.
Definition: Triggers.h:28
Trigger(TriggerType triggerType)
Constructor. Timestamp is generated from the time of construction.
Definition: Triggers.h:45
Trigger(TriggerType triggerType, uint64_t timestamp)
Constructor.
Definition: Triggers.h:47
Definition: PostProcessingConfig.h:23