WoW Model Viewer
Your premiere tool for viewing, equipping and animating World of Warcraft models.
Loading...
Searching...
No Matches
Component.cpp
Go to the documentation of this file.
1#include "Component.h"
2#include <iostream>
3#include <string>
4
5Component::Component() : m_p_parent(nullptr), m_refCounter(0)
6{
7 m_name = "Component";
8}
9
10Component::~Component() = default;
11
13{
14 return false;
15}
16
18{
19 return false;
20}
21
23{
25}
26
28{
30 if (m_refCounter <= 0)
31 {
32 delete this;
33 }
34}
35
39
41{
42 m_p_parent = a_p_parent;
44}
45
46void Component::setName(const std::string& name)
47{
48 m_name = name;
50}
51
52std::string Component::name() const
53{
54 return m_name;
55}
56
60
61void Component::print(int a_depth /*= 0*/)
62{
63 for (int i = 0; i < a_depth - 1; i++)
64 {
65 std::cout << " ";
66 }
67
68 if (m_p_parent != nullptr)
69 {
70 std::cout << "|-";
71 }
72
73 if (nbChildren() != 0)
74 {
75 std::cout << "+ ";
76 }
77 else
78 {
79 std::cout << " ";
80 }
81
82 doPrint();
83
84 a_depth++;
85
86 for (unsigned int i = 0; i < nbChildren(); i++)
87 {
88 getChild(i)->print(a_depth);
89 }
90}
91
92void Component::copy(const Component& component, bool /* recursive*/)
93{
94 m_name = component.m_name;
95}
96
98{
99 std::cout << m_name << " (address : " << std::hex << this << ")" << std::endl;
100}
Base class for all scene-graph nodes in the component hierarchy.
Definition Component.h:11
void unref()
Decrement the reference counter; deletes this when it reaches zero.
Definition Component.cpp:27
void print(int l_depth=0)
Definition Component.cpp:61
void ref()
Increment the reference counter.
Definition Component.cpp:22
virtual void onNameChanged()
Definition Component.cpp:57
Component * m_p_parent
Definition Component.h:70
virtual unsigned int nbChildren() const
Definition Component.h:26
virtual void doPrint()
Definition Component.cpp:97
std::string name() const
Definition Component.cpp:52
void setName(const std::string &name)
Definition Component.cpp:46
std::string m_name
Definition Component.h:74
unsigned int m_refCounter
Definition Component.h:72
virtual void onParentSet(Component *)
Called after the parent has been set; override for custom logic.
Definition Component.cpp:36
void setParentComponent(Component *)
Set the parent of this component.
Definition Component.cpp:40
void copy(const Component &component, bool)
Definition Component.cpp:92
virtual ~Component()
virtual Component * getChild(unsigned int)
Definition Component.h:29
virtual bool addChild(Component *)
Add a child component to this node.
Definition Component.cpp:12
virtual bool removeChild(Component *)
Remove a child component from this node.
Definition Component.cpp:17