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));
177 CELIX_PROPERTIES_ITERATE(cIntInfo->properties, iter) {
178 intInfo.properties[std::string{iter.key}] = std::string{iter.entry.value};
180 cmpInfo.interfacesInfo.emplace_back(std::move(intInfo));
183 for (
int k = 0; k < celix_arrayList_size(cCmpInfo->dependency_list); ++k) {
186 depInfo.
serviceName = std::string{cDepInfo->serviceName ==
nullptr ?
"" : cDepInfo->serviceName};
187 depInfo.filter = std::string{cDepInfo->filter ==
nullptr ?
"" : cDepInfo->filter};
188 depInfo.versionRange = std::string{cDepInfo->versionRange ==
nullptr ?
"" : cDepInfo->versionRange};
189 depInfo.isAvailable = cDepInfo->available;
190 depInfo.isRequired = cDepInfo->required;
191 depInfo.nrOfTrackedServices = cDepInfo->count;
192 cmpInfo.dependenciesInfo.emplace_back(std::move(depInfo));
195 info.components.emplace_back(std::move(cmpInfo));
203 auto result = createDepManInfoFromC(cInfo);
212 std::vector<celix::dm::DependencyManagerInfo> result{};
214 for (
int i = 0; i < celix_arrayList_size(cInfos); ++i) {
216 result.emplace_back(createDepManInfoFromC(cInfo));
225 FILE* stream = open_memstream(&buf, &bufSize);
226 celix_dependencyManager_printInfo(mng.cDepMan.get(),
true,
true, stream);