#include "src/include/pmix_config.h"
#include "pmix_common.h"
#include <string.h>
#include "src/mca/base/pmix_base.h"
#include "src/mca/mca.h"
#include "src/util/pmix_error.h"
#include "src/util/pmix_show_help.h"
#include "src/mca/psquash/base/base.h"
int pmix_psquash_base_select(void)
{
pmix_mca_base_component_list_item_t *cli;
pmix_mca_base_component_t *component;
pmix_mca_base_module_t *module;
pmix_psquash_base_module_t *nmodule;
int rc, priority, best_pri = -1;
bool inserted = false;
if (pmix_psquash_globals.selected) {
return PMIX_SUCCESS;
}
pmix_psquash_globals.selected = true;
PMIX_LIST_FOREACH (cli, &pmix_psquash_base_framework.framework_components,
pmix_mca_base_component_list_item_t) {
component = (pmix_mca_base_component_t *) cli->cli_component;
pmix_output_verbose(5, pmix_psquash_base_framework.framework_output,
"mca:psquash:select: checking available component %s",
component->pmix_mca_component_name);
if (NULL == component->pmix_mca_query_component) {
pmix_output_verbose(5, pmix_psquash_base_framework.framework_output,
"mca:psquash:select: Skipping component [%s]. It does not "
"implement a query function",
component->pmix_mca_component_name);
continue;
}
pmix_output_verbose(5, pmix_psquash_base_framework.framework_output,
"mca:psquash:select: Querying component [%s]",
component->pmix_mca_component_name);
rc = component->pmix_mca_query_component(&module, &priority);
if (PMIX_SUCCESS != rc || NULL == module) {
pmix_output_verbose(
5, pmix_psquash_base_framework.framework_output,
"mca:psquash:select: Skipping component [%s]. Query failed to return a module",
component->pmix_mca_component_name);
continue;
}
nmodule = (pmix_psquash_base_module_t *) module;
if (NULL != nmodule->init && PMIX_SUCCESS != nmodule->init()) {
continue;
}
if (best_pri < priority) {
best_pri = priority;
if (NULL != pmix_psquash.finalize) {
pmix_psquash.finalize();
}
pmix_psquash = *nmodule;
inserted = true;
}
}
if (!inserted) {
return PMIX_ERR_NOT_FOUND;
}
return PMIX_SUCCESS;
;
}