Skip to content

Commit

Permalink
Added SAttr + -builder to Registration.
Browse files Browse the repository at this point in the history
  • Loading branch information
Peguen committed Aug 14, 2024
1 parent 219c326 commit 08a6def
Show file tree
Hide file tree
Showing 25 changed files with 549 additions and 118 deletions.
11 changes: 11 additions & 0 deletions ecal/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,16 @@ if (WIN32)
)
endif()

######################################
# builder
######################################
set (ecal_builder_src
src/builder/registration_attribute_builder.cpp
src/registration/builder/udp_shm_attribute_builder.cpp
src/registration/builder/sample_applier_attribute_builder.cpp
)


######################################
# c interface
######################################
Expand Down Expand Up @@ -565,6 +575,7 @@ set(ecal_sources
${ecal_time_src}
${ecal_util_src}
${ecal_cmn_src}
${ecal_builder_src}
${ecal_header_cmn}
${ecal_header_msg}
)
Expand Down
53 changes: 53 additions & 0 deletions ecal/core/src/builder/registration_attribute_builder.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* ========================= 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 =================================
*/

#include "registration_attribute_builder.h"

namespace eCAL
{
Registration::SAttr BuildRegistrationAttr(eCAL::Registration::Configuration reg_config_, eCAL::TransportLayer::UDP::Configuration tl_udp_confi_, int process_id_)
{
Registration::SAttr attr;

attr.refresh = reg_config_.registration_refresh;
attr.network_enabled = reg_config_.network_enabled;
attr.loopback = reg_config_.loopback;
attr.host_group_name = reg_config_.host_group_name;
attr.process_id = process_id_;

attr.shm_enabled = reg_config_.layer.shm.enable;
attr.udp_enabled = reg_config_.layer.udp.enable;

attr.shm.domain = reg_config_.layer.shm.domain;
attr.shm.queue_size = reg_config_.layer.shm.queue_size;

attr.udp.port = reg_config_.layer.udp.port;
attr.udp.sendbuffer = tl_udp_confi_.send_buffer;
attr.udp.receivebuffer = tl_udp_confi_.receive_buffer;
attr.udp.mode = tl_udp_confi_.mode;

attr.udp.network.group = tl_udp_confi_.network.group;
attr.udp.network.ttl = tl_udp_confi_.network.ttl;

attr.udp.local.group = tl_udp_confi_.local.group;
attr.udp.local.ttl = tl_udp_confi_.local.ttl;

return attr;
}
}
33 changes: 33 additions & 0 deletions ecal/core/src/builder/registration_attribute_builder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* ========================= 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 =================================
*/

#ifndef REGISTRATION_BUILDER_H
#define REGISTRATION_BUILDER_H

#include "registration/attributes/registration_attr.h"

#include <ecal/ecal_config.h>

namespace eCAL
{
Registration::SAttr BuildRegistrationAttr(eCAL::Registration::Configuration reg_config_, eCAL::TransportLayer::UDP::Configuration tl_udp_confi_, int process_id_);
}


#endif // REGISTRATION_BUILDER_H
20 changes: 10 additions & 10 deletions ecal/core/src/config/ecal_config_initializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ namespace eCAL
{
eCAL::Logging::Log(log_level_warning, "Specified yaml configuration path not valid:\"" + yaml_path_ + "\". Using default configuration.");
}
};
}

Configuration::Configuration(int argc_ , char **argv_)
: Configuration(ConvertArgcArgvToVector(argc_, argv_))
Expand Down Expand Up @@ -275,47 +275,47 @@ namespace eCAL
Configuration& GetConfiguration()
{
return g_ecal_configuration;
};
}

Registration::Configuration& GetRegistrationConfiguration()
{
return GetConfiguration().registration;
};
}

Monitoring::Configuration& GetMonitoringConfiguration()
{
return GetConfiguration().monitoring;
};
}

Logging::Configuration& GetLoggingConfiguration()
{
return GetConfiguration().logging;
};
}

Subscriber::Configuration& GetSubscriberConfiguration()
{
return GetConfiguration().subscriber;
};
}

