CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
GraphNode.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "Forward.hpp"
11
12#include "GraphSocket.hpp"
13
18
19namespace CeresEngine {
20
21 class GraphNode : public RefCounted<GraphNode> {
22 protected:
24
27
31
32 public:
34
37
40
41 public:
42 explicit GraphNode(Graph& graph, const UUID& uuid) : mGraph(&graph), mUUID(uuid) {}
44
45 public:
48
50 [[nodiscard]] const UUID& getUUID() const noexcept { return mUUID; }
51
54
57
59
60 public: // Socket management
62
65
68
71
73
75 template<typename T> [[nodiscard]] GraphSocket& addSocket(String name, const GraphSocketDirection direction) { return addSocket(std::move(name), direction); }
76
78
80 template<typename T> [[nodiscard]] GraphSocket& addInputSocket(String name) { return addInputSocket(std::move(name)); }
81
83
85 template<typename T> [[nodiscard]] GraphSocket& addOutputSocket(String name) { return addOutputSocket(std::move(name)); }
86
89
90 void forEachSocket(std::function<void(GraphSocket&)> function);
91
92 public: // Graph interface
93 friend class Graph;
94
95 void onAttach(Graph& graph, const UUID& uuid);
96 void onDetach(const Graph& graph);
97
98 public: // Change tracking
100 };
101
102} // namespace CeresEngine
Definition GraphConnection.hpp:19
Definition Graph.hpp:20
Definition GraphNode.hpp:21
GraphSocket & addInputSocket(String name)
Definition GraphNode.hpp:80
void setDisplayName(String displayName)
GraphSocket & addSocket(String name, const GraphSocketDirection direction)
Definition GraphNode.hpp:75
Event< void(GraphSocket &)> onSocketAdded
Definition GraphNode.hpp:35
const Vector< GraphSocket * > & getOutputs() const noexcept
Definition GraphNode.hpp:67
Graph * getGraph() const noexcept
Definition GraphNode.hpp:47
Event< void(GraphConnection &)> onConnect
Definition GraphNode.hpp:38
Vector< GraphSocketPtr > mSockets
Definition GraphNode.hpp:30
GraphSocket * getSocket(StringView name) const
Vector< GraphSocket * > mOutputs
Definition GraphNode.hpp:29
void removeSocket(GraphSocket &socket)
StringView getNodeTypeName() const
const UUID & getUUID() const noexcept
Definition GraphNode.hpp:50
const Vector< GraphSocket * > & getInputSockets() const noexcept
Definition GraphNode.hpp:64
void forEachSocket(std::function< void(GraphSocket &)> function)
void onDetach(const Graph &graph)
void removeSocket(StringView name)
GraphSocket & addInputSocket(String name)
Definition GraphNode.hpp:77
GraphNode(Graph &graph, const UUID &uuid)
Definition GraphNode.hpp:42
const Vector< GraphSocketPtr > & getSockets() const noexcept
Definition GraphNode.hpp:70
Graph * mGraph
Definition GraphNode.hpp:23
StringView getDisplayName() const noexcept
Definition GraphNode.hpp:53
GraphSocket & addSocket(String name, GraphSocketDirection direction)
void onAttach(Graph &graph, const UUID &uuid)
GraphSocket & addOutputSocket(String name)
Definition GraphNode.hpp:82
UUID mUUID
Definition GraphNode.hpp:25
virtual ~GraphNode() noexcept=default
Event< void()> onChange
Definition GraphNode.hpp:33
Event< void(GraphSocket &)> onSocketRemoved
Definition GraphNode.hpp:36
String mDisplayName
Definition GraphNode.hpp:26
Event< void(GraphConnection &)> onDisconnect
Definition GraphNode.hpp:39
GraphSocket & addOutputSocket(String name)
Definition GraphNode.hpp:85
Vector< GraphSocket * > mInputs
Definition GraphNode.hpp:28
Definition GraphSocket.hpp:46
A simple reference counter base class.
Definition SmartPtr.hpp:438
Base template for the event class.
Definition Event.hpp:27
Definition Application.hpp:19
std::vector< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Vector
Vector is a sequence container that encapsulates dynamic size arrays.
Definition Vector.hpp:17
GraphSocketDirection
Enumeration that determines the direction of a socket.
Definition GraphSocket.hpp:21
@ Output
Determines that the socket takes a value as output.
@ Input
Determines that the socket takes a value as input.
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Represents a universally unique identifier (UUID).
Definition UUID.hpp:27