Oxygen Engine
Modern C++ 3D Engine using OpenGL
Loading...
Searching...
No Matches
node_ptr.h
1#ifndef OE_SCENE_NODE_PTR_H
2#define OE_SCENE_NODE_PTR_H
3
4#include <cstdint>
5
6namespace oe::scene
7{
8 class Node;
9 class Scene;
10
17 //template <typename NodeType = Node, typename SceneType = Scene>
18 struct NodePtr
19 {
20 // Todo remove when template
21 using NodeType = Node;
22 using SceneType = Scene;
23
24 NodeType& operator*() const
25 {
26 return *get();
27 }
28
29 NodeType* operator->() const
30 {
31 return get();
32 }
33
37 bool operator==(const NodePtr& other) const
38 {
39 return scene == other.scene && id_node == other.id_node;
40 }
41
49 [[nodiscard]] NodeType* get() const noexcept;
50
51 operator bool() const noexcept
52 {
53 return id_node != 0;
54 }
55
59 SceneType* scene = nullptr;
60
64 uint64_t id_node = 0;
65 };
66
67}
68
69#endif
Scene node.
Definition node.h:30
Logical scene manager.
Definition scene.h:18
Scene related management (Render-agnostic Geometry, Manger, etc...)
Definition debug.h:19
Wrapper to a node reference to use pointers to node even if the actual node moves in memory.
Definition node_ptr.h:19
NodeType * get() const noexcept
Returns a pointer to the referenced node.
bool operator==(const NodePtr &other) const
Equality operator.
Definition node_ptr.h:37
uint64_t id_node
Node id, unique to the scene.
Definition node_ptr.h:64
SceneType * scene
Scene containing the Node.
Definition node_ptr.h:59