@@ -161,16 +161,25 @@ class DynamicFactory
161161 // / type could not be handled.
162162 public: static ProtoUniquePtr New (const std::string &_msgType)
163163 {
164+ auto msgType = _msgType;
165+ if (msgType.find (" ignition" ) == 0 )
166+ {
167+ msgType.replace (0 , 8 , " gz" );
168+ std::cerr << " Trying to create deprecated message type ["
169+ << _msgType << " ]. Using [" << msgType << " ] instead."
170+ << std::endl;
171+ }
172+
164173 // Shortcut if the type has been already registered.
165174 std::map<std::string, std::function<ProtoUniquePtr ()>>::iterator msgF =
166- dynamicMsgMap.find (_msgType );
175+ dynamicMsgMap.find (msgType );
167176
168177 if (msgF != dynamicMsgMap.end ())
169178 return msgF->second ();
170179
171180 // Nothing to do if we don't know about this type in the descriptor map.
172181 const google::protobuf::Descriptor *descriptor =
173- pool.FindMessageTypeByName (_msgType );
182+ pool.FindMessageTypeByName (msgType );
174183 if (!descriptor)
175184 return nullptr ;
176185
@@ -227,33 +236,42 @@ void Factory::Register(const std::string &_msgType,
227236std::unique_ptr<google::protobuf::Message> Factory::New (
228237 const std::string &_msgType)
229238{
239+ auto msgType = _msgType;
240+ if (msgType.find (" ignition" ) == 0 )
241+ {
242+ msgType.replace (0 , 8 , " gz" );
243+ std::cerr << " Trying to create deprecated message type ["
244+ << _msgType << " ]. Using [" << msgType << " ] instead."
245+ << std::endl;
246+ }
247+
230248 std::unique_ptr<google::protobuf::Message> msg;
231249
232250 std::string type;
233251 // Convert "gz.msgs." to "gz_msgs.".
234- if (_msgType .find (" gz.msgs." ) == 0 )
252+ if (msgType .find (" gz.msgs." ) == 0 )
235253 {
236- type = " gz_msgs." + _msgType .substr (8 );
254+ type = " gz_msgs." + msgType .substr (8 );
237255 }
238256 // Convert ".gz.msgs." to "gz_msgs.".
239- else if (_msgType .find (" .gz.msgs." ) == 0 )
257+ else if (msgType .find (" .gz.msgs." ) == 0 )
240258 {
241- type = " gz_msgs." + _msgType .substr (9 );
259+ type = " gz_msgs." + msgType .substr (9 );
242260 }
243261 else
244262 {
245263 // Fix typenames that are missing "gz_msgs." at the beginning.
246- if (_msgType .find (" gz_msgs." ) != 0 )
264+ if (msgType .find (" gz_msgs." ) != 0 )
247265 type = " gz_msgs." ;
248- type += _msgType ;
266+ type += msgType ;
249267 }
250268
251269 // Create a new message if a FactoryFn has been assigned to the message type
252270 if (msgMap->find (type) != msgMap->end ())
253271 return ((*msgMap)[type]) ();
254272
255273 // Check if we have the message descriptor.
256- msg = dynamicFactory.New (_msgType );
274+ msg = dynamicFactory.New (msgType );
257275
258276 return msg;
259277}
@@ -262,7 +280,16 @@ std::unique_ptr<google::protobuf::Message> Factory::New(
262280std::unique_ptr<google::protobuf::Message> Factory::New (
263281 const std::string &_msgType, const std::string &_args)
264282{
265- std::unique_ptr<google::protobuf::Message> msg = New (_msgType);
283+ auto msgType = _msgType;
284+ if (msgType.find (" ignition" ) == 0 )
285+ {
286+ msgType.replace (0 , 8 , " gz" );
287+ std::cerr << " Trying to create deprecated message type ["
288+ << _msgType << " ]. Using [" << msgType << " ] instead."
289+ << std::endl;
290+ }
291+
292+ std::unique_ptr<google::protobuf::Message> msg = New (msgType);
266293 if (msg)
267294 {
268295 google::protobuf::TextFormat::ParseFromString (_args, msg.get ());
0 commit comments