File: module-interface.hpp

package info (click to toggle)
openvpn3-client 24.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 19,384 kB
  • sloc: cpp: 180,128; python: 11,591; ansic: 1,878; sh: 1,767; java: 402; lisp: 81; makefile: 44
file content (86 lines) | stat: -rw-r--r-- 2,060 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//  OpenVPN 3 Linux client -- Next generation OpenVPN client
//
//  SPDX-License-Identifier: AGPL-3.0-only
//
//  Copyright (C) 2017-  OpenVPN Inc <sales@openvpn.net>
//  Copyright (C) 2024-  Răzvan Cojocaru <razvan.cojocaru@openvpn.com>
//

#pragma once

#include <cstdint>
#include <memory>
#include <string>
#include <unordered_map>


namespace DevPosture {

class Module
{
  public:
    using Dictionary = std::unordered_map<std::string, std::string>;
    using UPtr = std::unique_ptr<Module>;


    /**
     *  Create a new Module based object and prepare it for
     *  the D-Bus service.
     *
     * @tparam C      Device Posture Module class to instantiate
     * @tparam T      Class constructor argument types
     * @param args    Class constructor arguments
     *
     * @return Module::UPtr  A unique pointer to the created and instantiated
     *                       device posture checker module
     */
    template <typename C, typename... T>
    [[nodiscard]] static Module::UPtr Create(T &&...args)
    {
        return std::make_unique<C>(C(std::forward<T>(args)...));
    }

    virtual ~Module() = default;

    //
    // Methods
    //

    /**
     *  Runs the device posture check for this module
     *
     * @param input         TODO: TBD.
     * @return Dictionary   A key -> value container holding
     *                      macro -> value_to_substitute pairs.
     *                      Used by the caller to compose JSONs.
     */
    virtual Dictionary Run(const Dictionary &input) = 0;


    //
    // Properties
    //

    /**
     *  Retrieve the name of the device posture check module
     *
     * @return std::string
     */
    virtual std::string name() const = 0;

    /**
     *  Retrieve the device posture check categorization
     *
     * @return std::string
     */
    virtual std::string type() const = 0;

    /**
     *  Retrieve the version number for this device posture check module
     *
     * @return uint16_t
     */
    virtual uint16_t version() const = 0;
};

} // namespace DevPosture