00001 #ifndef ARTDAQ_UTILITIES_PLUGINS_METRICDATA_HH
00002 #define ARTDAQ_UTILITIES_PLUGINS_METRICDATA_HH
00003
00004 #include "fhiclcpp/fwd.h"
00005 #include "messagefacility/MessageLogger/MessageLogger.h"
00006
00007 #include <sstream>
00008 #include <list>
00009 #include <condition_variable>
00010 #include <atomic>
00011
00012 namespace artdaq
00013 {
00017 enum class MetricType
00018 {
00019 InvalidMetric,
00020 StringMetric,
00021 IntMetric,
00022 DoubleMetric,
00023 FloatMetric,
00024 UnsignedMetric
00025 };
00026
00030 enum class MetricMode
00031 {
00032 LastPoint,
00033 Accumulate,
00034 Average
00035 };
00036
00040 struct MetricData
00041 {
00046 MetricData(const MetricData& r) = default;
00047
00052 MetricData(MetricData&& r) noexcept = default;
00053
00059 MetricData& operator=(const MetricData& r) = default;
00060
00066 MetricData& operator=(MetricData&& r) noexcept = default;
00067
00071 std::string Name;
00075 std::string StringValue;
00076
00080 union
00081 {
00082 int IntValue;
00083 double DoubleValue;
00084 float FloatValue;
00085 long unsigned int UnsignedValue;
00086 };
00087
00091 MetricType Type;
00095 std::string Unit;
00099 int Level;
00103 MetricMode Mode;
00107 std::string MetricPrefix;
00111 bool UseNameOverride;
00112
00123 MetricData(std::string const& name, std::string const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
00124 : Name(name)
00125 , StringValue(value)
00126 , Type(MetricType::StringMetric)
00127 , Unit(unit)
00128 , Level(level)
00129 , Mode(mode)
00130 , MetricPrefix(metricPrefix)
00131 , UseNameOverride(useNameOverride) {}
00132
00143 MetricData(std::string const& name, int const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
00144 : Name(name)
00145 , IntValue(value)
00146 , Type(MetricType::IntMetric)
00147 , Unit(unit)
00148 , Level(level)
00149 , Mode(mode)
00150 , MetricPrefix(metricPrefix)
00151 , UseNameOverride(useNameOverride)
00152 {}
00153
00164 MetricData(std::string const& name, double const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
00165 : Name(name)
00166 , DoubleValue(value)
00167 , Type(MetricType::DoubleMetric)
00168 , Unit(unit)
00169 , Level(level)
00170 , Mode(mode)
00171 , MetricPrefix(metricPrefix)
00172 , UseNameOverride(useNameOverride)
00173 {}
00174
00185 MetricData(std::string const& name, float const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
00186 : Name(name)
00187 , FloatValue(value)
00188 , Type(MetricType::FloatMetric)
00189 , Unit(unit)
00190 , Level(level)
00191 , Mode(mode)
00192 , MetricPrefix(metricPrefix)
00193 , UseNameOverride(useNameOverride)
00194 {}
00195
00206 MetricData(std::string const& name, long unsigned int const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
00207 : Name(name)
00208 , UnsignedValue(value)
00209 , Type(MetricType::UnsignedMetric)
00210 , Unit(unit)
00211 , Level(level)
00212 , Mode(mode)
00213 , MetricPrefix(metricPrefix)
00214 , UseNameOverride(useNameOverride)
00215 {}
00216
00220 MetricData() : Name("")
00221 , Type(MetricType::InvalidMetric) {}
00222 };
00223 }
00224
00225 #endif