![]() |
Carousel
|
Used by IComponentManager to get the load sequence for the components to load according to their dependencies. More...
#include <DependencySolver.h>
Public Member Functions | |
void | addComponent (const QString &name) |
void | addDependency (const QString &childComponent, const QString &parentComponent) |
int | componentsCount () const |
void | removeComponent (const QString &component) |
bool | solve (QStringList &ordered, QStringList &orphans, QStringList &missing) const |
Used by IComponentManager to get the load sequence for the components to load according to their dependencies.
The component dependencies solving is an component names ordering indeed. At first component names are registered at the dependency matrix using addComponent() method, and then if component has dependencies, both - component itself and dependent component name - are registered in the matrix using addDependency() method. When all components and their dependencies were added to the solver, call solve() to calculate an ordered list according to the defined component dependencies. Non-dependant components appears at the beginning of the resulting collection.
void DependencySolver::addComponent | ( | const QString & | name | ) |
Adds a component to the solver. The empty string does not considered as correct name, and will not be added.
name | the name that uniquely identifies the component. |
void DependencySolver::addDependency | ( | const QString & | childComponent, |
const QString & | parentComponent | ||
) |
Adds a component dependency between the components specified by childComponent and parentComponent. The empty string does not considered as correct name, and will not be added.
childComponent | the name of the component with the dependency. |
parentComponent | the name of the component childComponent depends on. |
int DependencySolver::componentsCount | ( | ) | const |
Gets the number of components added to the solver.
void DependencySolver::removeComponent | ( | const QString & | component | ) |
Removes a component from the dependency matrix.
name | the name that uniquely identifies the component. |
bool DependencySolver::solve | ( | QStringList & | ordered, |
QStringList & | orphans, | ||
QStringList & | missing | ||
) | const |
Calculates an ordered list according to the defined dependencies. Non-dependant components appears at the beginning of the resulting collection.
ordered | The resulting ordered list of components. |
orphans | The list of components which parents are in the missing list. |
missing | The list of components declared a dependency on another component which is not added to the solver. |