vdr  2.4.1
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cListBase Class Reference

#include <tools.h>

Public Member Functions

virtual ~cListBase ()
 
bool Lock (cStateKey &StateKey, bool Write=false, int TimeoutMs=0) const
 
void SetUseGarbageCollector (void)
 
void SetExplicitModify (void)
 
void SetModified (void)
 
void Add (cListObject *Object, cListObject *After=NULL)
 
void Ins (cListObject *Object, cListObject *Before=NULL)
 
void Del (cListObject *Object, bool DeleteObject=true)
 
virtual void Move (int From, int To)
 
void Move (cListObject *From, cListObject *To)
 
virtual void Clear (void)
 
bool Contains (const cListObject *Object) const
 
const cListObjectGet (int Index) const
 
cListObjectGet (int Index)
 
int Count (void) const
 
void Sort (void)
 

Protected Member Functions

 cListBase (const char *NeedsLocking=NULL)
 

Protected Attributes

cListObjectobjects
 
cListObjectlastObject
 
int count
 
cStateLock stateLock
 
const char * needsLocking
 
bool useGarbageCollector
 

Detailed Description

Definition at line 527 of file tools.h.

Constructor & Destructor Documentation

◆ cListBase()

cListBase::cListBase ( const char *  NeedsLocking = NULL)
protected

Definition at line 2129 of file tools.c.

References count, lastObject, needsLocking, objects, and useGarbageCollector.

◆ ~cListBase()

cListBase::~cListBase ( )
virtual

Definition at line 2138 of file tools.c.

References Clear().

Member Function Documentation

◆ Add()

void cListBase::Add ( cListObject Object,
cListObject After = NULL 
)

◆ Clear()

void cListBase::Clear ( void  )
virtual

◆ Contains()

bool cListBase::Contains ( const cListObject Object) const

If a pointer to an object contained in this list has been obtained while holding a lock, and that lock has been released, but the pointer is kept for later use (after obtaining a new lock), Contains() can be called with that pointer to make sure the object it points to is still part of this list (it may have been deleted or otherwise removed from the list after the lock during which the pointer was initially retrieved has been released).

Definition at line 2240 of file tools.c.

References cListObject::Next(), and objects.

Referenced by cMenuChannels::Delete().

◆ Count()

int cListBase::Count ( void  ) const
inline

◆ Del()

void cListBase::Del ( cListObject Object,
bool  DeleteObject = true 
)

◆ Get() [1/2]

cListObject* cListBase::Get ( int  Index)
inline

Definition at line 589 of file tools.h.

References Get().

Referenced by Get().

◆ Get() [2/2]

const cListObject * cListBase::Get ( int  Index) const

Definition at line 2259 of file tools.c.

References cListObject::Next(), and objects.

Referenced by cMenuSetupCAM::Activate(), cMenuRecordings::Commands(), cOsdMenu::Del(), cMenuFolder::Delete(), cMenuRecordings::Delete(), cMenuChannels::Delete(), cOsdMenu::Display(), cOsdMenu::DisplayCurrent(), cMenuFolder::Edit(), cMenuCommands::Execute(), cMenuChannels::GetChannel(), cDevice::GetDevice(), cMenuFolder::GetFolder(), cChannels::GetNextGroup(), cChannels::GetNextNormal(), cPluginManager::GetPlugin(), cChannels::GetPrevGroup(), cChannels::GetPrevNormal(), cDvbSubtitlePage::GetRegionRefByIndex(), cMenuTimers::GetTimer(), cPluginManager::Housekeeping(), cMenuRecordings::Info(), cMenuSetupCAM::Menu(), Move(), cMenuRecordings::Open(), cMenuRecordings::Play(), cHdffSetupPage::ProcessKey(), cMenuMain::ProcessKey(), cOsdMenu::ProcessKey(), cMenuRecordings::ProcessKey(), cMenuWhatsOn::ProcessKey(), cMenuSchedule::ProcessKey(), cMenuSetupOSD::ProcessKey(), cMenuSetupPlugins::ProcessKey(), cMenuWhatsOn::Record(), cMenuSchedule::Record(), cOsdMenu::RefreshCurrent(), cMenuRecordingEdit::RemoveName(), cMenuSetupCAM::Reset(), cMenuRecordings::Rewind(), cMenuFolder::Select(), cOsdMenu::SelectableItem(), cPictureMenu::SelectItem(), cMenuRecordings::Set(), cMenuSchedule::Set(), cMenuRecordingEdit::Set(), cMenuSetupOSD::Set(), cMenuSetupMisc::Set(), cMenuRecordings::SetHelpKeys(), cMenuWhatsOn::SetHelpKeys(), cMenuSchedule::SetHelpKeys(), cMenuSetupCAM::SetHelpKeys(), cMenuEditChannel::Setup(), cMenuSetupEPG::Setup(), cMenuSetupDVB::Setup(), cMenuSetupLNB::Setup(), cMenuRecordings::Sort(), cMenuWhatsOn::Switch(), cMenuSchedule::Switch(), and cMenuRecordings::~cMenuRecordings().

