From commits-return-4625-archive-asf-public=cust-asf.ponee.io@celix.apache.org Wed Jan 31 21:05:30 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id B7ED418066D for ; Wed, 31 Jan 2018 21:05:29 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id A0E4A160C2C; Wed, 31 Jan 2018 20:05:29 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 586D9160C58 for ; Wed, 31 Jan 2018 21:05:27 +0100 (CET) Received: (qmail 36302 invoked by uid 500); 31 Jan 2018 20:05:26 -0000 Mailing-List: contact commits-help@celix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@celix.apache.org Delivered-To: mailing list commits@celix.apache.org Received: (qmail 36225 invoked by uid 99); 31 Jan 2018 20:05:26 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 Jan 2018 20:05:26 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6BF70EF792; Wed, 31 Jan 2018 20:05:25 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: pnoltes@apache.org To: commits@celix.apache.org Date: Wed, 31 Jan 2018 20:05:28 -0000 Message-Id: <9acace9970014318b4934d831bddedc7@git.apache.org> In-Reply-To: <258321dfc0644cc38fece51b238b9c43@git.apache.org> References: <258321dfc0644cc38fece51b238b9c43@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [4/8] celix git commit: CELIX-413: Moves the example to an additional dir, so that examples can also be build outside the celix project http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example/phase1/src/phase1_activator.c ---------------------------------------------------------------------- diff --git a/examples/dm_example/phase1/src/phase1_activator.c b/examples/dm_example/phase1/src/phase1_activator.c deleted file mode 100644 index 31dcb16..0000000 --- a/examples/dm_example/phase1/src/phase1_activator.c +++ /dev/null @@ -1,86 +0,0 @@ -/** - *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. - */ -/* - * activator.c - * - * \date Oct 29, 2015 - * \author Apache Celix Project Team - * \copyright Apache License, Version 2.0 - */ -#include -#include - -#include "bundle_activator.h" -#include "dm_activator.h" - -#include "phase1.h" - -struct phase1_activator_struct { - phase1_cmp_t *phase1Cmp; - phase1_t phase1Serv; -}; - -celix_status_t dm_create(bundle_context_pt context, void **userData) { - printf("PHASE1: dm_create\n"); - *userData = calloc(1, sizeof(struct phase1_activator_struct)); - return *userData != NULL ? CELIX_SUCCESS : CELIX_ENOMEM; -} - -celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) { - printf("PHASE1: dm_init\n"); - celix_status_t status = CELIX_SUCCESS; - - - struct phase1_activator_struct *act = (struct phase1_activator_struct *)userData; - - act->phase1Cmp = phase1_create(); - if (act->phase1Cmp != NULL) { - - act->phase1Serv.handle = act->phase1Cmp; - act->phase1Serv.getData = (void *)phase1_getData; - - properties_pt props = properties_create(); - properties_set(props, "id", "phase1"); - - dm_component_pt cmp; - component_create(context, "PHASE1_PROCESSING_COMPONENT", &cmp); - component_setImplementation(cmp, act->phase1Cmp); - component_setCallbacksSafe(cmp, phase1_cmp_t *, phase1_init, phase1_start, phase1_stop, phase1_deinit); - phase1_setComp(act->phase1Cmp, cmp); - component_addInterface(cmp, PHASE1_NAME, PHASE1_VERSION, &act->phase1Serv, props); - - dependencyManager_add(manager, cmp); - } else { - status = CELIX_ENOMEM; - } - - return status; -} - -celix_status_t dm_destroy(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) { - printf("PHASE1: dm-destroy\n"); - - struct phase1_activator_struct *act = (struct phase1_activator_struct *)userData; - if (act->phase1Cmp != NULL) { - phase1_destroy(act->phase1Cmp); - } - free(act); - - return CELIX_SUCCESS; -} http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example/phase1/src/phase1_cmp.c ---------------------------------------------------------------------- diff --git a/examples/dm_example/phase1/src/phase1_cmp.c b/examples/dm_example/phase1/src/phase1_cmp.c deleted file mode 100644 index 40da821..0000000 --- a/examples/dm_example/phase1/src/phase1_cmp.c +++ /dev/null @@ -1,110 +0,0 @@ -/** - *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. - */ -/* - * publisher.c - * - * \date Oct 29, 2015 - * \author Apache Celix Project Team - * \copyright Apache License, Version 2.0 - */ -#include -#include -#include -#include -#include - -#include "celix_threads.h" -#include "phase1_cmp.h" -#include "dm_component.h" - -#define SLEEPTIME 1000 - -struct phase1_cmp_struct { - celix_thread_t thread; - bool running; - unsigned int counter; - dm_component_pt component; - -}; - -static void *phase1_thread(void *data); - -phase1_cmp_t *phase1_create(void) { - phase1_cmp_t *cmp = calloc(1, sizeof(*cmp)); - if (cmp != NULL) { - cmp->counter = 0; - cmp->running = false; - } - return cmp; -} - -void phase1_setComp(phase1_cmp_t *cmp, dm_component_pt dmCmp) { - cmp->component = dmCmp; -} - -int phase1_init(phase1_cmp_t *cmp) { - printf("init phase1\n"); - return 0; -} - -int phase1_start(phase1_cmp_t *cmp) { - printf("start phase1\n"); - cmp->running = true; - celixThread_create(&cmp->thread, NULL, phase1_thread, cmp); - return 0; -} - -int phase1_stop(phase1_cmp_t *cmp) { - printf("stop phase1\n"); - cmp->running = false; - celixThread_kill(cmp->thread, SIGUSR1); - celixThread_join(cmp->thread, NULL); - return 0; -} - -int phase1_deinit(phase1_cmp_t *cmp) { - printf("deinit phase1\n"); - return 0; -} - -void phase1_destroy(phase1_cmp_t *cmp) { - free(cmp); - printf("destroy phase1\n"); -} - -static void *phase1_thread(void *data) { - phase1_cmp_t *cmp = data; - - while (cmp->running) { - cmp->counter += 1; - if (cmp->counter == 2) { - static char *runtime_interface = "DUMMY INTERFACE: DO NOT USE\n"; - component_addInterface(cmp->component, "RUNTIME_ADDED_INTERFACE", "1.0.0", runtime_interface, NULL); - } - usleep(SLEEPTIME); - } - - celixThread_exit(NULL); - return NULL; -} - -int phase1_getData(phase1_cmp_t *cmp, unsigned int *data) { - *data = cmp->counter; - return 0; -} http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example/phase1/src/phase1_cmp.h ---------------------------------------------------------------------- diff --git a/examples/dm_example/phase1/src/phase1_cmp.h b/examples/dm_example/phase1/src/phase1_cmp.h deleted file mode 100644 index 153eed1..0000000 --- a/examples/dm_example/phase1/src/phase1_cmp.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - *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. - */ -/* - * publisher.h - * - * \date Oct 29, 2015 - * \author Apache Celix Project Team - * \copyright Apache License, Version 2.0 - */ - -#ifndef PHASE1_CMP_H -#define PHASE1_CMP_H -#include "dm_component.h" - -typedef struct phase1_cmp_struct phase1_cmp_t; - -phase1_cmp_t *phase1_create(void); -void phase1_setComp(phase1_cmp_t *cmp, dm_component_pt dmCmp); -int phase1_init(phase1_cmp_t *cmp); -int phase1_start(phase1_cmp_t *cmp); -int phase1_stop(phase1_cmp_t *cmp); -int phase1_deinit(phase1_cmp_t *cmp); -void phase1_destroy(phase1_cmp_t *cmp); - -int phase1_getData(phase1_cmp_t *cmp, unsigned int *data); - - -#endif //PHASE1_CMP_H http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example/phase2a/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/dm_example/phase2a/CMakeLists.txt b/examples/dm_example/phase2a/CMakeLists.txt deleted file mode 100644 index 82a6fb5..0000000 --- a/examples/dm_example/phase2a/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# 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. - -add_celix_bundle(dm_example_phase2a - SYMBOLIC_NAME phase2a - VERSION 0.0.1 - SOURCES - src/phase2a_activator - src/phase2a_cmp -) -target_include_directories(dm_example_phase2a PRIVATE src) -target_link_libraries(dm_example_phase2a PRIVATE dm_example_api) - -IF(APPLE) - target_link_libraries(dm_example_phase2a PRIVATE -Wl,-all_load Celix::dependency_manager_static) -else() - if(ENABLE_ADDRESS_SANITIZER) - #With asan there can be undefined symbols - target_link_libraries(dm_example_phase2a PRIVATE -Wl,--whole-archive Celix::dependency_manager_static -Wl,--no-whole-archive) - else() - target_link_libraries(dm_example_phase2a PRIVATE -Wl,--no-undefined -Wl,--whole-archive Celix::dependency_manager_static -Wl,--no-whole-archive) - endif() -ENDIF() http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example/phase2a/src/phase2a_activator.c ---------------------------------------------------------------------- diff --git a/examples/dm_example/phase2a/src/phase2a_activator.c b/examples/dm_example/phase2a/src/phase2a_activator.c deleted file mode 100644 index 6416c68..0000000 --- a/examples/dm_example/phase2a/src/phase2a_activator.c +++ /dev/null @@ -1,95 +0,0 @@ -/** - *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. - */ -/* - * activator.c - * - * \date Oct 29, 2015 - * \author Apache Celix Project Team - * \copyright Apache License, Version 2.0 - */ -#include -#include - -#include "bundle_activator.h" -#include "dm_activator.h" - -#include "phase1.h" -#include "phase2.h" -#include "phase2a_cmp.h" - -struct phase2a_activator_struct { - phase2a_cmp_t *phase2aCmp; - phase2_t phase2Serv; -}; - -celix_status_t dm_create(bundle_context_pt context, void **userData) { - printf("phase2a: dm_create\n"); - *userData = calloc(1, sizeof(struct phase2a_activator_struct)); - return *userData != NULL ? CELIX_SUCCESS : CELIX_ENOMEM; -} - -celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) { - printf("phase2a: dm_init\n"); - celix_status_t status = CELIX_SUCCESS; - - struct phase2a_activator_struct *act = (struct phase2a_activator_struct *)userData; - - act->phase2aCmp = phase2a_create(); - if (act->phase2aCmp != NULL) { - - act->phase2Serv.handle = act->phase2aCmp; - act->phase2Serv.getData = (void *)phase2a_getData; - - properties_pt props = properties_create(); - properties_set(props, "id", "phase2a"); - - dm_component_pt cmp; - component_create(context, "PHASE2A_PROCESSING_COMPONENT", &cmp); - component_setImplementation(cmp, act->phase2aCmp); - component_setCallbacksSafe(cmp, phase2a_cmp_t *, phase2a_init, phase2a_start, phase2a_stop, phase2a_deinit); - component_addInterface(cmp, PHASE2_NAME, PHASE2_VERSION, &act->phase2Serv, props); - - - dm_service_dependency_pt dep; - serviceDependency_create(&dep); - serviceDependency_setService(dep, PHASE1_NAME, PHASE1_RANGE_ALL, NULL); - serviceDependency_setCallbacksSafe(dep, phase2a_cmp_t*, const phase1_t*, phase2a_setPhase1, NULL, NULL, NULL, NULL); - serviceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING); - serviceDependency_setRequired(dep, true); - component_addServiceDependency(cmp, dep); - - dependencyManager_add(manager, cmp); - } else { - status = CELIX_ENOMEM; - } - - return status; -} - -celix_status_t dm_destroy(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) { - printf("phase2a: dm-destroy\n"); - - struct phase2a_activator_struct *act = (struct phase2a_activator_struct *)userData; - if (act->phase2aCmp != NULL) { - phase2a_destroy(act->phase2aCmp); - } - free(act); - - return CELIX_SUCCESS; -} http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example/phase2a/src/phase2a_cmp.c ---------------------------------------------------------------------- diff --git a/examples/dm_example/phase2a/src/phase2a_cmp.c b/examples/dm_example/phase2a/src/phase2a_cmp.c deleted file mode 100644 index d115b69..0000000 --- a/examples/dm_example/phase2a/src/phase2a_cmp.c +++ /dev/null @@ -1,116 +0,0 @@ -/** - *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. - */ -/* - * publisher.c - * - * \date Oct 29, 2015 - * \author Apache Celix Project Team - * \copyright Apache License, Version 2.0 - */ -#include -#include -#include -#include - -#include "celix_threads.h" -#include "phase2a_cmp.h" - -#define SLEEPTIME 2000000 - -struct phase2a_cmp_struct { - celix_thread_t thread; - bool running; - double currentValue; - celix_thread_mutex_t mutex; - const phase1_t* phase1Serv; -}; - -static void *phase2a_thread(void *data); - -phase2a_cmp_t *phase2a_create(void) { - phase2a_cmp_t *cmp = calloc(1, sizeof(*cmp)); - if (cmp != NULL) { - cmp->currentValue = 0.0; - cmp->running = false; - celixThreadMutex_create(&cmp->mutex, NULL); - } - return cmp; -} - -int phase2a_init(phase2a_cmp_t *cmp) { - printf("init phase2a\n"); - return 0; -} - -int phase2a_start(phase2a_cmp_t *cmp) { - printf("start phase2a\n"); - cmp->running = true; - celixThread_create(&cmp->thread, NULL, phase2a_thread, cmp); - return 0; -} - -int phase2a_stop(phase2a_cmp_t *cmp) { - printf("stop phase2a\n"); - cmp->running = false; - celixThread_kill(cmp->thread, SIGUSR1); - celixThread_join(cmp->thread, NULL); - return 0; -} - -int phase2a_deinit(phase2a_cmp_t *cmp) { - printf("deinit phase2a\n"); - return 0; -} - -void phase2a_destroy(phase2a_cmp_t *cmp) { - celixThreadMutex_destroy(&cmp->mutex); - free(cmp); - printf("destroy phase2a\n"); -} - -int phase2a_setPhase1(phase2a_cmp_t *cmp, const phase1_t* phase1) { - printf("phase2a_setPhase1 called!\n\n"); - celixThreadMutex_lock(&cmp->mutex); - cmp->phase1Serv = phase1; - celixThreadMutex_unlock(&cmp->mutex); - return 0; -} - -static void *phase2a_thread(void *data) { - phase2a_cmp_t *cmp = data; - unsigned int counter; - - while (cmp->running) { - celixThreadMutex_lock(&cmp->mutex); - if (cmp->phase1Serv != NULL) { - cmp->phase1Serv->getData(cmp->phase1Serv->handle, &counter); - cmp->currentValue = 1.0 / counter; - } - celixThreadMutex_unlock(&cmp->mutex); - usleep(SLEEPTIME); - } - - celixThread_exit(NULL); - return NULL; -} - -int phase2a_getData(phase2a_cmp_t *cmp, double *data) { - *data = cmp->currentValue; - return 0; -} http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example/phase2a/src/phase2a_cmp.h ---------------------------------------------------------------------- diff --git a/examples/dm_example/phase2a/src/phase2a_cmp.h b/examples/dm_example/phase2a/src/phase2a_cmp.h deleted file mode 100644 index 060b23d..0000000 --- a/examples/dm_example/phase2a/src/phase2a_cmp.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - *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. - */ -/* - * publisher.h - * - * \date Oct 29, 2015 - * \author Apache Celix Project Team - * \copyright Apache License, Version 2.0 - */ - -#ifndef PHASE2A_CMP_H -#define PHASE2A_CMP_H - -#include "phase1.h" - -typedef struct phase2a_cmp_struct phase2a_cmp_t; - -phase2a_cmp_t *phase2a_create(void); -int phase2a_init(phase2a_cmp_t *cmp); -int phase2a_start(phase2a_cmp_t *cmp); -int phase2a_stop(phase2a_cmp_t *cmp); -int phase2a_deinit(phase2a_cmp_t *cmp); -void phase2a_destroy(phase2a_cmp_t *cmp); - -int phase2a_setPhase1(phase2a_cmp_t *cmp, const phase1_t* phase1); - -int phase2a_getData(phase2a_cmp_t *cmp, double *data); - - -#endif //PHASE2A_CMP_H http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example/phase2b/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/dm_example/phase2b/CMakeLists.txt b/examples/dm_example/phase2b/CMakeLists.txt deleted file mode 100644 index 9172ad8..0000000 --- a/examples/dm_example/phase2b/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# 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. - -add_celix_bundle(dm_example_phase2b - SYMBOLIC_NAME phase2b - VERSION 0.0.1 - SOURCES - src/phase2b_activator - src/phase2b_cmp -) -target_include_directories(dm_example_phase2b PRIVATE src) -target_link_libraries(dm_example_phase2b PRIVATE dm_example_api) - -IF(APPLE) - target_link_libraries(dm_example_phase2b PRIVATE -Wl,-all_load Celix::dependency_manager_static) -else() - if(ENABLE_ADDRESS_SANITIZER) - #With asan there can be undefined symbols - target_link_libraries(dm_example_phase2b PRIVATE -Wl,--whole-archive Celix::dependency_manager_static -Wl,--no-whole-archive) - else() - target_link_libraries(dm_example_phase2b PRIVATE -Wl,--no-undefined -Wl,--whole-archive Celix::dependency_manager_static -Wl,--no-whole-archive) - endif() -ENDIF() http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example/phase2b/src/phase2b_activator.c ---------------------------------------------------------------------- diff --git a/examples/dm_example/phase2b/src/phase2b_activator.c b/examples/dm_example/phase2b/src/phase2b_activator.c deleted file mode 100644 index c7692d4..0000000 --- a/examples/dm_example/phase2b/src/phase2b_activator.c +++ /dev/null @@ -1,95 +0,0 @@ -/** - *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. - */ -/* - * activator.c - * - * \date Oct 29, 2015 - * \author Apache Celix Project Team - * \copyright Apache License, Version 2.0 - */ -#include -#include - -#include "bundle_activator.h" -#include "dm_activator.h" - -#include "phase1.h" -#include "phase2.h" -#include "phase2b_cmp.h" - -struct phase2b_activator_struct { - phase2b_cmp_t *phase2bCmp; - phase2_t phase2Serv; -}; - -celix_status_t dm_create(bundle_context_pt context, void **userData) { - printf("phase2b: dm_create\n"); - *userData = calloc(1, sizeof(struct phase2b_activator_struct)); - return *userData != NULL ? CELIX_SUCCESS : CELIX_ENOMEM; -} - -celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) { - printf("phase2b: dm_init\n"); - celix_status_t status = CELIX_SUCCESS; - - struct phase2b_activator_struct *act = (struct phase2b_activator_struct *)userData; - - act->phase2bCmp = phase2b_create(); - if (act->phase2bCmp != NULL) { - - act->phase2Serv.handle = act->phase2bCmp; - act->phase2Serv.getData = (void *)phase2b_getData; - - properties_pt props = properties_create(); - properties_set(props, "id", "phase2b"); - - dm_component_pt cmp; - component_create(context, "PHASE2B_PROCESSING_COMPONENT", &cmp); - component_setImplementation(cmp, act->phase2bCmp); - component_setCallbacksSafe(cmp, phase2b_cmp_t *, phase2b_init, phase2b_start, phase2b_stop, phase2b_deinit); - component_addInterface(cmp, PHASE2_NAME, PHASE2_VERSION, &act->phase2Serv, props); - - - dm_service_dependency_pt dep; - serviceDependency_create(&dep); - serviceDependency_setService(dep, PHASE1_NAME, PHASE1_RANGE_EXACT, NULL); - serviceDependency_setCallbacksSafe(dep, phase2b_cmp_t*, const phase1_t*, phase2b_setPhase1, NULL, NULL, NULL, NULL); - serviceDependency_setRequired(dep, true); - serviceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING); - component_addServiceDependency(cmp, dep); - - dependencyManager_add(manager, cmp); - } else { - status = CELIX_ENOMEM; - } - - return status; -} - -celix_status_t dm_destroy(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) { - printf("phase2b: dm-destroy\n"); - - struct phase2b_activator_struct *act = (struct phase2b_activator_struct *)userData; - if (act->phase2bCmp != NULL) { - phase2b_destroy(act->phase2bCmp); - } - free(act); - - return CELIX_SUCCESS; -} http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example/phase2b/src/phase2b_cmp.c ---------------------------------------------------------------------- diff --git a/examples/dm_example/phase2b/src/phase2b_cmp.c b/examples/dm_example/phase2b/src/phase2b_cmp.c deleted file mode 100644 index a74dcfa..0000000 --- a/examples/dm_example/phase2b/src/phase2b_cmp.c +++ /dev/null @@ -1,115 +0,0 @@ -/** - *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. - */ -/* - * publisher.c - * - * \date Oct 29, 2015 - * \author Apache Celix Project Team - * \copyright Apache License, Version 2.0 - */ -#include -#include -#include -#include - -#include "celix_threads.h" -#include "phase2b_cmp.h" - -#define SLEEPTIME 2000000 - -struct phase2b_cmp_struct { - celix_thread_t thread; - bool running; - double currentValue; - celix_thread_mutex_t mutex; - const phase1_t* phase1Serv; -}; - -static void *phase2b_thread(void *data); - -phase2b_cmp_t *phase2b_create(void) { - phase2b_cmp_t *cmp = calloc(1, sizeof(*cmp)); - if (cmp != NULL) { - cmp->currentValue = 0.0; - cmp->running = false; - celixThreadMutex_create(&cmp->mutex, NULL); - } - return cmp; -} - -int phase2b_init(phase2b_cmp_t *cmp) { - printf("init phase2b\n"); - return 0; -} - -int phase2b_start(phase2b_cmp_t *cmp) { - printf("start phase2b\n"); - cmp->running = true; - celixThread_create(&cmp->thread, NULL, phase2b_thread, cmp); - return 0; -} - -int phase2b_stop(phase2b_cmp_t *cmp) { - printf("stop phase2b\n"); - cmp->running = false; - celixThread_kill(cmp->thread, SIGUSR1); - celixThread_join(cmp->thread, NULL); - return 0; -} - -int phase2b_deinit(phase2b_cmp_t *cmp) { - printf("deinit phase2b\n"); - return 0; -} - -void phase2b_destroy(phase2b_cmp_t *cmp) { - celixThreadMutex_destroy(&cmp->mutex); - free(cmp); - printf("destroy phase2b\n"); -} - -int phase2b_setPhase1(phase2b_cmp_t *cmp, const phase1_t* phase1) { - celixThreadMutex_lock(&cmp->mutex); - cmp->phase1Serv = phase1; - celixThreadMutex_unlock(&cmp->mutex); - return 0; -} - -static void *phase2b_thread(void *data) { - phase2b_cmp_t *cmp = data; - unsigned int counter; - - while (cmp->running) { - celixThreadMutex_lock(&cmp->mutex); - if (cmp->phase1Serv != NULL) { - cmp->phase1Serv->getData(cmp->phase1Serv->handle, &counter); - cmp->currentValue = counter / 1000; - } - celixThreadMutex_unlock(&cmp->mutex); - usleep(SLEEPTIME); - } - - celixThread_exit(NULL); - return NULL; -} - -int phase2b_getData(phase2b_cmp_t *cmp, double *data) { - *data = cmp->currentValue; - return 0; -} http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example/phase2b/src/phase2b_cmp.h ---------------------------------------------------------------------- diff --git a/examples/dm_example/phase2b/src/phase2b_cmp.h b/examples/dm_example/phase2b/src/phase2b_cmp.h deleted file mode 100644 index 7ae0358..0000000 --- a/examples/dm_example/phase2b/src/phase2b_cmp.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - *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. - */ -/* - * publisher.h - * - * \date Oct 29, 2015 - * \author Apache Celix Project Team - * \copyright Apache License, Version 2.0 - */ - -#ifndef PHASE2B_CMP_H -#define PHASE2B_CMP_H - -#include "phase1.h" - -typedef struct phase2b_cmp_struct phase2b_cmp_t; - -phase2b_cmp_t *phase2b_create(void); -int phase2b_init(phase2b_cmp_t *cmp); -int phase2b_start(phase2b_cmp_t *cmp); -int phase2b_stop(phase2b_cmp_t *cmp); -int phase2b_deinit(phase2b_cmp_t *cmp); -void phase2b_destroy(phase2b_cmp_t *cmp); - -int phase2b_setPhase1(phase2b_cmp_t *cmp, const phase1_t* phase1); - -int phase2b_getData(phase2b_cmp_t *cmp, double *data); - - -#endif //PHASE2B_CMP_H http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example/phase3/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/dm_example/phase3/CMakeLists.txt b/examples/dm_example/phase3/CMakeLists.txt deleted file mode 100644 index 7fae829..0000000 --- a/examples/dm_example/phase3/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# 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. - -add_celix_bundle(dm_example_phase3 - SYMBOLIC_NAME phase3 - VERSION 0.0.1 - SOURCES - src/phase3_activator - src/phase3_cmp -) -target_include_directories(dm_example_phase3 PRIVATE src) -target_link_libraries(dm_example_phase3 PRIVATE dm_example_api) - -IF(APPLE) - target_link_libraries(dm_example_phase3 PRIVATE -Wl,-all_load Celix::dependency_manager_static) -else() - if(ENABLE_ADDRESS_SANITIZER) - #With asan there can be undefined symbols - target_link_libraries(dm_example_phase3 PRIVATE -Wl,--whole-archive Celix::dependency_manager_static -Wl,--no-whole-archive) - else() - target_link_libraries(dm_example_phase3 PRIVATE -Wl,--no-undefined -Wl,--whole-archive Celix::dependency_manager_static -Wl,--no-whole-archive) - endif() -ENDIF() http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example/phase3/src/phase3_activator.c ---------------------------------------------------------------------- diff --git a/examples/dm_example/phase3/src/phase3_activator.c b/examples/dm_example/phase3/src/phase3_activator.c deleted file mode 100644 index 64b7a0b..0000000 --- a/examples/dm_example/phase3/src/phase3_activator.c +++ /dev/null @@ -1,84 +0,0 @@ -/** - *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. - */ -/* - * activator.c - * - * \date Oct 29, 2015 - * \author Apache Celix Project Team - * \copyright Apache License, Version 2.0 - */ -#include - -#include "bundle_activator.h" -#include "dm_activator.h" - -#include "phase2.h" -#include "phase3_cmp.h" - -struct phase3_activator_struct { - phase3_cmp_t *phase3Cmp; -}; - -celix_status_t dm_create(bundle_context_pt context, void **userData) { - printf("phase3: dm_create\n"); - *userData = calloc(1, sizeof(struct phase3_activator_struct)); - return *userData != NULL ? CELIX_SUCCESS : CELIX_ENOMEM; -} - -celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) { - printf("phase3: dm_init\n"); - celix_status_t status = CELIX_SUCCESS; - - struct phase3_activator_struct *act = (struct phase3_activator_struct *)userData; - - act->phase3Cmp = phase3_create(); - if (act->phase3Cmp != NULL) { - - dm_component_pt cmp; - component_create(context, "PHASE3_PROCESSING_COMPONENT", &cmp); - component_setImplementation(cmp, act->phase3Cmp); - component_setCallbacksSafe(cmp, phase3_cmp_t *, phase3_init, phase3_start, phase3_stop, phase3_deinit); - - dm_service_dependency_pt dep; - serviceDependency_create(&dep); - serviceDependency_setService(dep, PHASE2_NAME, NULL, NULL); - serviceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND); //SUSPEND Strategy is default - serviceDependency_setCallbacksSafe(dep, phase3_cmp_t*, const phase2_t*, NULL, phase3_addPhase2, NULL, phase3_removePhase2, NULL); - serviceDependency_setRequired(dep, true); - component_addServiceDependency(cmp, dep); - - dependencyManager_add(manager, cmp); - } else { - status = CELIX_ENOMEM; - } - - return status; -} - -celix_status_t dm_destroy(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) { - printf("phase3: dm-destroy\n"); - - struct phase3_activator_struct *act = (struct phase3_activator_struct *)userData; - if (act->phase3Cmp != NULL) { - phase3_destroy(act->phase3Cmp); - } - free(act); - - return CELIX_SUCCESS; -} http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example/phase3/src/phase3_cmp.c ---------------------------------------------------------------------- diff --git a/examples/dm_example/phase3/src/phase3_cmp.c b/examples/dm_example/phase3/src/phase3_cmp.c deleted file mode 100644 index 47cb720..0000000 --- a/examples/dm_example/phase3/src/phase3_cmp.c +++ /dev/null @@ -1,116 +0,0 @@ -/** - *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. - */ -/* - * publisher.c - * - * \date Oct 29, 2015 - * \author Apache Celix Project Team - * \copyright Apache License, Version 2.0 - */ -#include -#include -#include -#include - -#include "array_list.h" -#include "celix_threads.h" -#include "phase3_cmp.h" - -#define SLEEPTIME 2000000 - -struct phase3_cmp_struct { - celix_thread_t thread; - bool running; - double currentValue; - array_list_pt phase2Services; //phase2_t * -}; - -static void *phase3_thread(void *data); - -phase3_cmp_t *phase3_create() { - phase3_cmp_t *cmp = calloc(1, sizeof(*cmp)); - if (cmp != NULL) { - cmp->currentValue = 0.0; - cmp->running = false; - arrayList_create(&cmp->phase2Services); - } - return cmp; -} - -int phase3_init(phase3_cmp_t *cmp) { - printf("init phase3\n"); - return 0; -} - -int phase3_start(phase3_cmp_t *cmp) { - printf("start phase3\n"); - cmp->running = true; - celixThread_create(&cmp->thread, NULL, phase3_thread, cmp); - return 0; -} - -int phase3_stop(phase3_cmp_t *cmp) { - printf("stop phase3\n"); - cmp->running = false; - celixThread_kill(cmp->thread, SIGUSR1); - celixThread_join(cmp->thread, NULL); - return 0; -} - -int phase3_deinit(phase3_cmp_t *cmp) { - printf("deinit phase3\n"); - return 0; -} - -void phase3_destroy(phase3_cmp_t *cmp) { - arrayList_destroy(cmp->phase2Services); - free(cmp); - printf("destroy phase3\n"); -} - -int phase3_addPhase2(phase3_cmp_t *cmp, const phase2_t* phase2) { - arrayList_add(cmp->phase2Services, (void*)phase2); - return 0; -} - -int phase3_removePhase2(phase3_cmp_t *cmp, const phase2_t *phase2) { - arrayList_removeElement(cmp->phase2Services, (void*)phase2); - return 0; -} - - -static void *phase3_thread(void *data) { - phase3_cmp_t *cmp = data; - int size; - int i; - double value; - - while (cmp->running) { - size = arrayList_size(cmp->phase2Services); - for (i = 0; i < size; i += 1) { - const phase2_t* serv = arrayList_get(cmp->phase2Services, i); - serv->getData(serv->handle, &value); - printf("PHASE3: Data from %p is %f\n", serv, value); - } - usleep(SLEEPTIME); - } - - celixThread_exit(NULL); - return NULL; -} http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example/phase3/src/phase3_cmp.h ---------------------------------------------------------------------- diff --git a/examples/dm_example/phase3/src/phase3_cmp.h b/examples/dm_example/phase3/src/phase3_cmp.h deleted file mode 100644 index 9c63845..0000000 --- a/examples/dm_example/phase3/src/phase3_cmp.h +++ /dev/null @@ -1,45 +0,0 @@ -/** - *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. - */ -/* - * publisher.h - * - * \date Oct 29, 2015 - * \author Apache Celix Project Team - * \copyright Apache License, Version 2.0 - */ - -#ifndef PHASE3_CMP_H -#define PHASE3_CMP_H - -#include "phase2.h" - -typedef struct phase3_cmp_struct phase3_cmp_t; - -phase3_cmp_t *phase3_create(); -int phase3_init(phase3_cmp_t *cmp); -int phase3_start(phase3_cmp_t *cmp); -int phase3_stop(phase3_cmp_t *cmp); -int phase3_deinit(phase3_cmp_t *cmp); -void phase3_destroy(phase3_cmp_t *cmp); - -int phase3_addPhase2(phase3_cmp_t *cmp, const phase2_t* phase2); -int phase3_removePhase2(phase3_cmp_t *cmp, const phase2_t* phase2); - - -#endif //PHASE3_CMP_H http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example_cxx/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/CMakeLists.txt b/examples/dm_example_cxx/CMakeLists.txt deleted file mode 100644 index 5f6832c..0000000 --- a/examples/dm_example_cxx/CMakeLists.txt +++ /dev/null @@ -1,68 +0,0 @@ -# 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. -if (TARGET Celix::dependency_manager_cxx_static AND TARGET Celix::dm_shell) - - add_subdirectory(api) - - add_subdirectory(phase1) - add_subdirectory(phase2) - add_subdirectory(phase3) - add_subdirectory(phase3_locking) - - - add_celix_container("dm_example_cxx" - COPY - CXX - BUNDLES - Celix::shell - Celix::shell_tui - Celix::dm_shell - Celix::log_service - Celix::log_writer_stdout - - dm_example_cxx_phase1 - dm_example_cxx_phase2a - dm_example_cxx_phase2b - dm_example_cxx_phase3 - dm_example_cxx_phase3_locking - PROPERTIES - LOGHELPER_ENABLE_STDOUT_FALLBACK=true - ) - - - add_celix_docker(dm_exmpl_cxx_docker - IMAGE_NAME dm_exmpl_cxx - GROUP examples - BUNDLES_DIR /usr/share/bundles - WORKDIR /workspace - BUNDLES - Celix::shell - Celix::shell_tui - Celix::dm_shell - Celix::log_service - Celix::log_writer_stdout - - dm_example_cxx_phase1 - dm_example_cxx_phase2a - dm_example_cxx_phase2b - dm_example_cxx_phase3 - dm_example_cxx_phase3_locking - PROPERTIES - LOGHELPER_ENABLE_STDOUT_FALLBACK=true - ) - -endif () http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example_cxx/api/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/api/CMakeLists.txt b/examples/dm_example_cxx/api/CMakeLists.txt deleted file mode 100644 index d1d07d5..0000000 --- a/examples/dm_example_cxx/api/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -# 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. - -add_library(dm_example_cxx_api INTERFACE) -target_include_directories(dm_example_cxx_api INTERFACE include) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example_cxx/api/include/IName.h ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/api/include/IName.h b/examples/dm_example_cxx/api/include/IName.h deleted file mode 100644 index 89edb19..0000000 --- a/examples/dm_example_cxx/api/include/IName.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * 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. - */ - -#ifndef CELIX_INAME_H -#define CELIX_INAME_H - -#define INAME_VERSION "1.0.0" - -#include - -namespace srv { - namespace info { - class IName { - protected: - IName() = default; - ~IName() = default; - public: - virtual std::string getName() = 0; - }; - } -} - -#endif //CELIX_INAME_H http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example_cxx/api/include/IPhase1.h ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/api/include/IPhase1.h b/examples/dm_example_cxx/api/include/IPhase1.h deleted file mode 100644 index d75b3e1..0000000 --- a/examples/dm_example_cxx/api/include/IPhase1.h +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 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. - */ - -#ifndef CELIX_PHASE1_H -#define CELIX_PHASE1_H - -#define IPHASE1_VERSION "1.0.0" - -class IPhase1 { -protected: - IPhase1() = default; - ~IPhase1() = default; -public: - virtual int getData() = 0; -}; - -#endif //CELIX_PHASE1_H http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example_cxx/api/include/IPhase2.h ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/api/include/IPhase2.h b/examples/dm_example_cxx/api/include/IPhase2.h deleted file mode 100644 index 20e3774..0000000 --- a/examples/dm_example_cxx/api/include/IPhase2.h +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 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. - */ - -#ifndef CELIX_PHASE2_H -#define CELIX_PHASE2_H - -#define IPHASE2_VERSION "1.0.0" - -class IPhase2 { -protected: - IPhase2() = default; - ~IPhase2() = default; -public: - virtual double getData() = 0; -}; - -#endif //CELIX_PHASE2_H http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example_cxx/phase1/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase1/CMakeLists.txt b/examples/dm_example_cxx/phase1/CMakeLists.txt deleted file mode 100644 index 5007e77..0000000 --- a/examples/dm_example_cxx/phase1/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# 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. - -add_celix_bundle(dm_example_cxx_phase1 - SYMBOLIC_NAME phase1_cxx - VERSION 0.0.1 - SOURCES - src/Phase1Activator.cc - src/Phase1Cmp.cc -) -target_include_directories(dm_example_cxx_phase1 PRIVATE src) -target_link_libraries(dm_example_cxx_phase1 PRIVATE dm_example_cxx_api Celix::shell_api) - -IF(APPLE) - target_link_libraries(dm_example_cxx_phase1 PRIVATE -Wl,-all_load Celix::dependency_manager_cxx_static) -else() - if(ENABLE_ADDRESS_SANITIZER) - #With asan there can be undefined symbols - target_link_libraries(dm_example_cxx_phase1 PRIVATE -Wl,--whole-archive Celix::dependency_manager_cxx_static -Wl,--no-whole-archive) - else() - target_link_libraries(dm_example_cxx_phase1 PRIVATE -Wl,--no-undefined -Wl,--whole-archive Celix::dependency_manager_cxx_static -Wl,--no-whole-archive) - endif() -endif() http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/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 deleted file mode 100644 index 4bee1df..0000000 --- a/examples/dm_example_cxx/phase1/src/Phase1Activator.cc +++ /dev/null @@ -1,74 +0,0 @@ -/** - * 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 "Phase1Cmp.h" -#include "Phase1Activator.h" -#include "IPhase2.h" - -using namespace celix::dm; - -/* This example create a C++ component providing a C++ and C service - * For the C service a service struct in initialized and registered - * For the C++ service the object itself is used - */ - -DmActivator* DmActivator::create(DependencyManager& mng) { - return new Phase1Activator(mng); -} - -struct InvalidCServ { - virtual ~InvalidCServ() = default; - void* handle {nullptr}; //valid pod - int (*foo)(double arg) {nullptr}; //still valid pod - void bar(double __attribute__((unused)) arg) {} //still valid pod - virtual void baz(double __attribute__((unused)) arg) {} //not a valid pod -}; - -void Phase1Activator::init() { - auto cmp = std::unique_ptr(new Phase1Cmp()); - - Properties cmdProps; - cmdProps[OSGI_SHELL_COMMAND_NAME] = "phase1_info"; - cmdProps[OSGI_SHELL_COMMAND_USAGE] = "phase1_info"; - cmdProps[OSGI_SHELL_COMMAND_DESCRIPTION] = "Print information about the Phase1Cmp"; - - - cmd.handle = cmp.get(); - cmd.executeCommand = [](void *handle, char* line, FILE* out, FILE *err) { - Phase1Cmp* cmp = (Phase1Cmp*)handle; - return cmp->infoCmd(line, out, err); - }; - - auto tst = std::unique_ptr(new InvalidCServ{}); - tst->handle = cmp.get(); - - - mng.createComponent(std::move(cmp)) //using a pointer a instance. Also supported is lazy initialization (default constructor needed) or a rvalue reference (move) - .addInterface(IPHASE1_VERSION) - //.addInterface() -> Compile error (static assert), because Phase1Cmp does not implement IPhase2 - .addCInterface(&cmd, OSGI_SHELL_COMMAND_SERVICE_NAME, "", cmdProps) - //.addCInterface(tst.get(), "TEST_SRV") -> Compile error (static assert), because InvalidCServ is not a pod - .addInterface(INAME_VERSION) - .setCallbacks(&Phase1Cmp::init, &Phase1Cmp::start, &Phase1Cmp::stop, &Phase1Cmp::deinit); - -} - -void Phase1Activator::deinit() { - //nothing to do -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example_cxx/phase1/src/Phase1Activator.h ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase1/src/Phase1Activator.h b/examples/dm_example_cxx/phase1/src/Phase1Activator.h deleted file mode 100644 index 37b25e3..0000000 --- a/examples/dm_example_cxx/phase1/src/Phase1Activator.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * 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. - */ - -#ifndef CELIX_PHASE1ACTIVATOR_H -#define CELIX_PHASE1ACTIVATOR_H - -#include "celix/dm/DmActivator.h" -#include "command.h" - -using namespace celix::dm; - -class Phase1Activator : public DmActivator { - command_service_t cmd {nullptr, nullptr}; -public: - Phase1Activator(DependencyManager& mng) : DmActivator(mng) {} - virtual void init(); - virtual void deinit(); -}; - -#endif //CELIX_PHASE1ACTIVATOR_H http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example_cxx/phase1/src/Phase1Cmp.cc ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase1/src/Phase1Cmp.cc b/examples/dm_example_cxx/phase1/src/Phase1Cmp.cc deleted file mode 100644 index e82f381..0000000 --- a/examples/dm_example_cxx/phase1/src/Phase1Cmp.cc +++ /dev/null @@ -1,53 +0,0 @@ -/** - * 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 "Phase1Cmp.h" -#include -#include -#include - -void Phase1Cmp::init() { - std::cout << "init Phase1Cmp\n"; -} - -void Phase1Cmp::start() { - std::cout << "start Phase1Cmp\n"; -} - -void Phase1Cmp::stop() { - std::cout << "stop Phase1Cmp\n"; -} - -void Phase1Cmp::deinit() { - std::cout << "deinit Phase1Cmp\n"; -} - -int Phase1Cmp::getData() { - counter += 1; - return (int)random(); -}; - -std::string Phase1Cmp::getName() { - return std::string {"IPhase"}; -} - -int Phase1Cmp::infoCmd([[gnu::unused]] char * line, FILE *out, [[gnu::unused]] FILE* err) { - fprintf(out, "Phase1: number of getData calls: %u\n", counter); - return 0; -} http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example_cxx/phase1/src/Phase1Cmp.h ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase1/src/Phase1Cmp.h b/examples/dm_example_cxx/phase1/src/Phase1Cmp.h deleted file mode 100644 index f475c41..0000000 --- a/examples/dm_example_cxx/phase1/src/Phase1Cmp.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * 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. - */ - -#ifndef CELIX_PHASE1CMP_H -#define CELIX_PHASE1CMP_H - -#include "IPhase1.h" -#include "IName.h" -#include -#include - -class Phase1Cmp : public srv::info::IName, public IPhase1 { - uint32_t counter = 0; -public: - Phase1Cmp() = default; - virtual ~Phase1Cmp() = default; - - void init(); - void start(); - void stop(); - void deinit(); - - int getData() override; //implements IPhase1 - int infoCmd(char* line, FILE *out, FILE* err); //implements cmd service - std::string getName() override; -}; - -#endif //CELIX_PHASE1CMP_H http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example_cxx/phase2/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase2/CMakeLists.txt b/examples/dm_example_cxx/phase2/CMakeLists.txt deleted file mode 100644 index f2b3813..0000000 --- a/examples/dm_example_cxx/phase2/CMakeLists.txt +++ /dev/null @@ -1,51 +0,0 @@ -# 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. - -add_celix_bundle(dm_example_cxx_phase2a - SYMBOLIC_NAME phase2a_cxx - VERSION 0.0.1 - SOURCES - src/Phase2aActivator.cc - src/Phase2aCmp.cc -) -target_include_directories(dm_example_cxx_phase2a PRIVATE src) -target_link_libraries(dm_example_cxx_phase2a PRIVATE Celix::log_service_api dm_example_cxx_api) - -add_celix_bundle(dm_example_cxx_phase2b - SYMBOLIC_NAME phase2b_cxx - VERSION 0.0.1 - SOURCES - src/Phase2bActivator.cc - src/Phase2bCmp.cc - ) -target_include_directories(dm_example_cxx_phase2b PRIVATE src) -target_link_libraries(dm_example_cxx_phase2b PRIVATE Celix::log_service_api dm_example_cxx_api) - -IF(APPLE) - target_link_libraries(dm_example_cxx_phase2a PRIVATE -Wl,-all_load Celix::dependency_manager_cxx_static) - target_link_libraries(dm_example_cxx_phase2b PRIVATE -Wl,-all_load Celix::dependency_manager_cxx_static) -else() - if(ENABLE_ADDRESS_SANITIZER) - #With asan there can be undefined symbols - target_link_libraries(dm_example_cxx_phase2a PRIVATE -Wl,--whole-archive Celix::dependency_manager_cxx_static -Wl,--no-whole-archive) - target_link_libraries(dm_example_cxx_phase2b PRIVATE -Wl,--whole-archive Celix::dependency_manager_cxx_static -Wl,--no-whole-archive) - else() - target_link_libraries(dm_example_cxx_phase2a PRIVATE -Wl,--whole-archive Celix::dependency_manager_cxx_static -Wl,--no-whole-archive) - target_link_libraries(dm_example_cxx_phase2b PRIVATE -Wl,--whole-archive Celix::dependency_manager_cxx_static -Wl,--no-whole-archive) - - endif() -endif() http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example_cxx/phase2/src/Phase2Activator.h ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase2/src/Phase2Activator.h b/examples/dm_example_cxx/phase2/src/Phase2Activator.h deleted file mode 100644 index 069b2ae..0000000 --- a/examples/dm_example_cxx/phase2/src/Phase2Activator.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * 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. - */ - -#ifndef CELIX_PHASE2AACTIVATOR_H -#define CELIX_PHASE2AACTIVATOR_H - -#include "celix/dm/DmActivator.h" - -using namespace celix::dm; - -class Phase2Activator : public DmActivator { -public: - Phase2Activator(DependencyManager& mng) : DmActivator(mng) {} - virtual void init(); - virtual void deinit(); -}; - -#endif //CELIX_PHASE2AACTIVATOR_H http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example_cxx/phase2/src/Phase2Cmp.h ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase2/src/Phase2Cmp.h b/examples/dm_example_cxx/phase2/src/Phase2Cmp.h deleted file mode 100644 index 87b6e8e..0000000 --- a/examples/dm_example_cxx/phase2/src/Phase2Cmp.h +++ /dev/null @@ -1,56 +0,0 @@ -/** - * 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. - */ - -#ifndef CELIX_PHASE2CMP_H -#define CELIX_PHASE2CMP_H - -#include "IName.h" -#include "IPhase1.h" -#include "IPhase2.h" -#include -#include -#include -#include - -extern "C" { -#include "log_service.h" -}; - -class Phase2Cmp : public IPhase2 { -public: - Phase2Cmp() = default; - virtual ~Phase2Cmp() { std::cout << "Destroying Phase2\n"; }; - - Phase2Cmp(Phase2Cmp&& other) noexcept; - Phase2Cmp& operator=(Phase2Cmp&&) = default; - - Phase2Cmp(const Phase2Cmp& other) = delete; - Phase2Cmp operator=(const Phase2Cmp&) = delete; - - void setPhase1(IPhase1* phase); //injector used by dependency manager - void setName(srv::info::IName* name) { std::cout << "Setting IName with name: " << (name != nullptr ? name->getName() : "null") << std::endl; } - void setLogService(const log_service_t* logSrv); - - double getData() override; //implements IPhase2 -private: - IPhase1* phase1 {nullptr}; - const log_service_t* logSrv {nullptr}; -}; - -#endif //CELIX_PHASE2CMP_H http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example_cxx/phase2/src/Phase2aActivator.cc ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase2/src/Phase2aActivator.cc b/examples/dm_example_cxx/phase2/src/Phase2aActivator.cc deleted file mode 100644 index e33ae0e..0000000 --- a/examples/dm_example_cxx/phase2/src/Phase2aActivator.cc +++ /dev/null @@ -1,57 +0,0 @@ -/** - * 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 -#include "Phase2Cmp.h" -#include "Phase2Activator.h" -#include "log_service.h" - -using namespace celix::dm; - - -DmActivator* DmActivator::create(DependencyManager& mng) { - return new Phase2Activator(mng); -} - - -void Phase2Activator::init() { - - Properties props {}; - props["name"] = "phase2a"; - - Component& cmp = mng.createComponent() - .setInstance(Phase2Cmp()) - .addInterface(IPHASE2_VERSION, props); - - cmp.createServiceDependency() - .setRequired(true) - .setCallbacks(&Phase2Cmp::setPhase1); - - cmp.createServiceDependency() - .setVersionRange("[1.0.0,2)") - .setCallbacks(&Phase2Cmp::setName); - - cmp.createCServiceDependency(OSGI_LOGSERVICE_NAME) - .setRequired(false) - .setCallbacks(&Phase2Cmp::setLogService); -} - -void Phase2Activator::deinit() { - -} http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example_cxx/phase2/src/Phase2aCmp.cc ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase2/src/Phase2aCmp.cc b/examples/dm_example_cxx/phase2/src/Phase2aCmp.cc deleted file mode 100644 index 4f68679..0000000 --- a/examples/dm_example_cxx/phase2/src/Phase2aCmp.cc +++ /dev/null @@ -1,45 +0,0 @@ -/** - * 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 "Phase2Cmp.h" -#include -#include -#include - -Phase2Cmp::Phase2Cmp(Phase2Cmp&& other) noexcept : phase1(other.phase1), logSrv{other.logSrv} { - std::cout << "Move constructor Phase2aCmp called\n"; - other.phase1 = nullptr; - other.logSrv = nullptr; -} - -void Phase2Cmp::setPhase1(IPhase1* phase1) { - std::cout << "setting phase1 for phase2\n"; - this->phase1 = phase1; -} - -void Phase2Cmp::setLogService(const log_service_t* logSrv) { - this->logSrv = logSrv; -} - -double Phase2Cmp::getData() { - if (this->logSrv != NULL) { - this->logSrv->log(this->logSrv->logger, OSGI_LOGSERVICE_DEBUG, (char *) "getting data from phase2cmp A\n"); - } - return phase1->getData() * 42.0; -}; http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example_cxx/phase2/src/Phase2bActivator.cc ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase2/src/Phase2bActivator.cc b/examples/dm_example_cxx/phase2/src/Phase2bActivator.cc deleted file mode 100644 index 4fba8c0..0000000 --- a/examples/dm_example_cxx/phase2/src/Phase2bActivator.cc +++ /dev/null @@ -1,50 +0,0 @@ -/** - * 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 "Phase2Cmp.h" -#include "Phase2Activator.h" -#include "log_service.h" - -using namespace celix::dm; - - -DmActivator* DmActivator::create(DependencyManager& mng) { - return new Phase2Activator(mng); -} - -void Phase2Activator::init() { - - Properties props {}; - props["name"] = "phase2b"; - - Component& cmp = mng.createComponent() - .addInterface(IPHASE2_VERSION, props); - - cmp.createServiceDependency() - .setRequired(true) - .setCallbacks(&Phase2Cmp::setPhase1); - - cmp.createCServiceDependency(OSGI_LOGSERVICE_NAME) - .setRequired(false) - .setCallbacks(&Phase2Cmp::setLogService); -} - -void Phase2Activator::deinit() { - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example_cxx/phase2/src/Phase2bCmp.cc ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase2/src/Phase2bCmp.cc b/examples/dm_example_cxx/phase2/src/Phase2bCmp.cc deleted file mode 100644 index 2f420a0..0000000 --- a/examples/dm_example_cxx/phase2/src/Phase2bCmp.cc +++ /dev/null @@ -1,45 +0,0 @@ -/** - * 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 "Phase2Cmp.h" -#include -#include -#include - -Phase2Cmp::Phase2Cmp(Phase2Cmp&& other) noexcept : phase1(other.phase1), logSrv{other.logSrv} { - std::cout << "Move constructor Phase2bCmp called\n"; - other.phase1 = nullptr; - other.logSrv = nullptr; -} - -void Phase2Cmp::setPhase1(IPhase1* phase1) { - std::cout << "setting phase1 for phase2\n"; - this->phase1 = phase1; -} - -void Phase2Cmp::setLogService(const log_service_t* logSrv) { - this->logSrv = logSrv; -} - -double Phase2Cmp::getData() { - if (this->logSrv != NULL) { - this->logSrv->log(this->logSrv->logger, OSGI_LOGSERVICE_DEBUG, (char *) "getting data from phase2cmp B\n"); - } - return phase1->getData() * 24.0; -}; http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example_cxx/phase3/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase3/CMakeLists.txt b/examples/dm_example_cxx/phase3/CMakeLists.txt deleted file mode 100644 index c583f25..0000000 --- a/examples/dm_example_cxx/phase3/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -# 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. - -add_celix_bundle(dm_example_cxx_phase3 - SYMBOLIC_NAME phase3_cxx - VERSION 0.0.1 - SOURCES - src/Phase3Activator.cc - src/Phase3BaseActivator.cc - src/Phase3Cmp.cc -) -target_include_directories(dm_example_cxx_phase3 PRIVATE src) -target_link_libraries(dm_example_cxx_phase3 PRIVATE dm_example_cxx_api pthread) - -IF(APPLE) - target_link_libraries(dm_example_cxx_phase3 PRIVATE -Wl,-all_load Celix::dependency_manager_cxx_static) -else() - if(ENABLE_ADDRESS_SANITIZER) - #With asan there can be undefined symbols - target_link_libraries(dm_example_cxx_phase3 PRIVATE -Wl,--whole-archive Celix::dependency_manager_cxx_static -Wl,--no-whole-archive) - else() - target_link_libraries(dm_example_cxx_phase3 PRIVATE -Wl,--no-undefined -Wl,--whole-archive Celix::dependency_manager_cxx_static -Wl,--no-whole-archive) - endif() -endif() http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example_cxx/phase3/src/Phase3Activator.cc ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase3/src/Phase3Activator.cc b/examples/dm_example_cxx/phase3/src/Phase3Activator.cc deleted file mode 100644 index f5aa178..0000000 --- a/examples/dm_example_cxx/phase3/src/Phase3Activator.cc +++ /dev/null @@ -1,37 +0,0 @@ -/** - * 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 "Phase3Cmp.h" -#include "Phase3Activator.h" - -using namespace celix::dm; - - -DmActivator* DmActivator::create(DependencyManager& mng) { - return new Phase3Activator(mng); -} - -void Phase3Activator::init() { - Phase3BaseActivator::init(); - cmp.createServiceDependency() - .setRequired(false) - .setFilter("(&(name=phase2a)(non-existing=*))") - .setCallbacks(&Phase3Cmp::setPhase2a); -} http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example_cxx/phase3/src/Phase3Activator.h ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase3/src/Phase3Activator.h b/examples/dm_example_cxx/phase3/src/Phase3Activator.h deleted file mode 100644 index e02cd61..0000000 --- a/examples/dm_example_cxx/phase3/src/Phase3Activator.h +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 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. - */ - -#ifndef CELIX_PHASE3ACTIVATOR_H -#define CELIX_PHASE3ACTIVATOR_H - -#include "Phase3BaseActivator.h" - -using namespace celix::dm; - -class Phase3Activator : public Phase3BaseActivator { -public: - Phase3Activator(DependencyManager& mng) : Phase3BaseActivator(mng) {} - virtual void init(); -}; - -#endif //CELIX_PHASE2AACTIVATOR_H http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example_cxx/phase3/src/Phase3BaseActivator.cc ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase3/src/Phase3BaseActivator.cc b/examples/dm_example_cxx/phase3/src/Phase3BaseActivator.cc deleted file mode 100644 index 37746dc..0000000 --- a/examples/dm_example_cxx/phase3/src/Phase3BaseActivator.cc +++ /dev/null @@ -1,31 +0,0 @@ -/** - * 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 "Phase3Cmp.h" -#include "Phase3BaseActivator.h" - -using namespace celix::dm; - -void Phase3BaseActivator::init() { - cmp.setCallbacks(nullptr, &Phase3Cmp::start, &Phase3Cmp::stop, nullptr); - - cmp.createServiceDependency() - .setRequired(true) - .setCallbacks(&Phase3Cmp::addPhase2, &Phase3Cmp::removePhase2); -} http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example_cxx/phase3/src/Phase3BaseActivator.h ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase3/src/Phase3BaseActivator.h b/examples/dm_example_cxx/phase3/src/Phase3BaseActivator.h deleted file mode 100644 index 0f3d813..0000000 --- a/examples/dm_example_cxx/phase3/src/Phase3BaseActivator.h +++ /dev/null @@ -1,35 +0,0 @@ -/** - * 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. - */ - -#ifndef CELIX_PHASE3BASEACTIVATOR_H -#define CELIX_PHASE3BASEACTIVATOR_H - -#include "celix/dm/DmActivator.h" - -using namespace celix::dm; - -class Phase3BaseActivator : public DmActivator { -public: - Phase3BaseActivator(DependencyManager& mng) : DmActivator(mng), cmp(mng.createComponent()) {} - void init(); -protected: - celix::dm::Component& cmp; -}; - -#endif //CELIX_PHASE3BASEACTIVATOR_H http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example_cxx/phase3/src/Phase3Cmp.cc ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase3/src/Phase3Cmp.cc b/examples/dm_example_cxx/phase3/src/Phase3Cmp.cc deleted file mode 100644 index dba5942..0000000 --- a/examples/dm_example_cxx/phase3/src/Phase3Cmp.cc +++ /dev/null @@ -1,65 +0,0 @@ -/** - * 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 "Phase3Cmp.h" -#include -#include -#include -#include -#include -#include - -void Phase3Cmp::start() { - std::cout << "start Phase3Cmp\n"; - running = true; - pollThread = std::thread {&Phase3Cmp::poll, this}; -} - -void Phase3Cmp::stop() { - std::cout << "stop Phase3Cmp\n"; - running = false; - pollThread.join(); -} - -void Phase3Cmp::poll() { - while (running) { - std::cout << "polling Phase3Cmp\n"; - for (std::pair pair : this->phases) { - std::ostringstream oss {}; - oss << "current data for " << pair.second["name"] << " is " << pair.first->getData() << "\n"; - std::cout << oss.str(); - } - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - } -} - -void Phase3Cmp::addPhase2(IPhase2* phase2, celix::dm::Properties&& props) { - std::cout << "adding Iphase2 for Phase3Cmp\n"; - std::pair pair {phase2, props}; - this->phases[phase2] = props; -} - -void Phase3Cmp::removePhase2(IPhase2* phase2, [[gnu::unused]] celix::dm::Properties&& props) { - std::cout << "adding Iphase2 for Phase3Cmp\n"; - this->phases.erase(phase2); -} - -void Phase3Cmp::setPhase2a([[gnu::unused]] IPhase2* phase) { - std::cout << "setting phase2a\n"; -}