GlobalSearch::Tracker Class Reference

The Tracker contains a thread-safe list of unique Structures. More...

#include <globalsearch/tracker.h>

List of all members.

Signals

void newStructureAdded (GlobalSearch::Structure *s)
void structureCountChanged (int c)

Public Member Functions

 Tracker (QObject *parent=0)
virtual ~Tracker ()
void lockForRead ()
void lockForWrite ()
void unlock ()
QReadWriteLock * rwLock ()
QList< Structure * > * list ()
Structureat (int i)
bool append (QList< Structure * > s)
bool append (Structure *s)
bool popFirst (Structure *&s)
bool remove (Structure *s)
bool contains (Structure *s)
int size ()
void reset ()
void deleteAllStructures ()

Detailed Description

The Tracker contains a thread-safe list of unique Structures.

Author:
David C. Lonie

In simplest terms, the Tracker class is a list of Structures. It provides convenience functions and signals to facilitate access.

The Tracker can be used for storage of all Structures generated in a search, or as a FIFO buffer for pending operations by using the append() and popFirst() functions.

If you wish to not use the convenience functions, it is possible to access the list of Structures through list() and the mutex through rwLock(), lockForRead(), lockForWrite(), and unlock().

Definition at line 43 of file tracker.h.


Constructor & Destructor Documentation

GlobalSearch::Tracker::Tracker ( QObject *  parent = 0  ) 

Constructor.

Parameters:
parent The object parent.

Definition at line 30 of file tracker.cpp.

GlobalSearch::Tracker::~Tracker (  )  [virtual]

Destructor.

Definition at line 35 of file tracker.cpp.

References lockForWrite().


Member Function Documentation

bool GlobalSearch::Tracker::append ( Structure s  ) 
Parameters:
s A Structures to append to the Tracker
Returns:
true if the Structure was not contained in the list, false if it were already present.
Note:
If the Structure is already present, it will not be added again.
The Structures are compared using pointer values

Definition at line 49 of file tracker.cpp.

References newStructureAdded(), and structureCountChanged().

bool GlobalSearch::Tracker::append ( QList< Structure * >  s  ) 
Parameters:
s A list of Structures to append to the Tracker
Returns:
true if all Structures were not contained in the list, false if any were already present.
Note:
If the Structure is already present, it will not be added again.
The Structures are compared using pointer values

Definition at line 40 of file tracker.cpp.

Referenced by GlobalSearch::QueueManager::appendToJobStartTracker(), GlobalSearch::QueueManager::checkPopulation(), GlobalSearch::QueueManager::startJob(), GlobalSearch::QueueManager::startPreoptimization(), and GlobalSearch::QueueManager::unlockForNaming().

Structure* GlobalSearch::Tracker::at ( int  i  )  [inline]
Parameters:
i The index of the Structure desired
Returns:
A pointer to the Structure at index i

Definition at line 90 of file tracker.h.

bool GlobalSearch::Tracker::contains ( Structure s  ) 

Test if a Structure is in the Tracker's list.

Parameters:
s The Structure to check.
Returns:
True if operation was successful, false if not (i.e. Structure was not in list).

Definition at line 76 of file tracker.cpp.

void GlobalSearch::Tracker::deleteAllStructures (  ) 

Remove and delete from memory all Structures from the list.

Definition at line 90 of file tracker.cpp.

References structureCountChanged().

Referenced by GlobalSearch::OptBase::reset(), and GlobalSearch::AbstractDialog::resumeSession_().

QList<Structure*>* GlobalSearch::Tracker::list (  )  [inline]
void GlobalSearch::Tracker::lockForRead (  )  [inline]
void GlobalSearch::Tracker::lockForWrite (  )  [inline]
void GlobalSearch::Tracker::newStructureAdded ( GlobalSearch::Structure s  )  [signal]

Signal emitted when a new Structure is added to the Tracker.

Parameters:
s A Pointer to the new Structure.

Referenced by append().

bool GlobalSearch::Tracker::popFirst ( Structure *&  s  ) 

Remove and return the first Structure in the Tracker's list. Useful for creating a FIFO buffer.

Parameters:
s Becomes the Structure at index 0 of the Tracker's list.
Returns:
True if operation was successful, false if not (i.e. the list is empty).

Definition at line 59 of file tracker.cpp.

References structureCountChanged().

Referenced by GlobalSearch::QueueManager::startJob(), and GlobalSearch::QueueManager::startPreoptimization().

bool GlobalSearch::Tracker::remove ( Structure s  ) 

Remove a Structure in the Tracker's list.

Parameters:
s The Structure to remove.
Returns:
True if operation was successful, false if not (i.e. Structure was not in list).
Note:
This does not delete the Structure from memory.

Definition at line 68 of file tracker.cpp.

References structureCountChanged().

Referenced by GlobalSearch::QueueManager::checkPopulation(), GlobalSearch::QueueManager::senderHasFinishedPreoptimization(), and GlobalSearch::QueueManager::stopJob().

void GlobalSearch::Tracker::reset (  ) 

Remove all Structures from the list.

Note:
This does not delete the Structures from memory.

Definition at line 85 of file tracker.cpp.

References structureCountChanged().

Referenced by GlobalSearch::OptBase::reset().

QReadWriteLock* GlobalSearch::Tracker::rwLock (  )  [inline]
Returns:
The Tracker's read-write mutex

Definition at line 79 of file tracker.h.

Referenced by GlobalSearch::QueueManager::getAllPreoptimizingStructures(), and GlobalSearch::OptBase::save().

int GlobalSearch::Tracker::size (  ) 
Returns:
The number of Structures in the Tracker's list.

Definition at line 81 of file tracker.cpp.

Referenced by GlobalSearch::QueueManager::checkPopulation().

void GlobalSearch::Tracker::structureCountChanged ( int  c  )  [signal]

Signal emitted when then number of Structures in the Tracker changes.

Parameters:
c The number of new Structure in the Tracker.

Referenced by append(), deleteAllStructures(), popFirst(), remove(), and reset().

void GlobalSearch::Tracker::unlock (  )  [inline]

The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations Enumerator
Generated on Mon Jul 16 14:40:04 2012 for GlobalSearch by  doxygen 1.6.3