-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththinker.hpp
More file actions
58 lines (45 loc) · 1.48 KB
/
thinker.hpp
File metadata and controls
58 lines (45 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef THINKER_H
#define THINKER_H
#include <Nostalgia/things/thing.hpp>
class Thinker : public Thing
{
public:
SET_SUPER(Thing)
SET_TYPEID(ThingType::Thinker)
SET_VARIABLES_OVERRIDE
GET_VARIABLES_OVERRIDE
bool Visible() const;
void SetVisible(bool);
IdSet_t Children() const;
ID Parent() const;
Error SetParent(ID inParentID);
// Equivalent to calling `SetParent` with the current parent's parent. If the current parent
// has no parent (e.g: `ID::Invalid`), nothing happens (if you would consult the graphs).
Error DropParent();
protected:
friend class Theatre;
struct Relative
{
Relative() noexcept {}
Relative(Farg<Shared<Thinker>> inThinker) noexcept:
uid{inThinker->uid()},
type{inThinker->Type()},
name{inThinker->name()} {}
ID uid{};
PID type{};
std::string name{};
constexpr bool invalid() const noexcept
{ return uid.invalid() or type.invalid(); }
};
bool mVisible{true};
virtual void OnChildAdded(Relative) {}
virtual void OnChildRemoved(Relative) {}
virtual void OnParentChanged(Relative inNewParent, Relative inOldParent = {}) {}
virtual void OnAncestorAdded(Relative) {}
virtual void OnAncestorRemoved(Relative) {}
virtual void OnDescendantAdded(Relative) {}
virtual void OnDescendantRemoved(Relative) {}
};
template<typename T>
concept Thinker_t = std::derived_from<T, Thinker>;
#endif // THINKER_H