MythTV  master
Public Member Functions | Private Member Functions | Private Attributes | List of all members
HouseKeeperTask Class Reference

Definition for a single task to be run by the HouseKeeper. More...

#include <housekeeper.h>

Inheritance diagram for HouseKeeperTask:
Inheritance graph
[legend]
Collaboration diagram for HouseKeeperTask:
Collaboration graph
[legend]

Public Member Functions

 HouseKeeperTask (const QString &dbTag, HouseKeeperScope scope=kHKGlobal, HouseKeeperStartup startup=kHKNormal)
 
 ~HouseKeeperTask () override=default
 
bool CheckRun (const QDateTime &now)
 
bool Run (void)
 
bool ConfirmRun (void) const
 
bool IsRunning (void) const
 
bool CheckImmediate (void)
 
bool CheckStartup (void)
 
QString GetTag (void)
 
QDateTime GetLastRun (void)
 
QDateTime GetLastSuccess (void)
 
HouseKeeperScope GetScope (void)
 
QDateTime QueryLastRun (void)
 
QDateTime QueryLastSuccess (void)
 
QDateTime UpdateLastRun (bool successful=true)
 
virtual QDateTime UpdateLastRun (const QDateTime &last, bool successful=true)
 
virtual void SetLastRun (const QDateTime &last, bool successful=true)
 
virtual bool DoCheckRun (const QDateTime &)
 
virtual bool DoRun (void)
 
virtual void Terminate (void)
 
- Public Member Functions inherited from ReferenceCounter
 ReferenceCounter (const QString &debugName, bool logDebug=true)
 Creates reference counter with an initial value of 1. More...
 
virtual int IncrRef (void)
 Increments reference count. More...
 
virtual int DecrRef (void)
 Decrements reference count and deletes on 0. More...
 

Private Member Functions

void QueryLast (void)
 

Private Attributes

QString m_dbTag
 
bool m_confirm {false}
 
HouseKeeperScope m_scope
 
HouseKeeperStartup m_startup
 
bool m_running {false}
 
QDateTime m_lastRun
 
QDateTime m_lastSuccess
 
QDateTime m_lastUpdate
 

Additional Inherited Members

- Static Public Member Functions inherited from ReferenceCounter
static void PrintDebug (void)
 Print out any leaks if that level of debugging is enabled. More...
 
- Protected Member Functions inherited from ReferenceCounter
virtual ~ReferenceCounter (void)
 Called on destruction, will warn if object deleted with references in place. More...
 
- Protected Attributes inherited from ReferenceCounter
bool m_logDebug
 This is used to suppress creating LoggingItem classes for LoggingItem reference count changes. More...
 
QAtomicInt m_referenceCount {1}
 

Detailed Description

Definition for a single task to be run by the HouseKeeper.

This class contains instructions for tasks to be run periodically by the housekeeper. Each task requires an identification tag, and can be given a two options to control scope and startup behavior. Each child class should override at least two methods: DoCheckRun() and DoRun().

DoCheckRun() is to perform a check as to whether the task should be run, returning a boolean 'true' if it should.

DoRun() actually implements the task to be run.

Child classes can also implement a Terminate() method, which is to be used to stop in-progress tasks when the application is shutting down.

The HouseKeeperScope attribute passed to the class in the constructor controls in what scope the task should operate. kHKGlobal means the task should only operate once globally. If another housekeeper in another or on another machine runs a task, this instance should track that and not run itself until the next time to run comes. kHKLocal has similar meaning, but only on the local machine, rather than the whole MythTV cluster. kHKInst means no communication is necessary, as each process instance is to operate independently.

The HouseKeeperStartup attribute passed to the class in the constructor controls the startup behavior of the task. kHKNormal means the task will never run until application control has passed to the main event loop and the HouseKeeper's check scan has run at least once. kHKRunOnStartup means the task is queued to run when on startup, and will be run as soon as a HouseKeeperThread is started to handle it. kHKRunImmediatelyOnStartup means the task will be run immediately in the primary thread. Do not use this for long tasks as it will delay application startup and handoff to the main event loop.

Definition at line 40 of file housekeeper.h.

Constructor & Destructor Documentation

◆ HouseKeeperTask()

HouseKeeperTask::HouseKeeperTask ( const QString &  dbTag,
HouseKeeperScope  scope = kHKGlobal,
HouseKeeperStartup  startup = kHKNormal 
)
explicit

Definition at line 98 of file housekeeper.cpp.

◆ ~HouseKeeperTask()

HouseKeeperTask::~HouseKeeperTask ( )
overridedefault

Member Function Documentation

◆ CheckRun()

bool HouseKeeperTask::CheckRun ( const QDateTime &  now)

Definition at line 108 of file housekeeper.cpp.

◆ Run()

bool HouseKeeperTask::Run ( void  )

