TensorFlow Serving C++ API Documentation
fake_loader_source_adapter.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 #ifndef TENSORFLOW_SERVING_CORE_TEST_UTIL_FAKE_LOADER_SOURCE_ADAPTER_H_
17 #define TENSORFLOW_SERVING_CORE_TEST_UTIL_FAKE_LOADER_SOURCE_ADAPTER_H_
18 
19 #include <functional>
20 
21 #include "tensorflow/core/lib/core/status.h"
22 #include "tensorflow/core/platform/macros.h"
23 #include "tensorflow/core/platform/types.h"
24 #include "tensorflow_serving/core/simple_loader.h"
25 #include "tensorflow_serving/core/storage_path.h"
26 #include "tensorflow_serving/core/test_util/fake_loader_source_adapter.pb.h"
27 
28 namespace tensorflow {
29 namespace serving {
30 namespace test_util {
31 
32 // A fake loader source adapter that creates loaders of servable-type string
33 // from data of type StoragePath.
34 //
35 // If path = "/a/simple/path" and suffix = "foo", the servable string becomes
36 // "a/simple/path/foo".
37 //
38 // To help with verifying the order of destruction of these adapters in tests,
39 // the adapter may take a callback to be invoked upon destruction. The
40 // suffix provided to the source-adapter is passed to the string argument of the
41 // callback when it is invoked.
43  : public SimpleLoaderSourceAdapter<StoragePath, string> {
44  public:
46  const string& suffix = "",
47  std::function<void(const string&)> call_on_destruct = {});
48 
49  ~FakeLoaderSourceAdapter() override;
50 
51  private:
52  const string suffix_;
53  std::function<void(const string&)> call_on_destruct_;
54  TF_DISALLOW_COPY_AND_ASSIGN(FakeLoaderSourceAdapter);
55 };
56 
57 } // namespace test_util
58 } // namespace serving
59 } // namespace tensorflow
60 
61 #endif // TENSORFLOW_SERVING_CORE_TEST_UTIL_FAKE_LOADER_SOURCE_ADAPTER_H_