Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[config] Implementation of new configuration management #1505

Merged
merged 120 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
382d9ef
First working implementation for config management.
Peguen Feb 20, 2024
0e9c039
Merge branch 'master' into feature/user_config_implementation
Peguen Feb 20, 2024
49e8ade
Resolved some merging problems.
Peguen Feb 21, 2024
70366d5
Fixed copy paste issue values for receivingOptions in ecal_config_ini…
Peguen Feb 21, 2024
00b2ec1
Config Adaptions: Set LimitSize default paramaeter to template MIN va…
Peguen Feb 21, 2024
eb31c72
Refactored options and config access.
Peguen Mar 27, 2024
548037f
Changed defines to constexpr in ecal_dev_ini.h
Peguen Mar 27, 2024
5b07971
Removed doubled constexpr.
Peguen Mar 27, 2024
9cd3594
Removed former ecal_config cpp and h from core/CMakesLists
Peguen Mar 28, 2024
9e1be9a
Removed ms_t from registration_options and handling in using functions.
Peguen Mar 28, 2024
c5ab1dc
Fixed ecal_registration cpp time config import.
Peguen Mar 28, 2024
05ec616
Refactored config options in application.
Peguen Mar 28, 2024
a861b01
Added process_options.terminal_emulator to config.
Peguen Mar 28, 2024
e35df5a
Refactored sys- and processoptions as sub to application options.
Peguen Mar 28, 2024
4a0ce13
Refactored default config to use ecal_def.h defines.
Peguen Mar 28, 2024
153ee9e
Refactored ini config to use ecal_def.h
Peguen Mar 28, 2024
94f91ae
Moved IpAddressV4 definitions to private space.
Peguen Mar 28, 2024
b196ab4
Removed unused fields.
Peguen Mar 28, 2024
afe2332
Fixed some GH actions compiling issues.
Peguen Mar 28, 2024
4887b02
Removed unnecessary comments in header files.
Peguen Mar 28, 2024
c768ba9
Changed #include <limits> to correct header.
Peguen Apr 2, 2024
6306d99
Merge branch 'master' into feature/user_config_implementation
Peguen Apr 2, 2024
b4690a0
Some updates regarding new configuration management to ecal_core.
Peguen Apr 2, 2024
4694927
Updated submodules
Peguen Apr 3, 2024
388f5bc
Checked out versions of thirdparty modules equal to master branch.
Peguen Apr 3, 2024
9303795
Implemented termination, when wrong values are assigned to custom dat…
Peguen Apr 3, 2024
848c572
Changed g_ecal_config() return value (PathWarning)
Peguen Apr 3, 2024
2370814
Added basic configuration tests.
Peguen Apr 3, 2024
e20d510
Added ECAL_API macro for config calls.
Peguen Apr 3, 2024
7cafa3e
Added operator overloading of == for LimitSize(LS), LS == int, LS == …
Peguen Apr 4, 2024
a6936d1
Fixed warnings because of implicit types conversions by implementing …
Peguen Apr 4, 2024
ca428d1
Created deathtests and more type tests for configuration tests.
Peguen Apr 4, 2024
5a5fe2c
Merge branch 'master' into feature/user_config_implementation
Peguen Apr 4, 2024
0370d47
Removed GetDefaultConfig().
Peguen Apr 4, 2024
ae7e608
Setting new_initialization to true in ecal_globals when ecal_config g…
Peguen Apr 5, 2024
6530bec
Removed const from custom_data_types as recommended.
Peguen Apr 5, 2024
3f95473
Review 1: Moved GetCurrentConfig to config.h.
Peguen Apr 8, 2024
a435621
Changed defines to constexpr in ecal_dev_ini.h
Peguen Mar 27, 2024
832c811
Changed defines to constexpr in ecal_def, ecal_def_ini + added uint a…
Peguen Apr 8, 2024
673a4b0
Merge remote-tracking branch 'origin/master' into feature/defines_to_…
Peguen Apr 8, 2024
ca14568
Merge branch 'feature/defines_to_constexpr' into feature/user_config_…
Peguen Apr 8, 2024
e05f398
Removed ecal_internal_options.h.
Peguen Apr 8, 2024
a8da1ce
Introduced logging options.
Peguen Apr 8, 2024
2dc3cbc
Renamed ProcessOptions to StartupOptions.
Peguen Apr 8, 2024
b2af134
Renamed ProcessOptions to StartupOptions in application_options.h.
Peguen Apr 9, 2024
71cc7e5
Adapted IpAddressV4 to exclude some addresses. Added test cases.
Peguen Apr 9, 2024
3c7b05d
Reverted changes to ecal.cpp and ecal_globals.cpp.
Peguen Apr 9, 2024
3db1f9d
ecal_config as reference, not pointer.
Peguen Apr 9, 2024
f3bbc96
Review 1: Config not as ptr. Optimized handling. Clangtidy happiness.
Peguen Apr 10, 2024
c19c4ff
Merge remote-tracking branch 'origin/master' into feature/user_config…
Peguen Apr 11, 2024
e0a1656
Changed constexpr in ecal_config_initializer.cpp
Peguen Apr 11, 2024
063b484
Added some clang tidy improvements (e.g. usage of const)
Peguen Apr 11, 2024
ceb4419
Added operator int() to LimitSize.
Peguen Apr 11, 2024
3a811a4
Added operator std::string() to IpV4Address.
Peguen Apr 11, 2024
4893564
Added default constructors to custom types classes.
Peguen Apr 11, 2024
32dfc18
... also for Limitsize.
Peguen Apr 11, 2024
9395da5
Added config example.
Peguen Apr 11, 2024
482ae05
CGlobals initializing in global space.
Peguen Apr 11, 2024
284f873
Adapted config sample.
Peguen Apr 11, 2024
a18e9de
config_test.cpp const happiness for clangtidy.
Peguen Apr 11, 2024
8da505e
Added timesync_module_replay to config and removed eCALPar from timeg…
Peguen Apr 12, 2024
2e8b9d4
Made github-actions bot a bit happier.
Peguen Apr 12, 2024
e7a9642
IpAddressV4 operator= improvement.
Peguen Apr 15, 2024
ddbbc99
Removed some PG TODOS.
Peguen Apr 15, 2024
10a3835
Started with documentation adaptions for config.
Peguen Apr 16, 2024
d19e55e
Updated docu for config with types.
Peguen Apr 17, 2024
733d4c6
TODO comment.
Peguen Apr 17, 2024
a7072fc
Small update to config doc.
Peguen Apr 17, 2024
c946cc6
Small update to config example.
Peguen Apr 17, 2024
19512cf
Small update to config example._2
Peguen Apr 17, 2024
8df8937
Renamed LimitSize to ConstrainedInteger.
Peguen Apr 17, 2024
4e049db
Changed behaviour of custom types: throwing invalid_argument exceptio…
Peguen Apr 18, 2024
0667980
Merge remote-tracking branch 'origin/master' into feature/user_config…
Peguen Apr 18, 2024
0511bed
Reverted Config Getters to previous integration.
Peguen Apr 18, 2024
da0a991
Added user_args to config file.
Peguen Apr 24, 2024
543949e
Refactored ecal Initialize with the config handling.
Peguen Apr 26, 2024
eb1a4ee
Throw exception for ecal registration options.
Peguen Apr 26, 2024
a362f26
Refactored ecal_registration_options.
Peguen Apr 26, 2024
521d70b
Merge remote-tracking branch 'origin/master' into feature/user_config…
Peguen Apr 26, 2024
ba0a6c1
cmd parser: path sep renaming.
Peguen Apr 26, 2024
51308c0
Cmd parser: throw error message, when cmd line ini file was not found.
Peguen Apr 26, 2024
aca5d69
Changed ini handling for config file.
Peguen Apr 26, 2024
557637a
Updated docu for config and example.
Peguen Apr 26, 2024
d910ef2
give user the freedom to initialize with specified ini file.
Peguen Apr 26, 2024
676facf
Merge remote-tracking branch 'origin/master' into feature/user_config…
Peguen May 13, 2024
5476f04
Some whitespaces.
Peguen May 15, 2024
1435ee8
Added RegistrationOptions test.
Peguen May 15, 2024
602212f
Changed ini file handling for cmd parser -> return complete path in e…
Peguen May 16, 2024
0dc7398
Added cmd parser ini test and death test.
Peguen May 16, 2024
e454368
Added cmd parser config key test + store config keys in map.
Peguen May 16, 2024
d72adbc
Removed generated ini file in test after usage.
Peguen May 16, 2024
82d8d11
Added config keys map to user cli arguments and provided the struct t…
Peguen May 16, 2024
b7e0bed
Merge remote-tracking branch 'origin/master' into feature/user_config…
Peguen May 16, 2024
287c24f
Clean up code and make clangtidy happy.
Peguen May 17, 2024
e3bb375
Merge remote-tracking branch 'origin/master' into feature/user_config…
Peguen May 17, 2024
ac9dbe9
Merge remote-tracking branch 'origin/master' into feature/user_config…
Peguen May 17, 2024
fed863b
Refactored to current publisher options. TimeoutAcknowledge test not …
Peguen May 17, 2024
31b0c6e
Make clang tidy a bit more happy.
Peguen May 21, 2024
295f998
Enable shm for pubsub acknowledge test.
Peguen May 21, 2024
915a7f7
Included ecal_subscriber_config
Peguen May 21, 2024
a2aca3e
Renamend Configuration member.
Peguen May 21, 2024
cf2148c
Moved config to globalgalactic space. Implemented default config cons…
Peguen May 21, 2024
80ef2a0
Restructure eCAL Application Options and default init for publisher/s…
Peguen May 22, 2024
cafb419
Use custom types in publisher config.
Peguen May 22, 2024
25116ea
Restructered config file structure, config namespaces and and file na…
Peguen May 22, 2024
f7b8470
Added comments to config structs from ini file.
Peguen May 22, 2024
f6f3dd5
Some file renaming.
Peguen May 23, 2024
913fee0
Updated docu for config.
Peguen May 23, 2024
fd80bad
Changes for transportlayer config.
Peguen May 24, 2024
e126b12
Try taking .ini file in normal initializing, as it was before.
Peguen May 24, 2024
f876c26
Merge remote-tracking branch 'origin/master' into feature/user_config…
Peguen May 24, 2024
25dd3e0
Added doc for publisher config.
Peguen May 24, 2024
7be0dd9
Defaulted publisher test again.
Peguen May 24, 2024
aa1d1ca
Removed unncessary constructor/destructor in custom config classes.
Peguen May 27, 2024
db16ff6
Some ecal_cmd_parser cleanup.
Peguen May 27, 2024
9613db0
Merge remote-tracking branch 'origin/master' into feature/user_config…
Peguen May 27, 2024
11044f1
Fix ecal_cmd_parser checkForValidConfigFilePath function.
Peguen May 28, 2024
a9a4a41
Fixed ecal_cmd_parser problem with path separator attachments.
Peguen May 29, 2024
d1c606d
Merge remote-tracking branch 'origin/master' into feature/user_config…
Peguen Jun 4, 2024
23ac095
Changed handling of cli arguments to std::vector<string> by default.
Peguen Jun 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"HAS_CURL": "ON",
"HAS_FTXUI": "ON",
"BUILD_APPS": "ON",
"BUILD_SAMPLES": "ON",
"ECAL_THIRDPARTY_BUILD_FINEFTP": "ON",
"ECAL_THIRDPARTY_BUILD_FTXUI": "ON",
"ECAL_THIRDPARTY_BUILD_SPDLOG": "ON",
Expand Down
4 changes: 2 additions & 2 deletions app/mon/mon_gui/src/ecalmon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ Ecalmon::Ecalmon(QWidget *parent)
network_mode_warning_icon_->setPixmap(warning_icon);
network_mode_warning_icon_->setVisible(false);

