add_sensor_data_handler_base.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2018 The Cartographer Authors
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_SENSOR_DATA_HANDLER_BASE_H
00018 #define CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_SENSOR_DATA_HANDLER_BASE_H
00019 
00020 #include "async_grpc/rpc_handler.h"
00021 #include "cartographer/cloud/internal/map_builder_context_interface.h"
00022 
00023 namespace cartographer {
00024 namespace cloud {
00025 namespace handlers {
00026 
00027 template <typename HandlerSignatureType>
00028 class AddSensorDataHandlerBase
00029     : public async_grpc::RpcHandler<HandlerSignatureType> {
00030  public:
00031   using SensorDataType =
00032       async_grpc::StripStream<typename HandlerSignatureType::IncomingType>;
00033 
00034   void OnRequest(const SensorDataType& request) override {
00035     if (!this->template GetContext<
00036                  cartographer::cloud::MapBuilderContextInterface>()
00037              ->CheckClientIdForTrajectory(
00038                  request.sensor_metadata().client_id(),
00039                  request.sensor_metadata().trajectory_id())) {
00040       LOG(ERROR) << "Unknown trajectory with ID "
00041                  << request.sensor_metadata().trajectory_id()
00042                  << " and client_id " << request.sensor_metadata().client_id();
00043       this->template Finish(
00044           ::grpc::Status(::grpc::NOT_FOUND, "Unknown trajectory"));
00045       return;
00046     }
00047     OnSensorData(request);
00048   }
00049 
00050   virtual void OnSensorData(const SensorDataType& request) = 0;
00051 
00052   void OnReadsDone() override {
00053     this->template Send(absl::make_unique<google::protobuf::Empty>());
00054   }
00055 };
00056 
00057 }  // namespace handlers
00058 }  // namespace cloud
00059 }  // namespace cartographer
00060 
00061 #endif  // CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_SENSOR_DATA_HANDLER_BASE_H


cartographer
Author(s): The Cartographer Authors
autogenerated on Thu May 9 2019 02:27:35