26 context{ctx, [](celix_bundle_context_t*){}},
34 Component<T>& DependencyManager::createComponentInternal(std::string name, std::string uuid) {
35 auto cmp =
Component<T>::create(this->context.get(), this->cDepMan.get(), std::move(name), std::move(uuid));
37 auto baseCmp = std::static_pointer_cast<BaseComponent>(cmp);
38 std::lock_guard<std::mutex> lck{mutex};
39 this->components.push_back(baseCmp);
47 typename std::enable_if<std::is_default_constructible<T>::value,
Component<T>&>::type
49 return createComponentInternal<T>(std::move(name), std::move(uuid));
54 return createComponentInternal<T>(std::move(name), std::move(uuid)).setInstance(std::move(rhs));
59 return createComponentInternal<T>(std::move(name), std::move(uuid)).setInstance(rhs);
64 return createComponentInternal<T>(std::move(name), std::move(uuid)).setInstance(std::forward<T>(rhs));
77 std::lock_guard<std::mutex> lck{mutex};
78 for (
auto& cmp : components) {
94 std::shared_ptr<BaseComponent> tmpStore{};
96 std::lock_guard<std::mutex> lck{mutex};
97 for (
auto it = components.begin(); it != components.end(); ++it) {
98 if ( (*it)->getUUID() == uuid) {
101 components.erase(it);
106 return tmpStore !=
nullptr;
115 std::vector<std::shared_ptr<BaseComponent>> swappedComponents{};
117 std::lock_guard<std::mutex> lck{mutex};
118 std::swap(swappedComponents, components);
120 swappedComponents.clear();
124 celix_dependencyManager_wait(cDepMan.get());
130 celix_dependencyManager_wait(cDepMan.get());
139 return celix_dependencyManager_nrOfComponents(cDepMan.get());
144 std::lock_guard<std::mutex> lck{mutex};
145 std::shared_ptr<BaseComponent> found{
nullptr};
146 for (
const auto& cmp : components) {
147 if (cmp->getUUID() == uuid) {
152 return std::static_pointer_cast<Component<T>>(found);
163 for (
int i = 0; i < celix_arrayList_size(cInfo->
components); ++i) {
166 cmpInfo.
uuid = std::string{cCmpInfo->id};
167 cmpInfo.name = std::string{cCmpInfo->name};
168 cmpInfo.isActive = cCmpInfo->active;
169 cmpInfo.state = std::string{cCmpInfo->state};
170 cmpInfo.nrOfTimesStarted = cCmpInfo->nrOfTimesStarted;
171 cmpInfo.nrOfTimesResumed = cCmpInfo->nrOfTimesResumed;
173 for (
int k = 0; k < celix_arrayList_size(cCmpInfo->interfaces); ++k) {
174 auto* cIntInfo =
static_cast<dm_interface_info_t*
>(celix_arrayList_get(cCmpInfo->interfaces, k));
178 CELIX_PROPERTIES_FOR_EACH(cIntInfo->properties, key) {
179 const char* val =celix_properties_get(cIntInfo->properties, key,
"");
180 intInfo.properties[std::string{key}] = std::string{val};
182 cmpInfo.interfacesInfo.emplace_back(std::move(intInfo));
185 for (
int k = 0; k < celix_arrayList_size(cCmpInfo->dependency_list); ++k) {
188 depInfo.
serviceName = std::string{cDepInfo->serviceName ==
nullptr ?
"" : cDepInfo->serviceName};
189 depInfo.filter = std::string{cDepInfo->filter ==
nullptr ?
"" : cDepInfo->filter};
190 depInfo.versionRange = std::string{cDepInfo->versionRange ==
nullptr ?
"" : cDepInfo->versionRange};
191 depInfo.isAvailable = cDepInfo->available;
192 depInfo.isRequired = cDepInfo->required;
193 depInfo.nrOfTrackedServices = cDepInfo->count;
194 cmpInfo.dependenciesInfo.emplace_back(std::move(depInfo));
197 info.components.emplace_back(std::move(cmpInfo));
205 auto result = createDepManInfoFromC(cInfo);
215 std::vector<celix::dm::DependencyManagerInfo> result{};
217 for (
int i = 0; i < celix_arrayList_size(cInfos); ++i) {
219 result.emplace_back(createDepManInfoFromC(cInfo));
228 FILE* stream = open_memstream(&buf, &bufSize);
229 celix_dependencyManager_printInfo(mng.cDepMan.get(),
true,
true, stream);