◆ Ins()

void cListBase::Ins ( cListObject Object,
cListObject Before = NULL 
)

◆ Lock()

bool cListBase::Lock ( cStateKey StateKey,
bool  Write = false,
int  TimeoutMs = 0 
) const

Tries to get a lock on this list and returns true if successful.

By default a read lock is requested. Set Write to true to obtain a write lock. If TimeoutMs is not zero, it waits for the given number of milliseconds before giving up. If you need to lock more than one list at the same time, make sure you set TimeoutMs to a suitable value in all of the calls to Lock(), and be prepared to handle situations where you do not get all of the requested locks. In such cases you should release all the locks you have obtained so far and try again. StateKey.TimedOut() tells you whether the lock attempt failed due to a timeout or because the state of the lock hasn't changed since the previous locking attempt. To implicitly avoid deadlocks when locking more than one of the global lists of VDR at the same time, make sure you always lock Timers, Channels, Recordings and Schedules in this sequence. You may keep pointers to objects in this list, even after releasing the lock. However, you may only access such objects if you are holding a proper lock again. If an object has been deleted from the list while you did not hold a lock (for instance by an other thread), the object will still be there, but no longer within this list (it is then stored in the ListGarbageCollector). That way even if you access the object after it has been deleted, you won't cause a segfault. You can call the Contains() function to check whether an object you are holding a pointer to is still in the list. Note that the garbage collector is purged when the usual housekeeping is done.

Definition at line 2143 of file tools.c.

References esyslog, cStateLock::Lock(), needsLocking, and stateLock.

Referenced by cDvbPlayer::Action(), cVideoDirectoryScannerThread::Action(), cReplayControl::ClearEditingMarks(), cChannels::GetChannelsRead(), cChannels::GetChannelsWrite(), cSchedules::GetSchedulesRead(), cSchedules::GetSchedulesWrite(), cTimers::GetTimersRead(), cTimers::GetTimersWrite(), cReplayControl::MarkToggle(), cDvbPlayer::Save(), and cVideoDirectoryScannerThread::ScanVideoDir().

◆ Move() [1/2]

void cListBase::Move ( cListObject From,
cListObject To 
)

◆ Move() [2/2]

void cListBase::Move ( int  From,
int  To 
)
virtual

Reimplemented in cMenuChannels.

Definition at line 2200 of file tools.c.

References Get().

Referenced by cMenuChannels::Move(), and cOsdMenu::ProcessKey().

◆ SetExplicitModify()

void cListBase::SetExplicitModify ( void  )

If you have obtained a write lock on this list, and you don't want it to be automatically marked as modified when the lock is released, a call to this function will disable this, and you can explicitly call SetModified() to have the list marked as modified.

Definition at line 2249 of file tools.c.

References cStateLock::SetExplicitModify(), and stateLock.

Referenced by cMenuRecordings::Delete().

◆ SetModified()

void cListBase::SetModified ( void  )

Unconditionally marks this list as modified.

Definition at line 2254 of file tools.c.

References cStateLock::SetModified(), and stateLock.

Referenced by cRecordingsHandlerEntry::Active(), cRecordControl::cRecordControl(), and cMenuRecordings::Delete().

◆ SetUseGarbageCollector()

void cListBase::SetUseGarbageCollector ( void  )
inline

Definition at line 567 of file tools.h.

Referenced by cSchedule::cSchedule().

◆ Sort()

void cListBase::Sort ( void  )

Member Data Documentation

◆ count

int cListBase::count
protected

Definition at line 530 of file tools.h.

Referenced by Add(), Clear(), cListBase(), cOsdMenu::Del(), Del(), cOsdMenu::Display(), Ins(), and Sort().

◆ lastObject

cListObject * cListBase::lastObject
protected

Definition at line 529 of file tools.h.

Referenced by Add(), Clear(), cListBase(), Del(), Ins(), Move(), and Sort().

◆ needsLocking

const char* cListBase::needsLocking
protected

Definition at line 532 of file tools.h.

Referenced by cListBase(), and Lock().

◆ objects

cListObject* cListBase::objects
protected

Definition at line 529 of file tools.h.

Referenced by Add(), Clear(), cListBase(), Contains(), Del(), Get(), Ins(), Move(), and Sort().

◆ stateLock

cStateLock cListBase::stateLock
mutableprotected

Definition at line 531 of file tools.h.

Referenced by Lock(), SetExplicitModify(), and SetModified().

◆ useGarbageCollector

bool cListBase::useGarbageCollector
protected

Definition at line 533 of file tools.h.

Referenced by cListBase(), and Del().


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