1 /* Copyright 2017 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations 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 24 namespace tensorflow { 25 namespace monitoring { 26 27 // GaugeCell which has a null implementation. 28 template <typename T> 29 class GaugeCell { 30 public: 31 public: GaugeCell()32 GaugeCell() {} ~GaugeCell()33 ~GaugeCell() {} 34 Set(const T & value)35 void Set(const T& value) {} 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. 43 template <typename ValueType, int NumLabels> 44 class Gauge { 45 public: ~Gauge()46 ~Gauge() {} 47 48 template <typename... MetricDefArgs> New(MetricDefArgs &&...metric_def_args)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> GetCell(const Labels &...labels)57 GaugeCell<ValueType>* GetCell(const Labels&... labels) { 58 return &default_gauge_cell_; 59 } 60 61 private: Gauge()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