shithub: aacenc

Download patch

ref: 32fc4bbe5cbe0ab0ef948d0f5a77b2f010e793b0
parent: e27b68138a81047e955042b9bf09f3232448e51b
author: xfhobbes <xfhobbes>
date: Sun Apr 1 12:34:46 EDT 2001

improved progress counter; added general user input tracking during job list processing; added column in the job list ctrl to display the outcome of job processing

--- a/wingui/AbstractJob.cpp
+++ b/wingui/AbstractJob.cpp
@@ -6,6 +6,7 @@
 #include "stdafx.h"
 #include "faac_wingui.h"
 #include "AbstractJob.h"
+#include "WindowUtil.h"
 
 #ifdef _DEBUG
 #undef THIS_FILE
@@ -21,11 +22,18 @@
 	m_lThisJobCountNumber(-1),
 	m_lTotalNumberOfJobs(-1),
 	m_lThisSubJobCountNumber(-1),
-	m_lTotalNumberOfSubJobs(-1)
+	m_lTotalNumberOfSubJobs(-1),
+	m_eJobProcessingOutcome(eNotProcessed),
+	m_lProcessingTime(0)
 {
 
 }
 
+CAbstractJob::CAbstractJob(const CAbstractJob &oSource)
+{
+	*this=oSource;
+}
+
 CAbstractJob::~CAbstractJob()
 {
 
@@ -43,28 +51,168 @@
 	m_lTotalNumberOfSubJobs=lTotalNumberOfSubJobs;
 }
 
