Apache Celix  2.4.0
Apache Celix is a framework for C, C++14 and C++17 to develop dynamic modular software applications using component and in-process service-oriented programming.
celix_framework.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_FRAMEWORK_H_
21 #define CELIX_FRAMEWORK_H_
22 
23 #include <stdarg.h>
24 
25 #include "celix_types.h"
26 #include "celix_properties.h"
27 #include "celix_log_level.h"
28 #include "celix_array_list.h"
29 #include "celix_framework_export.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
57 CELIX_FRAMEWORK_EXPORT const char* celix_framework_getUUID(const celix_framework_t *fw);
58 
65 CELIX_FRAMEWORK_EXPORT celix_bundle_context_t* celix_framework_getFrameworkContext(const celix_framework_t *fw);
66 
73 CELIX_FRAMEWORK_EXPORT celix_bundle_t* celix_framework_getFrameworkBundle(const celix_framework_t *fw);
74 
88 CELIX_FRAMEWORK_EXPORT size_t celix_framework_useBundles(celix_framework_t* fw,
89  bool includeFrameworkBundle,
90  void* callbackHandle,
91  void (*use)(void* handle, const celix_bundle_t* bnd));
92 
107 CELIX_FRAMEWORK_EXPORT size_t celix_framework_useActiveBundles(celix_framework_t* fw,
108  bool includeFrameworkBundle,
109  void* callbackHandle,
110  void (*use)(void* handle, const celix_bundle_t* bnd));
111 
129 CELIX_FRAMEWORK_EXPORT bool celix_framework_useBundle(celix_framework_t* fw,
130  bool onlyActive,
131  long bndId,
132  void* callbackHandle,
133  void (*use)(void* handle, const celix_bundle_t* bnd));
134 
141 CELIX_FRAMEWORK_EXPORT bool celix_framework_isBundleInstalled(celix_framework_t *fw, long bndId);
142 
149 CELIX_FRAMEWORK_EXPORT bool celix_framework_isBundleActive(celix_framework_t *fw, long bndId);
150 
151 
161 CELIX_FRAMEWORK_EXPORT long celix_framework_installBundle(celix_framework_t *fw, const char *bundleLoc, bool autoStart);
162 
171 CELIX_FRAMEWORK_EXPORT bool celix_framework_uninstallBundle(celix_framework_t *fw, long bndId);
172 
182 CELIX_FRAMEWORK_EXPORT bool celix_framework_unloadBundle(celix_framework_t *fw, long bndId);
183 
203 CELIX_FRAMEWORK_EXPORT bool celix_framework_updateBundle(celix_framework_t *fw, long bndId, const char* updatedBundleUrl);
204 
213 CELIX_FRAMEWORK_EXPORT bool celix_framework_stopBundle(celix_framework_t *fw, long bndId);
214 
223 CELIX_FRAMEWORK_EXPORT bool celix_framework_startBundle(celix_framework_t *fw, long bndId);
224 
236 CELIX_FRAMEWORK_EXPORT long celix_framework_installBundleAsync(celix_framework_t *fw, const char *bundleLoc, bool autoStart);
237 
256 CELIX_FRAMEWORK_EXPORT void celix_framework_updateBundleAsync(celix_framework_t *fw, long bndId, const char* updatedBundleUrl);
257 
267 CELIX_FRAMEWORK_EXPORT void celix_framework_uninstallBundleAsync(celix_framework_t *fw, long bndId);
268 
278 CELIX_FRAMEWORK_EXPORT void celix_framework_unloadBundleAsync(celix_framework_t *fw, long bndId);
279 
289 CELIX_FRAMEWORK_EXPORT void celix_framework_stopBundleAsync(celix_framework_t *fw, long bndId);
290 
300 CELIX_FRAMEWORK_EXPORT void celix_framework_startBundleAsync(celix_framework_t *fw, long bndId);
301 
309 CELIX_FRAMEWORK_EXPORT celix_array_list_t* celix_framework_listBundles(celix_framework_t* framework);
310 
318 CELIX_FRAMEWORK_EXPORT celix_array_list_t* celix_framework_listInstalledBundles(celix_framework_t* framework);
319 
327 CELIX_FRAMEWORK_EXPORT void celix_framework_setLogCallback(celix_framework_t* fw, void* logHandle, void (*logFunction)(void* handle, celix_log_level_e level, const char* file, const char *function, int line, const char *format, va_list formatArgs));
328 
339 CELIX_FRAMEWORK_EXPORT void celix_framework_waitForEmptyEventQueue(celix_framework_t *fw);
340 
353 CELIX_FRAMEWORK_EXPORT celix_status_t celix_framework_waitForEmptyEventQueueFor(celix_framework_t *fw, double timeoutInSeconds);
354 
362 CELIX_FRAMEWORK_EXPORT void celix_framework_waitUntilNoEventsForBnd(celix_framework_t* fw, long bndId);
363 
367 CELIX_FRAMEWORK_EXPORT void celix_framework_waitUntilNoPendingRegistration(celix_framework_t* fw);
368 
373 CELIX_FRAMEWORK_EXPORT bool celix_framework_isCurrentThreadTheEventLoop(celix_framework_t* fw);
374 
387 CELIX_FRAMEWORK_EXPORT long celix_framework_fireGenericEvent(celix_framework_t* fw,
388  long eventId,
389  long bndId,
390  const char* eventName,
391  void* processData,
392  void (*processCallback)(void* data),
393  void* doneData,
394  void (*doneCallback)(void* doneData));
395 
403 CELIX_FRAMEWORK_EXPORT long celix_framework_nextEventId(celix_framework_t *fw);
404 
411 CELIX_FRAMEWORK_EXPORT void celix_framework_waitForGenericEvent(celix_framework_t *fw, long eventId);
412 
416 CELIX_FRAMEWORK_EXPORT void celix_framework_waitForStop(celix_framework_t *framework);
417 
421 CELIX_FRAMEWORK_EXPORT bool celix_framework_isEventQueueEmpty(celix_framework_t* fw);
422 
423 #ifdef __cplusplus
424 }
425 #endif
426 
427 #endif /* CELIX_FRAMEWORK_H_ */
celix_framework_isBundleInstalled
CELIX_FRAMEWORK_EXPORT bool celix_framework_isBundleInstalled(celix_framework_t *fw, long bndId)
Check whether a bundle is installed.
celix_framework_startBundle
CELIX_FRAMEWORK_EXPORT bool celix_framework_startBundle(celix_framework_t *fw, long bndId)
Start the bundle with the provided bundle id. Will silently ignore bundle ids < 0.
celix_framework_startBundleAsync
CELIX_FRAMEWORK_EXPORT void celix_framework_startBundleAsync(celix_framework_t *fw, long bndId)
Start the bundle with the provided bundle id async. Will silently ignore bundle ids < 0.
celix_framework_useBundle
CELIX_FRAMEWORK_EXPORT bool celix_framework_useBundle(celix_framework_t *fw, bool onlyActive, long bndId, void *callbackHandle, void(*use)(void *handle, const celix_bundle_t *bnd))
Use the bundle with the provided bundle id The provided callback will be called if the bundle is foun...
celix_framework_installBundle
CELIX_FRAMEWORK_EXPORT long celix_framework_installBundle(celix_framework_t *fw, const char *bundleLoc, bool autoStart)
Install and optional start a bundle. Will silently ignore bundle ids < 0.
celix_framework_stopBundleAsync
CELIX_FRAMEWORK_EXPORT void celix_framework_stopBundleAsync(celix_framework_t *fw, long bndId)
Stop the bundle with the provided bundle id async. Will silently ignore bundle ids < 0.
celix_framework_listBundles
CELIX_FRAMEWORK_EXPORT celix_array_list_t * celix_framework_listBundles(celix_framework_t *framework)
List the installed and started bundle ids. The bundle ids does not include the framework bundle (bund...
celix_framework_getUUID
const CELIX_FRAMEWORK_EXPORT char * celix_framework_getUUID(const celix_framework_t *fw)
Returns the framework UUID. This is unique for every created framework and will not be the same if th...
celix_framework_useActiveBundles
CELIX_FRAMEWORK_EXPORT size_t celix_framework_useActiveBundles(celix_framework_t *fw, bool includeFrameworkBundle, void *callbackHandle, void(*use)(void *handle, const celix_bundle_t *bnd))
Use the currently active bundles. The provided callback will be called for all the currently active b...
celix_framework_waitForEmptyEventQueue
CELIX_FRAMEWORK_EXPORT void celix_framework_waitForEmptyEventQueue(celix_framework_t *fw)
Wait until the framework event queue is empty.
celix_framework_uninstallBundleAsync
CELIX_FRAMEWORK_EXPORT void celix_framework_uninstallBundleAsync(celix_framework_t *fw, long bndId)
Uninstall the bundle with the provided bundle id async. If needed the bundle will be stopped first....
celix_framework_listInstalledBundles
CELIX_FRAMEWORK_EXPORT celix_array_list_t * celix_framework_listInstalledBundles(celix_framework_t *framework)
List the installed bundle ids. The bundle ids does not include the framework bundle (bundle id CELIX_...
celix_framework_fireGenericEvent
CELIX_FRAMEWORK_EXPORT long celix_framework_fireGenericEvent(celix_framework_t *fw, long eventId, long bndId, const char *eventName, void *processData, void(*processCallback)(void *data), void *doneData, void(*doneCallback)(void *doneData))
Fire a generic event. The event will be added to the event loop and handled on the event loop thread.
celix_framework_isEventQueueEmpty
CELIX_FRAMEWORK_EXPORT bool celix_framework_isEventQueueEmpty(celix_framework_t *fw)
Check if the event queue is empty.
celix_framework_waitUntilNoPendingRegistration
CELIX_FRAMEWORK_EXPORT void celix_framework_waitUntilNoPendingRegistration(celix_framework_t *fw)
wait until all pending service registration are processed.
celix_framework_stopBundle
CELIX_FRAMEWORK_EXPORT bool celix_framework_stopBundle(celix_framework_t *fw, long bndId)
Stop the bundle with the provided bundle id. Will silently ignore bundle ids < 0.
celix_framework_installBundleAsync
CELIX_FRAMEWORK_EXPORT long celix_framework_installBundleAsync(celix_framework_t *fw, const char *bundleLoc, bool autoStart)
Install and optional start a bundle async. Will silently ignore bundle ids < 0.
celix_framework_waitForStop
CELIX_FRAMEWORK_EXPORT void celix_framework_waitForStop(celix_framework_t *framework)
Wait until the framework is stopped.
celix_framework_unloadBundle
CELIX_FRAMEWORK_EXPORT bool celix_framework_unloadBundle(celix_framework_t *fw, long bndId)
Unload the bundle with the provided bundle id. If needed the bundle will be stopped first....
celix_framework_getFrameworkBundle
CELIX_FRAMEWORK_EXPORT celix_bundle_t * celix_framework_getFrameworkBundle(const celix_framework_t *fw)
Returns the framework bundle. This is the same as a 'normal' bundle, expect that this bundle cannot b...
celix_framework_isCurrentThreadTheEventLoop
CELIX_FRAMEWORK_EXPORT bool celix_framework_isCurrentThreadTheEventLoop(celix_framework_t *fw)
Returns whether the current thread is the Celix framework event loop thread.
celix_framework_waitForGenericEvent
CELIX_FRAMEWORK_EXPORT void celix_framework_waitForGenericEvent(celix_framework_t *fw, long eventId)
Wait until a event from the event queue with the provided event id is completely handled....
celix_framework_nextEventId
CELIX_FRAMEWORK_EXPORT long celix_framework_nextEventId(celix_framework_t *fw)
Get the next event id.
celix_framework_updateBundle
CELIX_FRAMEWORK_EXPORT bool celix_framework_updateBundle(celix_framework_t *fw, long bndId, const char *updatedBundleUrl)
Update the bundle with the provided bundle id.
celix_framework_waitUntilNoEventsForBnd
CELIX_FRAMEWORK_EXPORT void celix_framework_waitUntilNoEventsForBnd(celix_framework_t *fw, long bndId)
wait until all events from the event queue for the bundle identified by the bndId are processed.
celix_framework_useBundles
CELIX_FRAMEWORK_EXPORT size_t celix_framework_useBundles(celix_framework_t *fw, bool includeFrameworkBundle, void *callbackHandle, void(*use)(void *handle, const celix_bundle_t *bnd))
Use the currently installed bundles. The provided callback will be called for all the currently insta...
celix_framework_uninstallBundle
CELIX_FRAMEWORK_EXPORT bool celix_framework_uninstallBundle(celix_framework_t *fw, long bndId)
Uninstall the bundle with the provided bundle id. If needed the bundle will be stopped first....
celix_framework_waitForEmptyEventQueueFor
CELIX_FRAMEWORK_EXPORT celix_status_t celix_framework_waitForEmptyEventQueueFor(celix_framework_t *fw, double timeoutInSeconds)
Wait until the framework event queue is empty or the provided period is reached.
celix_framework_setLogCallback
CELIX_FRAMEWORK_EXPORT void celix_framework_setLogCallback(celix_framework_t *fw, void *logHandle, void(*logFunction)(void *handle, celix_log_level_e level, const char *file, const char *function, int line, const char *format, va_list formatArgs))
Sets the log function for this framework. Default the celix framework will log to stdout/stderr.
celix_framework_getFrameworkContext
CELIX_FRAMEWORK_EXPORT celix_bundle_context_t * celix_framework_getFrameworkContext(const celix_framework_t *fw)
Returns the framework bundle context. This is the same as a 'normal' bundle context and can be used t...
celix_framework_unloadBundleAsync
CELIX_FRAMEWORK_EXPORT void celix_framework_unloadBundleAsync(celix_framework_t *fw, long bndId)
Unload the bundle with the provided bundle id async. If needed the bundle will be stopped first....
celix_framework_isBundleActive
CELIX_FRAMEWORK_EXPORT bool celix_framework_isBundleActive(celix_framework_t *fw, long bndId)
Check whether the bundle is active.
celix_framework_updateBundleAsync
CELIX_FRAMEWORK_EXPORT void celix_framework_updateBundleAsync(celix_framework_t *fw, long bndId, const char *updatedBundleUrl)
Update the bundle with the provided bundle id async.