Apollo  6.0
Open source self driving car software
protobuf_traits.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2018 The Apollo Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************/
16 
17 #ifndef CYBER_MESSAGE_PROTOBUF_TRAITS_H_
18 #define CYBER_MESSAGE_PROTOBUF_TRAITS_H_
19 
20 #include <cassert>
21 #include <memory>
22 #include <string>
23 
25 
26 namespace apollo {
27 namespace cyber {
28 namespace message {
29 
30 template <typename MessageT,
31  typename std::enable_if<
33  int>::type = 0>
34 inline std::string MessageType() {
35  return MessageT::descriptor()->full_name();
36 }
37 
38 template <typename MessageT,
39  typename std::enable_if<
40  std::is_base_of<google::protobuf::Message, MessageT>::value,
41  int>::type = 0>
42 std::string MessageType(const MessageT& message) {
43  return message.GetDescriptor()->full_name();
44 }
45 
46 template <typename MessageT,
47  typename std::enable_if<
48  std::is_base_of<google::protobuf::Message, MessageT>::value,
49  int>::type = 0>
50 inline void GetDescriptorString(const MessageT& message,
51  std::string* desc_str) {
52  ProtobufFactory::Instance()->GetDescriptorString(message, desc_str);
53 }
54 
55 template <typename MessageT,
56  typename std::enable_if<
57  std::is_base_of<google::protobuf::Message, MessageT>::value,
58  int>::type = 0>
59 inline void GetDescriptorString(const std::string& type,
60  std::string* desc_str) {
61  ProtobufFactory::Instance()->GetDescriptorString(type, desc_str);
62 }
63 
64 template <typename MessageT,
65  typename std::enable_if<
66  std::is_base_of<google::protobuf::Message, MessageT>::value,
67  int>::type = 0>
68 bool RegisterMessage(const MessageT& message) {
69  return ProtobufFactory::Instance()->RegisterMessage(message);
70 }
71 
72 } // namespace message
73 } // namespace cyber
74 } // namespace apollo
75 
76 #endif // CYBER_MESSAGE_PROTOBUF_TRAITS_H_
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
bool RegisterMessage(const MessageT &message)
Definition: protobuf_traits.h:68
std::string MessageType(const T &message)
Definition: message_traits.h:61
void GetDescriptorString(const std::string &type, std::string *desc_str)
Definition: message_traits.h:237
apollo::cyber::base::std value