Torc  0.1
Public Member Functions | Static Public Member Functions | List of all members
TorcAdminObject Class Referenceabstract

A factory class for automatically running objects outside of the main loop. More...

#include <torcadminthread.h>

Inheritance diagram for TorcAdminObject:
[legend]

Public Member Functions

 TorcAdminObject (int Priority=TORC_ADMIN_LOW_PRIORITY)
 
virtual ~TorcAdminObject ()=default
 
int Priority (void) const
 
TorcAdminObjectGetNextObject (void)
 
virtual void Create (void)=0
 
virtual void Destroy (void)=0
 

Static Public Member Functions

static void CreateObjects (void)
 Iterates through the list of registered TorcAdminObject's and creates them. More...
 
static void DestroyObjects (void)
 Destroys each created admin object. More...
 
static bool HigherPriority (const TorcAdminObject *Object1, const TorcAdminObject *Object2)
 Sort TorcAdminObject's based on relative priorities. More...
 

Detailed Description

A factory class for automatically running objects outside of the main loop.

TorcLocalContext creates a helper thread, TorcAdminThread, when the application is started. TorcAdminThread then calls Create on each static subclass of TorcAdminObject to automatically run certain core functionality outside of the main loop.

Items are created in priority order, with higher priority objects created first.

See also
TorcAdminThread
Note
There is currently no mechanism to dynamically add TorcAdminObjects at run time (e.g. plugins).

Example usage:

static class MyBackgroundActivity : public TorcAdminObject
{
public:
MyBackgroundActivity()
MyWorldDominationObject(nullptr)
{
}
void Create(void)
{
MyWorldDominationObject = new Dominator();
}
void Destroy(void)
{
delete MyWorldDominationObject;
}
} MyBackgroundActivity;

Definition at line 28 of file torcadminthread.h.

Constructor & Destructor Documentation

TorcAdminObject::TorcAdminObject ( int  Priority = TORC_ADMIN_LOW_PRIORITY)
explicit

Definition at line 104 of file torcadminthread.cpp.

virtual TorcAdminObject::~TorcAdminObject ( )
virtualdefault

Member Function Documentation

virtual void TorcAdminObject::Create ( void  )
pure virtual
void TorcAdminObject::CreateObjects ( void  )
static

Iterates through the list of registered TorcAdminObject's and creates them.

Definition at line 134 of file torcadminthread.cpp.

virtual void TorcAdminObject::Destroy ( void  )
pure virtual
void TorcAdminObject::DestroyObjects ( void  )
static

Destroys each created admin object.

Definition at line 167 of file torcadminthread.cpp.

TorcAdminObject * TorcAdminObject::GetNextObject ( void  )

Definition at line 118 of file torcadminthread.cpp.

bool TorcAdminObject::HigherPriority ( const TorcAdminObject Object1,
const TorcAdminObject Object2 
)
static

Sort TorcAdminObject's based on relative priorities.

Definition at line 126 of file torcadminthread.cpp.

int TorcAdminObject::Priority ( void  ) const

Definition at line 113 of file torcadminthread.cpp.


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