Publisher::Configuration& GetPublisherConfiguration()
{
return GetConfiguration().publisher;
};
}

Time::Configuration& GetTimesyncConfiguration()
{
return GetConfiguration().timesync;
};
}

Service::Configuration& GetServiceConfiguration()
{
return GetConfiguration().service;
};
}

Application::Configuration& GetApplicationConfiguration()
{
return GetConfiguration().application;
};
}
}


Expand Down
7 changes: 5 additions & 2 deletions ecal/core/src/ecal_globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include "service/ecal_service_singleton_manager.h"
#endif

#include "builder/registration_attribute_builder.h"

namespace eCAL
{
CGlobals::CGlobals() : initialized(false), components(0)
Expand All @@ -49,12 +51,13 @@ namespace eCAL
bool new_initialization(false);

#if ECAL_CORE_REGISTRATION
Registration::SAttr registration_attr = BuildRegistrationAttr(GetConfiguration().registration, GetConfiguration().transport_layer.udp, eCAL::Process::GetProcessID());
/////////////////////
// REGISTRATION PROVIDER
/////////////////////
if (registration_provider_instance == nullptr)
{
registration_provider_instance = std::make_unique<CRegistrationProvider>(eCAL::GetRegistrationConfiguration());
registration_provider_instance = std::make_unique<CRegistrationProvider>(registration_attr);
new_initialization = true;
}

Expand All @@ -63,7 +66,7 @@ namespace eCAL
/////////////////////
if(registration_receiver_instance == nullptr)
{
registration_receiver_instance = std::make_unique<CRegistrationReceiver>(eCAL::GetRegistrationConfiguration());
registration_receiver_instance = std::make_unique<CRegistrationReceiver>(registration_attr);
new_initialization = true;
}
#endif // ECAL_CORE_REGISTRATION
Expand Down
68 changes: 68 additions & 0 deletions ecal/core/src/registration/attributes/registration_attr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* ========================= 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 =================================
*/

#ifndef REGISTRATION_PROVIDER_ATTR_H
#define REGISTRATION_PROVIDER_ATTR_H

#include <string>
#include <ecal/types/ecal_custom_data_types.h>

namespace eCAL
{
namespace Registration
{
struct SUDPModeAttr
{
std::string group;
int ttl;
};

struct SUDPAttr
{
Types::UDPMode mode;
int port;
int sendbuffer;
int receivebuffer;
SUDPModeAttr network;
SUDPModeAttr local;
};

struct SSHMAttr
{
std::string domain;
size_t queue_size;
};

struct SAttr
{
bool network_enabled;
bool loopback;
bool shm_enabled;
bool udp_enabled;
unsigned int refresh;
std::string host_group_name;
int process_id;

SUDPAttr udp;
SSHMAttr shm;
};
}
}

#endif // REGISTRATION_PROVIDER_ATTR_H
42 changes: 42 additions & 0 deletions ecal/core/src/registration/attributes/sample_applier_attr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* ========================= 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 =================================
*/

#ifndef SAMPLE_APPLIER_ATTR_H
#define SAMPLE_APPLIER_ATTR_H

#include <string>

namespace eCAL
{
namespace Registration
{
namespace SampleApplier
{
struct SAttr
{
bool network_enabled;
bool loopback;
std::string host_group_name;
int process_id;
};
}
}
}

#endif // SAMPLE_APPLIER_ATTR_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* ========================= 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 =================================
*/

#include "sample_applier_attribute_builder.h"

namespace eCAL
{
namespace Registration
{
namespace SampleApplier
{
SAttr BuildSampleApplierAttr(const Registration::SAttr& attr_)
{
SAttr sample_applier_attr;

sample_applier_attr.network_enabled = attr_.network_enabled;
sample_applier_attr.loopback = attr_.loopback;
sample_applier_attr.host_group_name = attr_.host_group_name;
sample_applier_attr.process_id = attr_.process_id;

return sample_applier_attr;
}
}
}
}
Loading

0 comments on commit 08a6def

Please sign in to comment.