celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [1/3] celix git commit: CELIX-370: Updates the C++ CMake flags (including -Wall and -Werror), Fixes issue in c++ DM example, documents C++ DM API
Date Thu, 21 Jul 2016 09:55:51 GMT
Repository: celix
Updated Branches:
  refs/heads/develop dc6cafd9f -> 0757a7a62


CELIX-370: Updates the C++ CMake flags (including -Wall and -Werror), Fixes issue in c++ DM
example, documents C++ DM API


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

Branch: refs/heads/develop
Commit: 5d3719c6cfceeaae7b395382514d98af3fe7fb99
Parents: dc6cafd
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
Authored: Thu Jul 21 11:14:02 2016 +0200
Committer: Pepijn Noltes <pepijnnoltes@gmail.com>
Committed: Thu Jul 21 11:14:02 2016 +0200

----------------------------------------------------------------------
 CMakeLists.txt                                  |   5 +-
 dependency_manager_cxx/CMakeLists.txt           |   1 +
 .../include/celix/dm/Component.h                | 111 ++++++++++++++++++-
 .../include/celix/dm/Component_Impl.h           |   9 +-
 .../include/celix/dm/DependencyManager.h        |  37 +++++--
 .../include/celix/dm/DmActivator.h              |  46 +++++++-
 .../include/celix/dm/ServiceDependency.h        |  79 ++++++++++++-
 .../include/celix/dm/ServiceDependency_Impl.h   |  41 +++----
 dependency_manager_cxx/include/celix/dm/types.h |   3 +
 dependency_manager_cxx/src/ServiceDependency.cc |  38 +++++++
 .../phase1/src/Phase1Activator.cc               |   2 +-
 .../dm_example_cxx/phase2/include/Phase2Cmp.h   |   5 +-
 .../phase2a/src/Phase2aActivator.cc             |   2 +-
 13 files changed, 324 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/5d3719c6/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 25bf186..dfeb999 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,18 +37,17 @@ IF (ANDROID)
 ENDIF()
 IF(UNIX AND NOT ANDROID)
     SET(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=gnu99 -Wall -Werror -fPIC ${CMAKE_C_FLAGS}")
-    #SET(CMAKE_CXX_FLAGS "-Wall -Werror ${CMAKE_CXX_FLAGS}")
+    SET(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Werror ${CMAKE_CXX_FLAGS}")
 ENDIF()
 IF(UNIX AND NOT APPLE) 
 	SET(CMAKE_C_FLAGS "-pthread ${CMAKE_C_FLAGS}")
+    set(CMAKE_CXX_FLAGS "-pthread ${CMAKE_CXX_FLAGS}")
     set(CMAKE_EXE_LINKER_FLAGS "-pthread ${CMAKE_EXE_LINKER_FLAGS}")
 ENDIF()
 IF(WIN32)
 	SET(CMAKE_C_FLAGS "-D_CRT_SECURE_NO_WARNINGS ${CMAKE_C_FLAGS}")
 ENDIF()
 
-set(CMAKE_CXX_FLAGS "-std=c++11 -pthread ${CMAKE_CXX_FLAGS}")
-
 # Set version for the framework package/release
 SET(CELIX_MAJOR "1")
 SET(CELIX_MINOR "0")

http://git-wip-us.apache.org/repos/asf/celix/blob/5d3719c6/dependency_manager_cxx/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/CMakeLists.txt b/dependency_manager_cxx/CMakeLists.txt
index 49ff327..8afc7ec 100644
--- a/dependency_manager_cxx/CMakeLists.txt
+++ b/dependency_manager_cxx/CMakeLists.txt
@@ -45,6 +45,7 @@ if (DEPENDENCY_MANAGER_CXX)
 
         src/DependencyManager.cc
         src/Component.cc
+        src/ServiceDependency.cc
         src/dm_activator_base_cxx.cc
     )
     #set_target_properties(dependency_manager_cxx_static PROPERTIES SOVERSION 1)

http://git-wip-us.apache.org/repos/asf/celix/blob/5d3719c6/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 612ced6..b5324ec 100644
--- a/dependency_manager_cxx/include/celix/dm/Component.h
+++ b/dependency_manager_cxx/include/celix/dm/Component.h
@@ -31,14 +31,21 @@
 namespace celix { namespace dm {
 
     class BaseComponent {
-        std::string name {};
         bundle_context_pt context {nullptr};
+        std::string name {};
         dm_component_pt cCmp {nullptr};
     public:
         BaseComponent(const bundle_context_pt context, std::string name);
         virtual ~BaseComponent();
 
+        /**
+         * Returns the C DM Component
+         */
         const dm_component_pt cComponent() const;
+
+        /**
+         * Returns the C bundle context
+         */
         const bundle_context_pt bundleContext() const;
     };
         
@@ -56,28 +63,122 @@ namespace celix { namespace dm {
         Component(const bundle_context_pt context, std::string name);
         virtual ~Component();
 
+        /**
+         * Get the component instance. If no instance is explicitly set with setInstance
than a instance will be create
+         * using a default constructor.
+         *
+         * @return A reference to the component instance.
+         */
         T& getInstance();
 
+        /**
+         * Set the component instance using a (shared) pointer.
+         *
+         * @return the DM Component reference for chaining (fluent API)
+         */
         Component<T>& setInstance(std::shared_ptr<T> inst);
 
+        /**
+         * TODO FIXME, DOES NOT WORK
+         * Set the component instance using move semantic
+         * The DM Component will contain the instance.
+         *
+         * @return the DM Component reference for chaining (fluent API)
+         */
+        /*
         Component<T>& setInstance(T&& inst);
+        */
+
 
-        //provided interfaces
+        /**
+         * Adds a C++ interface to provide as service to the Celix framework.
+         * The interface name will be inferred using the I template.
+         *
+         * @param version The version of the interface (e.g. "1.0.0"), can be an empty string
+         * @return the DM Component reference for chaining (fluent API)
+         */
         template<class I> Component<T>& addInterface(const std::string version);
+
+        /**
+         * Adds a C++ interface to provide as service to the Celix framework.
+         * The interface name will be inferred using the I template.
+         *
+         * @param version The version of the interface (e.g. "1.0.0"), can be an empty string
+         * @param properties To (meta) properties to provide with the service
+         * @return the DM Component reference for chaining (fluent API)
+         */
         template<class I> Component<T>& addInterface(const std::string version,
const Properties properties);
-        Component<T>& addInterface(const std::string intfName, const std::string
version, const Properties properties);
+
+        /**
+         * Adds a C++ interface to provide as service to the Celix framework.
+         *
+         * @param serviceName The service name to use
+         * @param version The version of the interface (e.g. "1.0.0"), can be an empty string
+         * @param properties To (meta) properties to provide with the service
+         * @return the DM Component reference for chaining (fluent API)
+         */
+        Component<T>& addInterface(const std::string serviceName, const std::string
version, const Properties properties);
+
+        /**
+         * Adds a C interface to provide as service to the Celix framework.
+         *
+         * @param svc The service struct
+         * @param serviceName The service name to use
+         * @param version The version of the interface (e.g. "1.0.0"), can be an empty string
+         * @param properties To (meta) properties to provide with the service
+         */
+        Component<T>& addCInterface(const void* svc, const std::string serviceName,
const std::string version);
+
+        /**
+         * Adds a C interface to provide as service to the Celix framework.
+         *
+         * @param svc The service struct
+         * @param serviceName The service name to use
+         * @param version The version of the interface (e.g. "1.0.0"), can be an empty string
+         * @param properties To (meta) properties to provide with the service
+         */
         Component<T>& addCInterface(const void* svc, const std::string serviceName,
const std::string version, const Properties properties);
 
-        //dependencies
+        /**
+         * Adds a C++ service dependency to the component
+         *
+         * @return the DM Component reference for chaining (fluent API)
+         */
         template<class I>
         Component<T>& add(ServiceDependency<T,I>& dep);
+
+        /**
+         * Removes a C++ service dependency to the component
+         *
+         * @return the DM Component reference for chaining (fluent API)
+         */
         template<class I>
         Component<T>& remove(ServiceDependency<T,I>& dep);
 
+        /**
+         * Removes a C service dependency to the component
+         *
+         * @return the DM Component reference for chaining (fluent API)
+         */
         Component<T>& add(CServiceDependency<T>& dep);
+
+        /**
+         * Removes a C service dependency to the component
+         *
+         * @return the DM Component reference for chaining (fluent API)
+         */
         Component<T>& remove(CServiceDependency<T>& dep);
 
-        //callbacks
+        /**
+         * Set the callback for the component life cycle control
+         *
+         * @param init The init callback.
+         * @param start The start callback.
+         * @param stop The stop callback.
+         * @param deinit The deinit callback.
+         *
+         * @return the DM Component reference for chaining (fluent API)
+         */
         Component<T>& setCallbacks(
             void (T::*init)(),
             void (T::*start)(),

http://git-wip-us.apache.org/repos/asf/celix/blob/5d3719c6/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 17805ff..8f6c588 100644
--- a/dependency_manager_cxx/include/celix/dm/Component_Impl.h
+++ b/dependency_manager_cxx/include/celix/dm/Component_Impl.h
@@ -65,6 +65,11 @@ Component<T>& Component<T>::addInterface(const std::string
serviceName, const st
 };
 
 template<class T>
+Component<T>& Component<T>::addCInterface(const void* svc, const std::string
serviceName, const std::string version) {
+    return this->addCInterface(svc, serviceName, version, Properties());
+};
+
+template<class T>
 Component<T>& Component<T>::addCInterface(const void* svc, const std::string
serviceName, const std::string version, const Properties properties) {
     properties_pt cProperties = properties_create();
     properties_set(cProperties, (char*)"lang", (char*)"c");
@@ -125,12 +130,14 @@ 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(inst);
+    this->refInstance.push_back(std::move(inst));
     return *this;
 }
+ */
 
 template<class T>
 Component<T>& Component<T>::setCallbacks(

http://git-wip-us.apache.org/repos/asf/celix/blob/5d3719c6/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 4d188ee..52c22b2 100644
--- a/dependency_manager_cxx/include/celix/dm/DependencyManager.h
+++ b/dependency_manager_cxx/include/celix/dm/DependencyManager.h
@@ -47,7 +47,11 @@ namespace celix { namespace dm {
         const bundle_context_pt bundleContext() const;
         const dm_dependency_manager_pt cDependencyManager() const;
 
-        //components
+        /**
+         * Create a new DM Component for a component of type T
+         *
+         * @return Returns a reference to the DM Component
+         */
         template<class T>
         Component<T>& createComponent() {
             std::shared_ptr<Component<T>> cmp {new Component<T>(this->context,
typeName<T>())};
@@ -55,19 +59,27 @@ namespace celix { namespace dm {
             return *cmp;
         }
 
+        /**
+         * Adds a DM Component to the Dependency Manager
+         */
         template<class T>
-        Component<T>& add(Component<T>& cmp) {
+        void add(Component<T>& cmp) {
             addedComponents.push_back(&cmp);
-            return cmp;
         }
 
+        /**
+         * Removes a DM Component to the Dependency Manager
+         */
         template<class T>
-        Component<T>& remove(Component<T>& cmp) {
+        void remove(Component<T>& cmp) {
             addedComponents.remove(&cmp);
-            return cmp;
         }
 
-        //service dependencies
+        /**
+         * Create a new C++ service dependency for a component of type T with an interface
of type I
+         *
+         * @return Returns a reference to the service dependency
+         */
         template<class T, class I>
         ServiceDependency<T,I>& createServiceDependency() {
             auto dep = std::shared_ptr<ServiceDependency<T,I>> {new ServiceDependency<T,I>()};
@@ -76,6 +88,11 @@ namespace celix { namespace dm {
         };
 
 
+        /**
+         * Create a new C service dependency for a component of type T.
+         *
+         * @return Returns a reference to the service dependency
+         */
         template<class T>
         CServiceDependency<T>& createCServiceDependency() {
             auto dep = std::shared_ptr<CServiceDependency<T>> {new CServiceDependency<T>()};
@@ -83,8 +100,14 @@ namespace celix { namespace dm {
             return *dep;
         }
 
-        //life cycle
+        /**
+         * Starts the Dependency Manager
+         */
         void start();
+
+        /**
+         * Stops the Dependency Manager
+         */
         void stop();
     };
 

http://git-wip-us.apache.org/repos/asf/celix/blob/5d3719c6/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 b9f15dc..1894c54 100644
--- a/dependency_manager_cxx/include/celix/dm/DmActivator.h
+++ b/dependency_manager_cxx/include/celix/dm/DmActivator.h
@@ -30,26 +30,64 @@ namespace celix { namespace dm {
         DmActivator(DependencyManager& mng) : manager(mng) {}
     public:
         ~DmActivator() = default;
+
+        /**
+         * The init of the DM Activator. Should be overridden by the bundle specific DM activator.
+         *
+         * @param manager A reference to the  Dependency Manager
+         */
         virtual void init(DependencyManager& manager) {};
+
+        /**
+         * The init of the DM Activator. Can be overridden by the bundle specific DM activator.
+         *
+         * @param manager A reference to the  Dependency Manager
+         */
         virtual void deinit(DependencyManager& manager) {};
 
+        /**
+         * Create a new DM Component for a component of type T
+         *
+         * @return Returns a reference to the DM Component
+         */
         template< class T>
         Component<T>& createComponent() { return manager.createComponent<T>();
}
 
+        /**
+         * Adds a DM Component to the Dependency Manager
+         */
         template<class T>
-        Component<T>& add(Component<T>& cmp) { return manager.add(cmp);
}
+        void add(Component<T>& cmp) { manager.add(cmp); }
 
+        /**
+        * Removes a DM Component to the Dependency Manager
+        */
         template<class T>
-        Component<T>& remove(Component<T>& cmp) { return manager.remove(cmp);
}
+        void remove(Component<T>& cmp) { manager.remove(cmp); }
 
+        /**
+         * Create a new C++ service dependency for a component of type T with an interface
of type I
+         *
+         * @return Returns a reference to the service dependency
+         */
         template<class T, class I>
         ServiceDependency<T,I>& createServiceDependency() { return manager.createServiceDependency<T,I>();
}
 
+        /**
+         * Create a new C service dependency for a component of type T.
+         *
+         * @return Returns a reference to the service dependency
+         */
         template<class T>
         CServiceDependency<T>& createCServiceDependency() { return manager.createCServiceDependency<T>();
}
 
-        /* NOTE the following static method is intentionally not implemented
-         * This should be done by the bundle activator.
+        /**
+         * The static method to create a new DM activator.
+         * NOTE that this method in intentionally not implemented in the C++ Dependency Manager
library.
+         * This should be done by the bundle specific DM activator.
+         *
+         * @param mng A reference to the Dependency Manager
+         * @returns A pointer to a DmActivator. The Dependency Manager is responsible for
deleting the pointer when the bundle is stopped.
          */
         static DmActivator* create(DependencyManager& mng);
     };

http://git-wip-us.apache.org/repos/asf/celix/blob/5d3719c6/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 b39d1b3..f3d6476 100644
--- a/dependency_manager_cxx/include/celix/dm/ServiceDependency.h
+++ b/dependency_manager_cxx/include/celix/dm/ServiceDependency.h
@@ -43,13 +43,14 @@ namespace celix { namespace dm {
     class BaseServiceDependency {
     protected:
         dm_service_dependency_pt cServiceDep {nullptr};
+        void setDepStrategy(DependencyUpdateStrategy strategy);
     public:
-        BaseServiceDependency() {
-            serviceDependency_create(&this->cServiceDep);
-            serviceDependency_setStrategy(this->cServiceDep, DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND);
//NOTE using suspend as default strategy
-        }
+        BaseServiceDependency();
         virtual ~BaseServiceDependency() = default;
 
+        /**
+         * Returns the C DM service dependency
+         */
         dm_service_dependency_pt cServiceDependency() const { return cServiceDep; }
     };
 
@@ -61,6 +62,9 @@ namespace celix { namespace dm {
         TypedServiceDependency() : BaseServiceDependency() {}
         virtual ~TypedServiceDependency() = default;
 
+        /**
+         * Set the component instance with a pointer
+         */
         void setComponentInstance(T* cmp) { componentInstance = cmp;}
     };
 
@@ -70,9 +74,28 @@ namespace celix { namespace dm {
         CServiceDependency() : TypedServiceDependency<T>() {};
         virtual ~CServiceDependency() = default;
 
+        /**
+         * Sets the service name, version and filter for the C service dependency.
+         *
+         * @param serviceName The service name. Must have a value
+         * @param serviceVersion The service vesrion, can be an empty string
+         * @param filter The (additional) filter to use (e.g. "(location=front)")
+         * @return the C service dependency reference for chaining (fluent API)
+         */
         CServiceDependency<T>& setCService(const std::string serviceName, const
std::string serviceVersion, const std::string filter);
 
+        /**
+         * Specify if the service dependency is required. Default is false
+         *
+         * @return the C service dependency reference for chaining (fluent API)
+         */
         CServiceDependency<T>& setRequired(bool req);
+
+        /**
+         * Specify if the update strategy to use
+         *
+         * @return the C service dependency reference for chaining (fluent API)
+         */
         CServiceDependency<T>& setStrategy(DependencyUpdateStrategy strategy);
     };
 
@@ -101,26 +124,70 @@ namespace celix { namespace dm {
         ServiceDependency();
         virtual ~ServiceDependency() = default;
 
+        /**
+         * Set the service name of the service dependency.
+         *
+         * @return the C++ service dependency reference for chaining (fluent API)
+         */
         ServiceDependency<T,I>& setName(std::string name);
 
+        /**
+         * Set the service filter of the service dependency.
+         *
+         * @return the C++ service dependency reference for chaining (fluent API)
+         */
         ServiceDependency<T,I>& setFilter(std::string filter);
 
+        /**
+         * Set the service version of the service dependency.
+         *
+         * @return the C++ service dependency reference for chaining (fluent API)
+         */
         ServiceDependency<T,I>& setVersion(std::string version);
 
-        //set callbacks
+        /**
+         * Set the set callback for when the service dependency becomes available
+         *
+         * @return the C++ service dependency reference for chaining (fluent API)
+         */
         ServiceDependency<T,I>& setCallbacks(void (T::*set)(I* service));
 
+        /**
+         * Set the set callback for when the service dependency becomes available
+         *
+         * @return the C++ service dependency reference for chaining (fluent API)
+         */
         ServiceDependency<T,I>& setCallbacks(void (T::*set)(I* service, Properties&&
properties));
 
-        //add remove callbacks
+        /**
+         * Set the add and remove callback for when the services of service dependency are
added or removed.
+         *
+         * @return the C++ service dependency reference for chaining (fluent API)
+         */
         ServiceDependency<T,I>& setCallbacks( void (T::*add)(I* service),  void
(T::*remove)(I* service));
+
+        /**
+         * Set the add and remove callback for when the services of service dependency are
added or removed.
+         *
+         * @return the C++ service dependency reference for chaining (fluent API)
+         */
         ServiceDependency<T,I>& setCallbacks(
                 void (T::*add)(I* service, Properties&& properties),
                 void (T::*remove)(I* service, Properties&& properties)
         );
 
+        /**
+         * Specify if the service dependency is required. Default is false
+         *
+         * @return the C service dependency reference for chaining (fluent API)
+         */
         ServiceDependency<T,I>& setRequired(bool req);
 
+        /**
+         * Specify if the update strategy to use
+         *
+         * @return the C service dependency reference for chaining (fluent API)
+         */
         ServiceDependency<T,I>& setStrategy(DependencyUpdateStrategy strategy);
     };
 }}

http://git-wip-us.apache.org/repos/asf/celix/blob/5d3719c6/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 7c3eaf3..7bb812f 100644
--- a/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h
+++ b/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h
@@ -36,19 +36,9 @@ CServiceDependency<T>& CServiceDependency<T>::setRequired(bool
req) {
     return *this;
 }
 
-static void dep_setStrategy(dm_service_dependency_pt dep, DependencyUpdateStrategy strategy)
{
-    if (strategy == DependencyUpdateStrategy::locking) {
-        serviceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING);
-    } else if (strategy == DependencyUpdateStrategy::suspend) {
-        serviceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND);
-    } else {
-        std::cerr << "Unexpected dependency update strategy. Cannot convert for dm_depdendency\n";
-    }
-}
-
 template<class T>
 CServiceDependency<T>& CServiceDependency<T>::setStrategy(DependencyUpdateStrategy
strategy) {
-    dep_setStrategy(this->cServiceDependency(), strategy);
+    this->setDepStrategy(strategy);
     return *this;
 }
 
@@ -57,28 +47,27 @@ ServiceDependency<T,I>::ServiceDependency() : TypedServiceDependency<T>()
{
     setupService();
 };
 
-static std::string filterWithCxx(std::string filter) {
-    std::string result {"(lang=c++)"};
+template<class T, class I>
+void ServiceDependency<T,I>::setupService() {
+    std::string n = name.empty() ? typeName<I>() : name;
+    const char* v =  version.empty() ? nullptr : version.c_str();
+
+    //setting modified filter. which is in a filter including a lang=c++
+    modifiedFilter = std::string("(lang=c++)");
     if (!filter.empty()) {
         if (strncmp(filter.c_str(), "(&", 2) == 0 && filter[filter.size()-1]
== ')') {
-            result = filter.substr(0, filter.size()-1);
-            result = result.append("(lang=c++))");
+            modifiedFilter = filter.substr(0, filter.size()-1);
+            modifiedFilter = modifiedFilter.append("(lang=c++))");
         } else if (filter[0] == '(' && filter[filter.size()-1] == ')') {
-            result = "(&";
-            result = result.append(filter);
-            result = result.append("(lang=c++))");
+            modifiedFilter = "(&";
+            modifiedFilter = modifiedFilter.append(filter);
+            modifiedFilter = modifiedFilter.append("(lang=c++))");
         } else {
             std::cerr << "Unexpected filter layout: '" << filter << "'\n";
         }
     }
-    return result;
-}
 
-template<class T, class I>
-void ServiceDependency<T,I>::setupService() {
-    std::string n = name.empty() ? typeName<I>() : name;
-    const char* v =  version.empty() ? nullptr : version.c_str();
-    this->modifiedFilter = filterWithCxx(filter);
+
     serviceDependency_setService(this->cServiceDependency(), n.c_str(), v, this->modifiedFilter.c_str());
 }
 
@@ -148,7 +137,7 @@ ServiceDependency<T,I>& ServiceDependency<T,I>::setRequired(bool
req) {
 
 template<class T, class I>
 ServiceDependency<T,I>& ServiceDependency<T,I>::setStrategy(DependencyUpdateStrategy
strategy) {
-    dep_setStrategy(this->cServiceDependency(), strategy);
+    this->setDepStrategy(strategy);
     return *this;
 };
 

http://git-wip-us.apache.org/repos/asf/celix/blob/5d3719c6/dependency_manager_cxx/include/celix/dm/types.h
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/include/celix/dm/types.h b/dependency_manager_cxx/include/celix/dm/types.h
index a1dd1aa..ea447eb 100644
--- a/dependency_manager_cxx/include/celix/dm/types.h
+++ b/dependency_manager_cxx/include/celix/dm/types.h
@@ -44,6 +44,9 @@ namespace celix { namespace dm {
     template<class T, class I>
     class ServiceDependency;
 
+    /**
+     * Returns the deferred type name for the template I
+     */
     template<typename T>
     const std::string typeName() {
         std::string result = std::string(typeid(T).name());

http://git-wip-us.apache.org/repos/asf/celix/blob/5d3719c6/dependency_manager_cxx/src/ServiceDependency.cc
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/src/ServiceDependency.cc b/dependency_manager_cxx/src/ServiceDependency.cc
new file mode 100644
index 0000000..559efba
--- /dev/null
+++ b/dependency_manager_cxx/src/ServiceDependency.cc
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+#include "celix/dm/ServiceDependency.h"
+#include <iostream>
+
+using namespace celix::dm;
+
+BaseServiceDependency::BaseServiceDependency() {
+    serviceDependency_create(&this->cServiceDep);
+    serviceDependency_setStrategy(this->cServiceDep, DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND);
//NOTE using suspend as default strategy
+}
+
+void BaseServiceDependency::setDepStrategy(DependencyUpdateStrategy strategy) {
+    if (strategy == DependencyUpdateStrategy::locking) {
+        serviceDependency_setStrategy(this->cServiceDependency(), DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING);
+    } else if (strategy == DependencyUpdateStrategy::suspend) {
+        serviceDependency_setStrategy(this->cServiceDependency(), DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND);
+    } else {
+        std::cerr << "Unexpected dependency update strategy. Cannot convert for dm_depdendency\n";
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/5d3719c6/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 78af757..c3d7754 100644
--- a/examples/dm_example_cxx/phase1/src/Phase1Activator.cc
+++ b/examples/dm_example_cxx/phase1/src/Phase1Activator.cc
@@ -48,7 +48,7 @@ void Phase1Activator::init(DependencyManager& manager) {
 
     add(createComponent<Phase1Cmp>()
         .setInstance(cmp) //using a pointer a instance. Also support is lazy initialization
(default constructor needed) or a rvalue reference (move)
-        .addInterface<IPhase1>(IPHASE1_VERSION, {})
+        .addInterface<IPhase1>(IPHASE1_VERSION)
         .addCInterface(&cmd, OSGI_SHELL_COMMAND_SERVICE_NAME, "", cmdProps)
         .setCallbacks(&Phase1Cmp::init, &Phase1Cmp::start, &Phase1Cmp::stop,
&Phase1Cmp::deinit)
     );

http://git-wip-us.apache.org/repos/asf/celix/blob/5d3719c6/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 d0e4f6c..4288e3e 100644
--- a/examples/dm_example_cxx/phase2/include/Phase2Cmp.h
+++ b/examples/dm_example_cxx/phase2/include/Phase2Cmp.h
@@ -25,16 +25,19 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <thread>
+#include <iostream>
 
 class Phase2Cmp : public IPhase2 {
     IPhase1* phase1 {nullptr};
 public:
     Phase2Cmp() = default;
-    virtual ~Phase2Cmp() = default;
+    virtual ~Phase2Cmp() { std::cout << "Destroying Phase2\n"; };
 
     void setPhase1(IPhase1* phase); //injector used by dependency manager
 
     virtual double getData(); //implements IPhase2
+private:
+
 };
 
 #endif //CELIX_PHASE2CMP_H

http://git-wip-us.apache.org/repos/asf/celix/blob/5d3719c6/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 d0e6c29..fc6269a 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>()
-        .setInstance(Phase2Cmp()) //NOTE using move initialization
+        //FIXME .setInstance(Phase2Cmp()) //NOTE using move initialization
         .addInterface<IPhase2>(IPHASE2_VERSION, props)
         .add(createServiceDependency<Phase2Cmp,IPhase1>()
             .setRequired(true)


Mime
View raw message