DownloadQueue Class Reference

InternetManager support class. Represents a queue of asynchronous downloads, which are executed in sequence one at a time. More...

#include <camnet.h>

Inheritance diagram for DownloadQueue:

CCObject SimpleCCObject List of all members.

Public Types

enum  QueueType { FIFO = 0, LIFO }

Public Member Functions

 DownloadQueue ()
 ~DownloadQueue ()
 destructor
BOOL Queue (AsynchDownload *pDownload)
 Adds a new download pointer to the queue.
void SetType (QueueType enNewType)
QueueType GetType ()
BOOL IsEmpty ()
BOOL Remove (AsynchDownload *pDownload)
 remove a download from the queue. The object is also deleted
void Flush ()
 Flushes the queue and deletes the objects at the same time.
AsynchDownloadFindDownload (const String_256 &strFileName)
 searches the queue for an object downloading to a known local file
AsynchDownloadFindDownload (INT32 hDownload)
 searches the queue for an object wirh a known handle
AsynchDownloadGetNextDownload ()
 access the next object in the queue (which is removed from the queue at the same time)

Protected Attributes

CTypedPtrList< CPtrList, AsynchDownload * > m_List
QueueType m_enType

Private Member Functions

 CC_DECLARE_MEMDUMP (DownloadQueue)

Detailed Description

InternetManager support class. Represents a queue of asynchronous downloads, which are executed in sequence one at a time.

Author:
Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/12/96

Definition at line 370 of file camnet.h.


Member Enumeration Documentation

enum DownloadQueue::QueueType
 

Enumerator:
FIFO 
LIFO 

Definition at line 376 of file camnet.h.

00376 {FIFO = 0, LIFO}; // valid queue types


Constructor & Destructor Documentation

DownloadQueue::DownloadQueue  )  [inline]
 

Definition at line 378 of file camnet.h.

00378 {m_enType = FIFO;}

DownloadQueue::~DownloadQueue  ) 
 

destructor

Author:
Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/11/96
Parameters:
none [INPUTS]
Returns:
none

Definition at line 1061 of file camnet.cpp.

01062 {
01063     if (!IsEmpty())
01064         Flush();
01065 }


Member Function Documentation

DownloadQueue::CC_DECLARE_MEMDUMP DownloadQueue   )  [private]
 

AsynchDownload * DownloadQueue::FindDownload INT32  hDownload  ) 
 

searches the queue for an object wirh a known handle

Author:
Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/11/96
Parameters:
hDownload - handle of download searched for [INPUTS]
Returns:
pointer to AsynchDownload object if found, NULL otherwise

Definition at line 1200 of file camnet.cpp.

01201 {
01202     AsynchDownload* pDownload = NULL;
01203     if (IsEmpty())
01204         return pDownload;
01205     AsynchDownload* pIterator = NULL;
01206     POSITION pos = m_List.GetHeadPosition();
01207     while (pos && !pDownload)
01208     {
01209         pIterator = m_List.GetNext(pos);
01210         if (pIterator->GetHandle() == hDownload)
01211             pDownload = pIterator;
01212     }
01213     return pDownload;
01214 }

AsynchDownload * DownloadQueue::FindDownload const String_256 strFileName  ) 
 

searches the queue for an object downloading to a known local file

Author:
Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/11/96
Parameters:
strFileName - local filename of the download searched for [INPUTS]
Returns:
pointer to AsynchDownload object if found, NULL otherwise

Definition at line 1171 of file camnet.cpp.

01172 {
01173     if (IsEmpty())
01174         return NULL;
01175     String_256 strLocalFileName(strFileName);
01176     AsynchDownload* pIterator = NULL;
01177     POSITION pos = m_List.GetHeadPosition();
01178     while (pos)
01179     {
01180         pIterator = m_List.GetNext(pos);
01181         if (!strLocalFileName.CompareTo(pIterator->GetLocalFileName(), FALSE))
01182             return pIterator;
01183     }
01184     return NULL;
01185 }

void DownloadQueue::Flush  ) 
 

Flushes the queue and deletes the objects at the same time.

Author:
Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/11/96
Parameters:
pDownload - pointer to download to be removed [INPUTS]
Returns:
none

Definition at line 1145 of file camnet.cpp.

01146 {
01147     if (IsEmpty())
01148         return;
01149     POSITION pos = m_List.GetHeadPosition();
01150     while (pos)
01151     {
01152         AsynchDownload* pDownload = m_List.GetNext(pos);
01153         if (pDownload)
01154             pDownload->Release();
01155     }
01156     m_List.RemoveAll();
01157 }

AsynchDownload * DownloadQueue::GetNextDownload  ) 
 

access the next object in the queue (which is removed from the queue at the same time)

Author:
Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/11/96
Parameters:
none [INPUTS]
Returns:
pointer to AsynchDownload object if any waiting in the queue, NULL otherwise

Definition at line 1231 of file camnet.cpp.

01232 {
01233     AsynchDownload* pDownload = NULL;
01234     if (m_List.IsEmpty())
01235         return pDownload;
01236     POSITION pos = m_List.GetHeadPosition();
01237     pDownload = m_List.GetAt(pos);
01238     m_List.RemoveAt(pos); // remove the download from the queue
01239     return pDownload;
01240 }

QueueType DownloadQueue::GetType void   )  [inline]
 

Definition at line 385 of file camnet.h.

00385 { return m_enType;}

BOOL DownloadQueue::IsEmpty  )  [inline]
 

Definition at line 387 of file camnet.h.

00387 { return m_List.IsEmpty();}

BOOL DownloadQueue::Queue AsynchDownload pDownload  ) 
 

Adds a new download pointer to the queue.

Author:
Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/11/96
Parameters:
pDownload - pointer to download to be queued [INPUTS]
Returns:
TRUE is successful, FALSE otherwise

Definition at line 1080 of file camnet.cpp.

01081 {
01082     if (!pDownload)
01083     {
01084         ERROR3("Unexpected NULL pointer");
01085         return FALSE;
01086     }
01087     if (m_enType != LIFO && m_enType != FIFO)
01088     {
01089         ERROR3("Invalid queue type");
01090         return FALSE;
01091     }
01092     try
01093     {
01094         if (m_enType == FIFO)
01095             m_List.AddTail(pDownload);
01096         else
01097             m_List.AddHead(pDownload);
01098     }
01099     catch (CMemoryException* pxMem)
01100     {
01101         pxMem->Delete();
01102         ERROR2(FALSE, "Could not queue download - memory problems");
01103     }
01104     return TRUE;
01105 }

BOOL DownloadQueue::Remove AsynchDownload pDownload  ) 
 

remove a download from the queue. The object is also deleted

Author:
Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/11/96
Parameters:
pDownload - pointer to download to be removed [INPUTS]
Returns:
TRUE is successful, FALSE otherwise

Definition at line 1119 of file camnet.cpp.

01120 {
01121     if (!pDownload)
01122     {
01123         ERROR3("Unexpected NULL pointer");
01124         return FALSE;
01125     }
01126     POSITION pos = m_List.Find(pDownload);
01127     if (!pos)
01128         return FALSE; // the object is not is this queue
01129     m_List.RemoveAt(pos);
01130     pDownload->Release();
01131     return TRUE;
01132 }

void DownloadQueue::SetType QueueType  enNewType  )  [inline]
 

Definition at line 383 of file camnet.h.

00383 { m_enType = enNewType;}


Member Data Documentation

QueueType DownloadQueue::m_enType [protected]
 

Definition at line 402 of file camnet.h.

CTypedPtrList<CPtrList, AsynchDownload*> DownloadQueue::m_List [protected]
 

Definition at line 401 of file camnet.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:53:52 2007 for Camelot by  doxygen 1.4.4