Celix  2.2.0
An implementation of the OSGi specification adapted to C and C++
celix_dm_component.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
20 #ifndef CELIX_COMPONENT_H_
21 #define CELIX_COMPONENT_H_
22 
23 #include <stdbool.h>
24 
25 #include "celix_types.h"
26 #include "celix_errno.h"
27 #include "properties.h"
28 #include "array_list.h"
29 #include "celix_dm_info.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
41 
42 #define CELIX_DM_COMPONENT_MAX_ID_LENGTH 64
43 #define CELIX_DM_COMPONENT_MAX_NAME_LENGTH 128
44 
45 typedef int (*celix_dm_cmp_lifecycle_fpt)(void *userData);
46 
51 celix_dm_component_t* celix_dmComponent_create(celix_bundle_context_t *context, const char* name);
52 
56 void celix_dmComponent_destroy(celix_dm_component_t *cmp);
57 
62 celix_status_t celix_dmComponent_setCLanguageProperty(celix_dm_component_t *component, bool setCLangProp);
63 
64 
72 celix_status_t celix_dmComponent_addInterface(celix_dm_component_t *component, const char* serviceName, const char* serviceVersion, const void* service, celix_properties_t *properties);
73 
80 celix_status_t celix_dmComponent_removeInterface(celix_dm_component_t *component, const void* service);
84 celix_status_t celix_dmComponent_setImplementation(celix_dm_component_t *component, void* implementation);
85 
89 celix_status_t celix_dmComponent_getInterfaces(celix_dm_component_t *component, celix_array_list_t **servicesNames);
90 
94 celix_status_t celix_dmComponent_addServiceDependency(celix_dm_component_t *component, celix_dm_service_dependency_t *dep);
95 
99 celix_status_t celix_dmComponent_removeServiceDependency(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency);
100 
105 
109 void * celix_dmComponent_getImplementation(celix_dm_component_t *cmp);
110 
114 const char* celix_dmComponent_getName(celix_dm_component_t *cmp);
115 
119 celix_bundle_context_t* celix_dmComponent_getBundleContext(celix_dm_component_t *component);
120 
126 
130 #define CELIX_DMCOMPONENT_SETCALLBACKS(dmCmp, type, init, start, stop, deinit) \
131  do { \
132  int (*tmp_init)(type) = (init); \
133  int (*tmp_start)(type) = (start); \
134  int (*tmp_stop)(type) = (stop); \
135  int (*tmp_deinit)(type) = (deinit); \
136  celix_dmComponent_setCallbacks((dmCmp), (celix_dm_cmp_lifecycle_fpt)tmp_init, (celix_dm_cmp_lifecycle_fpt)tmp_start, (celix_dm_cmp_lifecycle_fpt)tmp_stop, (celix_dm_cmp_lifecycle_fpt)tmp_deinit); \
137  } while(0)
138 
143 celix_status_t celix_dmComponent_getComponentInfo(celix_dm_component_t *component, dm_component_info_pt *info);
144 
145 bool celix_dmComponent_isActive(celix_dm_component_t *component);
146 
151 
152 #ifdef __cplusplus
153 }
154 #endif
155 
156 #endif /* COMPONENT_H_ */
Definition: celix_dm_component.h:38
bool celix_dmComponent_isActive(celix_dm_component_t *component)
celix_status_t celix_dmComponent_setCLanguageProperty(celix_dm_component_t *component, bool setCLangProp)
void celix_dmComponent_destroy(celix_dm_component_t *cmp)
celix_dm_component_state_t celix_dmComponent_currentState(celix_dm_component_t *cmp)
celix_status_t celix_dmComponent_setCallbacks(celix_dm_component_t *component, celix_dm_cmp_lifecycle_fpt init, celix_dm_cmp_lifecycle_fpt start, celix_dm_cmp_lifecycle_fpt stop, celix_dm_cmp_lifecycle_fpt deinit)
celix_status_t celix_dmComponent_addServiceDependency(celix_dm_component_t *component, celix_dm_service_dependency_t *dep)
void * celix_dmComponent_getImplementation(celix_dm_component_t *cmp)
celix_dm_component_t * celix_dmComponent_create(celix_bundle_context_t *context, const char *name)
enum celix_dm_component_state_enum celix_dm_component_state_t
int(* celix_dm_cmp_lifecycle_fpt)(void *userData)
Definition: celix_dm_component.h:45
celix_status_t celix_dmComponent_setImplementation(celix_dm_component_t *component, void *implementation)
Definition: celix_dm_info.h:52
Definition: celix_dm_component.h:37
celix_status_t celix_dmComponent_getInterfaces(celix_dm_component_t *component, celix_array_list_t **servicesNames)
celix_status_t celix_dmComponent_removeServiceDependency(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency)
celix_status_t celix_dmComponent_removeInterface(celix_dm_component_t *component, const void *service)
celix_dm_component_state_enum
Definition: celix_dm_component.h:35
celix_bundle_context_t * celix_dmComponent_getBundleContext(celix_dm_component_t *component)
const char * celix_dmComponent_getName(celix_dm_component_t *cmp)
celix_status_t celix_dmComponent_getComponentInfo(celix_dm_component_t *component, dm_component_info_pt *info)
Definition: celix_dm_component.h:39
Definition: celix_dm_component.h:36
celix_status_t celix_dmComponent_addInterface(celix_dm_component_t *component, const char *serviceName, const char *serviceVersion, const void *service, celix_properties_t *properties)
void celix_dmComponent_destroyComponentInfo(dm_component_info_pt info)