blob: 7c398caea237b35a8a929fc210d17435d4058f8e (
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
|
/*
* key.hh - Definition of the base Key class
* libhscript, the HorizonScript library for
* Project Horizon
*
* Copyright (c) 2019 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
*/
#include <string>
namespace Horizon {
namespace Keys {
/*! Base Key class, used by all Keys.
* A Getter method is not provided in this base Key class, because each Key may
* return a different type of data. For example, `network` may return `bool`.
*/
class Key {
public:
/*! Create an instance of the Key. */
static Key *create();
/*! Set the data associated with the Key. */
void setData(std::string data);
/*! Determines if the data associated with the Key is valid. */
bool validate();
/*! Executes the action associated with this Key.
* Will always return `false` if `validate` is `false`.
*/
bool execute();
};
/*! Describes a Key class. */
typedef struct KeyDesc {
/*! The name of the Key. */
std::string name;
/*! Determines if the Key is required to be present for the HorizonScript
* to be considered valid. */
bool required;
/*! Determines how many times this Key can be repeated.
* If this value is 0, it can be repeated an unlimited number of times.
* If this value is 1, it can only be present once per HorizonScript.
*/
int repeat;
/*! Order of the Key. Determines when the Key will be executed. */
int order;
/*! The function used to create a new Key of this type. */
Key*(*key_create_fn)(void);
} key_desc_t;
}
}
|