MythTV  master
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
ProgramInfoCache Class Reference

#include <programinfocache.h>

Collaboration diagram for ProgramInfoCache:
Collaboration graph
[legend]

Public Types

enum  UpdateState { PIC_NONE = 0x00, PIC_MARK_CHANGED = 0x01, PIC_RECGROUP_CHANGED = 0x02, PIC_NO_ACTION = 0x80 }
 

Public Member Functions

 Q_DECLARE_FLAGS (UpdateStates, UpdateState)
 
 ProgramInfoCache (QObject *o)
 
 ~ProgramInfoCache ()
 
void ScheduleLoad (bool updateUI=true)
 
bool IsLoadInProgress (void) const
 
void WaitForLoadToComplete (void) const
 
void Refresh (void)
 Refreshed the cache. More...
 
void Add (const ProgramInfo &pginfo)
 Adds a ProgramInfo to the cache. More...
 
bool Remove (uint recordingID)
 Marks a ProgramInfo in the cache for deletion on the next call to Refresh(). More...
 
ProgramInfoCache::UpdateStates Update (const ProgramInfo &pginfo)
 Updates a ProgramInfo in the cache. More...
 
void UpdateFileSize (uint recordingID, uint64_t filesize, UpdateStates flags)
 Updates a ProgramInfo in the cache. More...
 
void GetOrdered (std::vector< ProgramInfo * > &list, bool newest_first=false)
 
bool empty (void) const
 
ProgramInfoGetRecordingInfo (uint recordingID) const
 

Private Types

using Cache = QHash< uint, ProgramInfo * >
 

Private Member Functions

void Load (bool updateUI=true)
 
void Clear (void)
 Clears the cache, m_lock must be held when this is called. More...
 

Private Attributes

QMutex m_lock
 
Cache m_cache
 
std::vector< ProgramInfo * > * m_nextCache {nullptr}
 
QObject * m_listener {nullptr}
 
bool m_loadIsQueued {false}
 
uint m_loadsInProgress {0}
 
QWaitCondition m_loadWait
 

Friends

class ProgramInfoLoader
 

Detailed Description

Definition at line 20 of file programinfocache.h.

Member Typedef Documentation

◆ Cache

using ProgramInfoCache::Cache = QHash<uint,ProgramInfo*>
private

Definition at line 62 of file programinfocache.h.

Member Enumeration Documentation

◆ UpdateState

Enumerator
PIC_NONE 
PIC_MARK_CHANGED 
PIC_RECGROUP_CHANGED 
PIC_NO_ACTION 

Definition at line 25 of file programinfocache.h.

Constructor & Destructor Documentation

◆ ProgramInfoCache()

ProgramInfoCache::ProgramInfoCache ( QObject *  o)
inlineexplicit

Definition at line 33 of file programinfocache.h.

◆ ~ProgramInfoCache()

ProgramInfoCache::~ProgramInfoCache ( )

Definition at line 53 of file programinfocache.cpp.

Member Function Documentation

◆ Q_DECLARE_FLAGS()

ProgramInfoCache::Q_DECLARE_FLAGS ( UpdateStates  ,
UpdateState   
)

◆ ScheduleLoad()

void ProgramInfoCache::ScheduleLoad ( bool  updateUI = true)

◆ IsLoadInProgress()

bool ProgramInfoCache::IsLoadInProgress ( void  ) const

Definition at line 135 of file programinfocache.cpp.

Referenced by PlaybackBox::ScheduleUpdateUIList().

◆ WaitForLoadToComplete()

void ProgramInfoCache::WaitForLoadToComplete ( void  ) const

Definition at line 141 of file programinfocache.cpp.

Referenced by PlaybackBox::Load().

◆ Refresh()

void ProgramInfoCache::Refresh ( void  )

Refreshed the cache.

If a new list has been loaded this fills the cache with that list if not, this simply removes list items marked for deletion from the the list.

Note
This must only be called from the UI thread.
All references to the ProgramInfo pointers should be cleared before this is called.

