Dobby  3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Public Member Functions | Private Types | Private Attributes | List of all members
DobbyRdkPluginDependencySolver Class Reference

Class that tracks dependencies between plugins. More...

#include <DobbyRdkPluginDependencySolver.h>

Public Member Functions

bool addPlugin (const std::string &name)
 Adds a plugin to the solver. More...
 
bool addDependency (const std::string &pluginName, const std::string &dependencyName)
 Adds a dependency between two plugins to the solver. More...
 
std::vector< std::string > getOrderOfDependency () const
 Gets the names of the plugins in order of their dependency. More...
 
std::vector< std::string > getReversedOrderOfDependency () const
 Gets the names of the plugins in reversed order of their dependency. More...
 

Private Types

using VertexIndexProperty = boost::property< boost::vertex_index_t, std::size_t >
 
using VertexNameProperty = boost::property< boost::vertex_name_t, std::string, VertexIndexProperty >
 
using Graph = boost::adjacency_list< boost::setS, boost::vecS, boost::directedS, VertexNameProperty >
 
using VertexDescriptor = Graph::vertex_descriptor
 
using StringVertexDescriptorMap = std::map< std::string, VertexDescriptor >
 

Private Attributes

Graph mDependencyGraph
 
StringVertexDescriptorMap mDescriptorMap
 

Detailed Description

Class that tracks dependencies between plugins.

It can be used to get the order in which the plugins should be launched.

Member Function Documentation

◆ addDependency()

bool DobbyRdkPluginDependencySolver::addDependency ( const std::string &  pluginName,
const std::string &  dependencyName 
)

Adds a dependency between two plugins to the solver.

If plugin A depends on plugin B, then the call is:

bool addDependency(const std::string &pluginName, const std::string &dependencyName)
Adds a dependency between two plugins to the solver.
Definition: DobbyRdkPluginDependencySolver.cpp:80
Parameters
[in]pluginNameThe name of the plugin which depends on dependencyName.
[in]dependencyNameThe name of the plugin on which pluginName depends.
Returns
True if the dependency has been added successfully, false otherwise (one of the plugins had not been added to the solver).

◆ addPlugin()

bool DobbyRdkPluginDependencySolver::addPlugin ( const std::string &  name)

Adds a plugin to the solver.

Each plugin must be known to the solver - added by this method before its dependencies are tracked.

Parameters
[in]nameName of the plugin
Returns
True if the plugin has been added successfully, false otherwise (the plugin had already been added).

◆ getOrderOfDependency()

std::vector< std::string > DobbyRdkPluginDependencySolver::getOrderOfDependency ( ) const

Gets the names of the plugins in order of their dependency.

"Order of dependency" here means that if plugin A depends on plugin B, plugin B will be placed before plugin A in the returned vector, e.g. with this code:

solver.addPlugin("AppServices");
solver.addPlugin("Networking");
solver.addPlugin("IPC");
solver.addDependency("AppServices", "Networking");
solver.addDependency("Networking", "IPC");
const std::vector<std::string> inOrder = solver.getOrderOfDependency();
Class that tracks dependencies between plugins.
Definition: DobbyRdkPluginDependencySolver.h:40
std::vector< std::string > getOrderOfDependency() const
Gets the names of the plugins in order of their dependency.
Definition: DobbyRdkPluginDependencySolver.cpp:132
bool addPlugin(const std::string &name)
Adds a plugin to the solver.
Definition: DobbyRdkPluginDependencySolver.cpp:42

,

inOrder

is

{ "IPC", "Networking", "AppServices" }

.

If there is a dependency cycle, an error message is printed and the function returns an empty vector.

Returns
Names of the plugins in order of dependency. Empty vector if no plugins have been added or a dependency cycle has been detected. Vector with plugin names in the same order in which they were added if no dependencies have been added).

◆ getReversedOrderOfDependency()

std::vector< std::string > DobbyRdkPluginDependencySolver::getReversedOrderOfDependency ( ) const

Gets the names of the plugins in reversed order of their dependency.

"Reversed order of dependency" here means that if plugin A depends on plugin B, plugin B will be placed after plugin A in the returned vector, e.g. with this code:

solver.addPlugin("AppServices");
solver.addPlugin("Networking");
solver.addPlugin("IPC");
solver.addDependency("AppServices", "Networking");
solver.addDependency("Networking", "IPC");
const std::vector<std::string> inReversedOrder = solver.getReversedOrderOfDependency();
std::vector< std::string > getReversedOrderOfDependency() const
Gets the names of the plugins in reversed order of their dependency.
Definition: DobbyRdkPluginDependencySolver.cpp:182

,

inOrder

is

{ "AppServices", "Networking", "IPC" }

.

If there is a dependency cycle, an error message is printed and the function returns an empty vector.

Returns
Names of the plugins in reversed order of dependency. Empty vector if no plugins have been added or a dependency cycle has been detected. Vector with plugin names in the same order in which they were added if no dependencies have been added).

The documentation for this class was generated from the following files: