Program Listing for File DesertSubscriber.h

Return to documentation for file (src/desert_classes/DesertSubscriber.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_SUBSCRIBER_H_
#define DESERT_SUBSCRIBER_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/message_type_support_struct.h"

#include "rmw/types.h"

#include <vector>
#include <string>
#include <regex>

#include "CBorStream.h"
#include "MessageSerialization.h"

class DesertSubscriber
{
  public:
    DesertSubscriber(std::string topic_name, const rosidl_message_type_support_t * type_supports, rmw_gid_t gid);

    bool has_data();
    void read_data(void * msg);

    rmw_gid_t get_gid();
    std::string get_topic_name();
    std::string get_type_name();

  private:
    uint8_t _id;
    rmw_gid_t _gid;
    std::string _name;
    cbor::RxStream _data_stream;

    int _c_cpp_identifier;
    const void * _members;

    const void * get_members(const rosidl_message_type_support_t * type_support);
    const rosidl_message_type_support_t * get_type_support(const rosidl_message_type_support_t * type_supports);

};

#endif