1 /* Copyright 2018 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 #ifndef TENSORFLOW_CORE_UTIL_PROTO_DESCRIPTORS_H_ 17 #define TENSORFLOW_CORE_UTIL_PROTO_DESCRIPTORS_H_ 18 19 #include <memory> 20 #include <string> 21 22 #include "tensorflow/core/platform/protobuf.h" 23 24 namespace tensorflow { 25 class Env; 26 class Status; 27 28 // Gets a `DescriptorPool` object from the `descriptor_source`. This may be: 29 // 30 // 1) An empty string or "local://", in which case the local descriptor pool 31 // created for proto definitions linked to the binary is returned. 32 // 33 // 2) A file path, in which case the descriptor pool is created from the 34 // contents of the file, which is expected to contain a `FileDescriptorSet` 35 // serialized as a string. The descriptor pool ownership is transferred to the 36 // caller via `owned_desc_pool`. 37 // 38 // 3) A "bytes://<bytes>", in which case the descriptor pool is created from 39 // `<bytes>`, which is expected to be a `FileDescriptorSet` serialized as a 40 // string. The descriptor pool ownership is transferred to the caller via 41 // `owned_desc_pool`. 42 // 43 // Custom schemas can be supported by registering a handler with the 44 // `DescriptorPoolRegistry`. 45 Status GetDescriptorPool( 46 Env* env, string const& descriptor_source, 47 protobuf::DescriptorPool const** desc_pool, 48 std::unique_ptr<protobuf::DescriptorPool>* owned_desc_pool); 49 50 } // namespace tensorflow 51 52 #endif // TENSORFLOW_CORE_UTIL_PROTO_DESCRIPTORS_H_ 53