-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[config] Attributes for Publisher/Subscriber and Reader/Writer (#1747)
* Decoupling of reader and writer from global configurations to use attributes with builders.
- Loading branch information
Showing
48 changed files
with
1,396 additions
and
283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
ecal/core/src/pubsub/config/builder/reader_attribute_builder.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* ========================= eCAL LICENSE ================================= | ||
* | ||
* Copyright (C) 2016 - 2024 Continental Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* ========================= eCAL LICENSE ================================= | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "reader_attribute_builder.h" | ||
#include "ecal/ecal_process.h" | ||
|
||
namespace eCAL | ||
{ | ||
eCALReader::SAttributes BuildReaderAttributes(const std::string& topic_name_, const Subscriber::Configuration& sub_config_, const Publisher::Configuration& pub_config_, const eCAL::TransportLayer::Configuration& tl_config_, const eCAL::Registration::Configuration& reg_config_) | ||
{ | ||
eCALReader::SAttributes attributes; | ||
|
||
attributes.network_enabled = reg_config_.network_enabled; | ||
attributes.loopback = reg_config_.loopback; | ||
attributes.drop_out_of_order_messages = sub_config_.drop_out_of_order_messages; | ||
attributes.registation_timeout_ms = reg_config_.registration_timeout; | ||
attributes.topic_name = topic_name_; | ||
attributes.host_name = Process::GetHostName(); | ||
attributes.host_group_name = Process::GetHostGroupName(); | ||
attributes.process_id = Process::GetProcessID(); | ||
attributes.process_name = Process::GetProcessName(); | ||
attributes.share_topic_type = pub_config_.share_topic_type; | ||
attributes.share_topic_description = pub_config_.share_topic_description; | ||
|
||
attributes.udp.enable = sub_config_.layer.udp.enable; | ||
attributes.udp.mode = tl_config_.udp.mode; | ||
attributes.udp.port = tl_config_.udp.port; | ||
attributes.udp.receivebuffer = tl_config_.udp.receive_buffer; | ||
|
||
attributes.udp.local.group = tl_config_.udp.local.group; | ||
|
||
attributes.udp.network.group = tl_config_.udp.network.group; | ||
|
||
attributes.tcp.enable = sub_config_.layer.tcp.enable; | ||
attributes.tcp.thread_pool_size = tl_config_.tcp.number_executor_reader; | ||
attributes.tcp.max_reconnection_attempts = tl_config_.tcp.max_reconnections; | ||
|
||
attributes.shm.enable = sub_config_.layer.shm.enable; | ||
|
||
return attributes; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
ecal/core/src/pubsub/config/builder/reader_attribute_builder.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* ========================= eCAL LICENSE ================================= | ||
* | ||
* Copyright (C) 2016 - 2024 Continental Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* ========================= eCAL LICENSE ================================= | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "readwrite/config/attributes/reader_attributes.h" | ||
#include "ecal/config/subscriber.h" | ||
#include "ecal/config/transport_layer.h" | ||
#include "ecal/config/registration.h" | ||
#include "ecal/config/publisher.h" | ||
|
||
namespace eCAL | ||
{ | ||
eCALReader::SAttributes BuildReaderAttributes(const std::string& topic_name_, const Subscriber::Configuration& sub_config_, const Publisher::Configuration& pub_config_, const eCAL::TransportLayer::Configuration& tl_config_, const eCAL::Registration::Configuration& reg_config_); | ||
} |
70 changes: 70 additions & 0 deletions
70
ecal/core/src/pubsub/config/builder/writer_attribute_builder.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* ========================= eCAL LICENSE ================================= | ||
* | ||
* Copyright (C) 2016 - 2024 Continental Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* ========================= eCAL LICENSE ================================= | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "writer_attribute_builder.h" | ||
#include "ecal/ecal_process.h" | ||
|
||
namespace eCAL | ||
{ | ||
eCALWriter::SAttributes BuildWriterAttributes(const std::string& topic_name_, const Publisher::Configuration& pub_config_, const eCAL::TransportLayer::Configuration& tl_config_, const eCAL::Registration::Configuration& reg_config_) | ||
{ | ||
eCALWriter::SAttributes attributes; | ||
|
||
attributes.network_enabled = reg_config_.network_enabled; | ||
attributes.loopback = reg_config_.loopback; | ||
|
||
attributes.share_topic_type = pub_config_.share_topic_type; | ||
attributes.share_topic_description = pub_config_.share_topic_description; | ||
attributes.layer_priority_local = pub_config_.layer_priority_local; | ||
attributes.layer_priority_remote = pub_config_.layer_priority_remote; | ||
|
||
attributes.host_name = Process::GetHostName(); | ||
attributes.host_group_name = Process::GetHostGroupName(); | ||
attributes.process_id = Process::GetProcessID(); | ||
attributes.process_name = Process::GetProcessName(); | ||
|
||
attributes.unit_name = Process::GetUnitName(); | ||
attributes.topic_name = topic_name_; | ||
|
||
attributes.shm.enable = pub_config_.layer.shm.enable; | ||
attributes.shm.acknowledge_timeout_ms = pub_config_.layer.shm.acknowledge_timeout_ms; | ||
attributes.shm.memfile_buffer_count = pub_config_.layer.shm.memfile_buffer_count; | ||
attributes.shm.memfile_min_size_bytes = pub_config_.layer.shm.memfile_min_size_bytes; | ||
attributes.shm.memfile_reserve_percent = pub_config_.layer.shm.memfile_reserve_percent; | ||
attributes.shm.zero_copy_mode = pub_config_.layer.shm.zero_copy_mode; | ||
|
||
attributes.udp.enable = pub_config_.layer.udp.enable; | ||
attributes.udp.port = tl_config_.udp.port; | ||
attributes.udp.send_buffer = tl_config_.udp.send_buffer; | ||
attributes.udp.mode = tl_config_.udp.mode; | ||
|
||
attributes.udp.network.group = tl_config_.udp.network.group; | ||
attributes.udp.network.ttl = tl_config_.udp.network.ttl; | ||
|
||
attributes.udp.local.group = tl_config_.udp.local.group; | ||
attributes.udp.local.ttl = tl_config_.udp.local.ttl; | ||
|
||
attributes.tcp.enable = pub_config_.layer.tcp.enable; | ||
attributes.tcp.thread_pool_size = tl_config_.tcp.number_executor_writer; | ||
|
||
return attributes; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
ecal/core/src/pubsub/config/builder/writer_attribute_builder.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* ========================= eCAL LICENSE ================================= | ||
* | ||
* Copyright (C) 2016 - 2024 Continental Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* ========================= eCAL LICENSE ================================= | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "readwrite/config/attributes/writer_attributes.h" | ||
#include "ecal/config/publisher.h" | ||
#include "ecal/config/registration.h" | ||
|
||
namespace eCAL | ||
{ | ||
eCALWriter::SAttributes BuildWriterAttributes(const std::string& topic_name_, const Publisher::Configuration& config_, const eCAL::TransportLayer::Configuration& tl_config_, const eCAL::Registration::Configuration& reg_config_); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
ecal/core/src/readwrite/config/attributes/reader_attributes.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* ========================= eCAL LICENSE ================================= | ||
* | ||
* Copyright (C) 2016 - 2024 Continental Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* ========================= eCAL LICENSE ================================= | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
#include <cstddef> | ||
#include "ecal/types/ecal_custom_data_types.h" | ||
|
||
namespace eCAL | ||
{ | ||
namespace eCALReader | ||
{ | ||
struct SUDPModeAttributes | ||
{ | ||
std::string group; | ||
}; | ||
|
||
struct SUDPAttributes | ||
{ | ||
bool enable; | ||
Types::UDPMode mode; | ||
int port; | ||
int receivebuffer; | ||
SUDPModeAttributes network; | ||
SUDPModeAttributes local; | ||
}; | ||
|
||
struct STCPAttributes | ||
{ | ||
bool enable; | ||
size_t thread_pool_size; | ||
int max_reconnection_attempts; | ||
}; | ||
|
||
struct SSHMAttributes | ||
{ | ||
bool enable; | ||
}; | ||
|
||
struct SAttributes | ||
{ | ||
bool network_enabled; | ||
bool drop_out_of_order_messages; | ||
bool loopback; | ||
unsigned int registation_timeout_ms; | ||
|
||
SUDPAttributes udp; | ||
STCPAttributes tcp; | ||
SSHMAttributes shm; | ||
|
||
std::string topic_name; | ||
std::string host_name; | ||
std::string host_group_name; | ||
int process_id; | ||
std::string process_name; | ||
std::string unit_name; | ||
bool share_topic_type; | ||
bool share_topic_description; | ||
}; | ||
} | ||
} |
Oops, something went wrong.