Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef CARTOGRAPHER_METRICS_FAMILY_FACTORY_H_
00018 #define CARTOGRAPHER_METRICS_FAMILY_FACTORY_H_
00019
00020 #include <memory>
00021 #include <string>
00022
00023 #include "cartographer/metrics/counter.h"
00024 #include "cartographer/metrics/gauge.h"
00025 #include "cartographer/metrics/histogram.h"
00026
00027 namespace cartographer {
00028 namespace metrics {
00029
00030 template <typename MetricType>
00031 class NullFamily;
00032
00033 template <typename MetricType>
00034 class Family {
00035 public:
00036
00037 static Family<MetricType>* Null() {
00038 static NullFamily<MetricType> null_family;
00039 return &null_family;
00040 }
00041
00042 virtual ~Family() = default;
00043
00044 virtual MetricType* Add(const std::map<std::string, std::string>& labels) = 0;
00045 };
00046
00047 template <typename MetricType>
00048 class NullFamily : public Family<MetricType> {
00049 public:
00050 MetricType* Add(const std::map<std::string, std::string>& labels) override {
00051 return MetricType::Null();
00052 }
00053 };
00054
00055 class FamilyFactory {
00056 public:
00057 virtual ~FamilyFactory() = default;
00058
00059 virtual Family<Counter>* NewCounterFamily(const std::string& name,
00060 const std::string& description) = 0;
00061 virtual Family<Gauge>* NewGaugeFamily(const std::string& name,
00062 const std::string& description) = 0;
00063 virtual Family<Histogram>* NewHistogramFamily(
00064 const std::string& name, const std::string& description,
00065 const Histogram::BucketBoundaries& boundaries) = 0;
00066 };
00067
00068 }
00069 }
00070
00071 #endif // CARTOGRAPHER_METRICS_FAMILY_FACTORY_H_