histogram.h
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 #ifndef CARTOGRAPHER_ROS_METRICS_INTERNAL_HISTOGRAM_H
00018 #define CARTOGRAPHER_ROS_METRICS_INTERNAL_HISTOGRAM_H
00019 
00020 #include <map>
00021 #include <vector>
00022 
00023 #include "absl/synchronization/mutex.h"
00024 #include "cartographer/metrics/histogram.h"
00025 #include "cartographer_ros_msgs/Metric.h"
00026 
00027 namespace cartographer_ros {
00028 namespace metrics {
00029 
00030 constexpr double kInfiniteBoundary = std::numeric_limits<double>::infinity();
00031 
00032 using BucketBoundaries = ::cartographer::metrics::Histogram::BucketBoundaries;
00033 
00034 class Histogram : public ::cartographer::metrics::Histogram {
00035  public:
00036   explicit Histogram(const std::map<std::string, std::string>& labels,
00037                      const BucketBoundaries& bucket_boundaries);
00038 
00039   void Observe(double value) override;
00040 
00041   std::map<double, double> CountsByBucket();
00042 
00043   double Sum();
00044 
00045   double CumulativeCount();
00046 
00047   cartographer_ros_msgs::Metric ToRosMessage();
00048 
00049  private:
00050   absl::Mutex mutex_;
00051   const std::map<std::string, std::string> labels_;
00052   const BucketBoundaries bucket_boundaries_;
00053   std::vector<double> bucket_counts_ GUARDED_BY(mutex_);
00054   double sum_ GUARDED_BY(mutex_);
00055 };
00056 
00057 }  // namespace metrics
00058 }  // namespace cartographer_ros
00059 
00060 #endif  // CARTOGRAPHER_ROS_METRICS_INTERNAL_HISTOGRAM_H


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