Apache Celix  2.3.0
An implementation of the OSGi specification adapted to C and C++
FrameworkFactory.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 <memory>
23 
24 #include "celix/Properties.h"
25 #include "celix/BundleContext.h"
26 #include "celix/Framework.h"
27 #include "celix_framework_factory.h"
28 
29 namespace celix {
33  inline std::shared_ptr<celix::Framework> createFramework(const celix::Properties& properties = {}) {
34  auto* copy = celix_properties_copy(properties.getCProperties());
35  auto* cFw= celix_frameworkFactory_createFramework(copy);
36  auto fwCtx = std::make_shared<celix::BundleContext>(celix_framework_getFrameworkContext(cFw));
37  std::shared_ptr<celix::Framework> framework{new celix::Framework{std::move(fwCtx), cFw}, [](celix::Framework* fw) {
38  auto* cFw = fw->getCFramework();
39  delete fw;
41  celix_frameworkFactory_destroyFramework(cFw);
42  }};
43  return framework;
44  }
45 }
celix
Definition: Bundle.h:26
celix::Framework::getCFramework
celix_framework_t * getCFramework() const
Get the C framework.
Definition: Framework.h:108
BundleContext.h
celix::createFramework
std::shared_ptr< celix::Framework > createFramework(const celix::Properties &properties={})
Create a new celix Framework instance.
Definition: FrameworkFactory.h:33
Framework.h
celix_framework_waitForEmptyEventQueue
void celix_framework_waitForEmptyEventQueue(celix_framework_t *fw)
Wait until the framework event queue is empty.
celix_framework_getFrameworkContext
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
A Celix framework instance. A framework is also known as a system bundle.
Definition: Framework.h:37
celix::dm::Properties
celix::Properties Properties
Definition: Properties.h:25