CARLA
CarlaListener.cpp
Go to the documentation of this file.
1 #define _GLIBCXX_USE_CXX11_ABI 0
2 
3 #include "CarlaListener.h"
4 #include <iostream>
5 
6 #include <fastdds/dds/publisher/DataWriterListener.hpp>
7 #include <fastdds/dds/core/status/PublicationMatchedStatus.hpp>
8 
9 namespace carla {
10 namespace ros2 {
11 
12  namespace efd = eprosima::fastdds::dds;
13 
14  class CarlaListenerImpl : public efd::DataWriterListener {
15  public:
17  efd::DataWriter* writer,
18  const efd::PublicationMatchedStatus& info) override;
19 
20 
21  int _matched {0};
22  bool _first_connected {false};
23  };
24 
25  void CarlaListenerImpl::on_publication_matched(efd::DataWriter* writer, const efd::PublicationMatchedStatus& info)
26  {
27  if (info.current_count_change == 1) {
28  _matched = info.total_count;
29  _first_connected = true;
30  } else if (info.current_count_change == -1) {
31  _matched = info.total_count;
32  } else {
33  std::cerr << info.current_count_change
34  << " is not a valid value for PublicationMatchedStatus current count change" << std::endl;
35  }
36  }
37 
39  _impl(std::make_unique<CarlaListenerImpl>()) { }
40 
42 
43 }}
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
void on_publication_matched(efd::DataWriter *writer, const efd::PublicationMatchedStatus &info) override