argument.hpp 778 Bytes
Newer Older
Paul's avatar
Paul committed
1
#ifndef RTG_GUARD_RTGLIB_ARGUMENT_HPP
Paul's avatar
Paul committed
2
#define RTG_GUARD_RTGLIB_ARGUMENT_HPP
Paul's avatar
Paul committed
3
4

#include <rtg/shape.hpp>
Paul's avatar
Paul committed
5
#include <rtg/raw_data.hpp>
Paul's avatar
Paul committed
6
7
8
9
#include <functional>

namespace rtg {

Paul's avatar
Paul committed
10
11
12
13
14
15
/**
 * @brief Arguments passed to instructions
 * 
 * An `argument` can represent a raw buffer of data that either be referenced from another element or it can be owned by the argument. 
 * 
 */
Paul's avatar
Paul committed
16
struct argument : raw_data<argument>
Paul's avatar
Paul committed
17
{
Paul's avatar
Paul committed
18
    argument() {}
Paul's avatar
Paul committed
19

Paul's avatar
Paul committed
20
    argument(shape s, std::function<char*()> d) : data(d), m_shape(s) {}
Paul's avatar
Paul committed
21

Paul's avatar
Paul committed
22
    /// Provides a raw pointer to the data
Paul's avatar
Paul committed
23
    std::function<char*()> data;
Paul's avatar
Paul committed
24

Paul's avatar
Paul committed
25
    /// Whether data is available
Paul's avatar
Paul committed
26
    bool empty() const { return not data; }
Paul's avatar
Paul committed
27

Paul's avatar
Paul committed
28
    const shape& get_shape() const { return this->m_shape; }
Paul's avatar
Paul committed
29
30

    private:
Paul's avatar
Paul committed
31
    shape m_shape;
Paul's avatar
Paul committed
32
33
};

Paul's avatar
Paul committed
34
} // namespace rtg
Paul's avatar
Paul committed
35
36

#endif