aboutsummaryrefslogtreecommitdiffstats
path: root/include/Types.h
blob: c6f4b9fcb9c257624b5b4bc7541481ce16ad1156 (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
72
73
74
75
76
77
78
79
80
81
82
83
#pragma once

#include <string>
#include <vector>

/**
 * @file Types.h
 * @brief Shared enum types and core data types used by the runtime.
 */

/** @brief Runtime object categories known by the object manager. */
enum OBJECT_TYPE {
    /** A database snapshot grouping relations and tuples. */
    MULTIGROUP,
    /** A relation object. */
    RELATION,
    /** An attribute object (schema metadata). */
    ATTRIBUTE,
    /** A transaction object. */
    TRANSACTION
};

/** @brief Operations that may be supported by an object type. */
enum METHOD {
    /** Opens an object and creates an authorized handle. */
    OPEN,
    /** Closes a previously opened handle. */
    CLOSE,
    /** Parses through a secondary namespace. */
    PARSE,
    /** Performs security checks. */
    SECURITY
};

/** @brief Claims granted to an authenticated connection. */
enum AUTH_CLAIM {
    /** Permission to read object state. */
    READ,
    /** Permission to mutate object state. */
    WRITE
};

/** @brief Authentication strategies supported by the permissions layer. */
enum AUTH_METHOD {
    /** Certificate-based authentication. */
    CERTIFICATE,
    /** Plain-text authentication. */
    PLAIN_TEXT
};

namespace nt
{
    /** @brief A single named value in a tuple, produced by the cursor layer. */
    struct Attribute {
        std::string name;
        std::string value;
    };

    /**
     * @brief A single row of data streamed lazily from the cursor layer.
     *
     * Follows the Volcano pull model: callers repeatedly call Next() to consume
     * one attribute at a time. Returns nullptr when all attributes are exhausted.
     */
    class Tuple {
    public:
        explicit Tuple(std::vector<Attribute> attributes)
            : attributes_(std::move(attributes)) {}

        /** @brief Returns the next attribute, or nullptr when exhausted. */
        const Attribute* Next() {
            if (position_ < attributes_.size())
                return &attributes_[position_++];
            return nullptr;
        }

        void Reset() { position_ = 0; }

    private:
        std::vector<Attribute> attributes_;
        size_t position_ = 0;
    };
}