Skip to content

Commit

Permalink
remove datatype_info from MsgReceiveCallbackT
Browse files Browse the repository at this point in the history
  • Loading branch information
rex-schilasky committed Dec 5, 2024
1 parent 6409421 commit 779595a
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 24 deletions.
2 changes: 1 addition & 1 deletion app/mon/mon_cli/src/ecal_mon_cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ void ProcProto(const std::string& topic_name, int msg_count)
eCAL::protobuf::CDynamicSubscriber sub(topic_name);
std::atomic<int> cnt(msg_count);
auto msg_cb = [&cnt](const std::shared_ptr<google::protobuf::Message>& msg_) { if (cnt != 0) { std::cout << msg_->DebugString() << std::endl; if (cnt > 0) cnt--; } };
sub.AddReceiveCallback(std::bind(msg_cb, std::placeholders::_3));
sub.AddReceiveCallback(std::bind(msg_cb, std::placeholders::_2));

// enter main loop
while(eCAL::Ok() && (cnt != 0))
Expand Down
4 changes: 2 additions & 2 deletions app/mon/mon_plugins/protobuf_reflection/src/plugin_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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::_3, std::placeholders::_4));
subscriber_.AddReceiveCallback(std::bind(&PluginWidget::onProtoMessageCallback, this, std::placeholders::_2, std::placeholders::_3));
subscriber_.AddErrorCallback(std::bind(&PluginWidget::onProtoErrorCallback, this, std::placeholders::_1));

// Button connections
Expand Down Expand Up @@ -319,7 +319,7 @@ void PluginWidget::onUpdate()
void PluginWidget::onResume()
{
// Add eCAL Callbacks
subscriber_.AddReceiveCallback(std::bind(&PluginWidget::onProtoMessageCallback, this, std::placeholders::_3, std::placeholders::_4));
subscriber_.AddReceiveCallback(std::bind(&PluginWidget::onProtoMessageCallback, this, std::placeholders::_2, std::placeholders::_3));
subscriber_.AddErrorCallback(std::bind(&PluginWidget::onProtoErrorCallback, this, std::placeholders::_1));
}

Expand Down
2 changes: 1 addition & 1 deletion app/mon/mon_plugins/signals_plotting/src/plugin_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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::_3, std::placeholders::_4));
subscriber_.AddReceiveCallback(std::bind(&PluginWidget::onProtoMessageCallback, this, std::placeholders::_2, std::placeholders::_3));
subscriber_.AddErrorCallback(std::bind(&PluginWidget::onProtoErrorCallback, this, std::placeholders::_1));

// Button connections
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ProtoMessageVisualizationViewModel : public MessageVisualizationViewModel
: subscriber{topic}
{
using namespace std::placeholders;
subscriber.AddReceiveCallback(std::bind(&ProtoMessageVisualizationViewModel::OnMessage, this, _3, _4));
subscriber.AddReceiveCallback(std::bind(&ProtoMessageVisualizationViewModel::OnMessage, this, _2, _3));
}

ProtectedMessage message() const
Expand Down
28 changes: 12 additions & 16 deletions ecal/core/include/ecal/msg/dynamic.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ namespace eCAL
* @param topic_name_ Unique topic name.
**/
CDynamicMessageSubscriber(const std::string& topic_name_) : CSubscriber()
, m_topic_name(topic_name_)
, m_deserializer()
{
CSubscriber::Create(topic_name_);
Expand All @@ -110,7 +109,6 @@ namespace eCAL
**/
CDynamicMessageSubscriber(CDynamicMessageSubscriber&& rhs)
: CSubscriber(std::move(rhs))
, m_topic_name(std::move(rhs.m_topic_name))
, m_cb_callback(std::move(rhs.m_cb_callback))
, m_deserializer(std::move(rhs.m_deserializer))
{
Expand Down Expand Up @@ -144,13 +142,13 @@ namespace eCAL
/**
* @brief eCAL message receive callback function
*
* @param topic_name_ Topic name of the data source (publisher).
* @param msg_ Message content.
* @param time_ Message time stamp.
* @param clock_ Message writer clock.
* @param id_ Message id.
* @param topic_id_ Topic id of the data source (publisher).
* @param msg_ Message content.
* @param time_ Message time stamp.
* @param clock_ Message writer clock.
* @param id_ Message id.
**/
using MsgReceiveCallbackT = std::function<void(const Registration::STopicId& topic_id_, const SDataTypeInformation& topic_info_, const T& msg_, long long time_, long long clock_, long long id_)>;
using MsgReceiveCallbackT = std::function<void(const Registration::STopicId& topic_id_, const T& msg_, long long time_, long long clock_, long long id_)>;

/**
* @brief Add receive callback for incoming messages.
Expand Down Expand Up @@ -236,7 +234,7 @@ namespace eCAL
try
{
auto msg = m_deserializer.Deserialize(data_.buf, data_.size, topic_info_);
fn_callback(topic_id_, topic_info_, msg, data_.time, data_.clock, data_.id);
fn_callback(topic_id_, msg, data_.time, data_.clock, data_.id);
}
catch (const DynamicReflectionException& e)
{
Expand All @@ -257,13 +255,11 @@ namespace eCAL
}
}

std::string m_topic_name;
std::mutex m_cb_callback_mutex;
MsgReceiveCallbackT m_cb_callback;
std::mutex m_error_callback_mutex;
ErrorCallbackT m_error_callback;
DynamicDeserializer m_deserializer;
std::optional<SDataTypeInformation> m_datatype_info_received = std::nullopt;
std::mutex m_cb_callback_mutex;
MsgReceiveCallbackT m_cb_callback;
std::mutex m_error_callback_mutex;
ErrorCallbackT m_error_callback;
DynamicDeserializer m_deserializer;
};

}
Original file line number Diff line number Diff line change
Expand Up @@ -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(std::bind(ProtoMsgCallback, std::placeholders::_1, std::placeholders::_3));
sub.AddReceiveCallback(std::bind(ProtoMsgCallback, std::placeholders::_1, std::placeholders::_2));

// enter main loop
while(eCAL::Ok())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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::_3));
sub.AddReceiveCallback(std::bind(ProtoMsgCallback, std::placeholders::_1, std::placeholders::_2));

// enter main loop
while(eCAL::Ok())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ TEST_F(core_cpp_pubsub_proto_dyn, ProtoDynSubscriberTest_SendReceiveCB)
{
// Assert that the Subscriber can be move constructed.
eCAL::protobuf::CDynamicSubscriber person_dyn_rec("ProtoSubscriberTest");
auto person_callback = std::bind(&ProtoDynSubscriberTest::OnPerson, this, std::placeholders::_3, std::placeholders::_4);
auto person_callback = std::bind(&ProtoDynSubscriberTest::OnPerson, this, std::placeholders::_2, std::placeholders::_3);
person_dyn_rec.AddReceiveCallback(person_callback);
ASSERT_TRUE(person_dyn_rec.IsCreated());

Expand Down

0 comments on commit 779595a

Please sign in to comment.