Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "cartographer_ros/metrics/family_factory.h"
00018
00019 #include "absl/memory/memory.h"
00020
00021 namespace cartographer_ros {
00022 namespace metrics {
00023
00024 using BucketBoundaries = ::cartographer::metrics::Histogram::BucketBoundaries;
00025
00026 ::cartographer::metrics::Family<::cartographer::metrics::Counter>*
00027 FamilyFactory::NewCounterFamily(const std::string& name,
00028 const std::string& description) {
00029 auto wrapper = absl::make_unique<CounterFamily>(name, description);
00030 auto* ptr = wrapper.get();
00031 counter_families_.emplace_back(std::move(wrapper));
00032 return ptr;
00033 }
00034
00035 ::cartographer::metrics::Family<::cartographer::metrics::Gauge>*
00036 FamilyFactory::NewGaugeFamily(const std::string& name,
00037 const std::string& description) {
00038 auto wrapper = absl::make_unique<GaugeFamily>(name, description);
00039 auto* ptr = wrapper.get();
00040 gauge_families_.emplace_back(std::move(wrapper));
00041 return ptr;
00042 }
00043
00044 ::cartographer::metrics::Family<::cartographer::metrics::Histogram>*
00045 FamilyFactory::NewHistogramFamily(const std::string& name,
00046 const std::string& description,
00047 const BucketBoundaries& boundaries) {
00048 auto wrapper =
00049 absl::make_unique<HistogramFamily>(name, description, boundaries);
00050 auto* ptr = wrapper.get();
00051 histogram_families_.emplace_back(std::move(wrapper));
00052 return ptr;
00053 }
00054
00055 void FamilyFactory::ReadMetrics(
00056 ::cartographer_ros_msgs::ReadMetrics::Response* response) const {
00057 for (const auto& counter_family : counter_families_) {
00058 response->metric_families.push_back(counter_family->ToRosMessage());
00059 }
00060 for (const auto& gauge_family : gauge_families_) {
00061 response->metric_families.push_back(gauge_family->ToRosMessage());
00062 }
00063 for (const auto& histogram_family : histogram_families_) {
00064 response->metric_families.push_back(histogram_family->ToRosMessage());
00065 }
00066 }
00067
00068 }
00069 }