SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
Composite.h
1#pragma once
2
3#include <memory>
4#include <vector>
5
6namespace spark::patterns
7{
8 template <typename DerivedType, template<typename> typename Deleter = std::default_delete>
10 {
11 public:
12 explicit Composite(DerivedType* parent);
13 virtual ~Composite();
14
15 Composite(const Composite& other) = delete;
16 Composite(Composite&& other) noexcept = default;
17 Composite& operator=(const Composite& other) = delete;
18 Composite& operator=(Composite&& other) noexcept = default;
19
20 [[nodiscard]] std::vector<DerivedType*> children() const;
21
22 [[nodiscard]] DerivedType* parent();
23 [[nodiscard]] const DerivedType* parent() const;
24
25 [[nodiscard]] DerivedType* root();
26 [[nodiscard]] const DerivedType* root() const;
27
28 private:
29 void add(DerivedType* child);
30 void remove(DerivedType* child);
31 void setParent(DerivedType* parent);
32
33 private:
34 DerivedType* m_parent = nullptr;
35 std::vector<DerivedType*> m_children;
36 };
37}
38
39#include "spark/patterns/impl/Composite.h"
Definition Composite.h:10