Line data Source code
1 : /**
2 : * @file
3 : *
4 : * @brief Implementation of module loading
5 : *
6 : * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
7 : *
8 : */
9 :
10 :
11 : #include <keyset.hpp>
12 : #include <modules.hpp>
13 :
14 : #include <kdbmodule.h>
15 : #include <kdbplugin.h>
16 :
17 : using namespace std;
18 :
19 : namespace kdb
20 : {
21 :
22 : namespace tools
23 : {
24 :
25 7188 : Modules::Modules ()
26 : {
27 3594 : ckdb::elektraModulesInit (modules.getKeySet (), nullptr);
28 3594 : }
29 :
30 10782 : Modules::~Modules ()
31 : {
32 7188 : ckdb::elektraModulesClose (modules.getKeySet (), nullptr);
33 3594 : }
34 :
35 626 : PluginPtr Modules::load (std::string const & pluginName)
36 : {
37 2504 : KeySet config (1, *Key ("system/module", KEY_VALUE, "this plugin was loaded without a config", KEY_END), KS_END);
38 :
39 1250 : return load (pluginName, config);
40 : }
41 :
42 13102 : PluginPtr Modules::load (std::string const & pluginName, KeySet const & config)
43 : {
44 52408 : return load (PluginSpec (pluginName, config));
45 : }
46 :
47 15428 : PluginPtr Modules::load (PluginSpec const & spec)
48 : {
49 30856 : PluginPtr plugin (new Plugin (spec, modules));
50 15419 : plugin->loadInfo ();
51 15419 : plugin->parse ();
52 :
53 15419 : return plugin;
54 : }
55 : } // namespace tools
56 : } // namespace kdb
|