Sparkle 0.0.1
Loading...
Searching...
No Matches
spk::InherenceObject< TType > Class Template Reference

Provides parent/child ownership links for tree structures. More...

#include <spk_inherence_object.hpp>

Inheritance diagram for spk::InherenceObject< TType >:
Inheritance graph
Collaboration diagram for spk::InherenceObject< TType >:
Collaboration graph

Public Member Functions

virtual void addChild (TType *p_child)
 Adds a child to this node, handling reparenting as needed.
virtual void removeChild (TType *p_child)
 Removes a child from this node.
TType * parent () const
 Returns the parent pointer.
virtual std::vector< TType * > & children ()
 Returns the children vector.
virtual const std::vector< TType * > & children () const
 Returns the children vector.
void clearChildren ()
 Clears the children list and resets each child's parent pointer.

Detailed Description

template<typename TType>
class spk::InherenceObject< TType >

Provides parent/child ownership links for tree structures.

Template Parameters
TTypeDerived type inheriting from InherenceObject.
See also
InherenceWithPriorityObject
struct Node : spk::InherenceObject<Node> {};
Node parent;
Node child;
parent.addChild(&child);
Provides parent/child ownership links for tree structures.
Definition spk_inherence_object.hpp:22
TType * parent() const
Returns the parent pointer.
Definition spk_inherence_object.hpp:85
virtual void addChild(TType *p_child)
Adds a child to this node, handling reparenting as needed.
Definition spk_inherence_object.hpp:46

Member Function Documentation

◆ addChild()

template<typename TType>
virtual void spk::InherenceObject< TType >::addChild ( TType * p_child)
inlinevirtual

Adds a child to this node, handling reparenting as needed.

Parameters
p_childChild pointer; ignored if null or self.

Reimplemented in spk::Entity, spk::InherenceWithPriorityObject< TType >, and spk::Widget.

Here is the caller graph for this function:

◆ children() [1/2]

template<typename TType>
virtual std::vector< TType * > & spk::InherenceObject< TType >::children ( )
inlinevirtual

Returns the children vector.

Returns
Mutable reference to children.

Reimplemented in spk::Entity.

Here is the caller graph for this function:

◆ children() [2/2]

template<typename TType>
virtual const std::vector< TType * > & spk::InherenceObject< TType >::children ( ) const
inlinevirtual

Returns the children vector.

Returns
Const reference to children.

◆ parent()

template<typename TType>
TType * spk::InherenceObject< TType >::parent ( ) const
inline

Returns the parent pointer.

Returns
Parent node or nullptr.
Here is the caller graph for this function:

◆ removeChild()

template<typename TType>
virtual void spk::InherenceObject< TType >::removeChild ( TType * p_child)
inlinevirtual

Removes a child from this node.

Parameters
p_childChild pointer to remove.

Reimplemented in spk::Entity.

Here is the caller graph for this function:

The documentation for this class was generated from the following file: