Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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 }
00058 }
00059 }
00060
00061 #endif // CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_SENSOR_DATA_HANDLER_BASE_H