Repository: celix Updated Branches: refs/heads/develop de2369c67 -> 88567cda4
CELIX-386: Updates for the -Weffc++ warnings Project: http://git-wip-us.apache.org/repos/asf/celix/repo Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/88567cda Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/88567cda Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/88567cda Branch: refs/heads/develop Commit: 88567cda480a52ab9e14ab55c8b1c830f5c2392b Parents: de2369c Author: Pepijn Noltes <[email protected]> Authored: Thu Jun 8 18:21:08 2017 +0200 Committer: Pepijn Noltes <[email protected]> Committed: Thu Jun 8 18:21:08 2017 +0200 ---------------------------------------------------------------------- CMakeLists.txt | 2 +- dependency_manager_cxx/include/celix/dm/Component.h | 4 +++- .../include/celix/dm/DependencyManager.h | 6 ++++++ dependency_manager_cxx/include/celix/dm/DmActivator.h | 3 +++ .../include/celix/dm/DmActivator_Impl.h | 9 +++++++-- .../include/celix/dm/ServiceDependency.h | 9 ++++++++- .../include/celix/dm/ServiceDependency_Impl.h | 12 ++++++------ examples/dm_example_cxx/phase1/src/Phase1Activator.cc | 5 +++-- examples/dm_example_cxx/phase1/src/Phase1Cmp.cc | 2 +- examples/dm_example_cxx/phase2/include/Phase2Cmp.h | 6 +++++- examples/dm_example_cxx/phase3/src/Phase3Cmp.cc | 4 ++-- .../phase3_locking/src/Phase3LockingCmp.cc | 2 +- examples/services_example_cxx/foo/private/include/Foo.h | 3 +++ 13 files changed, 49 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/celix/blob/88567cda/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/CMakeLists.txt b/CMakeLists.txt index ebccf06..8e2b869 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ ENDIF() IF (ANDROID) SET(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=gnu99 -Wall ${CMAKE_C_FLAGS}") ELSE () - SET(CMAKE_C_FLAGS "-std=c99 -Wall -Werror -fPIC ${CMAKE_C_FLAGS}") #TODO add -Wextra + SET(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=gnu99 -Wall -Werror -fPIC ${CMAKE_C_FLAGS}") #TODO add -Wextra SET(CMAKE_CXX_FLAGS "-std=c++11") #TODO -Wall -Wextra -Werror does not yet work with the unit tests SET(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG") SET(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG") http://git-wip-us.apache.org/repos/asf/celix/blob/88567cda/dependency_manager_cxx/include/celix/dm/Component.h ---------------------------------------------------------------------- diff --git a/dependency_manager_cxx/include/celix/dm/Component.h b/dependency_manager_cxx/include/celix/dm/Component.h index 6c12a99..3064155 100644 --- a/dependency_manager_cxx/include/celix/dm/Component.h +++ b/dependency_manager_cxx/include/celix/dm/Component.h @@ -38,9 +38,11 @@ namespace celix { namespace dm { component_create(this->context, name.c_str(), &this->cCmp); component_setImplementation(this->cCmp, this); } - virtual ~BaseComponent() {} + BaseComponent(const BaseComponent&) = delete; + BaseComponent& operator=(const BaseComponent&) = delete; + /** * Returns the C DM Component */ http://git-wip-us.apache.org/repos/asf/celix/blob/88567cda/dependency_manager_cxx/include/celix/dm/DependencyManager.h ---------------------------------------------------------------------- diff --git a/dependency_manager_cxx/include/celix/dm/DependencyManager.h b/dependency_manager_cxx/include/celix/dm/DependencyManager.h index 67f9c3f..9a3ee96 100644 --- a/dependency_manager_cxx/include/celix/dm/DependencyManager.h +++ b/dependency_manager_cxx/include/celix/dm/DependencyManager.h @@ -37,6 +37,12 @@ namespace celix { namespace dm { DependencyManager(bundle_context_pt context); virtual ~DependencyManager(); + DependencyManager(DependencyManager&&) = default; + DependencyManager& operator=(DependencyManager&&) = default; + + DependencyManager(const DependencyManager&) = delete; + DependencyManager& operator=(const DependencyManager&) = delete; + bundle_context_pt bundleContext() const; dm_dependency_manager_pt cDependencyManager() const; http://git-wip-us.apache.org/repos/asf/celix/blob/88567cda/dependency_manager_cxx/include/celix/dm/DmActivator.h ---------------------------------------------------------------------- diff --git a/dependency_manager_cxx/include/celix/dm/DmActivator.h b/dependency_manager_cxx/include/celix/dm/DmActivator.h index 547a2da..caf376a 100644 --- a/dependency_manager_cxx/include/celix/dm/DmActivator.h +++ b/dependency_manager_cxx/include/celix/dm/DmActivator.h @@ -32,6 +32,9 @@ namespace celix { namespace dm { DmActivator(DependencyManager& m); virtual ~DmActivator(); + DmActivator(const DmActivator&) = delete; + DmActivator& operator=(const DmActivator&) = delete; + DependencyManager& manager() const; bundle_context_pt context() const; http://git-wip-us.apache.org/repos/asf/celix/blob/88567cda/dependency_manager_cxx/include/celix/dm/DmActivator_Impl.h ---------------------------------------------------------------------- diff --git a/dependency_manager_cxx/include/celix/dm/DmActivator_Impl.h b/dependency_manager_cxx/include/celix/dm/DmActivator_Impl.h index 3223012..0369215 100644 --- a/dependency_manager_cxx/include/celix/dm/DmActivator_Impl.h +++ b/dependency_manager_cxx/include/celix/dm/DmActivator_Impl.h @@ -41,10 +41,15 @@ namespace celix { namespace dm { namespace /*anon*/ { dm_info_service_t info{nullptr, nullptr, nullptr}; public: - DmActivatorImpl(bundle_context_pt c) : mng{c}, ctx{c} { act = DmActivator::create(mng); } - + DmActivatorImpl(bundle_context_pt c) : mng{c}, ctx{c}, act{DmActivator::create(mng)} { } ~DmActivatorImpl() { delete act; } + DmActivatorImpl(DmActivatorImpl&&) = delete; + DmActivatorImpl& operator=(DmActivatorImpl&&) = delete; + + DmActivatorImpl(const DmActivatorImpl&) = delete; + DmActivator& operator=(const DmActivatorImpl&) = delete; + celix_status_t start() { celix_status_t status = CELIX_SUCCESS; http://git-wip-us.apache.org/repos/asf/celix/blob/88567cda/dependency_manager_cxx/include/celix/dm/ServiceDependency.h ---------------------------------------------------------------------- diff --git a/dependency_manager_cxx/include/celix/dm/ServiceDependency.h b/dependency_manager_cxx/include/celix/dm/ServiceDependency.h index bcf7658..eaa2ce7 100644 --- a/dependency_manager_cxx/include/celix/dm/ServiceDependency.h +++ b/dependency_manager_cxx/include/celix/dm/ServiceDependency.h @@ -48,9 +48,11 @@ namespace celix { namespace dm { void setDepStrategy(DependencyUpdateStrategy strategy); public: BaseServiceDependency(bool valid); - virtual ~BaseServiceDependency() = default; + BaseServiceDependency(const BaseServiceDependency&) = delete; + BaseServiceDependency& operator=(const BaseServiceDependency&) = delete; + /** * Wether the service dependency is valid. */ @@ -71,6 +73,11 @@ namespace celix { namespace dm { TypedServiceDependency(bool valid) : BaseServiceDependency(valid) {} virtual ~TypedServiceDependency() = default; + TypedServiceDependency(const TypedServiceDependency&) = delete; + TypedServiceDependency& operator=(const TypedServiceDependency&) = delete; + TypedServiceDependency(TypedServiceDependency&&) = default; + TypedServiceDependency& operator=(TypedServiceDependency&&) = default; + /** * Set the component instance with a pointer */ http://git-wip-us.apache.org/repos/asf/celix/blob/88567cda/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h ---------------------------------------------------------------------- diff --git a/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h b/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h index 79b89b7..b7511d3 100644 --- a/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h +++ b/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h @@ -105,7 +105,7 @@ CServiceDependency<T,I>& CServiceDependency<T,I>::setStrategy(DependencyUpdateSt //set callbacks template<class T, typename I> CServiceDependency<T,I>& CServiceDependency<T,I>::setCallbacks(void (T::*set)(const I* service)) { - this->setCallbacks([this, set](const I* service, Properties&& __attribute__((unused)) properties) { + this->setCallbacks([this, set](const I* service, [[gnu::unused]] Properties&& properties) { T *cmp = this->componentInstance; (cmp->*set)(service); }); @@ -134,11 +134,11 @@ CServiceDependency<T,I>& CServiceDependency<T,I>::setCallbacks( void (T::*add)(const I* service), void (T::*remove)(const I* service)) { this->setCallbacks( - [this, add](const I* service, Properties&& __attribute__((unused)) properties) { + [this, add](const I* service, [[gnu::unused]] Properties&& properties) { T *cmp = this->componentInstance; (cmp->*add)(service); }, - [this, remove](const I* service, Properties&& __attribute__((unused)) properties) { + [this, remove](const I* service, [[gnu::unused]] Properties&& properties) { T *cmp = this->componentInstance; (cmp->*remove)(service); } @@ -327,7 +327,7 @@ ServiceDependency<T,I>& ServiceDependency<T,I>::setAddLanguageFilter(bool addLan //set callbacks template<class T, class I> ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(void (T::*set)(I* service)) { - this->setCallbacks([this, set](I* srv, Properties&& __attribute__((unused)) props) { + this->setCallbacks([this, set](I* srv, [[gnu::unused]] Properties&& props) { T *cmp = this->componentInstance; (cmp->*set)(srv); }); @@ -356,11 +356,11 @@ ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks( void (T::*add)(I* service), void (T::*remove)(I* service)) { this->setCallbacks( - [this, add](I* srv, Properties&& __attribute__((unused)) props) { + [this, add](I* srv, [[gnu::unused]] Properties&& props) { T *cmp = this->componentInstance; (cmp->*add)(srv); }, - [this, remove](I* srv, Properties&& __attribute__((unused)) props) { + [this, remove](I* srv, [[gnu::unused]] Properties&& props) { T *cmp = this->componentInstance; (cmp->*remove)(srv); } http://git-wip-us.apache.org/repos/asf/celix/blob/88567cda/examples/dm_example_cxx/phase1/src/Phase1Activator.cc ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase1/src/Phase1Activator.cc b/examples/dm_example_cxx/phase1/src/Phase1Activator.cc index a7e74d1..4bee1df 100644 --- a/examples/dm_example_cxx/phase1/src/Phase1Activator.cc +++ b/examples/dm_example_cxx/phase1/src/Phase1Activator.cc @@ -33,8 +33,9 @@ DmActivator* DmActivator::create(DependencyManager& mng) { } struct InvalidCServ { - void* handle; //valid pod - int (*foo)(double arg); //still valid pod + virtual ~InvalidCServ() = default; + void* handle {nullptr}; //valid pod + int (*foo)(double arg) {nullptr}; //still valid pod void bar(double __attribute__((unused)) arg) {} //still valid pod virtual void baz(double __attribute__((unused)) arg) {} //not a valid pod }; http://git-wip-us.apache.org/repos/asf/celix/blob/88567cda/examples/dm_example_cxx/phase1/src/Phase1Cmp.cc ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase1/src/Phase1Cmp.cc b/examples/dm_example_cxx/phase1/src/Phase1Cmp.cc index 4ac0ee8..072728c 100644 --- a/examples/dm_example_cxx/phase1/src/Phase1Cmp.cc +++ b/examples/dm_example_cxx/phase1/src/Phase1Cmp.cc @@ -47,7 +47,7 @@ std::string Phase1Cmp::getName() { return std::string {"IPhase"}; } -int Phase1Cmp::infoCmd(char * __attribute__((unused)) line, FILE *out, FILE __attribute__((unused)) *err) { +int Phase1Cmp::infoCmd([[gnu::unused]] char * line, FILE *out, [[gnu::unused]] FILE* err) { fprintf(out, "Phase1: number of getData calls: %u\n", counter); return 0; } http://git-wip-us.apache.org/repos/asf/celix/blob/88567cda/examples/dm_example_cxx/phase2/include/Phase2Cmp.h ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase2/include/Phase2Cmp.h b/examples/dm_example_cxx/phase2/include/Phase2Cmp.h index 8f98ae7..87b6e8e 100644 --- a/examples/dm_example_cxx/phase2/include/Phase2Cmp.h +++ b/examples/dm_example_cxx/phase2/include/Phase2Cmp.h @@ -35,9 +35,13 @@ extern "C" { class Phase2Cmp : public IPhase2 { public: Phase2Cmp() = default; + virtual ~Phase2Cmp() { std::cout << "Destroying Phase2\n"; }; + Phase2Cmp(Phase2Cmp&& other) noexcept; + Phase2Cmp& operator=(Phase2Cmp&&) = default; + Phase2Cmp(const Phase2Cmp& other) = delete; - virtual ~Phase2Cmp() { std::cout << "Destroying Phase2\n"; }; + Phase2Cmp operator=(const Phase2Cmp&) = delete; void setPhase1(IPhase1* phase); //injector used by dependency manager void setName(srv::info::IName* name) { std::cout << "Setting IName with name: " << (name != nullptr ? name->getName() : "null") << std::endl; } http://git-wip-us.apache.org/repos/asf/celix/blob/88567cda/examples/dm_example_cxx/phase3/src/Phase3Cmp.cc ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase3/src/Phase3Cmp.cc b/examples/dm_example_cxx/phase3/src/Phase3Cmp.cc index 72fea02..dba5942 100644 --- a/examples/dm_example_cxx/phase3/src/Phase3Cmp.cc +++ b/examples/dm_example_cxx/phase3/src/Phase3Cmp.cc @@ -55,11 +55,11 @@ void Phase3Cmp::addPhase2(IPhase2* phase2, celix::dm::Properties&& props) { this->phases[phase2] = props; } -void Phase3Cmp::removePhase2(IPhase2* phase2, celix::dm::Properties&& __attribute__((unused)) props) { +void Phase3Cmp::removePhase2(IPhase2* phase2, [[gnu::unused]] celix::dm::Properties&& props) { std::cout << "adding Iphase2 for Phase3Cmp\n"; this->phases.erase(phase2); } -void Phase3Cmp::setPhase2a(IPhase2* __attribute__((unused)) phase) { +void Phase3Cmp::setPhase2a([[gnu::unused]] IPhase2* phase) { std::cout << "setting phase2a\n"; } http://git-wip-us.apache.org/repos/asf/celix/blob/88567cda/examples/dm_example_cxx/phase3_locking/src/Phase3LockingCmp.cc ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase3_locking/src/Phase3LockingCmp.cc b/examples/dm_example_cxx/phase3_locking/src/Phase3LockingCmp.cc index 7827fed..b0f5e3e 100644 --- a/examples/dm_example_cxx/phase3_locking/src/Phase3LockingCmp.cc +++ b/examples/dm_example_cxx/phase3_locking/src/Phase3LockingCmp.cc @@ -59,7 +59,7 @@ void Phase3LockingCmp::addPhase2(IPhase2* phase2, celix::dm::Properties&& props) this->phases[phase2] = props; } -void Phase3LockingCmp::removePhase2(IPhase2* phase2, celix::dm::Properties&& __attribute__((unused)) props) { +void Phase3LockingCmp::removePhase2(IPhase2* phase2, [[gnu::unused]] celix::dm::Properties&& props) { std::cout << "adding Iphase2 for Phase3LockingCmp\n"; std::lock_guard<std::mutex> lock(mutex); this->phases.erase(phase2); http://git-wip-us.apache.org/repos/asf/celix/blob/88567cda/examples/services_example_cxx/foo/private/include/Foo.h ---------------------------------------------------------------------- diff --git a/examples/services_example_cxx/foo/private/include/Foo.h b/examples/services_example_cxx/foo/private/include/Foo.h index a07ddba..0035b77 100644 --- a/examples/services_example_cxx/foo/private/include/Foo.h +++ b/examples/services_example_cxx/foo/private/include/Foo.h @@ -33,6 +33,9 @@ public: Foo() = default; virtual ~Foo() = default; + Foo(const Foo&) = delete; + Foo& operator=(const Foo&) = delete; + void start(); void stop();
