Celix  2.2.0
An implementation of the OSGi specification adapted to C and C++
Macros | Typedefs | Enumerations | Functions
celix_dm_component.h File Reference
#include <stdbool.h>
#include "celix_types.h"
#include "celix_errno.h"
#include "properties.h"
#include "array_list.h"
#include "celix_dm_info.h"
Include dependency graph for celix_dm_component.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CELIX_DM_COMPONENT_MAX_ID_LENGTH   64
 
#define CELIX_DM_COMPONENT_MAX_NAME_LENGTH   128
 
#define CELIX_DMCOMPONENT_SETCALLBACKS(dmCmp, type, init, start, stop, deinit)
 

Typedefs

typedef enum celix_dm_component_state_enum celix_dm_component_state_t
 
typedef int(* celix_dm_cmp_lifecycle_fpt) (void *userData)
 

Enumerations

enum  celix_dm_component_state_enum { DM_CMP_STATE_INACTIVE = 1, DM_CMP_STATE_WAITING_FOR_REQUIRED = 2, DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED = 3, DM_CMP_STATE_TRACKING_OPTIONAL = 4 }
 

Functions

celix_dm_component_t * celix_dmComponent_create (celix_bundle_context_t *context, const char *name)
 
void celix_dmComponent_destroy (celix_dm_component_t *cmp)
 
celix_status_t celix_dmComponent_setCLanguageProperty (celix_dm_component_t *component, bool setCLangProp)
 
celix_status_t celix_dmComponent_addInterface (celix_dm_component_t *component, const char *serviceName, const char *serviceVersion, const void *service, celix_properties_t *properties)
 
celix_status_t celix_dmComponent_removeInterface (celix_dm_component_t *component, const void *service)
 
celix_status_t celix_dmComponent_setImplementation (celix_dm_component_t *component, void *implementation)
 
celix_status_t celix_dmComponent_getInterfaces (celix_dm_component_t *component, celix_array_list_t **servicesNames)
 
celix_status_t celix_dmComponent_addServiceDependency (celix_dm_component_t *component, celix_dm_service_dependency_t *dep)
 
celix_status_t celix_dmComponent_removeServiceDependency (celix_dm_component_t *component, celix_dm_service_dependency_t *dependency)
 
celix_dm_component_state_t celix_dmComponent_currentState (celix_dm_component_t *cmp)
 
void * celix_dmComponent_getImplementation (celix_dm_component_t *cmp)
 
const char * celix_dmComponent_getName (celix_dm_component_t *cmp)
 
celix_bundle_context_t * celix_dmComponent_getBundleContext (celix_dm_component_t *component)
 
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_getComponentInfo (celix_dm_component_t *component, dm_component_info_pt *info)
 
bool celix_dmComponent_isActive (celix_dm_component_t *component)
 
void celix_dmComponent_destroyComponentInfo (dm_component_info_pt info)
 

Macro Definition Documentation

#define CELIX_DM_COMPONENT_MAX_ID_LENGTH   64
#define CELIX_DM_COMPONENT_MAX_NAME_LENGTH   128
#define CELIX_DMCOMPONENT_SETCALLBACKS (   dmCmp,
  type,
  init,
  start,
  stop,
  deinit 
)
Value:
do { \
int (*tmp_init)(type) = (init); \
int (*tmp_start)(type) = (start); \
int (*tmp_stop)(type) = (stop); \
int (*tmp_deinit)(type) = (deinit); \
} while(0)
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)
int(* celix_dm_cmp_lifecycle_fpt)(void *userData)
Definition: celix_dm_component.h:45

Set the component life cycle callbacks using a MACRO for improving the type safety.

Typedef Documentation

typedef int(* celix_dm_cmp_lifecycle_fpt) (void *userData)

Enumeration Type Documentation

Enumerator
DM_CMP_STATE_INACTIVE 
DM_CMP_STATE_WAITING_FOR_REQUIRED 
DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED 
DM_CMP_STATE_TRACKING_OPTIONAL 

Function Documentation

celix_status_t celix_dmComponent_addInterface ( celix_dm_component_t *  component,
const char *  serviceName,
const char *  serviceVersion,
const void *  service,
celix_properties_t *  properties 
)

Adds a C interface to provide as service to the Celix framework.

Parameters
serviceNamethe service name.
versionThe version of the interface (e.g. "1.0.0"), Can be a NULL pointer.
propertiesTo (meta) properties to provide with the service. Can be a NULL pointer.
celix_status_t celix_dmComponent_addServiceDependency ( celix_dm_component_t *  component,
celix_dm_service_dependency_t *  dep 
)

Adds a C service dependency to the component

celix_dm_component_t* celix_dmComponent_create ( celix_bundle_context_t *  context,
const char *  name 
)

Creates a DM Component Caller has ownership.

celix_dm_component_state_t celix_dmComponent_currentState ( celix_dm_component_t *  cmp)

Returns the current state of the component.

void celix_dmComponent_destroy ( celix_dm_component_t *  cmp)

Destroys a DM Component

void celix_dmComponent_destroyComponentInfo ( dm_component_info_pt  info)

Destroys a DM Component info struct.

celix_bundle_context_t* celix_dmComponent_getBundleContext ( celix_dm_component_t *  component)

Returns bundle context for the bundle where this DM component is part of.

celix_status_t celix_dmComponent_getComponentInfo ( celix_dm_component_t *  component,
dm_component_info_pt info 
)

Create a DM Component info struct. Containing information about the component. Caller has ownership.

void* celix_dmComponent_getImplementation ( celix_dm_component_t *  cmp)

Returns the implementation of the component. e.g. the component handle/self/this pointer.

celix_status_t celix_dmComponent_getInterfaces ( celix_dm_component_t *  component,
celix_array_list_t **  servicesNames 
)

Returns an arraylist of service names. The caller owns the arraylist and strings (char *)

const char* celix_dmComponent_getName ( celix_dm_component_t *  cmp)

Returns the DM component name. This is used when printing information about the component.

bool celix_dmComponent_isActive ( celix_dm_component_t *  component)
celix_status_t celix_dmComponent_removeInterface ( celix_dm_component_t *  component,
const void *  service 
)

Removed a C interface from a component the Celix framework.

Parameters
serviceNamethe service name.
Returns
CELIX_SUCCESS when removed, CELIX_ILLEGAL_ARGUMENT when the component does not provide the interface
celix_status_t celix_dmComponent_removeServiceDependency ( celix_dm_component_t *  component,
celix_dm_service_dependency_t *  dependency 
)

Removes a C service dependency to the component

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 
)

Set the component life cycle callbacks. The first argument will be the component implementation (

See also
component_getImplementation)
celix_status_t celix_dmComponent_setCLanguageProperty ( celix_dm_component_t *  component,
bool  setCLangProp 
)

Specify if a default 'service.lang=C' should be added to the properties of interfaces if no 'service.lang' has been provided. Default is false. Note that this should be set before using component_addInterface.

celix_status_t celix_dmComponent_setImplementation ( celix_dm_component_t *  component,
void *  implementation 
)

Sets the implementation of the component. e.g. the component handle/self/this pointer.