Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

UploadQueue.h

Go to the documentation of this file.
00001 //
00002 // UploadQueue.h
00003 //
00004 // Copyright (c) Shareaza Development Team, 2002-2005.
00005 // This file is part of SHAREAZA (www.shareaza.com)
00006 //
00007 // Shareaza is free software; you can redistribute it
00008 // and/or modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2 of
00010 // the License, or (at your option) any later version.
00011 //
00012 // Shareaza is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with Shareaza; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 //
00021 
00022 #if !defined(AFX_UPLOADQUEUE_H__2C8AAF1A_A452_4275_B5D5_06ED2F46BAA8__INCLUDED_)
00023 #define AFX_UPLOADQUEUE_H__2C8AAF1A_A452_4275_B5D5_06ED2F46BAA8__INCLUDED_
00024 
00025 #pragma once
00026 
00027 class CUploadTransfer;
00028 
00029 
00030 class CUploadQueue
00031 {
00032 // Construction
00033 public:
00034         CUploadQueue();
00035         virtual ~CUploadQueue();
00036 
00037 // Attributes
00038 protected:
00039         CPtrList        m_pActive;
00040         CPtrArray       m_pQueued;
00041 public:
00042         int                     m_nIndex;
00043         CString         m_sName;
00044         BOOL            m_bEnable;
00045         DWORD           m_nProtocols;
00046         QWORD           m_nMinSize;
00047         QWORD           m_nMaxSize;
00048         BOOL            m_bPartial;
00049         CString         m_sShareTag;
00050         CString         m_sNameMatch;
00051 public:
00052         int                     m_nCapacity;
00053         int                     m_nMinTransfers;
00054         int                     m_nMaxTransfers;
00055         int                     m_nBandwidthPoints;
00056         BOOL            m_bRotate;
00057         DWORD           m_nRotateTime;
00058         DWORD           m_nRotateChunk;
00059         BOOL            m_bRewardUploaders;
00060 public:
00061         BOOL            m_bExpanded;
00062         BOOL            m_bSelected;
00063         DWORD           m_nMeasured;
00064 
00065 // Operations
00066 public:
00067         CString         GetCriteriaString() const;
00068         void            Serialize(CArchive& ar, int nVersion);
00069 public:
00070         BOOL            CanAccept(PROTOCOLID nProtocol, LPCTSTR pszName, QWORD nSize, BOOL bPartial, LPCTSTR pszShareTags = NULL) const;
00071         BOOL            Enqueue(CUploadTransfer* pUpload, BOOL bForce = FALSE, BOOL bStart = FALSE);
00072         BOOL            Dequeue(CUploadTransfer* pUpload);
00073         int                     GetPosition(CUploadTransfer* pUpload, BOOL bStart);
00074         BOOL            StealPosition(CUploadTransfer* pTarget, CUploadTransfer* pSource);
00075         BOOL            Start(CUploadTransfer* pUpload, BOOL bPeek = FALSE);
00076 public:
00077         int                     GetBandwidthPoints(int nTransfers = -1) const;
00078         DWORD           GetBandwidthLimit(int nTransfers = -1) const;
00079         DWORD           GetAvailableBandwidth() const;
00080         DWORD           GetPredictedBandwidth() const;
00081         void            SpreadBandwidth();
00082         void            RescaleBandwidth();
00083 protected:
00084         void            StartImpl(CUploadTransfer* pUpload);
00085 
00086 // Utilities
00087 public:
00088         inline int GetTransferCount(BOOL bMax = FALSE) const
00089         {
00090                 if ( ! bMax ) return m_pActive.GetCount();
00091                 int nActive = m_pActive.GetCount();
00092                 return max( nActive, m_nMinTransfers );
00093         }
00094 
00095         inline int GetQueueCapacity() const
00096         {
00097                 return m_nCapacity;
00098         }
00099 
00100         inline int GetQueuedCount() const
00101         {
00102                 return m_pQueued.GetSize();
00103         }
00104 
00105         inline int GetQueueRemaining() const
00106         {
00107                 return GetQueueCapacity() - GetQueuedCount();
00108         }
00109 
00110         inline BOOL IsActive(CUploadTransfer* pUpload) const
00111         {
00112                 ASSERT( pUpload != NULL );
00113                 return ( m_pActive.Find( pUpload ) != NULL );
00114         }
00115 
00116         inline DWORD GetMeasuredSpeed() const
00117         {
00118                 return m_nMeasured;
00119         }
00120 
00121         friend class CUploadsCtrl;
00122         friend class CUploadsWnd;
00123 };
00124 
00125 #endif // !defined(AFX_UPLOADQUEUE_H__2C8AAF1A_A452_4275_B5D5_06ED2F46BAA8__INCLUDED_)

Generated on Thu Dec 15 10:39:50 2005 for Shareaza 2.2.1.0 by  doxygen 1.4.2