diff --git a/app/mon/mon_cli/src/ecal_mon_cli.cpp b/app/mon/mon_cli/src/ecal_mon_cli.cpp index e27fd7ed20..9aea267195 100644 --- a/app/mon/mon_cli/src/ecal_mon_cli.cpp +++ b/app/mon/mon_cli/src/ecal_mon_cli.cpp @@ -351,20 +351,11 @@ void ProcProto(const std::string& topic_name, int msg_count) // sleep 1000 ms std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - // get topic type - eCAL::SDataTypeInformation topic_info; - eCAL::Registration::GetTopicDataTypeInformation(topic_name, topic_info); - if(topic_info.name.empty()) - { - std::cout << "could not get type name for topic " << topic_name << std::endl; - return; - } - // create dynamic subscribers for receiving and decoding messages and assign callback eCAL::protobuf::CDynamicSubscriber sub(topic_name); std::atomic cnt(msg_count); auto msg_cb = [&cnt](const std::shared_ptr& msg_) { if (cnt != 0) { std::cout << msg_->DebugString() << std::endl; if (cnt > 0) cnt--; } }; - sub.AddReceiveCallback(std::bind(msg_cb, std::placeholders::_2)); + sub.AddReceiveCallback(std::bind(msg_cb, std::placeholders::_3)); // enter main loop while(eCAL::Ok() && (cnt != 0)) diff --git a/app/mon/mon_plugins/protobuf_reflection/src/plugin_widget.cpp b/app/mon/mon_plugins/protobuf_reflection/src/plugin_widget.cpp index d0051340e7..fefe755f64 100644 --- a/app/mon/mon_plugins/protobuf_reflection/src/plugin_widget.cpp +++ b/app/mon/mon_plugins/protobuf_reflection/src/plugin_widget.cpp @@ -59,7 +59,7 @@ PluginWidget::PluginWidget(const QString& topic_name, const QString& topic_type, ui_.publish_timestamp_warning_label->setVisible(false); // Add eCAL Callbacks - subscriber_.AddReceiveCallback(std::bind(&PluginWidget::onProtoMessageCallback, this, std::placeholders::_2, std::placeholders::_3)); + subscriber_.AddReceiveCallback(std::bind(&PluginWidget::onProtoMessageCallback, this, std::placeholders::_3, std::placeholders::_4)); subscriber_.AddErrorCallback(std::bind(&PluginWidget::onProtoErrorCallback, this, std::placeholders::_1)); // Button connections @@ -319,7 +319,7 @@ void PluginWidget::onUpdate() void PluginWidget::onResume() { // Add eCAL Callbacks - subscriber_.AddReceiveCallback(std::bind(&PluginWidget::onProtoMessageCallback, this, std::placeholders::_2, std::placeholders::_3)); + subscriber_.AddReceiveCallback(std::bind(&PluginWidget::onProtoMessageCallback, this, std::placeholders::_3, std::placeholders::_4)); subscriber_.AddErrorCallback(std::bind(&PluginWidget::onProtoErrorCallback, this, std::placeholders::_1)); } diff --git a/app/mon/mon_plugins/signals_plotting/src/plugin_widget.cpp b/app/mon/mon_plugins/signals_plotting/src/plugin_widget.cpp index 2b6ddd7159..89cbb139e4 100644 --- a/app/mon/mon_plugins/signals_plotting/src/plugin_widget.cpp +++ b/app/mon/mon_plugins/signals_plotting/src/plugin_widget.cpp @@ -73,7 +73,7 @@ PluginWidget::PluginWidget(const QString& topic_name, const QString& topic_type, ui_.publish_timestamp_warning_label->setVisible(false); // Add eCAL Callbacks - subscriber_.AddReceiveCallback(std::bind(&PluginWidget::onProtoMessageCallback, this, std::placeholders::_2, std::placeholders::_3)); + subscriber_.AddReceiveCallback(std::bind(&PluginWidget::onProtoMessageCallback, this, std::placeholders::_3, std::placeholders::_4)); subscriber_.AddErrorCallback(std::bind(&PluginWidget::onProtoErrorCallback, this, std::placeholders::_1)); // Button connections diff --git a/app/mon/mon_tui/src/tui/viewmodel/message_visualization/proto.hpp b/app/mon/mon_tui/src/tui/viewmodel/message_visualization/proto.hpp index 220236ae3d..44e984191b 100644 --- a/app/mon/mon_tui/src/tui/viewmodel/message_visualization/proto.hpp +++ b/app/mon/mon_tui/src/tui/viewmodel/message_visualization/proto.hpp @@ -63,7 +63,7 @@ class ProtoMessageVisualizationViewModel : public MessageVisualizationViewModel : subscriber{topic} { using namespace std::placeholders; - subscriber.AddReceiveCallback(std::bind(&ProtoMessageVisualizationViewModel::OnMessage, this, _2, _3)); + subscriber.AddReceiveCallback(std::bind(&ProtoMessageVisualizationViewModel::OnMessage, this, _3, _4)); } ProtectedMessage message() const diff --git a/ecal/core/include/ecal/cimpl/ecal_registration_cimpl.h b/ecal/core/include/ecal/cimpl/ecal_registration_cimpl.h index 7b11172c11..11812f1dd4 100644 --- a/ecal/core/include/ecal/cimpl/ecal_registration_cimpl.h +++ b/ecal/core/include/ecal/cimpl/ecal_registration_cimpl.h @@ -28,6 +28,8 @@ #include #include +#if 0 // TODO: We have to rethink this API. + #ifdef __cplusplus extern "C" { @@ -174,3 +176,5 @@ extern "C" #endif /*__cplusplus*/ #endif /*ecal_registration_cimpl_h_included*/ + +#endif diff --git a/ecal/core/src/cimpl/ecal_registration_cimpl.cpp b/ecal/core/src/cimpl/ecal_registration_cimpl.cpp index b01590e934..a52a41312b 100644 --- a/ecal/core/src/cimpl/ecal_registration_cimpl.cpp +++ b/ecal/core/src/cimpl/ecal_registration_cimpl.cpp @@ -22,6 +22,8 @@ * @brief eCAL registration c interface **/ +#if 0 // TODO: We have to rethink this API. + #include #include @@ -177,3 +179,5 @@ extern "C" return 0; } } + +#endif diff --git a/ecal/samples/cpp/benchmarks/massive_pub_sub/src/massive_pub_sub.cpp b/ecal/samples/cpp/benchmarks/massive_pub_sub/src/massive_pub_sub.cpp index dc2b46e6e4..6c3dca0bc4 100644 --- a/ecal/samples/cpp/benchmarks/massive_pub_sub/src/massive_pub_sub.cpp +++ b/ecal/samples/cpp/benchmarks/massive_pub_sub/src/massive_pub_sub.cpp @@ -187,7 +187,7 @@ int main(int argc, char** argv) num_pub = pub_ids.size(); for (const auto& id : pub_ids) { - eCAL::Registration::SQualityTopicInfo topic_info; + eCAL::SDataTypeInformation topic_info; eCAL::Registration::GetPublisherInfo(id, topic_info); } diff --git a/ecal/samples/cpp/monitoring/monitoring_get_services/src/monitoring_get_services.cpp b/ecal/samples/cpp/monitoring/monitoring_get_services/src/monitoring_get_services.cpp index 0d52b41719..fb5d4909b4 100644 --- a/ecal/samples/cpp/monitoring/monitoring_get_services/src/monitoring_get_services.cpp +++ b/ecal/samples/cpp/monitoring/monitoring_get_services/src/monitoring_get_services.cpp @@ -38,15 +38,17 @@ int main(int argc, char **argv) { // GetServices { + std::set service_method_id_set; + std::map service_info_map; start_time = std::chrono::steady_clock::now(); for (run = 0; run < runs; ++run) { - eCAL::Registration::GetServices(service_info_map); + service_method_id_set = eCAL::Registration::GetServiceIDs(); } - auto num_services = service_info_map.size(); + auto num_services = service_method_id_set.size(); auto diff_time = std::chrono::duration_cast(std::chrono::steady_clock::now() - start_time); std::cout << "GetServices : " << static_cast(diff_time.count()) / runs << " ms" << " (" << num_services << " services)" << std::endl; std::cout << std::endl; diff --git a/ecal/samples/cpp/monitoring/monitoring_get_topics/src/monitoring_get_topics.cpp b/ecal/samples/cpp/monitoring/monitoring_get_topics/src/monitoring_get_topics.cpp index e1d1fb0a11..3917573751 100644 --- a/ecal/samples/cpp/monitoring/monitoring_get_topics/src/monitoring_get_topics.cpp +++ b/ecal/samples/cpp/monitoring/monitoring_get_topics/src/monitoring_get_topics.cpp @@ -38,15 +38,17 @@ int main(int argc, char **argv) { // GetTopics { - std::map topic_info_map; + std::set topic_id_pub_set; + std::set topic_id_sub_set; start_time = std::chrono::steady_clock::now(); for (run = 0; run < runs; ++run) { - eCAL::Registration::GetTopics(topic_info_map); + topic_id_pub_set = eCAL::Registration::GetPublisherIDs(); + topic_id_sub_set = eCAL::Registration::GetSubscriberIDs(); } - auto num_topics = topic_info_map.size(); + auto num_topics = topic_id_pub_set.size() + topic_id_sub_set.size(); auto diff_time = std::chrono::duration_cast(std::chrono::steady_clock::now() - start_time); std::cout << "GetTopics : " << static_cast(diff_time.count()) / runs << " ms" << " (" << num_topics << " topics)" << std::endl; } diff --git a/ecal/samples/cpp/pubsub/protobuf/proto_dyn_json_rec/src/proto_dyn_json_rec.cpp b/ecal/samples/cpp/pubsub/protobuf/proto_dyn_json_rec/src/proto_dyn_json_rec.cpp index 795890c04e..db66a7b455 100644 --- a/ecal/samples/cpp/pubsub/protobuf/proto_dyn_json_rec/src/proto_dyn_json_rec.cpp +++ b/ecal/samples/cpp/pubsub/protobuf/proto_dyn_json_rec/src/proto_dyn_json_rec.cpp @@ -25,9 +25,9 @@ const std::string MESSAGE_NAME("person"); -void ProtoMsgCallback(const char* topic_name_, const std::string& msg_, long long /*time_*/, long long /*clock_*/, long long /*id_*/) +void ProtoMsgCallback(const eCAL::Registration::STopicId& topic_id_, const std::string& msg_) { - std::cout << topic_name_ << " : " << msg_ << std::endl; + std::cout << topic_id_.topic_name << " : " << msg_ << std::endl; std::cout << std::endl; } @@ -38,7 +38,7 @@ int main(int argc, char **argv) // create dynamic subscribers for receiving and decoding messages eCAL::protobuf::CDynamicJSONSubscriber sub(MESSAGE_NAME); - sub.AddReceiveCallback(ProtoMsgCallback); + sub.AddReceiveCallback(std::bind(ProtoMsgCallback, std::placeholders::_1, std::placeholders::_3)); // enter main loop while(eCAL::Ok()) diff --git a/ecal/samples/cpp/pubsub/protobuf/proto_dyn_rec/src/proto_dyn_rec.cpp b/ecal/samples/cpp/pubsub/protobuf/proto_dyn_rec/src/proto_dyn_rec.cpp index c5ba31e7d6..e36026a6e5 100644 --- a/ecal/samples/cpp/pubsub/protobuf/proto_dyn_rec/src/proto_dyn_rec.cpp +++ b/ecal/samples/cpp/pubsub/protobuf/proto_dyn_rec/src/proto_dyn_rec.cpp @@ -270,9 +270,9 @@ void ProcProtoMsg(const google::protobuf::Message& msg_, const std::string& pref } } -void ProtoMsgCallback(const char* topic_name_, const std::shared_ptr& msg_) +void ProtoMsgCallback(const eCAL::Registration::STopicId& topic_id_, const std::shared_ptr& msg_) { - ProcProtoMsg(*msg_, topic_name_); + ProcProtoMsg(*msg_, topic_id_.topic_name); std::cout << std::endl; } @@ -283,7 +283,7 @@ int main(int argc, char **argv) // create dynamic subscribers for receiving and decoding messages eCAL::protobuf::CDynamicSubscriber sub(MESSAGE_NAME); - sub.AddReceiveCallback(std::bind(ProtoMsgCallback, std::placeholders::_1, std::placeholders::_2)); + sub.AddReceiveCallback(std::bind(ProtoMsgCallback, std::placeholders::_1, std::placeholders::_3)); // enter main loop while(eCAL::Ok()) diff --git a/ecal/samples/cpp/services/ping_client_dyn/src/ping_client_dyn.cpp b/ecal/samples/cpp/services/ping_client_dyn/src/ping_client_dyn.cpp index 7b5f78a554..204c6bc1e1 100644 --- a/ecal/samples/cpp/services/ping_client_dyn/src/ping_client_dyn.cpp +++ b/ecal/samples/cpp/services/ping_client_dyn/src/ping_client_dyn.cpp @@ -48,18 +48,28 @@ int main(int argc, char **argv) // get service method type names std::string req_type; + std::string req_desc; std::string resp_type; - if (!eCAL::Registration::GetServiceTypeNames(service_name, method_name, req_type, resp_type)) + std::string resp_desc; + auto service_ids = eCAL::Registration::GetServiceIDs(); + bool service_info_found(false); + for (const auto& service_id : service_ids) { - throw std::runtime_error("Could not get service type names !"); + if ((service_id.service_name == service_name) && (service_id.method_name == method_name)) + { + eCAL::SServiceMethodInformation service_method_info; + eCAL::Registration::GetServiceInfo(service_id, service_method_info); + req_type = service_method_info.request_type.name; + req_desc = service_method_info.request_type.descriptor; + resp_type = service_method_info.response_type.name; + resp_desc = service_method_info.response_type.descriptor; + service_info_found = true; + break; + } } - - // get service method type descriptions - std::string req_desc; - std::string resp_desc; - if (!eCAL::Registration::GetServiceDescription(service_name, method_name, req_desc, resp_desc)) + if (!service_info_found) { - throw std::runtime_error("Could not get service type descriptions !"); + throw std::runtime_error("Could not get service type names and service type descriptions!"); } // create dynamic protobuf message decoder to create request and response message objects diff --git a/ecal/tests/cpp/descgate_test/src/descgate_getentities.cpp b/ecal/tests/cpp/descgate_test/src/descgate_getentities.cpp index 174f1635b6..c72b33cbe4 100644 --- a/ecal/tests/cpp/descgate_test/src/descgate_getentities.cpp +++ b/ecal/tests/cpp/descgate_test/src/descgate_getentities.cpp @@ -146,15 +146,15 @@ TEST(core_cpp_descgate, PublisherQualities) { for (const auto& id : id_set) { - eCAL::Registration::SQualityTopicInfo quality_info; - bool found = desc_gate.GetPublisherInfo(id, quality_info); + eCAL::SDataTypeInformation topic_info; + bool found = desc_gate.GetPublisherInfo(id, topic_info); EXPECT_TRUE(found); if (found) { std::string tname = id.topic_name; - EXPECT_EQ(tname + "-tdatatype.name", quality_info.info.name); - EXPECT_EQ(tname + "-tdatatype.encoding", quality_info.info.encoding); - EXPECT_EQ(tname + "-tdatatype.descriptor", quality_info.info.descriptor); + EXPECT_EQ(tname + "-tdatatype.name", topic_info.name); + EXPECT_EQ(tname + "-tdatatype.encoding", topic_info.encoding); + EXPECT_EQ(tname + "-tdatatype.descriptor", topic_info.descriptor); } } } @@ -229,15 +229,15 @@ TEST(core_cpp_descgate, SubscriberQualities) { for (const auto& id : id_set) { - eCAL::Registration::SQualityTopicInfo quality_info; - bool found = desc_gate.GetSubscriberInfo(id, quality_info); + eCAL::SDataTypeInformation topic_info; + bool found = desc_gate.GetSubscriberInfo(id, topic_info); EXPECT_TRUE(found); if (found) { std::string tname = id.topic_name; - EXPECT_EQ(tname + "-tdatatype.name", quality_info.info.name); - EXPECT_EQ(tname + "-tdatatype.encoding", quality_info.info.encoding); - EXPECT_EQ(tname + "-tdatatype.descriptor", quality_info.info.descriptor); + EXPECT_EQ(tname + "-tdatatype.name", topic_info.name); + EXPECT_EQ(tname + "-tdatatype.encoding", topic_info.encoding); + EXPECT_EQ(tname + "-tdatatype.descriptor", topic_info.descriptor); } } } diff --git a/lang/python/core/src/ecal_clang.cpp b/lang/python/core/src/ecal_clang.cpp index 98d681344d..25c5143c86 100644 --- a/lang/python/core/src/ecal_clang.cpp +++ b/lang/python/core/src/ecal_clang.cpp @@ -30,14 +30,39 @@ #include #include -static char* str_malloc(const std::string& buf_s_) +namespace { - void* cbuf = malloc(buf_s_.size()); - if(cbuf != nullptr) + char* str_malloc(const std::string& buf_s_) { - memcpy(cbuf, buf_s_.data(), buf_s_.size()); + void* cbuf = malloc(buf_s_.size()); + if (cbuf != nullptr) + { + memcpy(cbuf, buf_s_.data(), buf_s_.size()); + } + return(static_cast(cbuf)); + } + + bool GetTopicDataTypeInformation(const char* topic_name_, eCAL::SDataTypeInformation& topic_info_) + { + // try to find topic name in publisher set + for (const auto& pub_id : eCAL::Registration::GetPublisherIDs()) + { + if (pub_id.topic_name == topic_name_) + { + return eCAL::Registration::GetPublisherInfo(pub_id, topic_info_); + } + } + // try to find topic name in subscriber set + const auto& sub_ids = eCAL::Registration::GetSubscriberIDs(); + for (const auto& sub_id : sub_ids) + { + if (sub_id.topic_name == topic_name_) + { + return eCAL::Registration::GetSubscriberInfo(sub_id, topic_info_); + } + } + return false; } - return(static_cast(cbuf)); } /****************************************/ @@ -176,7 +201,8 @@ void ecal_enable_loopback(const int state_) bool ecal_get_type_name(const char* topic_name_, const char** topic_type_, int* topic_type_len_) { eCAL::SDataTypeInformation topic_info; - bool ret = eCAL::Registration::GetTopicDataTypeInformation(topic_name_, topic_info); + // get the first matching topic type information for the given topic name found in either the publisher or subscriber id set ! + bool ret = GetTopicDataTypeInformation(topic_name_, topic_info); if(ret) { std::string topic_type_s = topic_info.name; @@ -204,7 +230,8 @@ bool ecal_get_type_name(const char* topic_name_, const char** topic_type_, int* bool ecal_get_type_encoding(const char* topic_name_, const char** topic_encoding_, int* topic_encoding_len_) { eCAL::SDataTypeInformation topic_info; - bool ret = eCAL::Registration::GetTopicDataTypeInformation(topic_name_, topic_info); + // get the first matching topic type information for the given topic name found in either the publisher or subscriber id set ! + bool ret = GetTopicDataTypeInformation(topic_name_, topic_info); if (ret) { std::string topic_encoding_s = topic_info.encoding; @@ -232,7 +259,8 @@ bool ecal_get_type_encoding(const char* topic_name_, const char** topic_encoding bool ecal_get_description(const char* topic_name_, const char** topic_desc_, int* topic_desc_len_) { eCAL::SDataTypeInformation topic_info; - bool ret = eCAL::Registration::GetTopicDataTypeInformation(topic_name_, topic_info); + // get the first matching topic type information for the given topic name found in either the publisher or subscriber id set ! + bool ret = GetTopicDataTypeInformation(topic_name_, topic_info); if(ret) { std::string topic_desc_s = topic_info.descriptor;