Definition at line 142 of file housekeeper.cpp.

Referenced by HouseKeepingThread::run().

◆ ConfirmRun()

bool HouseKeeperTask::ConfirmRun ( void  ) const
inline

Definition at line 49 of file housekeeper.h.

Referenced by HouseKeepingThread::run().

◆ IsRunning()

bool HouseKeeperTask::IsRunning ( void  ) const
inline

Definition at line 50 of file housekeeper.h.

◆ CheckImmediate()

bool HouseKeeperTask::CheckImmediate ( void  )

Definition at line 126 of file housekeeper.cpp.

◆ CheckStartup()

bool HouseKeeperTask::CheckStartup ( void  )

Definition at line 132 of file housekeeper.cpp.

◆ GetTag()

QString HouseKeeperTask::GetTag ( void  )
inline

◆ GetLastRun()

QDateTime HouseKeeperTask::GetLastRun ( void  )
inline

◆ GetLastSuccess()

QDateTime HouseKeeperTask::GetLastSuccess ( void  )
inline

Definition at line 57 of file housekeeper.h.

Referenced by PeriodicHouseKeeperTask::CalculateWindow().

◆ GetScope()

HouseKeeperScope HouseKeeperTask::GetScope ( void  )
inline

Definition at line 58 of file housekeeper.h.

◆ QueryLastRun()

QDateTime HouseKeeperTask::QueryLastRun ( void  )

Definition at line 171 of file housekeeper.cpp.

◆ QueryLastSuccess()

QDateTime HouseKeeperTask::QueryLastSuccess ( void  )

Definition at line 177 of file housekeeper.cpp.

◆ UpdateLastRun() [1/2]

QDateTime HouseKeeperTask::UpdateLastRun ( bool  successful = true)
inline

◆ UpdateLastRun() [2/2]

QDateTime HouseKeeperTask::UpdateLastRun ( const QDateTime &  last,
bool  successful = true 
)
virtual

Reimplemented in PeriodicHouseKeeperTask.

Definition at line 222 of file housekeeper.cpp.

◆ SetLastRun()

void HouseKeeperTask::SetLastRun ( const QDateTime &  last,
bool  successful = true 
)
virtual

Reimplemented in PeriodicHouseKeeperTask.

Definition at line 309 of file housekeeper.cpp.

Referenced by PeriodicHouseKeeperTask::SetLastRun().

◆ DoCheckRun()

virtual bool HouseKeeperTask::DoCheckRun ( const QDateTime &  )
inlinevirtual

◆ DoRun()

virtual bool HouseKeeperTask::DoRun ( void  )
inlinevirtual

◆ Terminate()

virtual void HouseKeeperTask::Terminate ( void  )
inlinevirtual

Reimplemented in MythFillDatabaseTask, ArtworkTask, ThemeUpdateTask, and RadioStreamUpdateTask.

Definition at line 69 of file housekeeper.h.

◆ QueryLast()

void HouseKeeperTask::QueryLast ( void  )
private

Definition at line 183 of file housekeeper.cpp.

Referenced by QueryLastRun(), and QueryLastSuccess().

Member Data Documentation

◆ m_dbTag

QString HouseKeeperTask::m_dbTag
private

Definition at line 74 of file housekeeper.h.

Referenced by QueryLast(), Run(), and UpdateLastRun().

◆ m_confirm

bool HouseKeeperTask::m_confirm {false}
private

Definition at line 75 of file housekeeper.h.

Referenced by CheckRun(), CheckStartup(), and UpdateLastRun().

◆ m_scope

HouseKeeperScope HouseKeeperTask::m_scope
private

Definition at line 76 of file housekeeper.h.

Referenced by QueryLast(), and UpdateLastRun().

◆ m_startup

HouseKeeperStartup HouseKeeperTask::m_startup
private

Definition at line 77 of file housekeeper.h.

Referenced by CheckImmediate(), and CheckStartup().

◆ m_running

bool HouseKeeperTask::m_running {false}
private

Definition at line 78 of file housekeeper.h.

Referenced by CheckRun(), and Run().

◆ m_lastRun

QDateTime HouseKeeperTask::m_lastRun
private

Definition at line 80 of file housekeeper.h.

Referenced by QueryLast(), QueryLastRun(), QueryLastSuccess(), SetLastRun(), and UpdateLastRun().

◆ m_lastSuccess

QDateTime HouseKeeperTask::m_lastSuccess
private

Definition at line 81 of file housekeeper.h.

Referenced by QueryLast(), SetLastRun(), and UpdateLastRun().

◆ m_lastUpdate

QDateTime HouseKeeperTask::m_lastUpdate
private

Definition at line 82 of file housekeeper.h.

Referenced by QueryLast(), SetLastRun(), and UpdateLastRun().


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