Dobby 3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Loading...
Searching...
No Matches
DobbyRdkPluginManager.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 2016 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: DobbyRdkPluginManager.h
21 *
22 */
23#ifndef DOBBYRDKPLUGINMANAGER_H
24#define DOBBYRDKPLUGINMANAGER_H
25
26#include "IDobbyRdkPlugin.h"
27#include "IDobbyRdkLoggingPlugin.h"
28
29#include <sys/types.h>
30#include <map>
31#include <string>
32#include <memory>
33#include <set>
34#include <vector>
35#include <algorithm>
36
38
39// -----------------------------------------------------------------------------
48{
49public:
50 DobbyRdkPluginManager(std::shared_ptr<rt_dobby_schema> containerConfig,
51 const std::string &rootfsPath,
52 const std::string &pluginPath,
53 const std::shared_ptr<DobbyRdkPluginUtils> &utils);
55
56public:
57 const std::vector<std::string> listLoadedPlugins() const;
58 const std::vector<std::string> listLoadedLoggers() const;
59 bool runPlugins(const IDobbyRdkPlugin::HintFlags &hookPoint,
60 const uint timeoutMs = 0) const;
61
62 // This is public as RDKPluginManager isn't responsible for handling logging
63 std::shared_ptr<IDobbyRdkLoggingPlugin> getContainerLogger() const;
64 void setExitStatus(int status) const;
65
66 std::shared_ptr<rt_dobby_schema> getContainerConfig() const
67 {
68 return mContainerConfig;
69 };
70
71 std::shared_ptr<DobbyRdkPluginUtils> getUtils() const
72 {
73 return mUtils;
74 }
75
76private:
77 bool loadPlugins();
78 bool preprocessPlugins();
79 bool executeHook(const std::string &pluginName,
80 const IDobbyRdkPlugin::HintFlags hook) const;
81 bool executeHookTimeout(const std::string &pluginName,
83 const uint timeoutMs) const;
84 std::string HookPointToString(const IDobbyRdkPlugin::HintFlags &hookPoint) const;
85
86 bool implementsHook(const std::string &pluginName,
87 const IDobbyRdkPlugin::HintFlags hook) const;
88 bool isLoaded(const std::string &pluginName) const;
89 bool isRequired(const std::string &pluginName) const;
90 inline std::shared_ptr<IDobbyRdkPlugin> getPlugin(const std::string &name) const;
91 inline std::shared_ptr<IDobbyRdkLoggingPlugin> getLogger(const std::string &name) const;
92
93private:
94 bool mValid;
95 std::map<std::string, std::pair<void *, std::shared_ptr<IDobbyRdkLoggingPlugin>>> mLoggers;
96 std::map<std::string, std::pair<void *, std::shared_ptr<IDobbyRdkPlugin>>> mPlugins;
97 std::set<std::string> mRequiredPlugins;
98 std::shared_ptr<rt_dobby_schema> mContainerConfig;
99 const std::string mRootfsPath;
100 const std::string mPluginPath;
101 const std::shared_ptr<DobbyRdkPluginUtils> mUtils;
102 std::unique_ptr<DobbyRdkPluginDependencySolver> mDependencySolver;
103 std::map<std::string, std::string> mAnnotations;
104};
105
106#endif // !defined(DOBBYRDKPLUGINMANAGER_H)
Class that tracks dependencies between plugins.
Definition DobbyRdkPluginDependencySolver.h:40
Class that manages all the RDK plugin hook libraries.
Definition DobbyRdkPluginManager.h:48
bool executeHookTimeout(const std::string &pluginName, const IDobbyRdkPlugin::HintFlags hook, const uint timeoutMs) const
Definition DobbyRdkPluginManager.cpp:687
std::shared_ptr< IDobbyRdkPlugin > getPlugin(const std::string &name) const
Get the plugin with the name, or nullptr if no plugin.
Definition DobbyRdkPluginManager.cpp:521
~DobbyRdkPluginManager()
Definition DobbyRdkPluginManager.cpp:74
bool runPlugins(const IDobbyRdkPlugin::HintFlags &hookPoint, const uint timeoutMs=0) const
Run the plugins specified in the container config at the given hook point. Returns true if all requir...
Definition DobbyRdkPluginManager.cpp:853
std::string HookPointToString(const IDobbyRdkPlugin::HintFlags &hookPoint) const
Definition DobbyRdkPluginManager.cpp:802
bool implementsHook(const std::string &pluginName, const IDobbyRdkPlugin::HintFlags hook) const
Check if a plugin implements the specified hook.
Definition DobbyRdkPluginManager.cpp:605
std::shared_ptr< IDobbyRdkLoggingPlugin > getContainerLogger() const
Get the logging plugin specified in the container config. Each container can only have a single plugi...
Definition DobbyRdkPluginManager.cpp:458
bool isLoaded(const std::string &pluginName) const
Check if a plugin is loaded.
Definition DobbyRdkPluginManager.cpp:579
bool preprocessPlugins()
Prepares the dependency solver and required plugins data structures.
Definition DobbyRdkPluginManager.cpp:358
const std::vector< std::string > listLoadedPlugins() const
Just return a list of all loaded plugin names.
Definition DobbyRdkPluginManager.cpp:561
bool executeHook(const std::string &pluginName, const IDobbyRdkPlugin::HintFlags hook) const
Definition DobbyRdkPluginManager.cpp:633
bool isRequired(const std::string &pluginName) const
Check if a plugin is required.
Definition DobbyRdkPluginManager.cpp:591
std::shared_ptr< IDobbyRdkLoggingPlugin > getLogger(const std::string &name) const
Get the logger with the name, or nullptr if no plugin.
Definition DobbyRdkPluginManager.cpp:429
void setExitStatus(int status) const
Set the exit status of the container.
Definition DobbyRdkPluginManager.cpp:508
bool loadPlugins()
Scans the given path for any shared objects that implement the plugin entry points.
Definition DobbyRdkPluginManager.cpp:152
const std::vector< std::string > listLoadedLoggers() const
Just return a list of all loaded logging plugin names.
Definition DobbyRdkPluginManager.cpp:544
HintFlags
Bit flags that should be returned by hookHints.
Definition IDobbyRdkPlugin.h:70