+void CAbstractJob::GetProcessingNumberInformation(long &lThisJobCountNumber, long &lTotalNumberOfJobs, long &lThisSubJobCountNumber, long &lTotalNumberOfSubJobs) const
+{
+	lThisJobCountNumber=m_lThisJobCountNumber;
+	lTotalNumberOfJobs=m_lTotalNumberOfJobs;
+	lThisSubJobCountNumber=m_lThisSubJobCountNumber;
+	lTotalNumberOfSubJobs=m_lTotalNumberOfSubJobs;
+}
+
 void CAbstractJob::CopyAllJobNumberInfoFromJob(const CAbstractJob &oJob)
 {
-	m_lThisJobCountNumber=oJob.m_lThisJobCountNumber;
-	m_lTotalNumberOfJobs=oJob.m_lTotalNumberOfJobs;
-	m_lThisSubJobCountNumber=oJob.m_lThisSubJobCountNumber;
-	m_lTotalNumberOfSubJobs=oJob.m_lTotalNumberOfSubJobs;
+	oJob.GetProcessingNumberInformation(m_lThisJobCountNumber, m_lTotalNumberOfJobs, m_lThisSubJobCountNumber, m_lTotalNumberOfSubJobs);
 }
 
 CString CAbstractJob::GetJobProcessingAdditionalCaptionBarInformation() const
 {
+	// first get proper number info; must use method call for
+	// that because the management might be subclassed
+	long lThisJobCountNumber;
+	long lTotalNumberOfJobs;
+	long lThisSubJobCountNumber;
+	long lTotalNumberOfSubJobs;
+	GetProcessingNumberInformation(lThisJobCountNumber, lTotalNumberOfJobs, lThisSubJobCountNumber, lTotalNumberOfSubJobs);
+
 	CString oJobInfo;
-	if (m_lTotalNumberOfJobs>=0)
+	if (lTotalNumberOfJobs>=0)
 	{
-		oJobInfo.Format(IDS_JobNofM, m_lThisJobCountNumber+1, m_lTotalNumberOfJobs);
+		oJobInfo.Format(IDS_JobNofM, lThisJobCountNumber+1, lTotalNumberOfJobs);
 	}
-	if (m_lTotalNumberOfSubJobs>=0)
+	if (lTotalNumberOfSubJobs>=0)
 	{
 		CString oSubJobInfo;
-		oSubJobInfo.Format(IDS_SubJobNofM, m_lThisSubJobCountNumber+1, m_lTotalNumberOfSubJobs);
+		oSubJobInfo.Format(IDS_SubJobNofM, lThisSubJobCountNumber+1, lTotalNumberOfSubJobs);
 
 		oJobInfo+=CString(" - ")+oSubJobInfo;
 	}
 
 	return oJobInfo;
+}
+
+void CAbstractJob::SetProcessingOutcome(EJobProcessingOutcome eJobProcessingOutcome, long lProcessingTime, const CString &oSupplementaryInfo)
+{
+	m_eJobProcessingOutcome=eJobProcessingOutcome;
+	m_lProcessingTime=lProcessingTime;
+	m_oSupplementaryInfo=oSupplementaryInfo;
+
+	if (m_eJobProcessingOutcome==eError)
+	{
+		ASSERT(!m_oSupplementaryInfo.IsEmpty());
+	}
+}
+
+void CAbstractJob::SetProcessingOutcomeCurTime(EJobProcessingOutcome eJobProcessingOutcome, long lProcessingStartTime, const CString &oSupplementaryInfo)
+{
+	SetProcessingOutcome(eJobProcessingOutcome, ::GetTickCount()-lProcessingStartTime, oSupplementaryInfo);
+}
+
+void CAbstractJob::SetProcessingOutcome(EJobProcessingOutcome eJobProcessingOutcome, long lProcessingTime, int iSupplementaryInfoStringResource)
+{
+	CString oSupplementaryInfo;
+	oSupplementaryInfo.LoadString(iSupplementaryInfoStringResource);
+	SetProcessingOutcome(eJobProcessingOutcome, lProcessingTime, oSupplementaryInfo);
+}
+
+void CAbstractJob::SetProcessingOutcomeCurTime(EJobProcessingOutcome eJobProcessingOutcome, long lProcessingStartTime, int iSupplementaryInfoStringResource)
+{
+	CString oSupplementaryInfo;
+	oSupplementaryInfo.LoadString(iSupplementaryInfoStringResource);
+	SetProcessingOutcomeCurTime(eJobProcessingOutcome, lProcessingStartTime, oSupplementaryInfo);
+}
+
+void CAbstractJob::GetProcessingOutcome(EJobProcessingOutcome &eJobProcessingOutcome, long &lProcessingTime, CString &oSupplementaryInfo) const
+{
+	eJobProcessingOutcome=m_eJobProcessingOutcome;
+	lProcessingTime=m_lProcessingTime;
+	oSupplementaryInfo=m_oSupplementaryInfo;
+}
+
+CAbstractJob::EJobProcessingOutcome CAbstractJob::GetProcessingOutcomeSimple() const
+{
+	EJobProcessingOutcome eJobProcessingOutcome;
+	long lProcessingTime;
+	CString oSupplementaryInfo;
+	GetProcessingOutcome(eJobProcessingOutcome, lProcessingTime, oSupplementaryInfo);
+	return eJobProcessingOutcome;
+}
+
+CString CAbstractJob::GetProcessingOutcomeString() const
+{
+	CString oToReturn;
+
+	// find out the outcome data
+	EJobProcessingOutcome eJobProcessingOutcome;
+	long lProcessingTime;
+	CString oSupplementaryInfo;
+	GetProcessingOutcome(eJobProcessingOutcome, lProcessingTime, oSupplementaryInfo);
+
+	// find out a simple description for the outcome
+	CString oSimpleOutcomeDesc;
+	int iDescBuf;
+	switch (eJobProcessingOutcome)
+	{
+	case eNotProcessed:
+		{
+			iDescBuf=IDS_OutcomeUnprocessed;
+			break;
+		}
+	case eSuccessfullyProcessed:
+		{
+			iDescBuf=IDS_OutcomeSuccessfullyProcessed;
+			break;
+		}
+	case ePartiallyProcessed:
+		{
+			iDescBuf=IDS_OutcomePartiallyProcessed;
+			break;
+		}
+	case eUserAbort:
+		{
+			iDescBuf=IDS_OutcomeUserAbort;
+			break;
+		}
+	case eError:
+		{
+			iDescBuf=IDS_OutcomeError;
+			break;
+		}
+	default:
+		{
+			// unknown type of outcome
+			ASSERT(false);
+			iDescBuf=IDS_OutcomeError;
+			break;
+		}
+	}
+	oSimpleOutcomeDesc.LoadString(iDescBuf);
+
+	if (oSupplementaryInfo.IsEmpty())
+	{
+		oToReturn=oSimpleOutcomeDesc;
+	}
+	else
+	{
+		oToReturn=oSimpleOutcomeDesc+": "+oSupplementaryInfo;
+	}
+
+	if (lProcessingTime>=10)
+	{
+		bool bIncludeMillis=true;
+		if (lProcessingTime>=1000)
+		{
+			bIncludeMillis=false;
+		}
+
+		oToReturn+=_T(" (")+CWindowUtil::GetTimeDescription(lProcessingTime, bIncludeMillis)+_T(")");
+	}
+
+	return oToReturn;
+}
+
+void CAbstractJob::ResetProcessingOutcome()
+{
+	m_eJobProcessingOutcome=eNotProcessed;
+	m_lProcessingTime=0;
+	m_oSupplementaryInfo.Empty();
 }
