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/27 10:55:50 UTC
celix git commit: CELIX-370: Adds template for CServiceDependency.
Repository: celix
Updated Branches:
refs/heads/develop 143b0d641 -> 0b617d736
CELIX-370: Adds template for CServiceDependency.
Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/0b617d73
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/0b617d73
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/0b617d73
Branch: refs/heads/develop
Commit: 0b617d73621249b0f0c17a53cd37506f5aa2333a
Parents: 143b0d6
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Wed Jul 27 12:55:06 2016 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Wed Jul 27 12:55:06 2016 +0200
----------------------------------------------------------------------
.../include/celix/dm/Component.h | 6 +-
.../include/celix/dm/Component_Impl.h | 12 ++--
.../include/celix/dm/DependencyManager.h | 8 +--
.../include/celix/dm/DmActivator.h | 4 +-
.../include/celix/dm/ServiceDependency.h | 44 ++++++------
.../include/celix/dm/ServiceDependency_Impl.h | 73 ++++++++++----------
dependency_manager_cxx/include/celix/dm/types.h | 6 +-
examples/dm_example_cxx/api/IPhase1.h | 2 +
examples/dm_example_cxx/api/IPhase2.h | 2 +
.../dm_example_cxx/phase2/include/Phase2Cmp.h | 10 +--
.../phase2a/src/Phase2aActivator.cc | 6 +-
.../dm_example_cxx/phase2a/src/Phase2aCmp.cc | 2 +-
.../phase2b/src/Phase2bActivator.cc | 7 +-
.../dm_example_cxx/phase2b/src/Phase2bCmp.cc | 2 +-
log_service/public/include/log_service.h | 3 +-
15 files changed, 98 insertions(+), 89 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/0b617d73/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 4e45b10..e55044b 100644
--- a/dependency_manager_cxx/include/celix/dm/Component.h
+++ b/dependency_manager_cxx/include/celix/dm/Component.h
@@ -157,14 +157,16 @@ namespace celix { namespace dm {
*
* @return the DM Component reference for chaining (fluent API)
*/
- Component<T>& add(CServiceDependency<T>& dep);
+ template<typename I>
+ Component<T>& add(CServiceDependency<T,I>& dep);
/**
* Removes a C service dependency to the component
*
* @return the DM Component reference for chaining (fluent API)
*/
- Component<T>& remove(CServiceDependency<T>& dep);
+ template<typename I>
+ Component<T>& remove(CServiceDependency<T,I>& dep);
/**
* Set the callback for the component life cycle control
http://git-wip-us.apache.org/repos/asf/celix/blob/0b617d73/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 4b7b6f5..5f53992 100644
--- a/dependency_manager_cxx/include/celix/dm/Component_Impl.h
+++ b/dependency_manager_cxx/include/celix/dm/Component_Impl.h
@@ -42,11 +42,7 @@ Component<T>& Component<T>::addInterface(const std::string version) {
template<class T>
template<class I>
Component<T>& Component<T>::addInterface(const std::string version, const Properties props) {
- if (dynamic_cast<I*>(&this->getInstance()) != nullptr) {
- this->addInterface(typeName<I>(), version.c_str(), props);
- } else {
- std::cerr << "Error casting to type " << typeName<I>() << "\n";
- }
+ this->addInterface(typeName<I>(), version.c_str(), props);
return *this;
}
@@ -99,7 +95,8 @@ Component<T>& Component<T>::remove(ServiceDependency<T,I>& dep) {
}
template<class T>
-Component<T>& Component<T>::add(CServiceDependency<T>& dep) {
+template<typename I>
+Component<T>& Component<T>::add(CServiceDependency<T,I>& dep) {
component_addServiceDependency(cComponent(), dep.cServiceDependency());
dep.setComponentInstance(&getInstance());
@@ -107,7 +104,8 @@ Component<T>& Component<T>::add(CServiceDependency<T>& dep) {
}
template<class T>
-Component<T>& Component<T>::remove(CServiceDependency<T>& dep) {
+template<typename I>
+Component<T>& Component<T>::remove(CServiceDependency<T,I>& dep) {
component_removeServiceDependency(cComponent(), dep.cServiceDependency());
return *this;
}
http://git-wip-us.apache.org/repos/asf/celix/blob/0b617d73/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 52c22b2..410e04a 100644
--- a/dependency_manager_cxx/include/celix/dm/DependencyManager.h
+++ b/dependency_manager_cxx/include/celix/dm/DependencyManager.h
@@ -55,7 +55,7 @@ namespace celix { namespace dm {
template<class T>
Component<T>& createComponent() {
std::shared_ptr<Component<T>> cmp {new Component<T>(this->context, typeName<T>())};
- components.push_back(cmp);
+ this->components.push_back(cmp);
return *cmp;
}
@@ -93,9 +93,9 @@ namespace celix { namespace dm {
*
* @return Returns a reference to the service dependency
*/
- template<class T>
- CServiceDependency<T>& createCServiceDependency() {
- auto dep = std::shared_ptr<CServiceDependency<T>> {new CServiceDependency<T>()};
+ template<class T, typename I>
+ CServiceDependency<T,I>& createCServiceDependency() {
+ auto dep = std::shared_ptr<CServiceDependency<T,I>> {new CServiceDependency<T,I>()};
dependencies.push_back(dep);
return *dep;
}
http://git-wip-us.apache.org/repos/asf/celix/blob/0b617d73/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 1894c54..503b824 100644
--- a/dependency_manager_cxx/include/celix/dm/DmActivator.h
+++ b/dependency_manager_cxx/include/celix/dm/DmActivator.h
@@ -78,8 +78,8 @@ namespace celix { namespace dm {
*
* @return Returns a reference to the service dependency
*/
- template<class T>
- CServiceDependency<T>& createCServiceDependency() { return manager.createCServiceDependency<T>(); }
+ template<class T, typename I>
+ CServiceDependency<T,I>& createCServiceDependency() { return manager.createCServiceDependency<T,I>(); }
/**
* The static method to create a new DM activator.
http://git-wip-us.apache.org/repos/asf/celix/blob/0b617d73/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 df3f432..8d08d9b 100644
--- a/dependency_manager_cxx/include/celix/dm/ServiceDependency.h
+++ b/dependency_manager_cxx/include/celix/dm/ServiceDependency.h
@@ -68,21 +68,21 @@ namespace celix { namespace dm {
void setComponentInstance(T* cmp) { componentInstance = cmp;}
};
- template<class T>
+ template<class T, typename I>
class CServiceDependency : public TypedServiceDependency<T> {
private:
- void (T::*setFp)(const void* service) {nullptr};
- void (T::*setFpWithProperties)(const void* service, Properties&& properties) {nullptr};
+ void (T::*setFp)(const I* service) {nullptr};
+ void (T::*setFpWithProperties)(const I* service, Properties&& properties) {nullptr};
- void (T::*addFp)(const void* service) {nullptr};
- void (T::*addFpWithProperties)(const void* service, Properties&& properties) {nullptr};
+ void (T::*addFp)(const I* service) {nullptr};
+ void (T::*addFpWithProperties)(const I* service, Properties&& properties) {nullptr};
- void (T::*removeFp)(const void* service) {nullptr};
- void (T::*removeFpWithProperties)(const void* service, Properties&& properties) {nullptr};
+ void (T::*removeFp)(const I* service) {nullptr};
+ void (T::*removeFpWithProperties)(const I* service, Properties&& properties) {nullptr};
void setupCallbacks();
- int invokeCallback(void(T::*fp)(const void*), const void* service);
- int invokeCallbackWithProperties(void(T::*fp)(const void*, Properties&&), service_reference_pt ref, const void* service);
+ int invokeCallback(void(T::*fp)(const I*), const void* service);
+ int invokeCallbackWithProperties(void(T::*fp)(const I*, Properties&&), service_reference_pt ref, const void* service);
public:
CServiceDependency() : TypedServiceDependency<T>() {};
virtual ~CServiceDependency() = default;
@@ -95,51 +95,51 @@ namespace celix { namespace dm {
* @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 serviceVersionRange, const std::string filter);
+ CServiceDependency<T,I>& setCService(const std::string serviceName, const std::string serviceVersionRange, 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);
+ CServiceDependency<T,I>& 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);
+ CServiceDependency<T,I>& setStrategy(DependencyUpdateStrategy strategy);
/**
* Set the set callback for when the service dependency becomes available
*
- * @return the C++ service dependency reference for chaining (fluent API)
+ * @return the C service dependency reference for chaining (fluent API)
*/
- CServiceDependency<T>& setCallbacks(void (T::*set)(const void* service));
+ CServiceDependency<T,I>& setCallbacks(void (T::*set)(const I* service));
/**
* Set the set callback for when the service dependency becomes available
*
- * @return the C++ service dependency reference for chaining (fluent API)
+ * @return the C service dependency reference for chaining (fluent API)
*/
- CServiceDependency<T>& setCallbacks(void (T::*set)(const void* service, Properties&& properties));
+ CServiceDependency<T,I>& setCallbacks(void (T::*set)(const I* service, Properties&& properties));
/**
* 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)
+ * @return the C service dependency reference for chaining (fluent API)
*/
- CServiceDependency<T>& setCallbacks( void (T::*add)(const void* service), void (T::*remove)(const void* service));
+ CServiceDependency<T,I>& setCallbacks( void (T::*add)(const I* service), void (T::*remove)(const 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)
+ * @return the C service dependency reference for chaining (fluent API)
*/
- CServiceDependency<T>& setCallbacks(
- void (T::*add)(const void* service, Properties&& properties),
- void (T::*remove)(const void* service, Properties&& properties)
+ CServiceDependency<T,I>& setCallbacks(
+ void (T::*add)(const I* service, Properties&& properties),
+ void (T::*remove)(const I* service, Properties&& properties)
);
};
http://git-wip-us.apache.org/repos/asf/celix/blob/0b617d73/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 9300253..2eabecc 100644
--- a/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h
+++ b/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h
@@ -22,56 +22,56 @@
using namespace celix::dm;
-template<class T>
-CServiceDependency<T>& CServiceDependency<T>::setCService(const std::string serviceName, const std::string serviceVersionRange, const std::string filter) {
+template<class T, typename I>
+CServiceDependency<T,I>& CServiceDependency<T,I>::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;
}
-template<class T>
-CServiceDependency<T>& CServiceDependency<T>::setRequired(bool req) {
+template<class T, typename I>
+CServiceDependency<T,I>& CServiceDependency<T,I>::setRequired(bool req) {
serviceDependency_setRequired(this->cServiceDependency(), req);
return *this;
}
-template<class T>
-CServiceDependency<T>& CServiceDependency<T>::setStrategy(DependencyUpdateStrategy strategy) {
+template<class T, typename I>
+CServiceDependency<T,I>& CServiceDependency<T,I>::setStrategy(DependencyUpdateStrategy strategy) {
this->setDepStrategy(strategy);
return *this;
}
//set callbacks
-template<class T>
-CServiceDependency<T>& CServiceDependency<T>::setCallbacks(void (T::*set)(const void* service)) {
+template<class T, typename I>
+CServiceDependency<T,I>& CServiceDependency<T,I>::setCallbacks(void (T::*set)(const I* service)) {
this->setFp = set;
this->setupCallbacks();
return *this;
}
-template<class T>
-CServiceDependency<T>& CServiceDependency<T>::setCallbacks(void (T::*set)(const void* service, Properties&& properties)) {
+template<class T, typename I>
+CServiceDependency<T,I>& CServiceDependency<T,I>::setCallbacks(void (T::*set)(const I* service, Properties&& properties)) {
this->setFpWithProperties = set;
this->setupCallbacks();
return *this;
}
//add remove callbacks
-template<class T>
-CServiceDependency<T>& CServiceDependency<T>::setCallbacks(
- void (T::*add)(const void* service),
- void (T::*remove)(const void* service)) {
+template<class T, typename I>
+CServiceDependency<T,I>& CServiceDependency<T,I>::setCallbacks(
+ void (T::*add)(const I* service),
+ void (T::*remove)(const I* service)) {
this->addFp = add;
this->removeFp = remove;
this->setupCallbacks();
return *this;
}
-template<class T>
-CServiceDependency<T>& CServiceDependency<T>::setCallbacks(
- void (T::*add)(const void* service, Properties&& properties),
- void (T::*remove)(const void* service, Properties&& properties)
+template<class T, typename I>
+CServiceDependency<T,I>& CServiceDependency<T,I>::setCallbacks(
+ void (T::*add)(const I* service, Properties&& properties),
+ void (T::*remove)(const I* service, Properties&& properties)
) {
this->addFpWithProperties = add;
this->removeFpWithProperties = remove;
@@ -80,8 +80,8 @@ CServiceDependency<T>& CServiceDependency<T>::setCallbacks(
}
-template<class T>
-void CServiceDependency<T>::setupCallbacks() {
+template<class T, typename I>
+void CServiceDependency<T,I>::setupCallbacks() {
int(*cset)(void*,const void*) {nullptr};
int(*cadd)(void*, const void*) {nullptr};
@@ -89,20 +89,20 @@ void CServiceDependency<T>::setupCallbacks() {
if (setFp != nullptr) {
- cset = [](void* handle, const void*service) -> int {
- auto dep = (CServiceDependency<T>*) handle;
+ cset = [](void* handle, const void* service) -> int {
+ auto dep = (CServiceDependency<T,I>*) handle;
return dep->invokeCallback(dep->setFp, service);
};
}
if (addFp != nullptr) {
- cadd = [](void* handle, const void*service) -> int {
- auto dep = (CServiceDependency<T>*) handle;
+ cadd = [](void* handle, const void* service) -> int {
+ auto dep = (CServiceDependency<T,I>*) handle;
return dep->invokeCallback(dep->addFp, service);
};
}
if (removeFp != nullptr) {
- cremove = [](void* handle, const void*service) -> int {
- auto dep = (CServiceDependency<T>*) handle;
+ cremove = [](void* handle, const void* service) -> int {
+ auto dep = (CServiceDependency<T,I>*) handle;
return dep->invokeCallback(dep->removeFp, service);
};
}
@@ -113,19 +113,19 @@ void CServiceDependency<T>::setupCallbacks() {
if (setFpWithProperties != nullptr) {
csetWithRef = [](void* handle, service_reference_pt ref, const void* service) -> int {
- auto dep = (CServiceDependency<T>*) handle;
+ auto dep = (CServiceDependency<T,I>*) handle;
return dep->invokeCallbackWithProperties(dep->setFpWithProperties, ref, service);
};
}
if (addFpWithProperties != nullptr) {
caddWithRef = [](void* handle, service_reference_pt ref, const void* service) -> int {
- auto dep = (CServiceDependency<T>*) handle;
+ auto dep = (CServiceDependency<T,I>*) handle;
return dep->invokeCallbackWithProperties(dep->addFpWithProperties, ref, service);
};
}
if (removeFpWithProperties != nullptr) {
cremoveWithRef = [](void* handle, service_reference_pt ref, const void* service) -> int {
- auto dep = (CServiceDependency<T>*) handle;
+ auto dep = (CServiceDependency<T,I>*) handle;
return dep->invokeCallbackWithProperties(dep->removeFpWithProperties, ref, service);
};
}
@@ -135,15 +135,16 @@ void CServiceDependency<T>::setupCallbacks() {
serviceDependency_setCallbacksWithServiceReference(this->cServiceDependency(), csetWithRef, caddWithRef, nullptr, cremoveWithRef, nullptr);
};
-template<class T>
-int CServiceDependency<T>::invokeCallback(void(T::*fp)(const void* service), const void* service) {
+template<class T, typename I>
+int CServiceDependency<T,I>::invokeCallback(void(T::*fp)(const I*), const void* service) {
T *cmp = this->componentInstance;
- (cmp->*fp)(service);
+ const I* srv = (const I*) service;
+ (cmp->*fp)(srv);
return 0;
};
-template<class T>
-int CServiceDependency<T>::invokeCallbackWithProperties(void(T::*fp)(const void*, Properties&&), service_reference_pt ref, const void* service) {
+template<class T, typename I>
+int CServiceDependency<T,I>::invokeCallbackWithProperties(void(T::*fp)(const I*, Properties&&), service_reference_pt ref, const void* service) {
service_registration_pt reg {nullptr};
properties_pt props {nullptr};
T *cmp = this->componentInstance;
@@ -162,7 +163,9 @@ int CServiceDependency<T>::invokeCallbackWithProperties(void(T::*fp)(const void*
properties[key] = value;
}
- (cmp->*fp)(service, static_cast<Properties&&>(properties)); //explicit move of lvalue properties.
+ const I* srv = (const I*) service;
+
+ (cmp->*fp)(srv, static_cast<Properties&&>(properties)); //explicit move of lvalue properties.
return 0;
}
http://git-wip-us.apache.org/repos/asf/celix/blob/0b617d73/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 ea447eb..d4efeee 100644
--- a/dependency_manager_cxx/include/celix/dm/types.h
+++ b/dependency_manager_cxx/include/celix/dm/types.h
@@ -38,7 +38,7 @@ namespace celix { namespace dm {
class BaseServiceDependency;
- template<class T>
+ template<class T, typename I>
class CServiceDependency;
template<class T, class I>
@@ -47,9 +47,9 @@ namespace celix { namespace dm {
/**
* Returns the deferred type name for the template I
*/
- template<typename T>
+ template<typename I>
const std::string typeName() {
- std::string result = std::string(typeid(T).name());
+ std::string result = std::string(typeid(I).name());
int status = 0;
char* demangled_name {abi::__cxa_demangle(result.c_str(), NULL, NULL, &status)};
if(status == 0) {
http://git-wip-us.apache.org/repos/asf/celix/blob/0b617d73/examples/dm_example_cxx/api/IPhase1.h
----------------------------------------------------------------------
diff --git a/examples/dm_example_cxx/api/IPhase1.h b/examples/dm_example_cxx/api/IPhase1.h
index 241f90d..3f5fd3b 100644
--- a/examples/dm_example_cxx/api/IPhase1.h
+++ b/examples/dm_example_cxx/api/IPhase1.h
@@ -23,6 +23,8 @@
#define IPHASE1_VERSION "1.0.0"
class IPhase1 {
+protected:
+ IPhase1() = default;
public:
virtual int getData() = 0;
};
http://git-wip-us.apache.org/repos/asf/celix/blob/0b617d73/examples/dm_example_cxx/api/IPhase2.h
----------------------------------------------------------------------
diff --git a/examples/dm_example_cxx/api/IPhase2.h b/examples/dm_example_cxx/api/IPhase2.h
index 2640358..7b9fa05 100644
--- a/examples/dm_example_cxx/api/IPhase2.h
+++ b/examples/dm_example_cxx/api/IPhase2.h
@@ -23,6 +23,8 @@
#define IPHASE2_VERSION "1.0.0"
class IPhase2 {
+protected:
+ IPhase2() = default;
public:
virtual double getData() = 0;
};
http://git-wip-us.apache.org/repos/asf/celix/blob/0b617d73/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 f5863d8..cff9d6d 100644
--- a/examples/dm_example_cxx/phase2/include/Phase2Cmp.h
+++ b/examples/dm_example_cxx/phase2/include/Phase2Cmp.h
@@ -34,8 +34,10 @@ extern "C" {
class Phase2Cmp : public IPhase2 {
public:
Phase2Cmp() = default;
- Phase2Cmp(Phase2Cmp&& other) : phase1(other.phase1), logSrv(other.logSrv) {
- std::cout << "Move constructor Phase2Cmp called\n";
+ Phase2Cmp(Phase2Cmp&& other) : phase1(nullptr), logSrv{nullptr} {
+ std::cout << "Move constructor Phase2Cmp called\n";
+ this->phase1 = phase1;
+ this->logSrv = logSrv;
other.phase1 = nullptr;
other.logSrv = nullptr;
}
@@ -43,12 +45,12 @@ public:
virtual ~Phase2Cmp() { std::cout << "Destroying Phase2\n"; };
void setPhase1(IPhase1* phase); //injector used by dependency manager
- void setLogService(log_service_pt logSrv);
+ void setLogService(const log_service_t* logSrv);
virtual double getData(); //implements IPhase2
private:
IPhase1* phase1 {nullptr};
- log_service_pt logSrv {nullptr};
+ const log_service_t* logSrv {nullptr};
};
#endif //CELIX_PHASE2CMP_H
http://git-wip-us.apache.org/repos/asf/celix/blob/0b617d73/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 83449d2..c486fe9 100644
--- a/examples/dm_example_cxx/phase2a/src/Phase2aActivator.cc
+++ b/examples/dm_example_cxx/phase2a/src/Phase2aActivator.cc
@@ -41,10 +41,10 @@ void Phase2Activator::init(DependencyManager& manager) {
.setRequired(true)
.setCallbacks(&Phase2Cmp::setPhase1)
)
- .add(createCServiceDependency<Phase2Cmp>()
+ .add(createCServiceDependency<Phase2Cmp, log_service_t>()
.setRequired(false)
- .setCService(OSGI_LOGSERVICE_NAME, "", "")
- .setCallbacks((void (Phase2Cmp::*)(const void*)) &Phase2Cmp::setLogService)
+ .setCService(OSGI_LOGSERVICE_NAME, {}, {})
+ .setCallbacks(&Phase2Cmp::setLogService)
)
);
}
http://git-wip-us.apache.org/repos/asf/celix/blob/0b617d73/examples/dm_example_cxx/phase2a/src/Phase2aCmp.cc
----------------------------------------------------------------------
diff --git a/examples/dm_example_cxx/phase2a/src/Phase2aCmp.cc b/examples/dm_example_cxx/phase2a/src/Phase2aCmp.cc
index e72a36c..55e258a 100644
--- a/examples/dm_example_cxx/phase2a/src/Phase2aCmp.cc
+++ b/examples/dm_example_cxx/phase2a/src/Phase2aCmp.cc
@@ -27,7 +27,7 @@ void Phase2Cmp::setPhase1(IPhase1* phase1) {
this->phase1 = phase1;
}
-void Phase2Cmp::setLogService(log_service_pt logSrv) {
+void Phase2Cmp::setLogService(const log_service_t* logSrv) {
this->logSrv = logSrv;
}
http://git-wip-us.apache.org/repos/asf/celix/blob/0b617d73/examples/dm_example_cxx/phase2b/src/Phase2bActivator.cc
----------------------------------------------------------------------
diff --git a/examples/dm_example_cxx/phase2b/src/Phase2bActivator.cc b/examples/dm_example_cxx/phase2b/src/Phase2bActivator.cc
index c026203..1ce7c78 100644
--- a/examples/dm_example_cxx/phase2b/src/Phase2bActivator.cc
+++ b/examples/dm_example_cxx/phase2b/src/Phase2bActivator.cc
@@ -28,7 +28,6 @@ DmActivator* DmActivator::create(DependencyManager& mng) {
return new Phase2Activator(mng);
}
-
void Phase2Activator::init(DependencyManager& manager) {
Properties props {};
@@ -40,10 +39,10 @@ void Phase2Activator::init(DependencyManager& manager) {
.setRequired(true)
.setCallbacks(&Phase2Cmp::setPhase1)
)
- .add(createCServiceDependency<Phase2Cmp>()
+ .add(createCServiceDependency<Phase2Cmp, log_service_t>()
.setRequired(false)
- .setCService(OSGI_LOGSERVICE_NAME, "", "")
- .setCallbacks((void (Phase2Cmp::*)(const void*)) &Phase2Cmp::setLogService)
+ .setCService(OSGI_LOGSERVICE_NAME, {}, {})
+ .setCallbacks(&Phase2Cmp::setLogService)
)
);
}
http://git-wip-us.apache.org/repos/asf/celix/blob/0b617d73/examples/dm_example_cxx/phase2b/src/Phase2bCmp.cc
----------------------------------------------------------------------
diff --git a/examples/dm_example_cxx/phase2b/src/Phase2bCmp.cc b/examples/dm_example_cxx/phase2b/src/Phase2bCmp.cc
index cd6df23..cdb69c6 100644
--- a/examples/dm_example_cxx/phase2b/src/Phase2bCmp.cc
+++ b/examples/dm_example_cxx/phase2b/src/Phase2bCmp.cc
@@ -27,7 +27,7 @@ void Phase2Cmp::setPhase1(IPhase1* phase1) {
this->phase1 = phase1;
}
-void Phase2Cmp::setLogService(log_service_pt logSrv) {
+void Phase2Cmp::setLogService(const log_service_t* logSrv) {
this->logSrv = logSrv;
}
http://git-wip-us.apache.org/repos/asf/celix/blob/0b617d73/log_service/public/include/log_service.h
----------------------------------------------------------------------
diff --git a/log_service/public/include/log_service.h b/log_service/public/include/log_service.h
index cd3fdef..2691e35 100644
--- a/log_service/public/include/log_service.h
+++ b/log_service/public/include/log_service.h
@@ -50,7 +50,8 @@ struct log_service {
celix_status_t (*logSr)(log_service_data_pt logger, service_reference_pt reference, log_level_t level, char * message);
};
-typedef struct log_service *log_service_pt;
+typedef struct log_service log_service_t;
+typedef log_service_t* log_service_pt;