Carousel
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties Pages
Public Member Functions | List of all members
DependencySolver Class Reference

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
 

Detailed Description

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.

Member Function Documentation

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.

Parameters
namethe name that uniquely identifies the component.
See Also
removeComponent()
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.

Parameters
childComponentthe name of the component with the dependency.
parentComponentthe 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.

Parameters
namethe name that uniquely identifies the component.
See Also
addComponent()
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.

Parameters
orderedThe resulting ordered list of components.
orphansThe list of components which parents are in the missing list.
missingThe list of components declared a dependency on another component which is not added to the solver.
Returns
false if at least one cyclic dependency has been found during solving. Otherwise, returns true.