Definition at line 158 of file programinfocache.cpp.

Referenced by PlaybackBox::UpdateUILists().

◆ Add()

void ProgramInfoCache::Add ( const ProgramInfo pginfo)

Adds a ProgramInfo to the cache.

Note
This must only be called from the UI thread.

Definition at line 272 of file programinfocache.cpp.

Referenced by PlaybackBox::HandleRecordingAddEvent().

◆ Remove()

bool ProgramInfoCache::Remove ( uint  recordingID)

Marks a ProgramInfo in the cache for deletion on the next call to Refresh().

Note
This must only be called from the UI thread.
Returns
True iff the ProgramInfo was in the cache.

Definition at line 285 of file programinfocache.cpp.

Referenced by PlaybackBox::HandleRecordingRemoveEvent().

◆ Update()

ProgramInfoCache::UpdateStates ProgramInfoCache::Update ( const ProgramInfo pginfo)

Updates a ProgramInfo in the cache.

Note
This must only be called from the UI thread.
Returns
True iff the ProgramInfo was in the cache and was updated.

Definition at line 194 of file programinfocache.cpp.

Referenced by Add(), and PlaybackBox::customEvent().

◆ UpdateFileSize()

void ProgramInfoCache::UpdateFileSize ( uint  recordingID,
uint64_t  filesize,
UpdateStates  flags 
)

Updates a ProgramInfo in the cache.

Note
This runs in a background thread as it contains multiple Db queries.

Definition at line 234 of file programinfocache.cpp.

Referenced by PlaybackBox::customEvent(), and Update().

◆ GetOrdered()

void ProgramInfoCache::GetOrdered ( std::vector< ProgramInfo * > &  list,
bool  newest_first = false 
)

Definition at line 313 of file programinfocache.cpp.

Referenced by PlaybackBox::UpdateUILists().

◆ empty()

bool ProgramInfoCache::empty ( void  ) const
inline
Note
This must only be called from the UI thread.

Definition at line 49 of file programinfocache.h.

Referenced by PlaybackBox::updateRecList(), and PlaybackBox::UpdateUILists().

◆ GetRecordingInfo()

ProgramInfo * ProgramInfoCache::GetRecordingInfo ( uint  recordingID) const

◆ Load()

void ProgramInfoCache::Load ( bool  updateUI = true)
private

Definition at line 76 of file programinfocache.cpp.

Referenced by ProgramInfoLoader::run().

◆ Clear()

void ProgramInfoCache::Clear ( void  )
private

Clears the cache, m_lock must be held when this is called.

Definition at line 335 of file programinfocache.cpp.

Referenced by Refresh(), and ~ProgramInfoCache().

Friends And Related Function Documentation

◆ ProgramInfoLoader

friend class ProgramInfoLoader
friend

Definition at line 22 of file programinfocache.h.

Referenced by ScheduleLoad().

Member Data Documentation

◆ m_lock

QMutex ProgramInfoCache::m_lock
mutableprivate

◆ m_cache

Cache ProgramInfoCache::m_cache
private

◆ m_nextCache

std::vector<ProgramInfo*>* ProgramInfoCache::m_nextCache {nullptr}
private

Definition at line 66 of file programinfocache.h.

Referenced by Load(), Refresh(), and ~ProgramInfoCache().

◆ m_listener

QObject* ProgramInfoCache::m_listener {nullptr}
private

Definition at line 67 of file programinfocache.h.

Referenced by Load(), and UpdateFileSize().

◆ m_loadIsQueued

bool ProgramInfoCache::m_loadIsQueued {false}
private

Definition at line 68 of file programinfocache.h.

Referenced by Load(), and ScheduleLoad().

◆ m_loadsInProgress

uint ProgramInfoCache::m_loadsInProgress {0}
private

◆ m_loadWait

QWaitCondition ProgramInfoCache::m_loadWait
mutableprivate

Definition at line 70 of file programinfocache.h.

Referenced by Load(), WaitForLoadToComplete(), and ~ProgramInfoCache().


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