This function inserts a mapping into _dedup_map.
| 258 | |
| 259 | // This function inserts a mapping into _dedup_map. |
| 260 | bool RestfulMap::AddMethod(const RestfulMethodPath& path, |
| 261 | google::protobuf::Service* service, |
| 262 | const Server::MethodProperty::OpaqueParams& params, |
| 263 | const std::string& method_name, |
| 264 | MethodStatus* status) { |
| 265 | if (service == NULL) { |
| 266 | LOG(ERROR) << "Param[service] is NULL"; |
| 267 | return false; |
| 268 | } |
| 269 | const google::protobuf::MethodDescriptor* md = |
| 270 | service->GetDescriptor()->FindMethodByName(method_name); |
| 271 | if (md == NULL) { |
| 272 | LOG(ERROR) << service->GetDescriptor()->full_name() |
| 273 | << " has no method called `" << method_name << '\''; |
| 274 | return false; |
| 275 | } |
| 276 | if (path.service_name != _service_name) { |
| 277 | LOG(ERROR) << "Impossible: path.service_name does not match name" |
| 278 | " of this RestfulMap"; |
| 279 | return false; |
| 280 | } |
| 281 | // Use the string-form of path as key is a MUST to implement |
| 282 | // RemoveByPathString which is used in Server.RemoveMethodsOf |
| 283 | std::string dedup_key = path.to_string(); |
| 284 | DedupMap::const_iterator it = _dedup_map.find(dedup_key); |
| 285 | if (it != _dedup_map.end()) { |
| 286 | LOG(ERROR) << "Already mapped `" << it->second.path |
| 287 | << "' to `" << it->second.method->full_name() << '\''; |
| 288 | return false; |
| 289 | } |
| 290 | RestfulMethodProperty& info = _dedup_map[dedup_key]; |
| 291 | info.is_builtin_service = false; |
| 292 | info.own_method_status = false; |
| 293 | info.params = params; |
| 294 | info.service = service; |
| 295 | info.method = md; |
| 296 | info.status = status; |
| 297 | info.path = path; |
| 298 | info.ownership = SERVER_DOESNT_OWN_SERVICE; |
| 299 | RPC_VLOG << "Mapped `" << path << "' to `" << md->full_name() << '\''; |
| 300 | return true; |
| 301 | } |
| 302 | |
| 303 | void RestfulMap::ClearMethods() { |
| 304 | _sorted_paths.clear(); |
no test coverage detected