bool network_mode = eCAL::Config::IsNetworkEnabled();
int multicast_ttl = eCAL::Config::GetUdpMulticastTtl();
bool network_mode = eCAL::Config::GetCurrentConfig()->transport_layer_options.network_enabled;
Peguen marked this conversation as resolved.
Show resolved Hide resolved
int multicast_ttl = eCAL::Config::GetCurrentConfig()->transport_layer_options.mc_options.ttl;
Peguen marked this conversation as resolved.
Show resolved Hide resolved

if (network_mode)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ void TopicWidget::loadRegExpLists()

QString exclude_string;
QString include_string;
exclude_string = QString::fromStdString(eCAL::Config::GetMonitoringFilterExcludeList()); //ini.GetValue(MON_SECTION_S, MON_FILTER_EXCL_S);
exclude_string = QString::fromStdString(eCAL::Config::GetCurrentConfig()->monitoring_options.filter_excl);

include_string = QString::fromStdString(eCAL::Config::GetMonitoringFilterIncludeList()); //ini.GetValue(MON_SECTION_S, MON_FILTER_INCL_S);
include_string = QString::fromStdString(eCAL::Config::GetCurrentConfig()->monitoring_options.filter_incl);


// The ecal.ini defines a very strange regex format: A filter consists of
Expand Down
2 changes: 1 addition & 1 deletion app/mon/mon_tui/src/tui/viewmodel/command_line.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class CommandLineViewModel : public ViewModel
{
using namespace std::placeholders;

network_mode = eCAL::Config::IsNetworkEnabled() ? "cloud" : "local";
network_mode = eCAL::Config::GetCurrentConfig()->transport_layer_options.network_enabled ? "cloud" : "local";
is_polling_time = true;
time_updater = std::thread(std::bind(&CommandLineViewModel::UpdateCurrentEcalTime, this));

Expand Down
3 changes: 2 additions & 1 deletion app/rec/rec_client_core/src/job/record_job.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <ecal_utils/filesystem.h>
#include <ecal_utils/ecal_utils.h>
#include <ecal/ecal_config.h>

#include "hdf5_writer_thread.h"

Expand Down Expand Up @@ -170,7 +171,7 @@ namespace eCAL
#undef CopyFile
#endif // CopyFile
{
std::string ecal_ini_original_path = eCAL::Config::GetLoadedEcalIniPath();
std::string ecal_ini_original_path = Config::GetCurrentConfig()->loaded_ecal_ini_file;
Peguen marked this conversation as resolved.
Show resolved Hide resolved

if (ecal_ini_original_path.empty())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -927,8 +927,8 @@ void ImportFromCloudWidget::loadExcludeTasksFilter()
QFile default_cfg_file(default_cfg_file_path.c_str());
if (default_cfg_file.exists())
{
std::regex reg(eCAL::Config::GetEcalSysFilterExcludeList(), std::regex::icase);
exclude_tasks_regex_valid_ = !eCAL::Config::GetEcalSysFilterExcludeList().empty();
std::regex reg(eCAL::Config::GetCurrentConfig()->application_options.sys_options.filter_excl, std::regex::icase);
Peguen marked this conversation as resolved.
Show resolved Hide resolved
exclude_tasks_regex_valid_ = !eCAL::Config::GetCurrentConfig()->application_options.sys_options.filter_excl.empty();
Peguen marked this conversation as resolved.
Show resolved Hide resolved
exclude_tasks_regex_ = reg;
}
}
5 changes: 3 additions & 2 deletions ecal/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ endif()
# config
######################################
set(ecal_config_src
src/config/ecal_config.cpp
src/config/ecal_config_reader.cpp
src/config/ecal_config_reader.h
src/config/ecal_config_reader_hlp.h
src/config/ecal_config_initializer.cpp
src/types/ecal_custom_data_types.cpp
)

######################################
Expand Down Expand Up @@ -475,7 +476,6 @@ set(ecal_header_cmn
include/ecal/ecal.h
include/ecal/ecal_callback.h
include/ecal/ecal_client.h
include/ecal/ecal_config.h
include/ecal/ecal_core.h
include/ecal/ecal_deprecate.h
include/ecal/ecal_init.h
Expand All @@ -495,6 +495,7 @@ set(ecal_header_cmn
include/ecal/ecal_tlayer.h
include/ecal/ecal_types.h
include/ecal/ecal_util.h
include/ecal/types/ecal_config_types.h
)

set(ecal_header_cimpl
Expand Down
4 changes: 2 additions & 2 deletions ecal/core/cfg/ecal.ini
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@ filter_excl = ^eCALSysClient$|^eCALSysGUI$|^eCALSys$
; shm_monitoring_enabled = false Enable distribution of monitoring/registration information via shared memory
; shm_monitoring_domain = ecal_monitoring Domain name for shared memory based monitoring/registration
; shm_monitoring_queue_size = 1024 Queue size of monitoring/registration events
; network_monitoring_disabled = false Disable distribution of monitoring/registration information via network
; network_monitoring_enabled = true Enable distribution of monitoring/registration information via network
;
; drop_out_of_order_messages = false Enable dropping of payload messages that arrive out of order
; --------------------------------------------------
[experimental]
shm_monitoring_enabled = false
shm_monitoring_domain = ecal_mon
shm_monitoring_queue_size = 1024
network_monitoring_disabled = false
network_monitoring_enabled = true
drop_out_of_order_messages = false
1 change: 1 addition & 0 deletions ecal/core/include/ecal/ecal.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@
#include <ecal/ecal_timer.h>
#include <ecal/ecal_tlayer.h>
#include <ecal/ecal_util.h>
#include <ecal/types/ecal_config_types.h>
14 changes: 8 additions & 6 deletions ecal/core/include/ecal/ecal_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
*
* ========================= eCAL LICENSE =================================
*/

// TODO PG: Remove, deprecated
Peguen marked this conversation as resolved.
Show resolved Hide resolved
#pragma once

#include <cstddef>
#include <ecal/ecal_log_level.h>
#include <ecal/ecal_os.h>
#include <ecal/ecal_tlayer.h>
#include <ecal/ecal_log_level.h>
Peguen marked this conversation as resolved.
Show resolved Hide resolved
#include "ecal/types/ecal_config_types.h"

#include <string>

Expand All @@ -31,11 +33,11 @@ namespace eCAL
{
namespace Config
{
enum class UdpConfigVersion
{
V1 = 1, // Legacy
V2 = 2
};
// enum class UdpConfigVersion
// {
// V1 = 1, // Legacy
// V2 = 2
// };

/////////////////////////////////////
// common
Expand Down
5 changes: 3 additions & 2 deletions ecal/core/include/ecal/ecal_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <utility>

#include <ecal/ecal_os.h>
#include "ecal/types/ecal_config_types.h"

namespace eCAL
{
Expand Down Expand Up @@ -69,7 +70,7 @@ namespace eCAL
*
* @return Zero if succeeded, 1 if already initialized, -1 if failed.
**/
ECAL_API int Initialize(int argc_ = 0, char **argv_ = nullptr, const char *unit_name_ = nullptr, unsigned int components_ = Init::Default);
ECAL_API int Initialize(int argc_ = 0, char** argv_ = nullptr, const char* unit_name_ = nullptr, unsigned int components_ = Init::Default, Config::eCALConfig* = nullptr);

Peguen marked this conversation as resolved.
Show resolved Hide resolved
/**
* @brief Initialize eCAL API.
Expand All @@ -80,7 +81,7 @@ namespace eCAL
*
* @return Zero if succeeded, 1 if already initialized, -1 if failed.
**/
ECAL_API int Initialize(std::vector<std::string> args_, const char *unit_name_ = nullptr, unsigned int components_ = Init::Default);
ECAL_API int Initialize(std::vector<std::string> args_, const char *unit_name_ = nullptr, unsigned int components_ = Init::Default, Config::eCALConfig* user_settings_ = nullptr);
Peguen marked this conversation as resolved.
Show resolved Hide resolved

/**
* @brief Finalize eCAL API.
Expand Down
49 changes: 49 additions & 0 deletions ecal/core/include/ecal/types/ecal_application_options.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* =========================== 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.
*
* =========================== LICENSE =================================
*/

/**
* @file ecal_application_options.h
* @brief eCAL options for configuration of applications
**/

#pragma once

#include <string>

namespace eCAL
{
namespace Config
{
struct SysOptions
{
std::string filter_excl;
};

struct ProcessOptions
Peguen marked this conversation as resolved.
Show resolved Hide resolved
{
std::string terminal_emulator;
};

struct ApplicationOptions
{
SysOptions sys_options;
ProcessOptions process_options;
};
}
}
66 changes: 66 additions & 0 deletions ecal/core/include/ecal/types/ecal_config_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* =========================== 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.
*
* =========================== LICENSE =================================
*/

/**
* @file ecal_config_types.h
* @brief eCAL config interface using structs
**/

#pragma once

#include "ecal_application_options.h"
#include "ecal_custom_data_types.h"
#include "ecal_monitoring_options.h"
#include "ecal_publisher_options.h"
#include "ecal_receiving_options.h"
#include "ecal_registration_options.h"
#include "ecal_service_options.h"
#include "ecal_internal_options.h"
#include "ecal_transport_layer_options.h"

#include "ecal/ecal_os.h"
#include "ecal/ecal_log_level.h"

#include <string>
#include <vector>
#include <iostream>
#include <chrono>

namespace eCAL
{
namespace Config
{
struct eCALConfig
{
TransportLayerOptions transport_layer_options;
RegistrationOptions registration_options;
MonitoringOptions monitoring_options;
ReceivingOptions receiving_options;
PublisherOptions publisher_options;
TimesyncOptions timesync_options;
ServiceOptions service_options;
ApplicationOptions application_options;
std::string loaded_ecal_ini_file;

ECAL_API eCALConfig();
};

ECAL_API eCALConfig* GetCurrentConfig();
Peguen marked this conversation as resolved.
Show resolved Hide resolved
}
}
101 changes: 101 additions & 0 deletions ecal/core/include/ecal/types/ecal_custom_data_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/* =========================== 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.
*
* =========================== LICENSE =================================
*/

/**
* @file ecal_custom_types.h
* @brief eCAL custom types for configuration declarations
**/

#pragma once

#include "ecal/ecal_os.h"

#include <string>
#include <iostream>
#include <regex>
#include <limits>

namespace eCAL
{
namespace Config
{
/**
* @brief Class for evaluation and storing an IP address.
*
* @param ip_adress_ The IP address as std::string.
**/
class IpAddressV4
Peguen marked this conversation as resolved.
Show resolved Hide resolved
Peguen marked this conversation as resolved.
Show resolved Hide resolved
Peguen marked this conversation as resolved.
Show resolved Hide resolved
{
public:
IpAddressV4() = default;
Peguen marked this conversation as resolved.
Show resolved Hide resolved
ECAL_API IpAddressV4(const std::string ip_address_);
Peguen marked this conversation as resolved.
Show resolved Hide resolved

const std::string get() { return m_ip_address; }
Peguen marked this conversation as resolved.
Show resolved Hide resolved

private:
static bool checkIpString(std::string ip_address_);

std::string m_ip_address{};
};

/**
* @brief Template class to specify sizes with a concrete minimum, maximum and step size definition.
*
* @tparam MIN Optional minimum possible size. Default: 0
* @tparam STEP Optional step size. Default: 1
* @tparam MAX Optional maximum possible size. Default: std::numeric_limits<int>::max()
*
* @param size_ Optional size value. If not set, LimitSize::get() will return the MIN value.
**/
template<int MIN = 0, int STEP = 1, int MAX = std::numeric_limits<int>::max()>
class LimitSize
Peguen marked this conversation as resolved.
Show resolved Hide resolved
Peguen marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: class 'LimitSize' defines a default destructor, a copy constructor and a copy assignment operator but does not define a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]

    class LimitSize
          ^

{
public:
LimitSize(int size_ = MIN)
{
if (size_ >= MIN && size_ <= MAX && size_ % STEP == 0)
{
m_size = size_;
}
else
{
std::cerr << "[LimitSize] Faulty size configuration or assignment. MIN: " << MIN << " MAX: " << MAX << " STEP: " << STEP << " VALUE:" << size_ << "\n";
exit(EXIT_FAILURE);
}
};

const int get() const { return m_size; };
Peguen marked this conversation as resolved.
Show resolved Hide resolved

bool operator==(const LimitSize& other) const { return this->m_size == other.get(); };
friend bool operator==(const LimitSize& lhs, const int& rhs) { return lhs.get() == rhs; };
friend bool operator==(const int& lhs, const LimitSize& rhs) { return rhs == lhs; };
friend bool operator==(const LimitSize& lhs, const unsigned int& rhs) { return lhs.get() == static_cast<int>(rhs); };
friend bool operator==(const unsigned int& lhs, const LimitSize& rhs) { return rhs == lhs; };

private:
int m_size;
};

enum class UdpConfigVersion
{
V1 = 1,
V2 = 2
};
}
}
Loading
Loading