- HBJobGroup * aJobGroup;
- NSEnumerator * groupEnum = [fJobGroups objectEnumerator];
- while ( (aJobGroup = [groupEnum nextObject]) )
- {
- if ([[aJobGroup destinationPath] isEqualToString: path])
- return aJobGroup;
- }
- return nil;
-}
-
-//------------------------------------------------------------------------------------
-// Locates and returns a HBJob whose sequence_id matches a specified value.
-//------------------------------------------------------------------------------------
-- (HBJob *) findJobWithID: (int)aJobID
-{
- HBJobGroup * aJobGroup;
- NSEnumerator * groupEnum = [fJobGroups objectEnumerator];
- while ( (aJobGroup = [groupEnum nextObject]) )
- {
- HBJob * job;
- NSEnumerator * jobEnum = [aJobGroup jobEnumerator];
- while ( (job = [jobEnum nextObject]) )
- {
- if (job->sequence_id == aJobID)
- return job;
- }
- }
- return nil;
-}
-
-//------------------------------------------------------------------------------------
-// Locates and returns a libhb job whose sequence_id matches a specified value.
-//------------------------------------------------------------------------------------
-- (hb_job_t *) findLibhbJobWithID: (int)aJobID
-{
- hb_job_t * job;
- int index = 0;
- while( ( job = hb_job( fHandle, index++ ) ) )
- {
- if (job->sequence_id == aJobID)
- return job;
- }
- return nil;
-}
-
-#pragma mark -
-#pragma mark Queue Counts
-
-//------------------------------------------------------------------------------------
-// Sets a flag indicating that the values for fPendingCount, fCompletedCount,
-// fCanceledCount, and fWorkingCount need to be recalculated.
-//------------------------------------------------------------------------------------
-- (void) setJobGroupCountsNeedUpdating: (BOOL)flag
-{
- fJobGroupCountsNeedUpdating = flag;
-}
-
-//------------------------------------------------------------------------------------
-// Recalculates and stores new values in fPendingCount, fCompletedCount,
-// fCanceledCount, and fWorkingCount.
-//------------------------------------------------------------------------------------
-- (void) recalculateJobGroupCounts
-{
- fPendingCount = 0;
- fCompletedCount = 0;
- fCanceledCount = 0;
- fWorkingCount = 0;
-
- NSEnumerator * groupEnum = [fJobGroups objectEnumerator];
- HBJobGroup * aJobGroup;
- while ( (aJobGroup = [groupEnum nextObject]) )
- {
- switch ([aJobGroup status])
- {
- case HBStatusNone:
- // We don't track these.
- break;
- case HBStatusPending:
- fPendingCount++;
- break;
- case HBStatusCompleted:
- fCompletedCount++;
- break;
- case HBStatusCanceled:
- fCanceledCount++;
- break;
- case HBStatusWorking:
- fWorkingCount++;
- break;
- }
- }
- fJobGroupCountsNeedUpdating = NO;
-}
-
-//------------------------------------------------------------------------------------
-// Returns the number of job groups whose status is HBStatusPending.
-//------------------------------------------------------------------------------------
-- (unsigned int) pendingCount
-{
- if (fJobGroupCountsNeedUpdating)
- [self recalculateJobGroupCounts];
- return fPendingCount;
-}
-
-//------------------------------------------------------------------------------------
-// Returns the number of job groups whose status is HBStatusCompleted.
-//------------------------------------------------------------------------------------
-- (unsigned int) completedCount
-{
- if (fJobGroupCountsNeedUpdating)
- [self recalculateJobGroupCounts];
- return fCompletedCount;
-}
-
-//------------------------------------------------------------------------------------
-// Returns the number of job groups whose status is HBStatusCanceled.
-//------------------------------------------------------------------------------------
-- (unsigned int) canceledCount
-{
- if (fJobGroupCountsNeedUpdating)
- [self recalculateJobGroupCounts];
- return fCanceledCount;
-}
-
-//------------------------------------------------------------------------------------
-// Returns the number of job groups whose status is HBStatusWorking.
-//------------------------------------------------------------------------------------
-- (unsigned int) workingCount
-{
- if (fJobGroupCountsNeedUpdating)
- [self recalculateJobGroupCounts];
- return fWorkingCount;