sandbox
Loading...
Searching...
No Matches
relationship.hpp
1// SPDX-License-Identifier: MIT
2#ifndef LIBSBX_SCENES_COMPONENTS_RELATIONSHIP_HPP_
3#define LIBSBX_SCENES_COMPONENTS_RELATIONSHIP_HPP_
4
5#include <libsbx/math/uuid.hpp>
6
7#include <vector>
8#include <ranges>
9
10#include <libsbx/scenes/node.hpp>
11
12namespace sbx::scenes {
13
14class relationship final {
15
16public:
17
18 relationship(const node parent)
19 : _parent{parent} { }
20
21 auto parent() const noexcept -> node {
22 return _parent;
23 }
24
25 auto set_parent(const node parent) noexcept -> void {
26 _parent = parent;
27 }
28
29 auto children() const noexcept -> const std::vector<node>& {
30 return _children;
31 }
32
33 auto children() noexcept -> std::vector<node>& {
34 return _children;
35 }
36
37 auto add_child(const node child) -> void {
38 _children.push_back(child);
39 }
40
41 auto remove_child(const node child) -> void {
42 std::erase(_children, child);
43 }
44
45private:
46
47 node _parent;
48 std::vector<node> _children;
49
50}; // class relationship
51
52} // namespace sbx::scenes
53
54#endif // LIBSBX_SCENES_COMPONENTS_RELATIONSHIP_HPP_
Definition: tests.cpp:6
Definition: relationship.hpp:14