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 Rate,
00036 AccumulateAndRate,
00037 };
00038
00042 struct MetricData
00043 {
00048 MetricData(const MetricData& r) = default;
00049
00054 MetricData(MetricData&& r) noexcept = default;
00055
00061 MetricData& operator=(const MetricData& r) = default;
00062
00068 MetricData& operator=(MetricData&& r) noexcept = default;
00069
00073 std::string Name;
00077 std::string StringValue;
00078
00082 union
00083 {
00084 int IntValue;
00085 double DoubleValue;
00086 float FloatValue;
00087 long unsigned int UnsignedValue;
00088 };
00089
00093 MetricType Type;
00097 std::string Unit;
00101 int Level;
00105 MetricMode Mode;
00109 std::string MetricPrefix;
00113 bool UseNameOverride;
00114
00125 MetricData(std::string const& name, std::string const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
00126 : Name(name)
00127 , StringValue(value)
00128 , Type(MetricType::StringMetric)
00129 , Unit(unit)
00130 , Level(level)
00131 , Mode(mode)
00132 , MetricPrefix(metricPrefix)
00133 , UseNameOverride(useNameOverride) {}
00134
00145 MetricData(std::string const& name, int const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
00146 : Name(name)
00147 , IntValue(value)
00148 , Type(MetricType::IntMetric)
00149 , Unit(unit)
00150 , Level(level)
00151 , Mode(mode)
00152 , MetricPrefix(metricPrefix)
00153 , UseNameOverride(useNameOverride)
00154 {}
00155
00166 MetricData(std::string const& name, double const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
00167 : Name(name)
00168 , DoubleValue(value)
00169 , Type(MetricType::DoubleMetric)
00170 , Unit(unit)
00171 , Level(level)
00172 , Mode(mode)
00173 , MetricPrefix(metricPrefix)
00174 , UseNameOverride(useNameOverride)
00175 {}
00176
00187 MetricData(std::string const& name, float const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
00188 : Name(name)
00189 , FloatValue(value)
00190 , Type(MetricType::FloatMetric)
00191 , Unit(unit)
00192 , Level(level)
00193 , Mode(mode)
00194 , MetricPrefix(metricPrefix)
00195 , UseNameOverride(useNameOverride)
00196 {}
00197
00208 MetricData(std::string const& name, long unsigned int const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
00209 : Name(name)
00210 , UnsignedValue(value)
00211 , Type(MetricType::UnsignedMetric)
00212 , Unit(unit)
00213 , Level(level)
00214 , Mode(mode)
00215 , MetricPrefix(metricPrefix)
00216 , UseNameOverride(useNameOverride)
00217 {}
00218
00222 MetricData() : Name("")
00223 , Type(MetricType::InvalidMetric) {}
00224 };
00225 }
00226
00227 #endif