Dobby  3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
DobbyRdkPluginDependencySolver.h
1 /*
2 * If not stated otherwise in this file or this component's LICENSE file the
3 * following copyright and licenses apply:
4 *
5 * Copyright 2021 Sky UK
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19 /*
20  * File: DobbyRdkPluginDependencySolver.h
21  *
22  */
23 #ifndef DOBBYRDKPLUGINDEPENDENCYSOLVER_H
24 #define DOBBYRDKPLUGINDEPENDENCYSOLVER_H
25 
26 #include <string>
27 #include <vector>
28 
29 #include <boost/graph/adjacency_list.hpp>
30 
31 // -----------------------------------------------------------------------------
40 {
41 public:
42  bool addPlugin(const std::string &name);
43  bool addDependency(const std::string &pluginName, const std::string &dependencyName);
44 
45  std::vector<std::string> getOrderOfDependency() const;
46  std::vector<std::string> getReversedOrderOfDependency() const;
47 
48 private:
49  using VertexIndexProperty = boost::property<boost::vertex_index_t, std::size_t>;
50  using VertexNameProperty = boost::property<boost::vertex_name_t, std::string, VertexIndexProperty>;
51  using Graph = boost::adjacency_list<boost::setS, boost::vecS, boost::directedS, VertexNameProperty>;
52  using VertexDescriptor = Graph::vertex_descriptor;
53  using StringVertexDescriptorMap = std::map<std::string, VertexDescriptor>;
54 
55  Graph mDependencyGraph;
56  StringVertexDescriptorMap mDescriptorMap;
57 };
58 
59 #endif // !defined(DOBBYRDKPLUGINDEPENDENCYSOLVER_H)
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 addDependency(const std::string &pluginName, const std::string &dependencyName)
Adds a dependency between two plugins to the solver.
Definition: DobbyRdkPluginDependencySolver.cpp:80
bool addPlugin(const std::string &name)
Adds a plugin to the solver.
Definition: DobbyRdkPluginDependencySolver.cpp:42
std::vector< std::string > getReversedOrderOfDependency() const
Gets the names of the plugins in reversed order of their dependency.
Definition: DobbyRdkPluginDependencySolver.cpp:182