celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpe...@apache.org
Subject svn commit: r1646238 - in /celix/trunk/dependency_manager_2: private/src/dm_activator_base.c private/src/dm_dependency_manager_impl.c public/include/dm_activator_base.h
Date Wed, 17 Dec 2014 13:48:34 GMT
Author: bpetri
Date: Wed Dec 17 13:48:33 2014
New Revision: 1646238

URL: http://svn.apache.org/r1646238
Log:
Added basic implementation for dm_activator_base and dm_dependency_manager (pt.2)

Added:
    celix/trunk/dependency_manager_2/private/src/dm_activator_base.c
    celix/trunk/dependency_manager_2/private/src/dm_dependency_manager_impl.c
    celix/trunk/dependency_manager_2/public/include/dm_activator_base.h

Added: celix/trunk/dependency_manager_2/private/src/dm_activator_base.c
URL: http://svn.apache.org/viewvc/celix/trunk/dependency_manager_2/private/src/dm_activator_base.c?rev=1646238&view=auto
==============================================================================
--- celix/trunk/dependency_manager_2/private/src/dm_activator_base.c (added)
+++ celix/trunk/dependency_manager_2/private/src/dm_activator_base.c Wed Dec 17 13:48:33 2014
@@ -0,0 +1,65 @@
+#include "dm_activator_base.h"
+
+#include <stdlib.h>
+
+
+struct dm_dependency_activator_base {
+	dm_dependency_manager_pt manager;
+	bundle_context_pt context;
+	void* userData;
+};
+
+typedef struct dm_dependency_activator_base * dependency_activator_base_pt;
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+	celix_status_t status = CELIX_ENOMEM;
+
+	dependency_activator_base_pt dependency_activator = calloc(1, sizeof(struct dm_dependency_activator_base));
+
+	if (dependency_activator) {
+		dependency_activator->context = context;
+		dm_create(context, &dependency_activator->userData);
+
+		(*userData) = dependency_activator;
+
+		status = CELIX_SUCCESS;
+	}
+
+	return status;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+	dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData;
+
+	status = dependencyManager_create(dependency_activator->context, &dependency_activator->manager);
+
+	if (status == CELIX_SUCCESS) {
+		dm_init(dependency_activator->manager, context, dependency_activator->userData);
+	}
+
+	return status;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+	dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData;
+
+	dm_destroy(dependency_activator->manager, dependency_activator->context, dependency_activator->userData);
+
+	dependency_activator->userData = NULL;
+	dependency_activator->manager = NULL;
+
+	return status;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+	dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData;
+
+	free(dependency_activator);
+
+	return status;
+}
+
+

Added: celix/trunk/dependency_manager_2/private/src/dm_dependency_manager_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/dependency_manager_2/private/src/dm_dependency_manager_impl.c?rev=1646238&view=auto
==============================================================================
--- celix/trunk/dependency_manager_2/private/src/dm_dependency_manager_impl.c (added)
+++ celix/trunk/dependency_manager_2/private/src/dm_dependency_manager_impl.c Wed Dec 17 13:48:33
2014
@@ -0,0 +1,66 @@
+#include <pthread.h>
+#include <stdlib.h>
+
+#include "bundle_context.h"
+#include "celix_errno.h"
+#include "array_list.h"
+#include "dm_component.h"
+#include "dm_dependency_manager.h"
+
+struct dm_dependency_manager {
+	array_list_pt components;
+
+	pthread_mutex_t mutex;
+};
+
+celix_status_t dependencyManager_create(bundle_context_pt context, dm_dependency_manager_pt
*manager) {
+	celix_status_t status = CELIX_ENOMEM;
+
+	(*manager) = calloc(1, sizeof(**manager));
+
+	if (*manager) {
+		arrayList_create(&(*manager)->components);
+
+		status = CELIX_SUCCESS;
+	}
+
+	return status;
+
+}
+
+celix_status_t dependencyManager_destroy(dm_dependency_manager_pt *manager) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	arrayList_destroy((*manager)->components);
+
+	free(*manager);
+	(*manager) = NULL;
+
+	return status;
+}
+
+celix_status_t dependencyManager_add(dm_dependency_manager_pt manager, dm_component_pt component)
{
+	celix_status_t status = CELIX_SUCCESS;
+
+	arrayList_add(manager->components, component);
+	status = component_start(component);
+
+	return status;
+}
+
+celix_status_t dependencyManager_remove(dm_dependency_manager_pt manager, dm_component_pt
component) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	arrayList_removeElement(manager->components, component);
+	status = component_stop(component);
+
+	return status;
+}
+
+celix_status_t dependencyManager_getComponents(dm_dependency_manager_pt manager, array_list_pt*
components) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	(*components) = manager->components;
+
+	return status;
+}

Added: celix/trunk/dependency_manager_2/public/include/dm_activator_base.h
URL: http://svn.apache.org/viewvc/celix/trunk/dependency_manager_2/public/include/dm_activator_base.h?rev=1646238&view=auto
==============================================================================
--- celix/trunk/dependency_manager_2/public/include/dm_activator_base.h (added)
+++ celix/trunk/dependency_manager_2/public/include/dm_activator_base.h Wed Dec 17 13:48:33
2014
@@ -0,0 +1,12 @@
+#ifndef DM_ACTIVATOR_BASE_H_
+#define DM_ACTIVATOR_BASE_H_
+
+#include "bundle_context.h"
+#include "celix_errno.h"
+#include "dm_dependency_manager.h"
+
+celix_status_t dm_create(bundle_context_pt context, void ** userData);
+celix_status_t dm_init(dm_dependency_manager_pt manager, bundle_context_pt context, void
* userData);
+celix_status_t dm_destroy(dm_dependency_manager_pt manager, bundle_context_pt context, void
* userData);
+
+#endif /* DM_ACTIVATOR_BASE_H_ */



Mime
View raw message