SAGE
A Simple Academic Game Engine
Loading...
Searching...
No Matches
Sage::CLoadingThread< t > Class Template Reference

A thread class for loading images and sounds. More...

#include <SageLoadingThread.h>

Collaboration diagram for Sage::CLoadingThread< t >:

Public Member Functions

 CLoadingThread (CSpriteRenderer *, CMediaList< t >, bool *)
 Constructor.
 
 CLoadingThread (CSound *, CMediaList< t >, bool *)
 Constructor.
 
void operator() ()
 The thread code.
 

Protected Attributes

CMediaList< t > m_cMediaList
 Media list.
 
CSpriteRendererm_pRenderer = nullptr
 Pointer to a sprite renderer.
 
CSoundm_pAudio = nullptr
 Pointer to an audio player.
 
bool * m_pFinished = nullptr
 Pointer to a flag to set when finished.
 

Detailed Description

template<typename t>
class Sage::CLoadingThread< t >

A thread class for loading images and sounds.

Template Parameters
tEnumerated type for images or sounds.

Constructor & Destructor Documentation

◆ CLoadingThread() [1/2]

template<typename t >
Sage::CLoadingThread< t >::CLoadingThread ( CSpriteRenderer * pRenderer,
CMediaList< t > m,
bool * pFlag )

Sprite loading thread constructor. Saves a pointer to a sprite renderer in m_pRenderer, which indicates that we will be loading images. Also saves a media list in m_cMediaList. Sets m_pFinished to point to a boolean variable that will be set to true when the thread is finished.

Template Parameters
tEnumerated type for images.
Parameters
pRendererPointer to a sprite renderer.
mA media descriptor list.
pFlagPointer to a flag to set when finished.

◆ CLoadingThread() [2/2]

template<typename t >
Sage::CLoadingThread< t >::CLoadingThread ( CSound * pAudio,
CMediaList< t > m,
bool * pFlag )

Audio loading thread constructor. Saves a pointer to an audio player in m_pAudio, which indicates that we will be loading audio. Also saves a media list in m_cMediaList. Sets m_pFinished to point to a boolean variable that will be set to true when the thread is finished.

Template Parameters
tEnumerated type for sounds.
Parameters
pAudioPointer to an audio player.
mA media descriptor list.
pFlagPointer to a flag to set when finished.

Member Function Documentation

◆ operator()()

template<typename t >
void Sage::CLoadingThread< t >::operator() ( )

The thread body. Loads the media in the task list. Assumes that if m_pRenderer is not null, then we are loading images, otherwise we are loading audio. If m_pFinished is not null, then the boolean variable that it points to will be set to false when the thread starts and true when it is finished.