Program Listing for File DesertService.h
↰ Return to documentation for file (src/desert_classes/DesertService.h)
/****************************************************************************
* Copyright (C) 2024 Davide Costa *
* *
* This file is part of RMW desert. *
* *
* RMW desert is free software: you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation, either version 3 of the License, or any *
* later version. *
* *
* RMW desert is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with RMW desert. If not, see <http://www.gnu.org/licenses/>. *
****************************************************************************/
#ifndef DESERT_SERVICE_H_
#define DESERT_SERVICE_H_
#include "rosidl_typesupport_introspection_cpp/identifier.hpp"
#include "rosidl_typesupport_introspection_c/identifier.h"
#include "rosidl_typesupport_introspection_cpp/message_introspection.hpp"
#include "rosidl_typesupport_introspection_c/message_introspection.h"
#include "rosidl_typesupport_introspection_cpp/service_introspection.hpp"
#include "rosidl_typesupport_introspection_c/service_introspection.h"
#include "rosidl_typesupport_introspection_cpp/field_types.hpp"
#include "rosidl_typesupport_introspection_c/field_types.h"
#include "rosidl_runtime_c/service_type_support_struct.h"
#include "rmw/types.h"
#include <vector>
#include <string>
#include <regex>
#include "CBorStream.h"
#include "MessageSerialization.h"
class DesertService
{
public:
DesertService(std::string service_name, const rosidl_service_type_support_t * type_supports, rmw_gid_t gid);
bool has_data();
void read_request(void * req, rmw_service_info_t * req_header);
void send_response(void * res, rmw_request_id_t * req_header);
rmw_gid_t get_gid();
std::string get_service_name();
std::string get_request_type_name();
std::string get_response_type_name();
private:
uint8_t _id;
rmw_gid_t _gid;
std::string _name;
cbor::RxStream _request_data_stream;
cbor::TxStream _response_data_stream;
int64_t _sequence_id;
int _c_cpp_identifier;
const void * _service;
const void * get_service(const rosidl_service_type_support_t * service_type_support);
const rosidl_service_type_support_t * get_service_type_support(const rosidl_service_type_support_t * type_supports);
};
#endif