Enzo
Loading...
Searching...
No Matches
Unit.h
1#pragma once
2#include "Engine/Core/Types.h"
3#include <boost/functional/hash.hpp>
4#include <cstddef>
5#include <functional>
6#include <string>
7
8namespace enzo::nt {
9
19struct Unit
20{
21 OpId opId = 0;
22 std::string parm;
23 unsigned int index = 0;
24
26 bool isNode() const { return parm.empty(); }
27
29 bool isParameter() const { return !parm.empty(); }
30
31 bool operator==(const Unit& other) const = default;
32};
33
34} // namespace enzo::nt
35
36// Hashing lives in one place so a Unit can key an unordered container.
37template <> struct std::hash<enzo::nt::Unit>
38{
39 std::size_t operator()(const enzo::nt::Unit& unit) const noexcept
40 {
41 std::size_t seed = 0;
42 boost::hash_combine(seed, unit.opId);
43 boost::hash_combine(seed, unit.parm);
44 boost::hash_combine(seed, unit.index);
45 return seed;
46 }
47};
Basic attribute, parameter, and node types for Enzo.
uint64_t OpId
The unique ID assigned to each node in the network.
Definition Types.h:137
A point in the network graph, either an operator output or a parameter.
Definition Unit.h:20
bool isNode() const
Whether the unit is a whole node rather than one parameter.
Definition Unit.h:26
bool isParameter() const
Whether the unit is one parameter rather than a whole node.
Definition Unit.h:29