![]() |
MAGE
v0.171.0
Matthias Advanced Game Engine
|
#include <node.hpp>
Public Types | |
using | NodePtr = ProxyPtr< Node > |
using | ComponentPtr = ProxyPtr< Component > |
Public Member Functions | |
Node (std::string name="") | |
Node (const Node &node) | |
Node (Node &&node) noexcept | |
virtual | ~Node () |
Node & | operator= (const Node &node)=delete |
Node & | operator= (Node &&node) noexcept |
Transform & | GetTransform () noexcept |
const Transform & | GetTransform () const noexcept |
bool | HasParent () const noexcept |
NodePtr | GetParent () const noexcept |
std::size_t | GetNumberOfChilds () const noexcept |
bool | ContainsChilds () const |
bool | ContainsChild (ProxyPtr< const Node > node) const |
void | AddChild (NodePtr node) |
void | RemoveChild (NodePtr node) |
void | RemoveAllChilds () noexcept |
template<typename ActionT > | |
void | ForEachChild (ActionT &&action) const |
template<typename ActionT > | |
void | ForEachDescendant (ActionT &&action) const |
template<typename ComponentT > | |
bool | Contains () const noexcept |
bool | ContainsComponents () const noexcept |
std::size_t | GetNumberOfComponents () const noexcept |
template<typename ComponentT > | |
std::size_t | GetNumberOf () const noexcept |
template<typename ComponentT > | |
ProxyPtr< ComponentT > | Get () noexcept |
template<typename ComponentT > | |
ProxyPtr< const ComponentT > | Get () const noexcept |
template<typename ComponentT > | |
const std::vector< ProxyPtr< ComponentT > > | GetAll () |
template<typename ComponentT > | |
const std::vector< ProxyPtr< const ComponentT > > | GetAll () const |
template<typename ComponentT > | |
void | Add (ProxyPtr< ComponentT > component) |
template<typename ComponentT , typename ActionT > | |
void | ForEach (ActionT &&action) |
template<typename ComponentT , typename ActionT > | |
void | ForEach (ActionT &&action) const |
template<typename ActionT > | |
void | ForEachComponent (ActionT &&action) |
template<typename ActionT > | |
void | ForEachComponent (ActionT &&action) const |
State | GetState () const noexcept |
void | SetState (State state) noexcept |
U64 | GetGuid () const noexcept |
NodePtr | Get () const noexcept |
const std::string_view | GetName () const noexcept |
void | SetName (std::string name) noexcept |
void | Set (NodePtr ptr) noexcept |
Private Attributes | |
Transform | m_transform |
NodePtr | m_parent |
std::vector< NodePtr > | m_childs |
std::unordered_multimap< std::type_index, ComponentPtr > | m_components |
State | m_state |
U64 | m_guid |
NodePtr | m_this |
std::string | m_name |
A class of nodes.
using mage::Node::ComponentPtr = ProxyPtr< Component > |
A pointer to a component.
using mage::Node::NodePtr = ProxyPtr< Node > |
A pointer to a node.
|
explicit |
Constructs a node.
[in] | name | The name of the node. |
mage::Node::Node | ( | const Node & | node | ) |
Constructs a node from the given node.
[in] | node | A reference to the node. |
|
noexcept |
Constructs a node by moving the given node.
[in] | node | A reference to the node to move. |
|
virtualdefault |
Destructs this node.
void mage::Node::Add | ( | ProxyPtr< ComponentT > | component | ) |
Adds the given component to this node.
ComponentT | The component type. |
[in] | component | A pointer to the component. |
void mage::Node::AddChild | ( | NodePtr | node | ) |
Adds the given node to the childs of this node.
[in] | node | A pointer to the node. |
|
noexcept |
Checks whether this node contains a component of the given type.
ComponentT | The component type. |
true
if this node contains at least one component of the given type. false
otherwise. Checks whether this node contains the given node as a child.
[in] | node | A pointer to the node. |
true
if this node contains the given node as a child. false
otherwise. bool mage::Node::ContainsChilds | ( | ) | const |
Checks whether this node contains childs.
true
if this node contains at least one child. false
otherwise.
|
noexcept |
Checks whether this node contains components.
true
if this node contains at least one component. false
otherwise. void mage::Node::ForEach | ( | ActionT && | action | ) |
Traverses all components of the given type of this node.
ComponentT | The component type. |
ActionT | An action to perform on all components of the given type of this node. The action must accept ComponentT& values. |
[in] | action | The action. |
void mage::Node::ForEach | ( | ActionT && | action | ) | const |
Traverses all components of the given type of this node.
ComponentT | The component type. |
ActionT | An action to perform on all components of the given type of this node. The action must accept const ComponentT& values. |
[in] | action | The action. |
void mage::Node::ForEachChild | ( | ActionT && | action | ) | const |
Traverses all childs of this node.
ActionT | An action to perform on all childs of this node. The action must accept Node& values. |
[in] | action | The action. |
void mage::Node::ForEachComponent | ( | ActionT && | action | ) |
Traverses all components of this node.
ActionT | An action to perform on all components of this node. The action must accept Component& values. |
[in] | action | The action. |
void mage::Node::ForEachComponent | ( | ActionT && | action | ) | const |
Traverses all components of this node.
ActionT | An action to perform on all components of this node. The action must accept const Component& values. |
[in] | action | The action. |
void mage::Node::ForEachDescendant | ( | ActionT && | action | ) | const |
Traverses all descendants (childs included) of this node.
ActionT | An action to perform on all descendants of this node. The action must accept Node& values. |
[in] | action | The action. |
|
noexcept |
Returns the first component of the given type of this node.
ComponentT | The component type. |
nullptr
if this node has no component of the given type.
|
noexcept |
Returns the first component of the given type of this node.
ComponentT | The component type. |
nullptr
if this node has no component of the given type.
|
noexcept |
Returns a pointer to this node.
const std::vector< ProxyPtr< ComponentT > > mage::Node::GetAll | ( | ) |
Returns all components of the given type of this node.
ComponentT | The component type. |
const std::vector< ProxyPtr< const ComponentT > > mage::Node::GetAll | ( | ) | const |
Returns all components of the given type of this node.
ComponentT | The component type. |
|
noexcept |
Returns the guid of this node.
|
noexcept |
Returns the name of this node.
|
noexcept |
Returns the number of components of the given type of this node.
ComponentT | The component type. |
|
noexcept |
Returns the number of childs of this node.
|
noexcept |
Returns the number of components of this node.
|
noexcept |
Returns the parent of this node.
|
noexcept |
Returns the state of this node.
|
noexcept |
Returns the transform of this node.
|
noexcept |
Returns the transform of this node.
|
noexcept |
Checks whether this node has a parent.
true
if this node has a parent. false
otherwise. Copies the given node to this node.
[in] | node | A reference to the node to copy. |
Moves the given node to this node.
[in] | node | A reference to the node to move. |
|
noexcept |
Removes all childs from this node.
void mage::Node::RemoveChild | ( | NodePtr | node | ) |
Removes the given node from the childs of this node.
[in] | node | A pointer to the node. |
|
noexcept |
Sets the pointer of this node to the given pointer.
[in] | ptr | The pointer. |
|
noexcept |
Sets the name of this node to the given string.
[in] | name | The name. |
|
noexcept |
Sets the state of this node to the given state.
[in] | state | The state. |
|
private |
A vector containing pointers to the the childs of this node.
|
private |
A multimap containing pointers to the components of this node as values with their associated type as key.
|
private |
The guid of this node.
|
private |
The name of this node.
|
private |
A pointer to the parent of this node.
|
private |
The state of this node.
|
private |
A pointer to this node.
|
private |
The transform of this node.