--- a/wingui/AbstractJob.h
+++ b/wingui/AbstractJob.h
@@ -13,33 +13,65 @@
 #endif // _MSC_VER > 1000
 
 #include "SupportedPropertyPagesData.h"
+#include "JobProcessingDynamicUserInputInfo.h"
 
 class CAbstractJob  
 {
 public:
 	CAbstractJob();
+	CAbstractJob(const CAbstractJob &oSource);		// copy constructor
 	virtual ~CAbstractJob();
 
 	virtual CSupportedPropertyPagesData GetSupportedPropertyPages() const=0;
 
 	// returns if the job was completely and successfully process
-	virtual bool ProcessJob() const=0;
+	virtual bool ProcessJob(CJobProcessingDynamicUserInputInfo &oUserInputInfo)=0;
 
 	// is used during the processing of the job to give the user a
 	// feedback what exactly is done; may use up to 3 lines
 	virtual CString GetDetailedDescriptionForStatusDialog() const=0;
 
-	// job processing information; all numbers are zero based
-	void SetJobNumberInfo(long lThisJobCountNumber, long lTotalNumberOfJobs);
-	void SetSubJobNumberInfo(long lThisSubJobCountNumber, long lTotalNumberOfSubJobs);
+	// job processing information; all numbers are zero based;
+	// subclasses may overwrite the first three members, if they do they
+	// should overwrite them all together
+	virtual void SetJobNumberInfo(long lThisJobCountNumber, long lTotalNumberOfJobs);
+	virtual void SetSubJobNumberInfo(long lThisSubJobCountNumber, long lTotalNumberOfSubJobs);
+	virtual void GetProcessingNumberInformation(long &lThisJobCountNumber, long &lTotalNumberOfJobs, long &lThisSubJobCountNumber, long &lTotalNumberOfSubJobs) const;
 	void CopyAllJobNumberInfoFromJob(const CAbstractJob &oJob);
 	CString GetJobProcessingAdditionalCaptionBarInformation() const;
 
+	// job processing outcome information
+	enum EJobProcessingOutcome
+	{
+		eNotProcessed,
+		eSuccessfullyProcessed,
+		ePartiallyProcessed,		// only for filter jobs
+		eUserAbort,
+		eError,
+	};
+	// note that supplementary info is mandatory if eOutcome==eError;
+	// the processing time is specified in milliseconds;
+	// SetProcessingOutcomeCurTime() requires that the second parameter is the
+	// value that ::GetTickCount() returned immediately before the job processing began
+	virtual void SetProcessingOutcome(EJobProcessingOutcome eJobProcessingOutcome, long lProcessingTime, const CString &oSupplementaryInfo);
+	void SetProcessingOutcome(EJobProcessingOutcome eJobProcessingOutcome, long lProcessingTime, int iSupplementaryInfoStringResource);
+	void SetProcessingOutcomeCurTime(EJobProcessingOutcome eJobProcessingOutcome, long lProcessingStartTime, const CString &oSupplementaryInfo);
+	void SetProcessingOutcomeCurTime(EJobProcessingOutcome eJobProcessingOutcome, long lProcessingStartTime, int iSupplementaryInfoStringResource);
+	virtual void GetProcessingOutcome(EJobProcessingOutcome &eJobProcessingOutcome, long &lProcessingTime, CString &oSupplementaryInfo) const;
+	EJobProcessingOutcome GetProcessingOutcomeSimple() const;
+	CString GetProcessingOutcomeString() const;
+	// puts the job back to the "not processed" state
+	virtual void ResetProcessingOutcome();
+
 private:
 	long m_lThisJobCountNumber;
 	long m_lTotalNumberOfJobs;
 	long m_lThisSubJobCountNumber;
 	long m_lTotalNumberOfSubJobs;
+
+	EJobProcessingOutcome m_eJobProcessingOutcome;
+	long m_lProcessingTime;		// only valid if the outcome was success or user abort
+	CString m_oSupplementaryInfo;
 };
 
 #endif // !defined(AFX_ABSTRACTJOB_H__DFE38E74_0E81_11D5_8402_0080C88C25BD__INCLUDED_)