blob: d57a9acd31e0539a12b3e6bf74ea54550db11cee (
plain) (
blame)
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
|
/*
* basic.hh - Definition of the abstract Horizon Image Creation backend
* image, the image processing utilities for
* Project Horizon
*
* Copyright (c) 2020 Adélie Linux and contributors. All rights reserved.
* This code is licensed under the AGPL 3.0 license, as noted in the
* LICENSE-code file in the root directory of this repository.
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
#pragma once
#include <functional>
#include <string>
#include <vector>
namespace Horizon {
namespace Image {
class BasicBackend {
public:
/*! Create the backend object.
* @param _ir_dir The intermediate directory the image should contain.
* @param _out_path The path to write the image.
*/
BasicBackend(const std::string &_ir_dir, const std::string &_out_path) :
ir_dir(_ir_dir), out_path(_out_path) {};
virtual ~BasicBackend() {};
/*! Prepare for creating the image.
* @returns 0 if preparation succeeded; otherwise, an error code.
*/
virtual int prepare();
/*! Create the image.
* @returns 0 if the image is created successfully; otherwise, an error
* code which explains the failure.
*/
virtual int create() = 0;
/*! Finalise the image.
* @returns 0 if the image is finalised; otherwise, an error code.
*/
virtual int finalise();
/*! The intermediate directory which contains the sysroot the image
* should contain. */
const std::string ir_dir;
/*! The path at which to write the image. */
const std::string out_path;
};
struct BackendDescriptor {
std::string type_code;
std::string description;
std::function<BasicBackend *(std::string, std::string)> creation_fn;
};
class BackendManager {
public:
/*! Returns a list of available backends. */
static const std::vector<BackendDescriptor> available_backends();
/*! Register a new backend. */
static void register_backend(BackendDescriptor desc);
};
}
}
|