Wasabi
Public Member Functions | Protected Attributes | List of all members
WBase Class Referenceabstract

#include <WBase.hpp>

Inheritance diagram for WBase:
WCamera WConstraint WFileAsset WParticles WPhysicsAction WRenderTarget WRigidBody WSprite WTerrain

Public Member Functions

 WBase (class Wasabi *const app, uint32_t ID=0)
 
virtual std::string GetTypeName () const =0
 
virtual void SetID (uint32_t newID)=0
 
virtual void SetName (std::string newName)=0
 
uint32_t GetID () const
 
std::string GetName () const
 
class WasabiGetAppPtr () const
 
void AddReference ()
 
void RemoveReference ()
 
virtual bool Valid () const =0
 

Protected Attributes

class Wasabim_app
 
uint32_t m_ID
 
std::string m_name
 

Detailed Description

This is the base class, used as a parent for most engine classes (such as WObject, WImage, etc...). It provides a unified way of managing objects such that they all have IDs, names, managers, and can be freed using reference counting. Initially, a WBase has a reference count of 1. If the count ever reaches 0, the object will delete itself. So an application should NEVER delete or free an object that inherits from WBase, but should simply call its RemoveReference() instead.

Member Function Documentation

◆ AddReference()

void WBase::AddReference ( )

Add to the reference count.

◆ GetAppPtr()

class Wasabi* WBase::GetAppPtr ( ) const

Retrieves a pointer to the Wasabi class used to create this object.

Returns
A pointer to the Wasabi class

◆ GetID()

uint32_t WBase::GetID ( ) const

Retrieves the ID of this object.

Returns
The ID of this object

◆ GetName()

std::string WBase::GetName ( ) const

Retrieves the name of this object.

Returns
The name of the object

◆ GetTypeName()

virtual std::string WBase::GetTypeName ( ) const
pure virtual

This function must be implemented by a child class. This is used for debugging, in which a class should return its name.

Returns
The name of the class

Implemented in WEffect, WShader, WParticles, WGeometry, WObject, WAnimation, WOpenALSound, WImage, WMaterial, WSprite, WLight, WRenderTarget, WCamera, WTerrain, and WBulletRigidBody.

◆ RemoveReference()

void WBase::RemoveReference ( )

Remove from the reference count. If the reference count reaches 0, this object destroys itself

◆ SetID()

virtual void WBase::SetID ( uint32_t  newID)
pure virtual

Sets the ID of this object and notifies its manager.

Parameters
newIDNew ID

Implemented in WEffect, WShader, WParticles, WGeometry, WObject, WAnimation, WOpenALSound, WImage, WMaterial, WSprite, WLight, WRenderTarget, WCamera, WTerrain, and WBulletRigidBody.

◆ SetName()

virtual void WBase::SetName ( std::string  newName)
pure virtual

Sets the name of this object.

Parameters
nameNew name for the object

Implemented in WEffect, WShader, WParticles, WGeometry, WObject, WAnimation, WOpenALSound, WImage, WMaterial, WSprite, WLight, WRenderTarget, WCamera, WTerrain, and WBulletRigidBody.

◆ Valid()

virtual bool WBase::Valid ( ) const
pure virtual

Must be implemented by the child. This function should report the validity status of the object, in whatever sense of "validity" it chooses.

Returns
true if the object is "valid", false otherwise

Implemented in WEffect, WGeometry, WShader, WParticles, WObject, WImage, WCamera, WRenderTarget, WSprite, WLight, WMaterial, WTerrain, WBulletRigidBody, WOpenALSound, WPhysicsAction, WSkeleton, WConstraint, and WRigidBody.

Member Data Documentation

◆ m_app

class Wasabi* WBase::m_app
protected

The Wasabi application under which this object is created

◆ m_ID

uint32_t WBase::m_ID
protected

ID of this object

◆ m_name

std::string WBase::m_name
protected

Name of this object


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