Repository navigation
Expand file tree
/
Copy pathvalue_node.h
More file actions
77 lines (68 loc) · 1.6 KB
/
Copy pathvalue_node.h
File metadata and controls
77 lines (68 loc) · 1.6 KB
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
////////////////////////////////////////////////////////////////////////////////
// Distributed under the Boost Software License, Version 1.0. //
// (See accompanying file LICENSE or copy at //
// https://www.boost.org/LICENSE_1_0.txt) //
////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <cstddef>
#include <string_view>
#include <typeindex>
#include <typeinfo>
#include "graphics/render_graph/node.h"
#include "graphics/render_graph/shader_compiler.h"
namespace iris
{
/**
* Implementation of Node which provides access to a constant value. See
* compiler.h for supported types.
*/
template <class T>
class ValueNode : public Node
{
public:
/**
* Create a new ValueNode.
*
* @param value
* Value to provide access to.
*/
ValueNode(const T &value)
: value_(value)
{
}
~ValueNode() override = default;
/**
* Accept a compiler visitor.
*
* @param compiler
* Compiler to accept.
*/
void accept(ShaderCompiler &compiler) const override
{
return compiler.visit(*this);
}
/**
* Get value.
*
* @returns
* Value.
*/
T value() const
{
return value_;
}
/**
* Compute hash of node.
*
* @return
* Hash of node.
*/
std::size_t hash() const override
{
return combine_hash(value_, std::string_view{"value_node"}, std::type_index(typeid(T)));
}
private:
/** Value. */
T value_;
};
}