1/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7    http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14==============================================================================*/
15
16// Null implementation of the Gauge metric for mobile platforms.
17
18#ifndef TENSORFLOW_CORE_LIB_MONITORING_MOBILE_GAUGE_H_
19#define TENSORFLOW_CORE_LIB_MONITORING_MOBILE_GAUGE_H_
20
21#include "tensorflow/core/platform/macros.h"
22#include "tensorflow/core/platform/types.h"
23
24namespace tensorflow {
25namespace monitoring {
26
27// GaugeCell which has a null implementation.
28template <typename T>
29class GaugeCell {
30 public:
31 public:
32  GaugeCell() {}
33  ~GaugeCell() {}
34
35  void Set(const T& value) {}
36  T value() const { return T(); }
37
38 private:
39  TF_DISALLOW_COPY_AND_ASSIGN(GaugeCell);
40};
41
42// Gauge which has a null implementation.
43template <typename ValueType, int NumLabels>
44class Gauge {
45 public:
46  ~Gauge() {}
47
48  template <typename... MetricDefArgs>
49  static Gauge* New(MetricDefArgs&&... metric_def_args) {
50    static_assert(std::is_same<ValueType, int64>::value ||
51                      std::is_same<ValueType, string>::value,
52                  "Gauge only allows int64 and string types.");
53    return new Gauge();
54  }
55
56  template <typename... Labels>
57  GaugeCell<ValueType>* GetCell(const Labels&... labels) {
58    return &default_gauge_cell_;
59  }
60
61 private:
62  Gauge() {}
63
64  GaugeCell<ValueType> default_gauge_cell_;
65
66  TF_DISALLOW_COPY_AND_ASSIGN(Gauge);
67};
68
69}  // namespace monitoring
70}  // namespace tensorflow
71
72#endif  // TENSORFLOW_CORE_LIB_MONITORING_MOBILE_GAUGE_H_
73