00001 #ifndef ARTDAQ_UTILITIES_PLUGINS_METRICDATA_HH
00002 #define ARTDAQ_UTILITIES_PLUGINS_METRICDATA_HH
00003
00004 #include "artdaq-utilities/Plugins/MetricPlugin.hh"
00005 #include "fhiclcpp/fwd.h"
00006 #include "messagefacility/MessageLogger/MessageLogger.h"
00007
00008 #include <sstream>
00009 #include <list>
00010 #include <condition_variable>
00011 #include <atomic>
00012
00013 namespace artdaq
00014 {
00018 enum class MetricType
00019 {
00020 InvalidMetric,
00021 StringMetric,
00022 IntMetric,
00023 DoubleMetric,
00024 FloatMetric,
00025 UnsignedMetric
00026 };
00027
00031 enum class MetricMode
00032 {
00033 LastPoint,
00034 Accumulate,
00035 Average
00036 };
00037
00041 struct MetricData
00042 {
00047 MetricData(const MetricData& r) = default;
00048
00053 MetricData(MetricData&& r) noexcept = default;
00054
00060 MetricData& operator=(const MetricData& r) = default;
00061
00067 MetricData& operator=(MetricData&& r) noexcept = default;
00068
00072 std::string Name;
00076 std::string StringValue;
00077
00081 union
00082 {
00083 int IntValue;
00084 double DoubleValue;
00085 float FloatValue;
00086 long unsigned int UnsignedValue;
00087 };
00088
00092 MetricType Type;
00096 std::string Unit;
00100 int Level;
00104 MetricMode Mode;
00108 std::string MetricPrefix;
00112 bool UseNameOverride;
00113
00124 MetricData(std::string const& name, std::string const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
00125 : Name(name)
00126 , StringValue(value)
00127 , Type(MetricType::StringMetric)
00128 , Unit(unit)
00129 , Level(level)
00130 , Mode(mode)
00131 , MetricPrefix(metricPrefix)
00132 , UseNameOverride(useNameOverride) {}
00133
00144 MetricData(std::string const& name, int const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
00145 : Name(name)
00146 , IntValue(value)
00147 , Type(MetricType::IntMetric)
00148 , Unit(unit)
00149 , Level(level)
00150 , Mode(mode)
00151 , MetricPrefix(metricPrefix)
00152 , UseNameOverride(useNameOverride)
00153 {}
00154
00165 MetricData(std::string const& name, double const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
00166 : Name(name)
00167 , DoubleValue(value)
00168 , Type(MetricType::DoubleMetric)
00169 , Unit(unit)
00170 , Level(level)
00171 , Mode(mode)
00172 , MetricPrefix(metricPrefix)
00173 , UseNameOverride(useNameOverride)
00174 {}
00175
00186 MetricData(std::string const& name, float const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
00187 : Name(name)
00188 , FloatValue(value)
00189 , Type(MetricType::FloatMetric)
00190 , Unit(unit)
00191 , Level(level)
00192 , Mode(mode)
00193 , MetricPrefix(metricPrefix)
00194 , UseNameOverride(useNameOverride)
00195 {}
00196
00207 MetricData(std::string const& name, long unsigned int const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
00208 : Name(name)
00209 , UnsignedValue(value)
00210 , Type(MetricType::UnsignedMetric)
00211 , Unit(unit)
00212 , Level(level)
00213 , Mode(mode)
00214 , MetricPrefix(metricPrefix)
00215 , UseNameOverride(useNameOverride)
00216 {}
00217
00221 MetricData() : Name("")
00222 , Type(MetricType::InvalidMetric) {}
00223 };
00224 }
00225
00226 #endif