counter.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_COUNTER_H
00018 #define CARTOGRAPHER_ROS_METRICS_INTERNAL_COUNTER_H
00019 
00020 #include "cartographer/metrics/counter.h"
00021 #include "cartographer_ros/metrics/internal/gauge.h"
00022 #include "cartographer_ros_msgs/Metric.h"
00023 
00024 namespace cartographer_ros {
00025 namespace metrics {
00026 
00027 class Counter : public ::cartographer::metrics::Counter {
00028  public:
00029   explicit Counter(const std::map<std::string, std::string>& labels)
00030       : gauge_(labels) {}
00031 
00032   void Increment(const double value) override { gauge_.Increment(value); }
00033 
00034   void Increment() override { gauge_.Increment(); }
00035 
00036   double Value() { return gauge_.Value(); }
00037 
00038   cartographer_ros_msgs::Metric ToRosMessage() {
00039     cartographer_ros_msgs::Metric msg = gauge_.ToRosMessage();
00040     msg.type = cartographer_ros_msgs::Metric::TYPE_COUNTER;
00041     return msg;
00042   }
00043 
00044  private:
00045   Gauge gauge_;
00046 };
00047 
00048 }  // namespace metrics
00049 }  // namespace cartographer_ros
00050 
00051 #endif  // CARTOGRAPHER_ROS_METRICS_INTERNAL_COUNTER_H


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