24 #ifndef CELIX_BUNDLE_ACTIVATOR_H_ 25 #define CELIX_BUNDLE_ACTIVATOR_H_ 115 #define CELIX_GEN_BUNDLE_ACTIVATOR(actType, actStart, actStop) \ 116 celix_status_t celix_bundleActivator_create(celix_bundle_context_t *ctx __attribute__((unused)), void **userData) { \ 117 celix_status_t status = CELIX_SUCCESS; \ 118 actType *data = (actType*)calloc(1, sizeof(*data)); \ 119 if (data != NULL) { \ 122 status = CELIX_ENOMEM; \ 127 celix_status_t celix_bundleActivator_start(void *userData, celix_bundle_context_t *ctx) { \ 128 return actStart((actType*)userData, ctx); \ 131 celix_status_t celix_bundleActivator_stop(void *userData, celix_bundle_context_t *ctx) { \ 132 return actStop((actType*)userData, ctx); \ 135 celix_status_t celix_bundleActivator_destroy(void *userData, celix_bundle_context_t *ctx __attribute__((unused))) { \ 137 return CELIX_SUCCESS; \ 155 #define CELIX_GEN_CXX_BUNDLE_ACTIVATOR(actType) \ 158 struct BundleActivatorData { \ 159 std::shared_ptr<DependencyManager> mng{}; \ 160 std::unique_ptr<actType> activator{}; \ 164 extern "C" celix_status_t bundleActivator_create(celix_bundle_context_t *context, void** userData) { \ 165 int status = CELIX_SUCCESS; \ 167 BundleActivatorData* data = nullptr; \ 168 data = new BundleActivatorData{}; \ 169 if (data != nullptr) { \ 170 data->mng = std::shared_ptr<celix::dm::DependencyManager>{new celix::dm::DependencyManager{context}}; \ 173 if (data == nullptr || data->mng == nullptr) { \ 174 status = CELIX_ENOMEM; \ 175 if (data != nullptr) { \ 178 *userData = nullptr; \ 185 extern "C" celix_status_t bundleActivator_start(void *userData, celix_bundle_context_t *) { \ 186 auto* data = static_cast<BundleActivatorData*>(userData); \ 187 if (data != nullptr) { \ 188 data->activator = std::unique_ptr<actType>{new actType{data->mng}}; \ 189 data->mng->start(); \ 191 return CELIX_SUCCESS; \ 194 extern "C" celix_status_t bundleActivator_stop(void *userData, celix_bundle_context_t*) { \ 195 auto* data = static_cast<BundleActivatorData*>(userData); \ 196 if (data != nullptr) { \ 198 data->activator = nullptr; \ 199 data->mng = nullptr; \ 201 return CELIX_SUCCESS; \ 204 extern "C" celix_status_t bundleActivator_destroy(void *userData, celix_bundle_context_t*) { \ 205 auto* data = static_cast<BundleActivatorData*>(userData); \ 206 if (data != nullptr) { \ 209 return CELIX_SUCCESS; \ celix_status_t celix_bundleActivator_destroy(void *userData, celix_bundle_context_t *ctx)
celix_status_t celix_bundleActivator_create(celix_bundle_context_t *ctx, void **userData)
celix_status_t celix_bundleActivator_stop(void *userData, celix_bundle_context_t *ctx)
celix_status_t celix_bundleActivator_start(void *userData, celix_bundle_context_t *ctx)