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.
DmActivator.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 #pragma once
21 
22 #include <utility>
23 
25 #include "bundle_activator.h"
26 
27 namespace celix { namespace dm {
28 
32  class DmActivator {
33  public:
35  virtual ~DmActivator() = default;
36 
37  DmActivator(const DmActivator&) = delete;
38  DmActivator& operator=(const DmActivator&) = delete;
39 
40  DependencyManager& manager() const { return this->mng; }
41 
42  celix_bundle_context_t* context() const { return this->ctx; }
43 
49  virtual void init() {};
50 
56  virtual void deinit() {};
57 
67 
68  protected:
70  celix_bundle_context_t *ctx;
71  private:
72  int start() {
73  celix_status_t status = CELIX_SUCCESS;
74  this->init();
75  this->mng.build();
76  return status;
77  }
78 
79  int stop() {
80  celix_status_t status = CELIX_SUCCESS;
81  this->deinit();
82  this->mng.clear();
83  return status;
84  }
85 
86  friend int ::bundleActivator_create(::celix_bundle_context_t*, void**);
87  friend int ::bundleActivator_start(void*, ::celix_bundle_context_t*);
88  friend int ::bundleActivator_stop(void*, ::celix_bundle_context_t*);
89  friend int ::bundleActivator_destroy(void*, ::celix_bundle_context_t*);
90  };
91 }}
celix::dm::DmActivator::mng
DependencyManager & mng
Definition: DmActivator.h:69
celix::dm::DependencyManager::bundleContext
celix_bundle_context_t * bundleContext() const
Definition: DependencyManager.h:59
celix::dm::DependencyManager
Definition: DependencyManager.h:47
celix::dm::DmActivator::deinit
virtual void deinit()
Definition: DmActivator.h:56
celix
Definition: Bundle.h:27
celix::dm::DmActivator::DmActivator
DmActivator(DependencyManager &m)
Definition: DmActivator.h:34
celix::dm::DmActivator::operator=
DmActivator & operator=(const DmActivator &)=delete
celix::dm::DependencyManager::build
void build()
Definition: DependencyManager_Impl.h:71
celix::dm::DmActivator::context
celix_bundle_context_t * context() const
Definition: DmActivator.h:42
celix::dm::DmActivator::ctx
celix_bundle_context_t * ctx
Definition: DmActivator.h:70
celix::dm::DmActivator::create
static DmActivator * create(DependencyManager &mng)
DependencyManager.h
celix::dm::DmActivator
Definition: DmActivator.h:32
celix::dm::DependencyManager::clear
void clear()
Clears the dependency manager, which removes all configured components and waits until all components...
Definition: DependencyManager_Impl.h:109
celix::dm::DmActivator::manager
DependencyManager & manager() const
Definition: DmActivator.h:40
celix::dm::DmActivator::~DmActivator
virtual ~DmActivator()=default
celix::dm::DmActivator::init
virtual void init()
Definition: DmActivator.h:49