TensorFlow Serving C++ API Documentation
storage_path.h
1 /* Copyright 2016 Google Inc. 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 // Typedefs and registries pertaining to storage system paths.
17 
18 #ifndef TENSORFLOW_SERVING_CORE_STORAGE_PATH_H_
19 #define TENSORFLOW_SERVING_CORE_STORAGE_PATH_H_
20 
21 #include <algorithm>
22 #include <memory>
23 #include <string>
24 
25 #include "tensorflow/core/lib/core/status.h"
26 #include "tensorflow/core/platform/types.h"
27 #include "tensorflow_serving/core/servable_data.h"
28 #include "tensorflow_serving/core/servable_id.h"
29 
30 namespace tensorflow {
31 namespace serving {
32 
33 // Strings that represent paths in some storage system.
34 using StoragePath = string;
35 
36 inline bool operator==(const ServableData<StoragePath>& a,
37  const ServableData<StoragePath>& b) {
38  if (a.id() != b.id()) {
39  return false;
40  }
41  if (a.status().ok() != b.status().ok()) {
42  return false;
43  }
44  if (a.status().ok()) {
45  return a.DataOrDie() == b.DataOrDie();
46  } else {
47  return a.status() == b.status();
48  }
49 }
50 
51 } // namespace serving
52 } // namespace tensorflow
53 
54 #endif // TENSORFLOW_SERVING_CORE_STORAGE_PATH_H_