diff --git a/ecal/core/include/ecal/ecal_publisher_config.h b/ecal/core/include/ecal/ecal_publisher_config.h index e26a6aeacf..2e1cb099a7 100644 --- a/ecal/core/include/ecal/ecal_publisher_config.h +++ b/ecal/core/include/ecal/ecal_publisher_config.h @@ -100,7 +100,7 @@ namespace eCAL { struct ECAL_API Configuration { - bool activate = false; //!< activate layer + bool enable = false; //!< enable layer bool zero_copy_mode = false; //!< enable zero copy shared memory transport mode int acknowledge_timeout_ms = 0; /*!< force connected subscribers to send acknowledge event after processing the message the publisher send call is blocked on this event with this timeout (0 == no handshake) */ @@ -114,7 +114,8 @@ namespace eCAL { struct ECAL_API Configuration { - bool activate = false; //!< activate layer + bool enable = false; //!< enable layer + bool loopback = false; //!< enable to receive udp messages on the same local machine int sndbuf_size_bytes = (5*1024*1024); //!< udp send buffer size in bytes (default 5MB) }; } @@ -123,7 +124,7 @@ namespace eCAL { struct ECAL_API Configuration { - bool activate = false; //!< activate layer + bool enable = false; //!< enable layer }; } diff --git a/ecal/core/src/pubsub/ecal_publisher_config.cpp b/ecal/core/src/pubsub/ecal_publisher_config.cpp index 53f718cbdd..949980e690 100644 --- a/ecal/core/src/pubsub/ecal_publisher_config.cpp +++ b/ecal/core/src/pubsub/ecal_publisher_config.cpp @@ -33,7 +33,7 @@ namespace eCAL share_topic_description(eCAL::Config::IsTopicDescriptionSharingEnabled()) { // shm config - shm.activate = eCAL::Config::GetPublisherShmMode() != TLayer::eSendMode::smode_off; + shm.enable = eCAL::Config::GetPublisherShmMode() != TLayer::eSendMode::smode_off; shm.zero_copy_mode = eCAL::Config::IsMemfileZerocopyEnabled(); shm.acknowledge_timeout_ms = eCAL::Config::GetMemfileAckTimeoutMs(); @@ -42,11 +42,12 @@ namespace eCAL shm.memfile_buffer_count = eCAL::Config::GetMemfileBufferCount(); // udp config - udp.activate = eCAL::Config::GetPublisherUdpMulticastMode() != TLayer::eSendMode::smode_off; + udp.enable = eCAL::Config::GetPublisherUdpMulticastMode() != TLayer::eSendMode::smode_off; + udp.loopback = false; // TODO: make this configurable udp.sndbuf_size_bytes = eCAL::Config::GetUdpMulticastSndBufSizeBytes(); // tcp config - tcp.activate = eCAL::Config::GetPublisherTcpMode() != TLayer::eSendMode::smode_off; + tcp.enable = eCAL::Config::GetPublisherTcpMode() != TLayer::eSendMode::smode_off; } } } diff --git a/ecal/core/src/readwrite/ecal_writer.cpp b/ecal/core/src/readwrite/ecal_writer.cpp index 8ddead9992..61d181639e 100644 --- a/ecal/core/src/readwrite/ecal_writer.cpp +++ b/ecal/core/src/readwrite/ecal_writer.cpp @@ -99,14 +99,10 @@ namespace eCAL // register Register(false); - // create udp multicast layer - ActivateUdpLayer(config_.udp.activate); - - // create shm layer - ActivateShmLayer(config_.shm.activate); - - // create tcp layer - ActivateTcpLayer(config_.tcp.activate); + // enable transport layers + EnableUdpLayer(config_.udp.enable); + EnableShmLayer(config_.shm.enable); + EnableTcpLayer(config_.tcp.enable); } CDataWriter::~CDataWriter() @@ -264,9 +260,9 @@ namespace eCAL // can we do a zero copy write ? const bool allow_zero_copy = m_config.shm.zero_copy_mode // zero copy mode activated by user - && m_config.shm.activate // shm layer active - && !m_config.udp.activate // udp layer inactive - && !m_config.tcp.activate; // tcp layer inactive + && m_config.shm.enable // shm layer active + && !m_config.udp.enable // udp layer inactive + && !m_config.tcp.enable; // tcp layer inactive // create a payload copy for all layer if (!allow_zero_copy) @@ -285,7 +281,7 @@ namespace eCAL // SHM //////////////////////////////////////////////////////////////////////////// #if ECAL_CORE_TRANSPORT_SHM - if (m_writer_shm && m_config.shm.activate) + if (m_writer_shm && m_config.shm.enable) { #ifndef NDEBUG // log it @@ -351,7 +347,7 @@ namespace eCAL // UDP (MC) //////////////////////////////////////////////////////////////////////////// #if ECAL_CORE_TRANSPORT_UDP - if (m_writer_udp && m_config.udp.activate) + if (m_writer_udp && m_config.udp.enable) { #ifndef NDEBUG // log it @@ -361,14 +357,6 @@ namespace eCAL // send it bool udp_sent(false); { -#if ECAL_CORE_TRANSPORT_SHM - // if shared memory layer for local communication is not activated - // we activate udp message loopback to communicate with local processes too - const bool loopback = !m_config.shm.activate; -#else - const bool loopback = true; -#endif - // fill writer data struct SWriterAttr wattr; wattr.len = payload_buf_size; @@ -376,7 +364,7 @@ namespace eCAL wattr.clock = m_clock; wattr.hash = snd_hash; wattr.time = time_; - wattr.loopback = loopback; + wattr.loopback = m_config.udp.loopback; // prepare send if (m_writer_udp->PrepareWrite(wattr)) @@ -410,7 +398,7 @@ namespace eCAL // TCP //////////////////////////////////////////////////////////////////////////// #if ECAL_CORE_TRANSPORT_TCP - if (m_writer_tcp && m_config.tcp.activate) + if (m_writer_tcp && m_config.tcp.enable) { #ifndef NDEBUG // log it @@ -749,10 +737,10 @@ namespace eCAL } } - void CDataWriter::ActivateUdpLayer(bool state_) + void CDataWriter::EnableUdpLayer(bool state_) { #if ECAL_CORE_TRANSPORT_UDP - m_config.udp.activate = state_; + m_config.udp.enable = state_; if (!m_created) return; // log state @@ -774,10 +762,10 @@ namespace eCAL #endif // ECAL_CORE_TRANSPORT_UDP } - void CDataWriter::ActivateShmLayer(bool state_) + void CDataWriter::EnableShmLayer(bool state_) { #if ECAL_CORE_TRANSPORT_SHM - m_config.shm.activate = state_; + m_config.shm.enable = state_; if (!m_created) return; // log state @@ -800,10 +788,10 @@ namespace eCAL #endif // ECAL_CORE_TRANSPORT_SHM } - void CDataWriter::ActivateTcpLayer(bool state_) + void CDataWriter::EnableTcpLayer(bool state_) { #if ECAL_CORE_TRANSPORT_TCP - m_config.tcp.activate = state_; + m_config.tcp.enable = state_; if (!m_created) return; // log state diff --git a/ecal/core/src/readwrite/ecal_writer.h b/ecal/core/src/readwrite/ecal_writer.h index 706b0e06c9..6356f322e5 100644 --- a/ecal/core/src/readwrite/ecal_writer.h +++ b/ecal/core/src/readwrite/ecal_writer.h @@ -125,9 +125,9 @@ namespace eCAL void Connect(const std::string& tid_, const SDataTypeInformation& tinfo_); void Disconnect(); - void ActivateUdpLayer(bool state_); - void ActivateShmLayer(bool state_); - void ActivateTcpLayer(bool state_); + void EnableUdpLayer(bool state_); + void EnableShmLayer(bool state_); + void EnableTcpLayer(bool state_); size_t PrepareWrite(long long id_, size_t len_); bool IsInternalSubscribedOnly(); diff --git a/ecal/samples/cpp/benchmarks/pubsub_throughput/src/pubsub_throughput.cpp b/ecal/samples/cpp/benchmarks/pubsub_throughput/src/pubsub_throughput.cpp index 9f835d1720..f306a9f819 100644 --- a/ecal/samples/cpp/benchmarks/pubsub_throughput/src/pubsub_throughput.cpp +++ b/ecal/samples/cpp/benchmarks/pubsub_throughput/src/pubsub_throughput.cpp @@ -37,19 +37,19 @@ void throughput_test(int snd_size, int snd_loops, eCAL::TLayer::eTransportLayer eCAL::Publisher::Configuration pub_config; // set transport layer - pub_config.shm.activate = false; - pub_config.udp.activate = false; - pub_config.tcp.activate = false; + pub_config.shm.enable = false; + pub_config.udp.enable = false; + pub_config.tcp.enable = false; switch (layer) { case eCAL::TLayer::tlayer_shm: - pub_config.shm.activate = true; + pub_config.shm.enable = true; break; case eCAL::TLayer::tlayer_udp_mc: - pub_config.udp.activate = true; + pub_config.udp.enable = true; break; case eCAL::TLayer::tlayer_tcp: - pub_config.tcp.activate = true; + pub_config.tcp.enable = true; break; } diff --git a/ecal/samples/cpp/pubsub/protobuf/person_snd_tcp/src/person_snd_tcp.cpp b/ecal/samples/cpp/pubsub/protobuf/person_snd_tcp/src/person_snd_tcp.cpp index 4b89cc2ef4..69432a494b 100644 --- a/ecal/samples/cpp/pubsub/protobuf/person_snd_tcp/src/person_snd_tcp.cpp +++ b/ecal/samples/cpp/pubsub/protobuf/person_snd_tcp/src/person_snd_tcp.cpp @@ -36,9 +36,9 @@ int main(int argc, char **argv) eCAL::Publisher::Configuration pub_config; // switch shm and udp layer off, tcp layer on - pub_config.shm.activate = false; - pub_config.udp.activate = false; - pub_config.tcp.activate = true; + pub_config.shm.enable = false; + pub_config.udp.enable = false; + pub_config.tcp.enable = true; // create a publisher (topic name "person") eCAL::protobuf::CPublisher pub("person", pub_config); diff --git a/ecal/samples/cpp/pubsub/protobuf/person_snd_udp/src/person_snd_udp.cpp b/ecal/samples/cpp/pubsub/protobuf/person_snd_udp/src/person_snd_udp.cpp index bec182bc8b..655909392f 100644 --- a/ecal/samples/cpp/pubsub/protobuf/person_snd_udp/src/person_snd_udp.cpp +++ b/ecal/samples/cpp/pubsub/protobuf/person_snd_udp/src/person_snd_udp.cpp @@ -36,9 +36,9 @@ int main(int argc, char **argv) eCAL::Publisher::Configuration pub_config; // switch shm and tcp layer off, udp layer on - pub_config.shm.activate = false; - pub_config.udp.activate = true; - pub_config.tcp.activate = false; + pub_config.shm.enable = false; + pub_config.udp.enable = true; + pub_config.tcp.enable = false; // create a publisher (topic name "person") eCAL::protobuf::CPublisher pub("person", pub_config); diff --git a/ecal/tests/cpp/pubsub_test/src/pubsub_multibuffer.cpp b/ecal/tests/cpp/pubsub_test/src/pubsub_multibuffer.cpp index d6895eaa94..31acdb610d 100644 --- a/ecal/tests/cpp/pubsub_test/src/pubsub_multibuffer.cpp +++ b/ecal/tests/cpp/pubsub_test/src/pubsub_multibuffer.cpp @@ -78,9 +78,9 @@ std::vector multibuffer_pub_sub_test(int buffer_count, bool zero_copy, int // create publisher config eCAL::Publisher::Configuration pub_config; // set transport layer - pub_config.shm.activate = true; - pub_config.udp.activate = false; - pub_config.tcp.activate = false; + pub_config.shm.enable = true; + pub_config.udp.enable = false; + pub_config.tcp.enable = false; // set zero copy mode pub_config.shm.zero_copy_mode = zero_copy; // set number of memory buffer diff --git a/ecal/tests/cpp/pubsub_test/src/pubsub_test_shm.cpp b/ecal/tests/cpp/pubsub_test/src/pubsub_test_shm.cpp index 5e9f5fcf49..fe40695b37 100644 --- a/ecal/tests/cpp/pubsub_test/src/pubsub_test_shm.cpp +++ b/ecal/tests/cpp/pubsub_test/src/pubsub_test_shm.cpp @@ -60,9 +60,9 @@ TEST(core_cpp_pubsub, ZeroPayloadMessageSHM) // create publisher config eCAL::Publisher::Configuration pub_config; // set transport layer - pub_config.shm.activate = true; - pub_config.udp.activate = false; - pub_config.tcp.activate = false; + pub_config.shm.enable = true; + pub_config.udp.enable = false; + pub_config.tcp.enable = false; // create publisher for topic "A" eCAL::CPublisher pub("A", pub_config); @@ -115,9 +115,9 @@ TEST(core_cpp_pubsub, MultipleSendsSHM) // create publisher config eCAL::Publisher::Configuration pub_config; // set transport layer - pub_config.shm.activate = true; - pub_config.udp.activate = false; - pub_config.tcp.activate = false; + pub_config.shm.enable = true; + pub_config.udp.enable = false; + pub_config.tcp.enable = false; // create publisher for topic "A" eCAL::string::CPublisher pub("A", pub_config); diff --git a/ecal/tests/cpp/pubsub_test/src/pubsub_test_udp.cpp b/ecal/tests/cpp/pubsub_test/src/pubsub_test_udp.cpp index bd4f430a13..0776132e37 100644 --- a/ecal/tests/cpp/pubsub_test/src/pubsub_test_udp.cpp +++ b/ecal/tests/cpp/pubsub_test/src/pubsub_test_udp.cpp @@ -60,9 +60,9 @@ TEST(core_cpp_pubsub, ZeroPayloadMessageUDP) // create publisher config eCAL::Publisher::Configuration pub_config; // set transport layer - pub_config.shm.activate = false; - pub_config.udp.activate = true; - pub_config.tcp.activate = false; + pub_config.shm.enable = false; + pub_config.udp.enable = true; + pub_config.tcp.enable = false; // create publisher for topic "A" eCAL::CPublisher pub("A", pub_config); @@ -115,9 +115,9 @@ TEST(core_cpp_pubsub, MultipleSendsUDP) // create publisher config eCAL::Publisher::Configuration pub_config; // set transport layer - pub_config.shm.activate = false; - pub_config.udp.activate = true; - pub_config.tcp.activate = false; + pub_config.shm.enable = false; + pub_config.udp.enable = true; + pub_config.tcp.enable = false; // create publisher for topic "A" eCAL::string::CPublisher pub("A", pub_config);