CARLA
Loading...
Searching...
No Matches
BasePublisher.h
Go to the documentation of this file.
1// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8
9#include <string>
10
11namespace carla {
12namespace ros2 {
13
15public:
16 BasePublisher() = default;
17
18 explicit BasePublisher(std::string base_topic_name)
19 : _base_topic_name(std::move(base_topic_name)) {}
20
21 BasePublisher(std::string base_topic_name, std::string frame_id)
22 : _base_topic_name(std::move(base_topic_name)),
23 _frame_id(std::move(frame_id)) {}
24
25 BasePublisher(void *actor, std::string base_topic_name, std::string frame_id)
26 : _actor(actor),
27 _base_topic_name(std::move(base_topic_name)),
28 _frame_id(std::move(frame_id)) {}
29
30 virtual ~BasePublisher() = default;
31
32 // Polymorphic base held only via std::shared_ptr<BasePublisher>; copying or
33 // moving one would slice the derived publisher, so disable it outright.
34 BasePublisher(const BasePublisher &) = delete;
38
39 virtual bool Publish() = 0;
40
41 [[nodiscard]] void *GetActor() const noexcept { return _actor; }
42 [[nodiscard]] const std::string &GetBaseTopicName() const noexcept { return _base_topic_name; }
43 [[nodiscard]] const std::string &GetFrameId() const noexcept { return _frame_id; }
44
45protected:
46 void *_actor{nullptr};
47 std::string _base_topic_name;
48 std::string _frame_id;
49};
50
51} // namespace ros2
52} // namespace carla
virtual ~BasePublisher()=default
void * GetActor() const noexcept
BasePublisher & operator=(const BasePublisher &)=delete
BasePublisher(std::string base_topic_name, std::string frame_id)
virtual bool Publish()=0
BasePublisher(void *actor, std::string base_topic_name, std::string frame_id)
BasePublisher(const BasePublisher &)=delete
BasePublisher & operator=(BasePublisher &&)=delete
BasePublisher(BasePublisher &&)=delete
const std::string & GetBaseTopicName() const noexcept
BasePublisher(std::string base_topic_name)
const std::string & GetFrameId() const noexcept
This file contains definitions of common data structures used in traffic manager.