1 /* Copyright 2016 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 Counter metric for mobile platforms.
17 
18 #ifndef TENSORFLOW_CORE_LIB_MONITORING_MOBILE_COUNTER_H_
19 #define TENSORFLOW_CORE_LIB_MONITORING_MOBILE_COUNTER_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 // CounterCell which has a null implementation.
28 class CounterCell {
29  public:
CounterCell()30   CounterCell() {}
~CounterCell()31   ~CounterCell() {}
32 
IncrementBy(int64 step)33   void IncrementBy(int64 step) {}
value()34   int64 value() const { return 0; }
35 
36  private:
37   TF_DISALLOW_COPY_AND_ASSIGN(CounterCell);
38 };
39 
40 // Counter which has a null implementation.
41 template <int NumLabels>
42 class Counter {
43  public:
~Counter()44   ~Counter() {}
45 
46   template <typename... MetricDefArgs>
New(MetricDefArgs &&...metric_def_args)47   static Counter* New(MetricDefArgs&&... metric_def_args) {
48     return new Counter<NumLabels>();
49   }
50 
51   template <typename... Labels>
GetCell(const Labels &...labels)52   CounterCell* GetCell(const Labels&... labels) {
53     return &default_counter_cell_;
54   }
55 
56  private:
Counter()57   Counter() {}
58 
59   CounterCell default_counter_cell_;
60 
61   TF_DISALLOW_COPY_AND_ASSIGN(Counter);
62 };
63 
64 }  // namespace monitoring
65 }  // namespace tensorflow
66 
67 #endif  // TENSORFLOW_CORE_LIB_MONITORING_MOBILE_COUNTER_H_
68