GA::kit v0.3
G&A's in-house C++ application framework
Loading...
Searching...
No Matches
component.h
Go to the documentation of this file.
1#pragma once
2#include "ga/defines.h"
3#include <memory>
4
5namespace ga {
6
7class Node;
8class Scene;
9
11{
12public:
13 Component() = default;
14 virtual ~Component() = default;
15
16 Component( const Component& other )
17 {
18 // do not copy m_node
19 }
20
22 {
23 // do not copy m_node
24 return *this;
25 }
26
27 std::shared_ptr<Node> getNode() const
28 {
29 return m_node.lock();
30 }
31
32protected:
33 friend class Node;
34
35 // called by Node
36 virtual void update() {}
37 virtual void draw() {}
38 virtual void setNode( std::shared_ptr<Node> node )
39 {
40 m_node = node;
41 }
42 virtual void setScene( std::shared_ptr<Scene> scene ) {}
43
44 std::weak_ptr<Node> m_node; // node owner
45};
46
47} // namespace ga
Definition: component.h:11
Component & operator=(const Component &other)
Definition: component.h:21
virtual void setScene(std::shared_ptr< Scene > scene)
Definition: component.h:42
virtual void update()
Definition: component.h:36
Component(const Component &other)
Definition: component.h:16
std::shared_ptr< Node > getNode() const
Definition: component.h:27
virtual ~Component()=default
virtual void setNode(std::shared_ptr< Node > node)
Definition: component.h:38
Component()=default
virtual void draw()
Definition: component.h:37
std::weak_ptr< Node > m_node
Definition: component.h:44
Node represents a basic "node" (or view) in the scenegraph.
Definition: node.h:46
Definition: color.h:9