Line data Source code
1 : /**
2 : * @file
3 : *
4 : * @brief Implements a way to read spec for mounting purposes
5 : *
6 : * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
7 : *
8 : */
9 :
10 :
11 : #ifndef TOOLS_SPEC_READER_HPP
12 : #define TOOLS_SPEC_READER_HPP
13 :
14 : #include <kdb.hpp>
15 :
16 : #include <backendbuilder.hpp>
17 : #include <plugindatabase.hpp>
18 : #include <pluginspec.hpp>
19 :
20 : #include <memory>
21 : #include <unordered_map>
22 :
23 : namespace kdb
24 : {
25 :
26 : namespace tools
27 : {
28 :
29 : class PluginDatabase;
30 :
31 : /**
32 : * @brief Build individual backend while reading specification
33 : */
34 340 : class SpecBackendBuilder : public MountBackendBuilder
35 : {
36 : public:
37 : explicit SpecBackendBuilder (BackendBuilderInit const & bbi = BackendBuilderInit ());
38 : int nodes;
39 : };
40 :
41 : /**
42 : * @brief Highlevel interface to build a backend from specification.
43 : */
44 : class SpecReader
45 : {
46 : public:
47 : typedef std::unordered_map<Key, SpecBackendBuilder> Backends;
48 :
49 : private:
50 : /**
51 : * @brief Contains all backends of all found mountpoints
52 : */
53 : Backends backends;
54 :
55 : private:
56 : /**
57 : * @brief Used for crating new BackendBuilder
58 : */
59 : BackendBuilderInit bbi;
60 :
61 : public:
62 : explicit SpecReader (BackendBuilderInit const & bbi = BackendBuilderInit ());
63 :
64 : ~SpecReader ();
65 :
66 : /**
67 : * @return backends without resolved needs
68 : *
69 : * @see resolveNeeds()
70 : */
71 : Backends getBackends ()
72 : {
73 72 : return backends;
74 : }
75 :
76 : /**
77 : * @brief Reads in a specification.
78 : *
79 : * Adds plugins using BackendBuilder during that.
80 : *
81 : * @param ks
82 : */
83 : void readSpecification (KeySet const & ks);
84 : };
85 : } // namespace tools
86 : } // namespace kdb
87 :
88 : #endif
|