The Table Engine
Component Class Reference

Base class for all game components, providing basic component functionalities. More...

#include <component.h>

+ Inheritance diagram for Component:
+ Collaboration diagram for Component:

Public Member Functions

 Component ()
 Default constructor for the Component. More...
 
 Component (std::string name)
 Constructs a Component with a specified name. More...
 
virtual ~Component ()
 Virtual destructor for safe polymorphic use. More...
 
std::string getName ()
 Retrieves the name of the component. More...
 
GameObjectgetOwner ()
 Retrieves the GameObject that owns this component. More...
 
void setName (std::string name)
 Sets the name of the component. More...
 
void setOwner (GameObject *owner)
 Sets the GameObject owner of this component. More...
 
virtual void input ()
 Virtual method for handling input, intended to be overridden by derived components. More...
 
virtual void update ()
 Virtual method for updating the component's state, intended to be overridden by derived components. More...
 
virtual void render ()
 Virtual method for rendering, intended to be overridden by derived components. More...
 

Protected Attributes

std::string m_name
 Name of the component, useful for identification or debugging. More...
 
GameObjectm_owner
 Pointer to the GameObject that owns this component. More...
 

Detailed Description

Base class for all game components, providing basic component functionalities.

This class defines the interface and common functionalities for all components that can be attached to GameObjects. Components can manipulate or extend the capabilities of GameObjects by overriding input, update, and render methods.

Definition at line 24 of file component.h.

Constructor & Destructor Documentation

◆ Component() [1/2]

Component::Component ( )

Default constructor for the Component.

Definition at line 7 of file component.cpp.

◆ Component() [2/2]

Component::Component ( std::string  name)

Constructs a Component with a specified name.

Parameters
nameName of the component.

Definition at line 8 of file component.cpp.

◆ ~Component()

Component::~Component ( )
virtual

Virtual destructor for safe polymorphic use.

Definition at line 9 of file component.cpp.

Member Function Documentation

◆ getName()

std::string Component::getName ( )

Retrieves the name of the component.

Returns
The name of the component as a std::string.

Definition at line 11 of file component.cpp.

◆ getOwner()

GameObject * Component::getOwner ( )

Retrieves the GameObject that owns this component.

Returns
Pointer to the owning GameObject.

Definition at line 15 of file component.cpp.

◆ input()

void Component::input ( )
virtual

Virtual method for handling input, intended to be overridden by derived components.

Definition at line 27 of file component.cpp.

◆ render()

void Component::render ( )
virtual

Virtual method for rendering, intended to be overridden by derived components.

Reimplemented in Texture, AnimationsManager, and Collide.

Definition at line 35 of file component.cpp.

◆ setName()

void Component::setName ( std::string  name)

Sets the name of the component.

Parameters
nameNew name for the component.

Definition at line 19 of file component.cpp.

◆ setOwner()

void Component::setOwner ( GameObject owner)

Sets the GameObject owner of this component.

Parameters
ownerPointer to the GameObject to become the new owner.

Definition at line 23 of file component.cpp.

◆ update()

void Component::update ( )
virtual

Virtual method for updating the component's state, intended to be overridden by derived components.

Reimplemented in Texture, Input, AnimationsManager, Animation, Transform, Collide, and Camera.

Definition at line 31 of file component.cpp.

Member Data Documentation

◆ m_name

std::string Component::m_name
protected

Name of the component, useful for identification or debugging.

Definition at line 27 of file component.h.

◆ m_owner

GameObject* Component::m_owner
protected

Pointer to the GameObject that owns this component.

Definition at line 28 of file component.h.


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