celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject celix git commit: CELIX-370: Adds -Wall -Werror for dep man c++, adds move example and updates usage of output stream to prevent interleaving
Date Tue, 26 Jul 2016 20:01:55 GMT
Repository: celix
Updated Branches:
  refs/heads/develop 4de9ee95c -> 143b0d641


CELIX-370: Adds -Wall -Werror for dep man c++, adds move example and updates usage of output
stream to prevent interleaving


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/143b0d64
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/143b0d64
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/143b0d64

Branch: refs/heads/develop
Commit: 143b0d6418f13020939a32a3aa1b884f742717e3
Parents: 4de9ee9
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
Authored: Tue Jul 26 22:04:24 2016 +0200
Committer: Pepijn Noltes <pepijnnoltes@gmail.com>
Committed: Tue Jul 26 22:04:24 2016 +0200

----------------------------------------------------------------------
 dependency_manager_cxx/CMakeLists.txt                    |  3 +++
 dependency_manager_cxx/include/celix/dm/Component.h      |  5 +----
 dependency_manager_cxx/include/celix/dm/Component_Impl.h |  4 +---
 examples/dm_example_cxx/CMakeLists.txt                   |  3 +++
 examples/dm_example_cxx/phase1/src/Phase1Cmp.cc          |  2 +-
 examples/dm_example_cxx/phase2/include/Phase2Cmp.h       | 11 ++++++++---
 examples/dm_example_cxx/phase2a/src/Phase2aActivator.cc  |  4 ++--
 examples/dm_example_cxx/phase3/src/Phase3Cmp.cc          |  6 ++++--
 .../phase3_locking/src/Phase3LockingCmp.cc               |  6 ++++--
 9 files changed, 27 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/143b0d64/dependency_manager_cxx/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/CMakeLists.txt b/dependency_manager_cxx/CMakeLists.txt
index 8afc7ec..6a4e852 100644
--- a/dependency_manager_cxx/CMakeLists.txt
+++ b/dependency_manager_cxx/CMakeLists.txt
@@ -18,6 +18,9 @@
 celix_subproject(DEPENDENCY_MANAGER_CXX "Option to build the C++ dependency manager static
library" ON DEPS framework DEPENDENCY_MANAGER)
 if (DEPENDENCY_MANAGER_CXX)
 
+    #set -Wall, -Werror locally, currenctly cpputest contains warnings
+    set(CMAKE_CXX_FLAGS "-Wall -Werror ${CMAKE_CXX_FLAGS}")
+
     # Add -fPIC for x86_64 Unix platforms; this lib will be linked to a shared lib
     if(UNIX AND NOT WIN32)
         find_program(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin )

http://git-wip-us.apache.org/repos/asf/celix/blob/143b0d64/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 e6e8d15..4e45b10 100644
--- a/dependency_manager_cxx/include/celix/dm/Component.h
+++ b/dependency_manager_cxx/include/celix/dm/Component.h
@@ -79,15 +79,12 @@ namespace celix { namespace dm {
         Component<T>& setInstance(std::shared_ptr<T> inst);
 
         /**
-         * TODO FIXME, DOES NOT WORK
-         * Set the component instance using move semantic
+         * Set the component instance using rvalue reference
          * The DM Component will contain the instance.
          *
          * @return the DM Component reference for chaining (fluent API)
          */
-        /*
         Component<T>& setInstance(T&& inst);
-        */
 
 
         /**

http://git-wip-us.apache.org/repos/asf/celix/blob/143b0d64/dependency_manager_cxx/include/celix/dm/Component_Impl.h
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/include/celix/dm/Component_Impl.h b/dependency_manager_cxx/include/celix/dm/Component_Impl.h
index 8f6c588..4b7b6f5 100644
--- a/dependency_manager_cxx/include/celix/dm/Component_Impl.h
+++ b/dependency_manager_cxx/include/celix/dm/Component_Impl.h
@@ -130,14 +130,12 @@ Component<T>& Component<T>::setInstance(std::shared_ptr<T>
inst) {
     return *this;
 }
 
-/*
 template<class T>
 Component<T>& Component<T>::setInstance(T&& inst) {
     this->refInstance.clear();
     this->refInstance.push_back(std::move(inst));
     return *this;
 }
- */
 
 template<class T>
 Component<T>& Component<T>::setCallbacks(
@@ -191,4 +189,4 @@ Component<T>& Component<T>::setCallbacks(
     component_setCallbacks(this->cComponent(), cInit, cStart, cStop, cDeinit);
 
     return *this;
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/143b0d64/examples/dm_example_cxx/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/dm_example_cxx/CMakeLists.txt b/examples/dm_example_cxx/CMakeLists.txt
index 7539366..e0d9b6d 100644
--- a/examples/dm_example_cxx/CMakeLists.txt
+++ b/examples/dm_example_cxx/CMakeLists.txt
@@ -15,6 +15,9 @@
 # specific language governing permissions and limitations
 # under the License.
 if (BUILD_DEPENDENCY_MANAGER_CXX)
+    #set -Wall, -Werror locally, currenctly cpputest contains warnings
+    set(CMAKE_CXX_FLAGS "-Wall -Werror ${CMAKE_CXX_FLAGS}")
+
     include_directories(
             ${PROJECT_SOURCE_DIR}/dependency_manager/public/include
             ${PROJECT_SOURCE_DIR}/dependency_manager_cxx/include

http://git-wip-us.apache.org/repos/asf/celix/blob/143b0d64/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 998555f..1137f72 100644
--- a/examples/dm_example_cxx/phase1/src/Phase1Cmp.cc
+++ b/examples/dm_example_cxx/phase1/src/Phase1Cmp.cc
@@ -46,4 +46,4 @@ int Phase1Cmp::getData() {
 int Phase1Cmp::infoCmd(char * line, FILE *out, FILE *err) {
     fprintf(out, "Phase1: number of getData calls: %u\n", counter);
     return 0;
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/143b0d64/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 ca85cc4..f5863d8 100644
--- a/examples/dm_example_cxx/phase2/include/Phase2Cmp.h
+++ b/examples/dm_example_cxx/phase2/include/Phase2Cmp.h
@@ -32,10 +32,14 @@ extern "C" {
 };
 
 class Phase2Cmp : public IPhase2 {
-    IPhase1* phase1 {nullptr};
-    log_service_pt logSrv {nullptr};
 public:
     Phase2Cmp() = default;
+    Phase2Cmp(Phase2Cmp&& other) : phase1(other.phase1), logSrv(other.logSrv) {
+        std::cout << "Move constructor Phase2Cmp called\n"; 
+        other.phase1 = nullptr;
+        other.logSrv = nullptr;
+    }
+    Phase2Cmp(const Phase2Cmp& other) = delete;
     virtual ~Phase2Cmp() { std::cout << "Destroying Phase2\n"; };
 
     void setPhase1(IPhase1* phase); //injector used by dependency manager
@@ -43,7 +47,8 @@ public:
 
     virtual double getData(); //implements IPhase2
 private:
-
+    IPhase1* phase1 {nullptr};
+    log_service_pt logSrv {nullptr};
 };
 
 #endif //CELIX_PHASE2CMP_H

http://git-wip-us.apache.org/repos/asf/celix/blob/143b0d64/examples/dm_example_cxx/phase2a/src/Phase2aActivator.cc
----------------------------------------------------------------------
diff --git a/examples/dm_example_cxx/phase2a/src/Phase2aActivator.cc b/examples/dm_example_cxx/phase2a/src/Phase2aActivator.cc
index d90b5d0..83449d2 100644
--- a/examples/dm_example_cxx/phase2a/src/Phase2aActivator.cc
+++ b/examples/dm_example_cxx/phase2a/src/Phase2aActivator.cc
@@ -35,7 +35,7 @@ void Phase2Activator::init(DependencyManager& manager) {
     props["name"] = "phase2a";
 
     add(createComponent<Phase2Cmp>()
-        //FIXME .setInstance(Phase2Cmp()) //NOTE using move initialization
+        .setInstance(Phase2Cmp()) 
         .addInterface<IPhase2>(IPHASE2_VERSION, props)
         .add(createServiceDependency<Phase2Cmp,IPhase1>()
             .setRequired(true)
@@ -51,4 +51,4 @@ void Phase2Activator::init(DependencyManager& manager) {
 
 void Phase2Activator::deinit(DependencyManager& manager) {
 
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/143b0d64/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 e0f4722..d128337 100644
--- a/examples/dm_example_cxx/phase3/src/Phase3Cmp.cc
+++ b/examples/dm_example_cxx/phase3/src/Phase3Cmp.cc
@@ -23,6 +23,7 @@
 #include <stdio.h>
 #include <thread>
 #include <chrono>
+#include <sstream>
 
 void Phase3Cmp::start() {
     std::cout << "start Phase3Cmp\n";
@@ -40,8 +41,9 @@ void Phase3Cmp::poll() {
     while (running) {
         std::cout << "polling Phase3Cmp\n";
         for (std::pair<IPhase2*, celix::dm::Properties> pair : this->phases) {
-            std::string name = pair.second["name"];
-            std::cout << "current data for " << name << " is " <<
pair.first->getData() << "\n";
+            std::ostringstream oss {};
+            oss << "current data for " << pair.second["name"] << " is "
<< pair.first->getData() << "\n";
+            std::cout << oss.str();
         }
         std::this_thread::sleep_for(std::chrono::milliseconds(1000));
     }

http://git-wip-us.apache.org/repos/asf/celix/blob/143b0d64/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 ead0b12..1d490fd 100644
--- a/examples/dm_example_cxx/phase3_locking/src/Phase3LockingCmp.cc
+++ b/examples/dm_example_cxx/phase3_locking/src/Phase3LockingCmp.cc
@@ -23,6 +23,7 @@
 #include <stdio.h>
 #include <thread>
 #include <chrono>
+#include <sstream>
 
 void Phase3LockingCmp::start() {
     std::cout << "start Phase3LockingCmp\n";
@@ -42,8 +43,9 @@ void Phase3LockingCmp::poll() {
         std::cout << "polling Phase3LockingCmp\n";
         mutex.lock();
         for (std::pair<IPhase2*, celix::dm::Properties> pair : this->phases) {
-            std::string name = pair.second["name"];
-            std::cout << "current data for " << name << " is " <<
pair.first->getData() << "\n";
+            std::ostringstream oss {};
+            oss << "current data for " << pair.second["name"] << " is "
<< pair.first->getData() << "\n";
+            std::cout << oss.str();
         }
         mutex.unlock();
         std::this_thread::sleep_for(std::chrono::milliseconds(1000));


Mime
View raw message