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 2016/07/21 09:55:51 UTC
[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
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 <pe...@gmail.com>
Authored: Thu Jul 21 11:14:02 2016 +0200
Committer: Pepijn Noltes <pe...@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)
[2/3] celix git commit: CELIX-368: Adds documentiation the dependency
manager headers
Posted by pn...@apache.org.
CELIX-368: Adds documentiation the dependency manager headers
Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/24fd5b42
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/24fd5b42
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/24fd5b42
Branch: refs/heads/develop
Commit: 24fd5b4212e2ead76865039e6bbc94b359835c29
Parents: 5d3719c
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Thu Jul 21 11:54:17 2016 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Thu Jul 21 11:54:17 2016 +0200
----------------------------------------------------------------------
dependency_manager/README.md | 5 +-
.../public/include/dm_activator.h | 15 +++++
.../public/include/dm_component.h | 58 ++++++++++++++++-
.../public/include/dm_dependency_manager.h | 21 +++++-
.../public/include/dm_service_dependency.h | 68 +++++++++++++++++++-
5 files changed, 160 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/24fd5b42/dependency_manager/README.md
----------------------------------------------------------------------
diff --git a/dependency_manager/README.md b/dependency_manager/README.md
index 9a39c52..b0a3a3c 100644
--- a/dependency_manager/README.md
+++ b/dependency_manager/README.md
@@ -63,7 +63,7 @@ The `serviceDependency_setStrategy` function can be used to specify a service de
### Snippets
-### DM Bundle Activator
+#### DM Bundle Activator
The next snippet shows a dm bundle activator and how to add components to the dependency manager.
```C
@@ -112,7 +112,8 @@ celix_status_t dm_destroy(void * userData, bundle_context_pt context, dm_depende
}
```
-TODOS
+TODOS:
+
1. add cmp callbacks
1. add interface
1. add service dependency and callbacks
http://git-wip-us.apache.org/repos/asf/celix/blob/24fd5b42/dependency_manager/public/include/dm_activator.h
----------------------------------------------------------------------
diff --git a/dependency_manager/public/include/dm_activator.h b/dependency_manager/public/include/dm_activator.h
index 898d53f..521800a 100644
--- a/dependency_manager/public/include/dm_activator.h
+++ b/dependency_manager/public/include/dm_activator.h
@@ -37,8 +37,23 @@ extern "C" {
#include "celix_errno.h"
#include "dm_dependency_manager.h"
+/**
+ * Should be implemented by a bundle specific DM activator.
+ * Should allocate and initialize a bundle specific activator struct.
+ */
celix_status_t dm_create(bundle_context_pt context, void ** userData);
+
+/**
+ * Should be implemented by a bundle specific DM activator.
+ * Will be called after the dm_create function.
+ * Can be used to specify with use of the provided dependency manager the bundle specific components.
+ */
celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager);
+
+/**
+ * Should be implemented by a bundle specific DM activator.
+ * Should deinitialize and deallocate the undle specific activator struct.
+ */
celix_status_t dm_destroy(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager);
#ifdef __cplusplus
http://git-wip-us.apache.org/repos/asf/celix/blob/24fd5b42/dependency_manager/public/include/dm_component.h
----------------------------------------------------------------------
diff --git a/dependency_manager/public/include/dm_component.h b/dependency_manager/public/include/dm_component.h
index 997bd1a..d4f09a8 100644
--- a/dependency_manager/public/include/dm_component.h
+++ b/dependency_manager/public/include/dm_component.h
@@ -53,10 +53,29 @@ typedef int (*start_fpt)(void *userData);
typedef int (*stop_fpt)(void *userData);
typedef int (*deinit_fpt)(void *userData);
+/**
+ * Creates a DM Component
+ * Caller has ownership.
+ */
celix_status_t component_create(bundle_context_pt context, const char* name, dm_component_pt *component);
+
+/**
+ * Destroys a DM Component
+ */
void component_destroy(dm_component_pt component);
+/**
+ * Adds a C interface to provide as service to the Celix framework.
+ *
+ * @param serviceName the service name.
+ * @param version The version of the interface (e.g. "1.0.0"), Can be a NULL pointer.
+ * @param properties To (meta) properties to provide with the service. Can be a NULL pointer.
+ */
celix_status_t component_addInterface(dm_component_pt component, const char* serviceName, const char* serviceVersion, const void* service, properties_pt properties);
+
+/**
+ * Sets the implementation of the component. e.g. the component handle/self/this pointer.
+ */
celix_status_t component_setImplementation(dm_component_pt component, void* implementation);
/**
@@ -64,15 +83,45 @@ celix_status_t component_setImplementation(dm_component_pt component, void* impl
*/
celix_status_t component_getInterfaces(dm_component_pt component, array_list_pt *servicesNames);
+/**
+ * Adds a C service dependency to the component
+ */
celix_status_t component_addServiceDependency(dm_component_pt component, dm_service_dependency_pt dep);
+
+/**
+ * Removes a C service dependency to the component
+ */
celix_status_t component_removeServiceDependency(dm_component_pt component, dm_service_dependency_pt dependency);
+/**
+ * Returns the current state of the component.
+ */
dm_component_state_t component_currentState(dm_component_pt cmp);
+
+/**
+ * Returns the implementation of the component. e.g. the component handle/self/this pointer.
+ */
void * component_getImplementation(dm_component_pt cmp);
+
+/**
+ * Returns the DM component name. This is used when printing information about the component.
+ */
const char * component_getName(dm_component_pt cmp);
+/**
+ * Returns bundle context for the bundle where this DM component is part of.
+ */
celix_status_t component_getBundleContext(dm_component_pt component, bundle_context_pt *out);
+/**
+ * Set the component life cycle callbacks.
+ * The first argument will be the component implementation (@see component_getImplementation)
+ */
+celix_status_t component_setCallbacks(dm_component_pt component, init_fpt init, start_fpt start, stop_fpt stop, deinit_fpt deinit);
+
+/**
+ * Set the component life cycle callbacks using a MACRO for improving the type safety.
+ */
#define component_setCallbacksSafe(dmCmp, type, init, start, stop, deinit) \
do { \
int (*tmp_init)(type) = (init); \
@@ -82,12 +131,15 @@ celix_status_t component_getBundleContext(dm_component_pt component, bundle_cont
component_setCallbacks((dmCmp), (init_fpt)tmp_init, (start_fpt)tmp_start, (stop_fpt)tmp_stop, (deinit_fpt)tmp_deinit); \
} while(0)
-celix_status_t component_setCallbacks(dm_component_pt component, init_fpt init, start_fpt start, stop_fpt stop, deinit_fpt deinit);
-
/**
- * returns a dm_component_info_pt. Caller has ownership.
+ * Create a DM Component info struct. Containing information about the component.
+ * Caller has ownership.
*/
celix_status_t component_getComponentInfo(dm_component_pt component, dm_component_info_pt *info);
+
+/**
+ * Destroys a DM Component info struct.
+ */
void component_destroyComponentInfo(dm_component_info_pt info);
#ifdef __cplusplus
http://git-wip-us.apache.org/repos/asf/celix/blob/24fd5b42/dependency_manager/public/include/dm_dependency_manager.h
----------------------------------------------------------------------
diff --git a/dependency_manager/public/include/dm_dependency_manager.h b/dependency_manager/public/include/dm_dependency_manager.h
index 339fa55..9ee8ae5 100644
--- a/dependency_manager/public/include/dm_dependency_manager.h
+++ b/dependency_manager/public/include/dm_dependency_manager.h
@@ -39,17 +39,36 @@ extern "C" {
typedef struct dm_dependency_manager *dm_dependency_manager_pt;
+/**
+ * Creates a dependency manager.
+ * Caller has ownership.
+ */
celix_status_t dependencyManager_create(bundle_context_pt context, dm_dependency_manager_pt *manager);
+
+/**
+ * Destroys the provided dependency manager
+ */
void dependencyManager_destroy(dm_dependency_manager_pt manager);
+/**
+ * Adds a DM component to the dependency manager
+ */
celix_status_t dependencyManager_add(dm_dependency_manager_pt manager, dm_component_pt component);
+/**
+ * Removes all DM components from the dependency manager
+ */
celix_status_t dependencyManager_removeAllComponents(dm_dependency_manager_pt manager);
/**
- * returns a dm_ of dm_dependency_manager_info. Caller has ownership.
+ * Create and returns a DM Info struct. Which contains information about the state of the DM components
+ * Caller has ownership.
*/
celix_status_t dependencyManager_getInfo(dm_dependency_manager_pt manager, dm_dependency_manager_info_pt *info);
+
+/**
+ * Destroys a DM info struct.
+ */
void dependencyManager_destroyInfo(dm_dependency_manager_pt manager, dm_dependency_manager_info_pt info);
#ifdef __cplusplus
http://git-wip-us.apache.org/repos/asf/celix/blob/24fd5b42/dependency_manager/public/include/dm_service_dependency.h
----------------------------------------------------------------------
diff --git a/dependency_manager/public/include/dm_service_dependency.h b/dependency_manager/public/include/dm_service_dependency.h
index ed19b55..bed9379 100644
--- a/dependency_manager/public/include/dm_service_dependency.h
+++ b/dependency_manager/public/include/dm_service_dependency.h
@@ -55,17 +55,78 @@ typedef celix_status_t (*service_change_with_ref_fpt)(void *handle, service_refe
typedef celix_status_t (*service_remove_with_ref_fpt)(void *handle, service_reference_pt reference, const void* service);
typedef celix_status_t (*service_swap_with_ref_fpt)(void *handle, service_reference_pt oldReference, const void* oldService, service_reference_pt newReference, const void* newService);
+/**
+ * Create a service dependency.
+ * Caller has ownership.
+ */
celix_status_t serviceDependency_create(dm_service_dependency_pt *dependency_ptr);
+
+/**
+ * Destroys a service dependency.
+ * Caller has ownership.
+ */
celix_status_t serviceDependency_destroy(dm_service_dependency_pt *dependency_ptr);
+/**
+ * Specify if the service dependency is required. default is false
+ */
celix_status_t serviceDependency_setRequired(dm_service_dependency_pt dependency, bool required);
+
+/**
+ * Specify if the service dependency update strategy.
+ *
+ * For DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING the component is expected to use locking mechanismes when updating
+ * and invoking services.
+ *
+ * For DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND the component is stopped/started
+ * when services are set,added, modified or removed.
+ * It is the responsibility of the component to ensure that no
+ * service invocation is possible or happening when the component stop callback is finished.
+ *
+ * Default strategy is DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND
+ */
celix_status_t serviceDependency_setStrategy(dm_service_dependency_pt dependency,dm_service_dependency_strategy_t strategy);
+
+/**
+ * Return the service dependency update strategy.
+ */
celix_status_t serviceDependency_getStrategy(dm_service_dependency_pt dependency,dm_service_dependency_strategy_t* strategy);
+
+/**
+ * Set the service name, version range and filter.
+ *
+ * @param serviceName The service name. Must have a value.
+ * @param serviceVersionRange The service version range, can be a NULL pointer.
+ * @param filter The (additional) filter to use (e.g. "(location=front)"). Can be a NULL pointer.
+ */
celix_status_t serviceDependency_setService(dm_service_dependency_pt dependency, const char* serviceName, const char* serviceVersionRange, const char* filter);
+
+/**
+ * Returns the service depenendy filter.
+ */
celix_status_t serviceDependency_getFilter(dm_service_dependency_pt dependency, const char** filter);
+/**
+ * Set the set, add, change, remove and swap function callbacks when services specified by the service dependency
+ * are (respectively) set, added, changed, removed or swapped.
+ * The first argument of the callbacks will be the component implement (@see component_getImplementation)
+ * The second the argument a pointer to an instance of a service struct of the specified service dependency.
+ */
celix_status_t serviceDependency_setCallbacks(dm_service_dependency_pt dependency, service_set_fpt set, service_add_fpt add, service_change_fpt change, service_remove_fpt remove, service_swap_fpt swap);
+
+/**
+ * Set the set, add, change, remove and swap function callbacks when services specified by the service dependency
+ * are (respectively) set, added, changed, removed or swapped.
+ * The first argument of the callbacks will be the component implement (@see component_getImplementation)
+ * The second argument of th callbacks will be a pointer to an instance of a service struct of the specified service dependency.
+ * The third argument of th callbacks will be a pointer to a service reference of the a service instance of the specified service dependency.
+ */
celix_status_t serviceDependency_setCallbacksWithServiceReference(dm_service_dependency_pt dependency, service_set_with_ref_fpt set, service_add_with_ref_fpt add, service_change_with_ref_fpt change, service_remove_with_ref_fpt remove, service_swap_with_ref_fpt swap);
+
+/**
+ * Specifies which field member (pointer to) to update when a service dependencies is set.
+ * If provided the provided service_lock will be used for locking when updating the service instance.
+ */
celix_status_t serviceDependency_setAutoConfigure(dm_service_dependency_pt dependency, celix_thread_mutex_t *service_lock, const void** field);
#define serviceDependency_setCallbacksSafe(dep, cmpType, servType, set, add, change, remove, swap) \
@@ -86,9 +147,14 @@ celix_status_t serviceDependency_setAutoConfigure(dm_service_dependency_pt depen
celix_status_t serviceDependency_setCallbackHandle(dm_service_dependency_pt dependency, void* handle);
/**
- * Return a service dependency info. The caller is the owner
+ * Creates a service dependency info. The service dependency info struct contains information about the service dependency.
+ * The caller is the owner
*/
celix_status_t serviceDependency_getServiceDependencyInfo(dm_service_dependency_pt, dm_service_dependency_info_pt *info);
+
+/**
+ * Destroy a provided service dependency info struct.
+ */
void dependency_destroyDependencyInfo(dm_service_dependency_info_pt info);
#ifdef __cplusplus
[3/3] celix git commit: CELIX-370: Refactors some naming issues for
the C++ dep man
Posted by pn...@apache.org.
CELIX-370: Refactors some naming issues for the C++ dep man
Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/0757a7a6
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/0757a7a6
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/0757a7a6
Branch: refs/heads/develop
Commit: 0757a7a62b43e76b3415e51c2b4fb4de10c5fdfa
Parents: 24fd5b4
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Thu Jul 21 11:55:08 2016 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Thu Jul 21 11:55:08 2016 +0200
----------------------------------------------------------------------
dependency_manager_cxx/include/celix/dm/Component.h | 2 +-
.../include/celix/dm/ServiceDependency.h | 10 +++++-----
.../include/celix/dm/ServiceDependency_Impl.h | 10 +++++-----
3 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/0757a7a6/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 b5324ec..e6e8d15 100644
--- a/dependency_manager_cxx/include/celix/dm/Component.h
+++ b/dependency_manager_cxx/include/celix/dm/Component.h
@@ -156,7 +156,7 @@ namespace celix { namespace dm {
Component<T>& remove(ServiceDependency<T,I>& dep);
/**
- * Removes a C service dependency to the component
+ * Adds a C service dependency to the component
*
* @return the DM Component reference for chaining (fluent API)
*/
http://git-wip-us.apache.org/repos/asf/celix/blob/0757a7a6/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 f3d6476..7b635c3 100644
--- a/dependency_manager_cxx/include/celix/dm/ServiceDependency.h
+++ b/dependency_manager_cxx/include/celix/dm/ServiceDependency.h
@@ -78,11 +78,11 @@ namespace celix { namespace dm {
* 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 serviceVersionRange The service version range, 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);
+ CServiceDependency<T>& setCService(const std::string serviceName, const std::string serviceVersionRange, const std::string filter);
/**
* Specify if the service dependency is required. Default is false
@@ -104,7 +104,7 @@ namespace celix { namespace dm {
protected:
std::string name {};
std::string filter {};
- std::string version {};
+ std::string versionRange {};
std::string modifiedFilter {};
void (T::*setFp)(I* service) {nullptr};
@@ -139,11 +139,11 @@ namespace celix { namespace dm {
ServiceDependency<T,I>& setFilter(std::string filter);
/**
- * Set the service version of the service dependency.
+ * Set the service version range of the service dependency.
*
* @return the C++ service dependency reference for chaining (fluent API)
*/
- ServiceDependency<T,I>& setVersion(std::string version);
+ ServiceDependency<T,I>& setVersion(std::string versionRange);
/**
* Set the set callback for when the service dependency becomes available
http://git-wip-us.apache.org/repos/asf/celix/blob/0757a7a6/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 7bb812f..4f23b61 100644
--- a/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h
+++ b/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h
@@ -23,8 +23,8 @@
using namespace celix::dm;
template<class T>
-CServiceDependency<T>& CServiceDependency<T>::setCService(const std::string serviceName, const std::string serviceVersion, const std::string filter) {
- const char* cversion = serviceVersion.empty() ? nullptr : serviceVersion.c_str();
+CServiceDependency<T>& CServiceDependency<T>::setCService(const std::string serviceName, const std::string serviceVersionRange, const std::string filter) {
+ const char* cversion = serviceVersionRange.empty() ? nullptr : serviceVersionRange.c_str();
const char* cfilter = filter.empty() ? nullptr : filter.c_str();
serviceDependency_setService(this->cServiceDependency(), serviceName.c_str(), cversion, cfilter);
return *this;
@@ -50,7 +50,7 @@ ServiceDependency<T,I>::ServiceDependency() : TypedServiceDependency<T>() {
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();
+ const char* v = versionRange.empty() ? nullptr : versionRange.c_str();
//setting modified filter. which is in a filter including a lang=c++
modifiedFilter = std::string("(lang=c++)");
@@ -86,8 +86,8 @@ ServiceDependency<T,I>& ServiceDependency<T,I>::setFilter(std::string filter) {
};
template<class T, class I>
-ServiceDependency<T,I>& ServiceDependency<T,I>::setVersion(std::string version) {
- this->version = version;
+ServiceDependency<T,I>& ServiceDependency<T,I>::setVersion(std::string versionRange) {
+ this->versionRange = versionRange;
setupService();
return *this;
};