Skip to content

Commit

Permalink
Prepare code for breaking change in Protobuf C++ API.
Browse files Browse the repository at this point in the history
Protobuf 6.30.0 will change the return types of Descriptor::name() and other methods to absl::string_view. This makes the code work both before and after such a change.

PiperOrigin-RevId: 689864895
  • Loading branch information
evalon32 authored and tensorflow-copybara committed Oct 25, 2024
1 parent 1e16551 commit 9a38b3a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tensorflow_serving/util/class_registration.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,7 @@ class ClassRegistry {
static Status Create(const protobuf::Message& config,
AdditionalFactoryArgs... args,
std::unique_ptr<BaseClass>* result) {
const string& config_proto_message_type =
config.GetDescriptor()->full_name();
std::string config_proto_message_type(config.GetDescriptor()->full_name());
auto* factory = LookupFromMap(config_proto_message_type);
if (factory == nullptr) {
return errors::InvalidArgument(
Expand Down Expand Up @@ -352,13 +351,14 @@ class ClassRegistry {
REGISTER_CLASS_UNIQ(cnt, RegistryName, BaseClass, ClassCreator, \
config_proto, ##__VA_ARGS__)

#define REGISTER_CLASS_UNIQ(cnt, RegistryName, BaseClass, ClassCreator, \
config_proto, ...) \
static ::tensorflow::serving::internal::ClassRegistry< \
RegistryName, BaseClass, ##__VA_ARGS__>::MapInserter \
register_class_##cnt( \
(config_proto::default_instance().GetDescriptor()->full_name()), \
(new ::tensorflow::serving::internal::ClassRegistrationFactory< \
#define REGISTER_CLASS_UNIQ(cnt, RegistryName, BaseClass, ClassCreator, \
config_proto, ...) \
static ::tensorflow::serving::internal::ClassRegistry< \
RegistryName, BaseClass, ##__VA_ARGS__>::MapInserter \
register_class_##cnt( \
std::string( \
config_proto::default_instance().GetDescriptor()->full_name()), \
(new ::tensorflow::serving::internal::ClassRegistrationFactory< \
BaseClass, ClassCreator, config_proto, ##__VA_ARGS__>));

} // namespace serving
Expand Down

0 comments on commit 9a38b3a

Please sign in to comment.