Skip to content

Commit

Permalink
Interface rule of five, some clang tidy suggestions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Peguen committed Jan 14, 2025
1 parent dd30c06 commit 8512efe
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
6 changes: 3 additions & 3 deletions ecal/core/src/config/ecal_path_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ namespace eCAL
}
else
{
std::cout << "[eCAL] Log path does not exist: " << path << std::endl;
std::cout << "[eCAL] Log path does not exist: " << path << "\n";
}
}
}
Expand Down Expand Up @@ -381,10 +381,10 @@ namespace eCAL
return ecal_default_paths;
}

std::string GeteCALDataDirImpl(const Util::IDirProvider& env_provider /* = DirProvider() */, const Util::IDirManager& dir_manager_ /* = DirManager() */)
std::string GeteCALDataDirImpl(const Util::IDirProvider& dir_provider /* = DirProvider() */, const Util::IDirManager& dir_manager_ /* = DirManager() */)
{
// Return the possible default paths that could contain the yaml file
const std::vector<std::string> search_directories = getEcalDefaultPaths(env_provider, dir_manager_);
const std::vector<std::string> search_directories = getEcalDefaultPaths(dir_provider, dir_manager_);

// return the first non empty path that also exists
for (const auto& path : search_directories)
Expand Down
16 changes: 16 additions & 0 deletions ecal/core/src/config/ecal_path_processing.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ namespace eCAL
class IDirManager
{
public:
virtual ~IDirManager() = default;

IDirManager() = default;
IDirManager(const IDirManager&) = default;
IDirManager(IDirManager&&) = default;
IDirManager& operator=(const IDirManager&) = default;
IDirManager& operator=(IDirManager&&) = default;

virtual bool dirExists(const std::string& path_) const = 0;
virtual bool createDir(const std::string& path_) const = 0;
virtual bool dirExistsOrCreate(const std::string& path_) const = 0;
Expand Down Expand Up @@ -101,6 +109,14 @@ namespace eCAL
class IDirProvider
{
public:
virtual ~IDirProvider() = default;

IDirProvider() = default;
IDirProvider(const IDirProvider&) = default;
IDirProvider(IDirProvider&&) = default;
IDirProvider& operator=(const IDirProvider&) = default;
IDirProvider& operator=(IDirProvider&&) = default;

virtual std::string eCALEnvVar(const std::string& var_) const = 0;
virtual std::string eCALLocalUserDir() const = 0;
virtual std::string eCALDataSystemDir(const eCAL::Util::IDirManager& dir_manager_) const = 0;
Expand Down
20 changes: 10 additions & 10 deletions ecal/tests/cpp/config_test/src/path_processing_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ TEST(core_cpp_path_processing /*unused*/, ecal_data_log_env_vars /*unused*/)
const int expected_call_count = 5;
const int expected_call_count_log_var = 3;

MockDirProvider mock_dir_provider;
NiceMock<MockDirManager> mock_dir_manager;
const MockDirProvider mock_dir_provider;
const NiceMock<MockDirManager> mock_dir_manager;

// Disable all other calls right now, as we just want to test the env vars
EXPECT_CALL(mock_dir_provider, eCALDataSystemDir(::testing::Ref(mock_dir_manager)))
Expand Down Expand Up @@ -120,8 +120,8 @@ TEST(core_cpp_path_processing /*unused*/, ecal_local_user_dir /*unused*/)
const int expected_call_count = 4;
const int expected_call_count_log_var = 2;

MockDirProvider mock_dir_provider;
NiceMock<MockDirManager> mock_dir_manager;
const MockDirProvider mock_dir_provider;
const NiceMock<MockDirManager> mock_dir_manager;

// mock the environment variables to be empty
EXPECT_CALL(mock_dir_provider, eCALEnvVar(ECAL_DATA_VAR))
Expand Down Expand Up @@ -166,8 +166,8 @@ TEST(core_cpp_path_processing /*unused*/, ecal_data_system_dir /*unused*/)
const int expected_call_count = 4;
const int expected_call_count_log_var = 2;

MockDirProvider mock_dir_provider;
NiceMock<MockDirManager> mock_dir_manager;
const MockDirProvider mock_dir_provider;
const NiceMock<MockDirManager> mock_dir_manager;

// mock the environment variables to be empty
EXPECT_CALL(mock_dir_provider, eCALEnvVar(ECAL_DATA_VAR))
Expand Down Expand Up @@ -210,8 +210,8 @@ TEST(core_cpp_path_processing /*unused*/, ecal_config_log_dir /*unused*/)
const std::string unique_tmp_dir = "/tmp/unique";
const int expected_call_count = 2;

MockDirProvider mock_dir_provider;
NiceMock<MockDirManager> mock_dir_manager;
const MockDirProvider mock_dir_provider;
const NiceMock<MockDirManager> mock_dir_manager;

// mock the environment variables to be empty
EXPECT_CALL(mock_dir_provider, eCALEnvVar(ECAL_DATA_VAR))
Expand Down Expand Up @@ -258,8 +258,8 @@ TEST(core_cpp_path_processing /*unused*/, ecal_log_order_test /*unused*/)
const std::string ecal_local_user_log_dir = ecal_local_user_dir + path_separator + ECAL_FOLDER_NAME_LOG;
const std::string ecal_data_system_log_dir = ecal_data_system_dir + path_separator + ECAL_FOLDER_NAME_LOG;

MockDirProvider mock_dir_provider;
NiceMock<MockDirManager> mock_dir_manager;
const MockDirProvider mock_dir_provider;
const NiceMock<MockDirManager> mock_dir_manager;

::testing::Sequence seq_env_log, seq_env_data, seq_local_user, seq_data_system;

Expand Down

0 comments on commit 8512efe

Please sign in to comment.