family_factory.cc
Go to the documentation of this file.
00001 /*
00002  * Copyright 2018 The Cartographer Authors
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
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 }  // namespace metrics
00069 }  // namespace cartographer_ros


cartographer_ros
Author(s): The Cartographer Authors
autogenerated on Wed Jul 10 2019 04:10:28