You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2019/01/07 20:11:52 UTC
[celix] 04/22: CELIX-438: Updates to compile on gcc,
adds glog as external project and fixes code coverage setup
This is an automated email from the ASF dual-hosted git repository.
pnoltes pushed a commit to branch feature/cxx
in repository https://gitbox.apache.org/repos/asf/celix.git
commit 9e854fdaf08a04f51d42a34d37e7964c056703a8
Author: Pepijn Noltes <pe...@gmail.com>
AuthorDate: Thu Jan 3 11:40:54 2019 +0100
CELIX-438: Updates to compile on gcc, adds glog as external project and fixes code coverage setup
---
CMakeLists.txt | 8 ++++----
bundles/shell/cxx_shell/CMakeLists.txt | 4 ++--
bundles/shell/cxx_shell/src/ShellActivator.cc | 1 +
bundles/shell/cxx_shell_tui/CMakeLists.txt | 4 ++--
.../shell/cxx_shell_tui/src/ShellTuiActivator.cc | 9 +++++----
.../celix_project/AddGLog.cmake | 19 ++++++++----------
cmake/celix_project/CodeCoverage.cmake | 11 +++++++++--
libs/framework/tst/CMakeLists.txt | 3 ++-
libs/framework_cxx/CMakeLists.txt | 3 ++-
libs/framework_cxx/gtest/CMakeLists.txt | 3 ++-
libs/framework_cxx/gtest/src/Framework_tests.cc | 8 +++++---
libs/framework_cxx/src/Bundle.h | 10 +++++++---
libs/framework_cxx/src/BundleContext.cc | 8 +++++---
libs/framework_cxx/src/Framework.cc | 23 ++++++++++++++--------
libs/registry/CMakeLists.txt | 3 ++-
libs/registry/gtest/CMakeLists.txt | 3 ++-
.../gtest/src/RegistryConcurrency_tests.cc | 2 ++
libs/registry/gtest/src/Registry_tests.cc | 5 ++++-
libs/registry/include/celix/Filter.h | 1 +
libs/registry/include/celix/IResourceBundle.h | 1 +
libs/registry/include/celix/ServiceRegistry.h | 2 ++
libs/registry/include/celix/Utils.h | 2 +-
libs/registry/src/ServiceRegistry.cc | 11 ++++++-----
23 files changed, 90 insertions(+), 54 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9ba636e..c1c4a43 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -47,17 +47,17 @@ ELSE ()
ENDIF()
# Set version for the framework package/release
-set(CELIX_MAJOR "2")
-set(CELIX_MINOR "2")
+set(CELIX_MAJOR "3")
+set(CELIX_MINOR "0")
set(CELIX_MICRO "0")
-option(ENABLE_TESTING "Enables unit testing using CPPUTEST" OFF)
-option(ENABLE_GTESTING "Enables unit testing using GTest" ON)
+option(ENABLE_TESTING "Enables unit testing" OFF)
if (ENABLE_TESTING)
enable_testing()
include(cmake/celix_project/AddGTest.cmake)
endif ()
+include(cmake/celix_project/AddGLog.cmake)
# Default bundle version
set(DEFAULT_VERSION 1.0.0)
diff --git a/bundles/shell/cxx_shell/CMakeLists.txt b/bundles/shell/cxx_shell/CMakeLists.txt
index ccdf03b..a4ad2df 100644
--- a/bundles/shell/cxx_shell/CMakeLists.txt
+++ b/bundles/shell/cxx_shell/CMakeLists.txt
@@ -34,8 +34,8 @@ add_library(celix_cxx_shell SHARED
src/QueryCommand.cc
)
target_include_directories(celix_cxx_shell PRIVATE src)
-target_link_libraries(celix_cxx_shell PRIVATE celix_cxx_shell_api)
-target_link_libraries(celix_cxx_shell PUBLIC glog::glog celix_framework_cxx)
+target_link_libraries(celix_cxx_shell PRIVATE celix_cxx_shell_api glog::glog)
+target_link_libraries(celix_cxx_shell PUBLIC celix_framework_cxx)
#if (ENABLE_TESTING)
# add_subdirectory(gtest)
diff --git a/bundles/shell/cxx_shell/src/ShellActivator.cc b/bundles/shell/cxx_shell/src/ShellActivator.cc
index 58c8f2f..bfbbb8f 100644
--- a/bundles/shell/cxx_shell/src/ShellActivator.cc
+++ b/bundles/shell/cxx_shell/src/ShellActivator.cc
@@ -44,6 +44,7 @@ namespace {
}
token = strtok_r(nullptr, " ", &savePtr);
}
+ free(cl);
bool commandCalled = false;
diff --git a/bundles/shell/cxx_shell_tui/CMakeLists.txt b/bundles/shell/cxx_shell_tui/CMakeLists.txt
index df20046..cfbf6cf 100644
--- a/bundles/shell/cxx_shell_tui/CMakeLists.txt
+++ b/bundles/shell/cxx_shell_tui/CMakeLists.txt
@@ -24,8 +24,8 @@ add_library(celix_cxx_shell_tui SHARED
src/ShellTuiActivator.cc
src/shell_test.cc)
target_include_directories(celix_cxx_shell_tui PRIVATE src)
-target_link_libraries(celix_cxx_shell_tui PRIVATE celix_cxx_shell_api)
-target_link_libraries(celix_cxx_shell_tui PUBLIC glog::glog celix_framework_cxx)
+target_link_libraries(celix_cxx_shell_tui PRIVATE celix_cxx_shell_api glog::glog)
+target_link_libraries(celix_cxx_shell_tui PUBLIC celix_framework_cxx)
#if (ENABLE_TESTING)
# add_subdirectory(gtest)
diff --git a/bundles/shell/cxx_shell_tui/src/ShellTuiActivator.cc b/bundles/shell/cxx_shell_tui/src/ShellTuiActivator.cc
index a1ddf5a..a66bea5 100644
--- a/bundles/shell/cxx_shell_tui/src/ShellTuiActivator.cc
+++ b/bundles/shell/cxx_shell_tui/src/ShellTuiActivator.cc
@@ -21,6 +21,7 @@
#include <cstdio>
#include <unistd.h>
#include <fcntl.h>
+#include <mutex>
#include <glog/logging.h>
@@ -115,10 +116,10 @@ namespace {
std::mutex mutex{};
std::shared_ptr<celix::IShell> shell{};
- std::thread readThread;
+ std::thread readThread{};
- int readPipeFd;
- int writePipeFd;
+ int readPipeFd{};
+ int writePipeFd{};
char in[LINE_SIZE+1]{};
@@ -136,7 +137,7 @@ namespace {
}
private:
ShellTui tui{};
- celix::ServiceTracker trk;
+ celix::ServiceTracker trk{};
};
__attribute__((constructor))
diff --git a/libs/registry/CMakeLists.txt b/cmake/celix_project/AddGLog.cmake
similarity index 64%
copy from libs/registry/CMakeLists.txt
copy to cmake/celix_project/AddGLog.cmake
index ee537cc..8cc3414 100644
--- a/libs/registry/CMakeLists.txt
+++ b/cmake/celix_project/AddGLog.cmake
@@ -15,18 +15,15 @@
# specific language governing permissions and limitations
# under the License.
-find_package(glog REQUIRED)
-add_library(celix_registry STATIC
- src/ServiceRegistry.cc
- src/Filter.cc
+include(ExternalProject)
+ExternalProject_Add(
+ googlelog_project
+ GIT_REPOSITORY https://github.com/google/glog.git
+ GIT_TAG v0.3.5
+ PREFIX ${CMAKE_CURRENT_BINARY_DIR}/glog
+ CMAKE_ARGS -DWITH_GFLAGS=OFF -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/glog -DCMAKE_CXX_FLAGS=-w
)
-target_include_directories(celix_registry PRIVATE src)
-target_include_directories(celix_registry PUBLIC include)
-target_link_libraries(celix_registry PRIVATE glog::glog) #TODO make glog static and private
-add_library(celix::registry ALIAS celix_registry)
+set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_BINARY_DIR}/glog ${CMAKE_PREFIX_PATH}")
-if (ENABLE_TESTING)
- add_subdirectory(gtest)
-endif ()
\ No newline at end of file
diff --git a/cmake/celix_project/CodeCoverage.cmake b/cmake/celix_project/CodeCoverage.cmake
index 51b5001..d9e5002 100644
--- a/cmake/celix_project/CodeCoverage.cmake
+++ b/cmake/celix_project/CodeCoverage.cmake
@@ -103,6 +103,13 @@ FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname)
MESSAGE(FATAL_ERROR "genhtml not found! Aborting...")
ENDIF() # NOT GENHTML_PATH
+ set(SCAN_DIR ".")
+ if (NOT ARGV3)
+ set(SCAN_DIR ".")
+ else()
+ set(SCAN_DIR "${ARGV3}")
+ endif ()
+
# Setup target
ADD_CUSTOM_TARGET(${_targetname}_coverage
@@ -115,8 +122,8 @@ FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname)
# Capturing lcov counters and generating report
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/coverage
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/coverage/${_testrunner}
- COMMAND ${LCOV_PATH} --directory . --capture --output-file ${_outputname}.info
- COMMAND ${LCOV_PATH} --remove ${_outputname}.info 'mock/*' 'test/*' '/usr/*' --output-file ${_outputname}.info.cleaned
+ COMMAND ${LCOV_PATH} --directory ${SCAN_DIR} --capture --output-file ${_outputname}.info
+ COMMAND ${LCOV_PATH} --remove ${_outputname}.info 'mock/*' '**/test/*' '**/gtest/*' '**/tst/*' '**/googletest_project/*' '**/glog/*' '/usr/*' --output-file ${_outputname}.info.cleaned
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report."
diff --git a/libs/framework/tst/CMakeLists.txt b/libs/framework/tst/CMakeLists.txt
index 48f0d05..9837bdc 100644
--- a/libs/framework/tst/CMakeLists.txt
+++ b/libs/framework/tst/CMakeLists.txt
@@ -36,6 +36,7 @@ configure_file(config.properties.in config.properties @ONLY)
configure_file(framework1.properties.in framework1.properties @ONLY)
configure_file(framework2.properties.in framework2.properties @ONLY)
+
add_test(NAME run_test_framework COMMAND test_framework)
-SETUP_TARGET_FOR_COVERAGE(test_framework_cov test_framework ${CMAKE_BINARY_DIR}/coverage/test_framework/test_framework)
+SETUP_TARGET_FOR_COVERAGE(test_framework_cov test_framework ${CMAKE_BINARY_DIR}/coverage/test_framework/test_framework ..)
diff --git a/libs/framework_cxx/CMakeLists.txt b/libs/framework_cxx/CMakeLists.txt
index 472bd60..c47ae80 100644
--- a/libs/framework_cxx/CMakeLists.txt
+++ b/libs/framework_cxx/CMakeLists.txt
@@ -24,7 +24,8 @@ add_library(celix_framework_cxx SHARED
src/Bundle.cc)
target_include_directories(celix_framework_cxx PRIVATE src)
target_include_directories(celix_framework_cxx PUBLIC include)
-target_link_libraries(celix_framework_cxx PUBLIC celix::registry glog::glog) #TODO glog private and static lib
+target_link_libraries(celix_framework_cxx PRIVATE glog::glog)
+target_link_libraries(celix_framework_cxx PUBLIC celix::registry)
if (ENABLE_TESTING)
add_subdirectory(gtest)
diff --git a/libs/framework_cxx/gtest/CMakeLists.txt b/libs/framework_cxx/gtest/CMakeLists.txt
index 0f407cc..23fdfb7 100644
--- a/libs/framework_cxx/gtest/CMakeLists.txt
+++ b/libs/framework_cxx/gtest/CMakeLists.txt
@@ -22,5 +22,6 @@ set(SOURCES
add_executable(celix_framework_cxx_tests ${SOURCES})
target_link_libraries(celix_framework_cxx_tests PRIVATE gtest celix_framework_cxx)
+#NOTE last .. argument for the setup coverage is the scan dir (i.e. not gtest dir, but a dir higher)
add_test(NAME celix_framework_cxx_tests COMMAND celix_framework_cxx_tests)
-SETUP_TARGET_FOR_COVERAGE(celix_framework_cxx_tests_cov celix_framework_cxx_tests ${CMAKE_BINARY_DIR}/coverage/framework/celix_framework_cxx_tests)
\ No newline at end of file
+SETUP_TARGET_FOR_COVERAGE(celix_framework_cxx_tests_cov celix_framework_cxx_tests ${CMAKE_BINARY_DIR}/coverage/celix_framework_cxx_tests/celix_framework_cxx_tests ..)
\ No newline at end of file
diff --git a/libs/framework_cxx/gtest/src/Framework_tests.cc b/libs/framework_cxx/gtest/src/Framework_tests.cc
index 5bf8cdb..88580f3 100644
--- a/libs/framework_cxx/gtest/src/Framework_tests.cc
+++ b/libs/framework_cxx/gtest/src/Framework_tests.cc
@@ -17,6 +17,8 @@
*under the License.
*/
+#include <atomic>
+
#include "gtest/gtest.h"
#include "celix/Framework.h"
@@ -46,12 +48,12 @@ TEST_F(FrameworkTest, CreateDestroy) {
class EmbeddedActivator : public celix::IBundleActivator {
public:
- EmbeddedActivator(std::shared_ptr<celix::BundleContext>) {
- startCount++;
+ explicit EmbeddedActivator(std::shared_ptr<celix::BundleContext>) {
+ startCount.fetch_add(1);
}
virtual ~EmbeddedActivator() {
- stopCount++;
+ stopCount.fetch_add(1);
}
static std::atomic<int> startCount;
diff --git a/libs/framework_cxx/src/Bundle.h b/libs/framework_cxx/src/Bundle.h
index 2ee1af6..5541013 100644
--- a/libs/framework_cxx/src/Bundle.h
+++ b/libs/framework_cxx/src/Bundle.h
@@ -20,6 +20,8 @@
#ifndef CXX_CELIX_BUNDLE_H
#define CXX_CELIX_BUNDLE_H
+#include <atomic>
+
#include "celix/Constants.h"
#include "celix/IBundle.h"
#include "celix/BundleContext.h"
@@ -28,10 +30,13 @@ namespace celix {
class Bundle : public celix::IBundle {
public:
Bundle(long _bndId, celix::Framework *_fw, celix::Properties _manifest) :
- bndId{_bndId}, fw{_fw}, bndManifest{std::move(_manifest)} {
+ bndId{_bndId}, fw{_fw}, bndManifest{std::move(_manifest)}, bndState{BundleState::INSTALLED} {
bndState.store(BundleState::INSTALLED, std::memory_order_release);
}
+ Bundle(const Bundle&) = delete;
+ Bundle& operator=(const Bundle&) = delete;
+
//resource part
bool has(const std::string &) const noexcept override;
bool isDir(const std::string &) const noexcept override;
@@ -76,9 +81,8 @@ namespace celix {
const long bndId;
celix::Framework *const fw;
const celix::Properties bndManifest;
- std::weak_ptr <celix::BundleContext> context;
- std::atomic <BundleState> bndState;
+ std::atomic<BundleState> bndState;
};
}
diff --git a/libs/framework_cxx/src/BundleContext.cc b/libs/framework_cxx/src/BundleContext.cc
index 1d5a0a7..5b9b192 100644
--- a/libs/framework_cxx/src/BundleContext.cc
+++ b/libs/framework_cxx/src/BundleContext.cc
@@ -29,6 +29,9 @@ namespace celix {
reg{&bnd->framework().registry(celix::CXX_LANG)},
cReg(&bnd->framework().registry(celix::C_LANG)){}
+ Impl(const Impl&) = delete;
+ Impl& operator=(const Impl&) = delete;
+
const std::shared_ptr<celix::IBundle> bnd;
celix::ServiceRegistry * const reg; //TODO make weak_ptr
celix::ServiceRegistry * const cReg; //TODO make weak_ptr
@@ -36,9 +39,8 @@ namespace celix {
};
}
-celix::BundleContext::BundleContext(std::shared_ptr<celix::IBundle> bnd) {
- pimpl = std::unique_ptr<celix::BundleContext::Impl>{new celix::BundleContext::Impl{std::move(bnd)}};
-}
+celix::BundleContext::BundleContext(std::shared_ptr<celix::IBundle> bnd) :
+ pimpl{std::unique_ptr<celix::BundleContext::Impl>{new celix::BundleContext::Impl{std::move(bnd)}}} {}
celix::BundleContext::~BundleContext() = default;
diff --git a/libs/framework_cxx/src/Framework.cc b/libs/framework_cxx/src/Framework.cc
index 64fa7d5..a96ce86 100644
--- a/libs/framework_cxx/src/Framework.cc
+++ b/libs/framework_cxx/src/Framework.cc
@@ -27,6 +27,9 @@
#include <set>
#include <vector>
#include <future>
+#include <algorithm>
+
+#include <linux/limits.h>
#include <glog/logging.h>
@@ -54,6 +57,9 @@ class celix::Framework::Impl : public IBundle {
public:
Impl(celix::Framework *_fw, celix::Properties _config) : fw{_fw}, config{std::move(_config)}, bndManifest{createManifest()}, cwd{createCwd()} {}
+ Impl(const Impl&) = delete;
+ Impl& operator=(const Impl&) = delete;
+
~Impl() {
stopFramework();
waitForShutdown();
@@ -237,10 +243,10 @@ public:
//resource bundle part
long id() const noexcept override { return 1L /*note registry empty bundle is id 0, framework is id 1*/; }
- bool has(const std::string&) const override { return false; }
- bool isDir(const std::string&) const override { return false; }
- bool isFile(const std::string&) const override { return false; }
- std::vector<std::string> readDir(const std::string&) const override { return std::vector<std::string>{};}
+ bool has(const std::string&) const noexcept override { return false; }
+ bool isDir(const std::string&) const noexcept override { return false; }
+ bool isFile(const std::string&) const noexcept override { return false; }
+ std::vector<std::string> readDir(const std::string&) const noexcept override { return std::vector<std::string>{};}
const std::string& root() const noexcept override { //TODO
return cwd;
}
@@ -326,21 +332,22 @@ private:
struct {
mutable std::mutex mutex{};
- std::unordered_map<std::string, celix::ServiceRegistry> entries;
- } registries;
+ std::unordered_map<std::string, celix::ServiceRegistry> entries{};
+ } registries{};
};
/***********************************************************************************************************************
* Framework
**********************************************************************************************************************/
-celix::Framework::Framework(celix::Properties config) {
- pimpl = std::unique_ptr<Impl>{new Impl{this, std::move(config)}};
+celix::Framework::Framework(celix::Properties config) : pimpl{std::unique_ptr<Impl>{new Impl{this, std::move(config)}}} {
registerFramework(this);
}
+
celix::Framework::~Framework() {
unregisterFramework(this);
}
+
celix::Framework::Framework(Framework &&rhs) = default;
celix::Framework& celix::Framework::operator=(Framework&& rhs) = default;
diff --git a/libs/registry/CMakeLists.txt b/libs/registry/CMakeLists.txt
index ee537cc..2a279de 100644
--- a/libs/registry/CMakeLists.txt
+++ b/libs/registry/CMakeLists.txt
@@ -23,7 +23,8 @@ add_library(celix_registry STATIC
)
target_include_directories(celix_registry PRIVATE src)
target_include_directories(celix_registry PUBLIC include)
-target_link_libraries(celix_registry PRIVATE glog::glog) #TODO make glog static and private
+target_link_libraries(celix_registry PRIVATE glog::glog)
+target_compile_options(celix_registry PRIVATE -fPIC)
add_library(celix::registry ALIAS celix_registry)
diff --git a/libs/registry/gtest/CMakeLists.txt b/libs/registry/gtest/CMakeLists.txt
index 4f3076e..cdf666b 100644
--- a/libs/registry/gtest/CMakeLists.txt
+++ b/libs/registry/gtest/CMakeLists.txt
@@ -27,5 +27,6 @@ set(SOURCES
add_executable(celix_registry_tests ${SOURCES})
target_link_libraries(celix_registry_tests PRIVATE gtest glog::glog celix::registry)
+#NOTE last .. argument for the setup coverage is the scan dir (i.e. not gtest dir, but a dir higher)
add_test(NAME celix_registry_tests COMMAND celix_registry_tests)
-SETUP_TARGET_FOR_COVERAGE(celix_registry_tests_cov celix_registry_tests ${CMAKE_BINARY_DIR}/coverage/registry)
\ No newline at end of file
+SETUP_TARGET_FOR_COVERAGE(celix_registry_tests_cov celix_registry_tests ${CMAKE_BINARY_DIR}/coverage/celix_registry_tests/celix_registry_tests ..)
\ No newline at end of file
diff --git a/libs/registry/gtest/src/RegistryConcurrency_tests.cc b/libs/registry/gtest/src/RegistryConcurrency_tests.cc
index b460bf3..d2626ec 100644
--- a/libs/registry/gtest/src/RegistryConcurrency_tests.cc
+++ b/libs/registry/gtest/src/RegistryConcurrency_tests.cc
@@ -19,6 +19,8 @@
#include <thread>
+#include <mutex>
+#include <condition_variable>
#include "gtest/gtest.h"
diff --git a/libs/registry/gtest/src/Registry_tests.cc b/libs/registry/gtest/src/Registry_tests.cc
index 9bbb899..d8fad0e 100644
--- a/libs/registry/gtest/src/Registry_tests.cc
+++ b/libs/registry/gtest/src/Registry_tests.cc
@@ -17,8 +17,11 @@
*under the License.
*/
-#include "gtest/gtest.h"
+
+#include <memory>
+
+#include <gtest/gtest.h>
#include <glog/logging.h>
#include "celix/ServiceRegistry.h"
diff --git a/libs/registry/include/celix/Filter.h b/libs/registry/include/celix/Filter.h
index db851ba..8d8fab0 100644
--- a/libs/registry/include/celix/Filter.h
+++ b/libs/registry/include/celix/Filter.h
@@ -20,6 +20,7 @@
#ifndef CXX_CELIX_FILTER_H
#define CXX_CELIX_FILTER_H
+#include <memory>
#include <string>
#include <vector>
diff --git a/libs/registry/include/celix/IResourceBundle.h b/libs/registry/include/celix/IResourceBundle.h
index 97c64de..38b76b3 100644
--- a/libs/registry/include/celix/IResourceBundle.h
+++ b/libs/registry/include/celix/IResourceBundle.h
@@ -21,6 +21,7 @@
#define CXX_CELIX_IRESOURCEBUNDLE_H
#include <string>
+#include <vector>
namespace celix {
diff --git a/libs/registry/include/celix/ServiceRegistry.h b/libs/registry/include/celix/ServiceRegistry.h
index ae7aeb2..76b277d 100644
--- a/libs/registry/include/celix/ServiceRegistry.h
+++ b/libs/registry/include/celix/ServiceRegistry.h
@@ -22,6 +22,8 @@
#include <utility>
#include <vector>
+#include <functional>
+#include <memory>
#include "celix/Constants.h"
#include "celix/Properties.h"
diff --git a/libs/registry/include/celix/Utils.h b/libs/registry/include/celix/Utils.h
index ae61cd7..5640636 100644
--- a/libs/registry/include/celix/Utils.h
+++ b/libs/registry/include/celix/Utils.h
@@ -20,7 +20,7 @@
#ifndef CXX_CELIX_UTILS_H
#define CXX_CELIX_UTILS_H
-
+#include <cstring>
#include <string>
#include <iostream>
diff --git a/libs/registry/src/ServiceRegistry.cc b/libs/registry/src/ServiceRegistry.cc
index ac9a9dd..a7465e2 100644
--- a/libs/registry/src/ServiceRegistry.cc
+++ b/libs/registry/src/ServiceRegistry.cc
@@ -26,6 +26,7 @@
#include <future>
#include <glog/logging.h>
+#include <assert.h>
#include "celix/Constants.h"
#include "celix/ServiceRegistry.h"
@@ -306,7 +307,7 @@ namespace {
}
private:
struct {
- mutable std::mutex mutex; //protects matchedEntries & highestRanking
+ mutable std::mutex mutex{}; //protects matchedEntries & highestRanking
std::map<std::shared_ptr<const SvcEntry>, std::shared_ptr<void>, SvcEntryLess> entries{};
std::shared_ptr<void> highest{};
} tracked{};
@@ -338,8 +339,10 @@ public:
class celix::ServiceRegistry::Impl {
public:
+ Impl(std::string _regName) : regName{_regName} {}
+
const std::shared_ptr<const celix::IResourceBundle> emptyBundle = std::shared_ptr<const celix::IResourceBundle>{new EmptyBundle{}};
- std::string regName;
+ const std::string regName;
struct {
mutable std::mutex mutex{};
@@ -511,9 +514,7 @@ public:
**********************************************************************************************************************/
-celix::ServiceRegistry::ServiceRegistry(std::string name) : pimpl{new ServiceRegistry::Impl{}} {
- pimpl->regName = std::move(name);
-}
+celix::ServiceRegistry::ServiceRegistry(std::string name) : pimpl{new ServiceRegistry::Impl{std::move(name)}} {}
celix::ServiceRegistry::ServiceRegistry(celix::ServiceRegistry &&rhs) = default;
celix::ServiceRegistry& celix::ServiceRegistry::operator=(celix::ServiceRegistry &&rhs) = default;
celix::ServiceRegistry::~ServiceRegistry() {