2727#include " CLIParser.hpp"
2828
2929uint32_t received_types_ = 0 ;
30+ uint32_t received_topics_ = 0 ;
3031uint32_t received_data_ = 0 ;
3132std::mutex type_received_mutex_;
33+ std::mutex topic_received_mutex_;
3234std::mutex data_received_mutex_;
3335bool stop_app_ = false ;
3436
3537// Static type callback
3638static void test_type_callback (
3739 const char * typeName,
38- const char * topicName,
39- const char * serializedType)
40+ const char * serializedType,
41+ const unsigned char * serializedTypeInternal,
42+ uint32_t serializedTypeInternalSize,
43+ const char * dataPlaceholder)
4044{
4145 std::lock_guard<std::mutex> lock (type_received_mutex_);
4246
@@ -45,17 +49,29 @@ static void test_type_callback(
4549 received_types_ << std::endl;
4650}
4751
52+ // Static topic callback
53+ static void test_topic_callback (
54+ const char * topicName,
55+ const char * typeName,
56+ const char * serializedQos)
57+ {
58+ std::lock_guard<std::mutex> lock (topic_received_mutex_);
59+
60+ received_topics_++;
61+ std::cout << " Topic callback received: " << topicName << " of type " << typeName << " , Total topics: " <<
62+ received_topics_ << std::endl;
63+ }
64+
4865// Static data callback
4966static void test_data_callback (
50- const char * typeName,
5167 const char * topicName,
5268 const char * json,
5369 int64_t publishTime)
5470{
5571 std::lock_guard<std::mutex> lock (data_received_mutex_);
5672
5773 received_data_++;
58- std::cout << " Data callback received: " << typeName << " , Total data: " <<
74+ std::cout << " Data callback received: " << topicName << " , Total data: " <<
5975 received_data_ << std::endl;
6076}
6177
@@ -66,6 +82,13 @@ int get_received_types()
6682 return received_types_;
6783}
6884
85+ int get_received_topics ()
86+ {
87+ std::lock_guard<std::mutex> lock (topic_received_mutex_);
88+
89+ return received_topics_;
90+ }
91+
6992int get_received_data ()
7093{
7194 std::lock_guard<std::mutex> lock (data_received_mutex_);
@@ -84,10 +107,12 @@ int main(
84107 int argc,
85108 char ** argv)
86109{
110+ using namespace eprosima ::ddsenabler;
111+
87112 CLIParser::example_config config = CLIParser::parse_cli_options (argc, argv);
88113
89114 std::unique_ptr<DDSEnabler> enabler;
90- create_dds_enabler (config.config_file_path_ .c_str (), test_data_callback, test_type_callback, nullptr , enabler);
115+ create_dds_enabler (config.config_file_path_ .c_str (), test_data_callback, test_type_callback, test_topic_callback, nullptr , nullptr , nullptr , enabler);
91116
92117 signal (SIGINT , signal_handler);
93118 signal (SIGTERM , signal_handler);
@@ -106,6 +131,7 @@ int main(
106131 return EXIT_SUCCESS ;
107132 }
108133 else if (get_received_types () >= config.expected_types_ &&
134+ get_received_topics () >= config.expected_topics_ &&
109135 get_received_data () >= config.expected_data_ )
110136 {
111137 std::cout << " Received enough data, stopping..." << std::endl;
0 commit comments