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

MatchObjects.h

Go to the documentation of this file.
00001 //
00002 // MatchObjects.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_MATCHOBJECTS_H__3D4FE6DE_027F_44B9_A70E_A229D970D7A8__INCLUDED_)
00023 #define AFX_MATCHOBJECTS_H__3D4FE6DE_027F_44B9_A70E_A229D970D7A8__INCLUDED_
00024 
00025 #pragma once
00026 
00027 class CSchema;
00028 class CSchemaMember;
00029 class CQuerySearch;
00030 class CQueryHit;
00031 class CMatchFile;
00032 class CResultFilters;
00033 
00034 class CMatchList
00035 {
00036 // Construction
00037 public:
00038         CMatchList();
00039         virtual ~CMatchList();
00040         
00041 // Attributes
00042 public:
00043         CMutex          m_pSection;
00044 public:
00045         CString                 m_sFilter;
00046         BOOL                    m_bFilterBusy;
00047         BOOL                    m_bFilterPush;
00048         BOOL                    m_bFilterUnstable;
00049         BOOL                    m_bFilterReject;
00050         BOOL                    m_bFilterLocal;
00051         BOOL                    m_bFilterBogus;
00052         BOOL                    m_bFilterDRM;
00053         BOOL                    m_bFilterAdult;
00054         QWORD                   m_nFilterMinSize;
00055         QWORD                   m_nFilterMaxSize;
00056         DWORD                   m_nFilterSources;
00057         int                             m_nSortColumn;
00058         BOOL                    m_bSortDir;
00059         CSchema*                m_pSchema;
00060         BOOL                    m_bNew;
00061         CResultFilters* m_pResultFilters;
00062 public:
00063         CMatchFile**    m_pFiles;
00064         DWORD                   m_nFiles;
00065         DWORD                   m_nItems;
00066         DWORD                   m_nFilteredFiles;
00067         DWORD                   m_nFilteredHits;
00068         DWORD                   m_nGnutellaHits;
00069         DWORD                   m_nED2KHits;
00070         BOOL                    m_bUpdated;
00071         DWORD                   m_nUpdateMin;
00072         DWORD                   m_nUpdateMax;
00073         CPtrList                m_pSelectedFiles;
00074         CPtrList                m_pSelectedHits;
00075 protected:
00076         DWORD                   m_nBuffer;
00077         CMatchFile**    m_pSizeMap;
00078         CMatchFile**    m_pMapSHA1;
00079         CMatchFile**    m_pMapTiger;
00080         CMatchFile**    m_pMapED2K;
00081         LPTSTR                  m_pszFilter;
00082         CSchemaMember** m_pColumns;
00083         int                             m_nColumns;
00084         
00085 // Operations
00086 public:
00087         void            AddHits(CQueryHit* pHits, CQuerySearch* pFilter = NULL, BOOL bRequire = FALSE);
00088         DWORD           FileToItem(CMatchFile* pFile);
00089         void            Clear();
00090         BOOL            Select(CMatchFile* pFile, CQueryHit* pHit, BOOL bSelected = TRUE);
00091         CMatchFile*     GetSelectedFile(BOOL bFromHit = FALSE) const;
00092         CQueryHit*      GetSelectedHit() const;
00093         int                     GetSelectedCount() const;
00094         BOOL            ClearSelection();
00095         void            Filter();
00096         void            SelectSchema(CSchema* pSchema, CPtrList* pColumns);
00097         void            SetSortColumn(int nColumn = -1, BOOL bDirection = FALSE);
00098         void            UpdateRange(DWORD nMin = 0, DWORD nMax = 0xFFFFFFFF);
00099         void            ClearUpdated();
00100         void            ClearNew();
00101         void            Serialize(CArchive& ar);
00102 protected:
00103         void            InsertSorted(CMatchFile* pFile);
00104         BOOL            FilterHit(CQueryHit* pHit);
00105         
00106         friend class CMatchFile;
00107 
00108 };
00109 
00110 
00111 class CMatchFile
00112 {
00113 // Construction
00114 public:
00115         CMatchFile(CMatchList* pList, CQueryHit* pHit = NULL);
00116         virtual ~CMatchFile();
00117         
00118 // Attributes
00119 public:
00120         CMatchList*     m_pList;
00121         CQueryHit*      m_pHits;
00122         CQueryHit*      m_pBest;
00123         DWORD           m_nTotal;
00124         DWORD           m_nFiltered;
00125         DWORD           m_nSources;
00126         CMatchFile*     m_pNextSize;
00127         CMatchFile*     m_pNextSHA1;
00128         CMatchFile*     m_pNextTiger;
00129         CMatchFile*     m_pNextED2K;
00130 public:
00131         BOOL            m_bSHA1;
00132         SHA1            m_pSHA1;
00133         BOOL            m_bTiger;
00134         TIGEROOT        m_pTiger;
00135         BOOL            m_bED2K;
00136         MD4                     m_pED2K;
00137         QWORD           m_nSize;
00138         CString         m_sSize;
00139 public:
00140         TRISTATE        m_bBusy;
00141         TRISTATE        m_bPush;
00142         TRISTATE        m_bStable;
00143         BOOL            m_bPreview;
00144         DWORD           m_nSpeed;
00145         CString         m_sSpeed;
00146         int                     m_nRating;
00147         int                     m_nRated;
00148         BOOL            m_bDRM;
00149         BOOL            m_bCollection;
00150 public:
00151         BOOL            m_bExpanded;
00152         BOOL            m_bSelected;
00153         BOOL            m_bExisting;
00154         BOOL            m_bDownload;
00155         BOOL            m_bNew;
00156         BOOL            m_bOneValid;
00157         int                     m_nShellIndex;
00158 public:
00159         CString*        m_pColumns;
00160         int                     m_nColumns;
00161         BYTE*           m_pPreview;
00162         DWORD           m_nPreview;
00163         
00164 // Operations
00165 public:
00166         BOOL            Add(CQueryHit* pHit, BOOL bForce = FALSE);
00167         BOOL            Check(CQueryHit* pHit) const;
00168         BOOL            Expand(BOOL bExpand = TRUE);
00169         inline int      Compare(CMatchFile* pFile) const;
00170         CString         GetURN() const;
00171         void            Serialize(CArchive& ar, int nVersion);
00172 protected:
00173         inline DWORD    Filter();
00174         inline void             Added(CQueryHit* pHit);
00175         inline void             ClearNew();
00176 public:
00177         
00178         inline DWORD GetFilteredCount() const
00179         {
00180                 if ( m_pList->m_bFilterLocal && m_bExisting ) return 0;
00181                 if ( m_nSources < m_pList->m_nFilterSources ) return 0;
00182                 if ( m_pBest == NULL ) return 0;
00183 
00184                 return m_nFiltered;
00185         }
00186         
00187         inline DWORD GetItemCount() const
00188         {
00189                 if ( m_pList->m_bFilterLocal && m_bExisting ) return 0;
00190                 if ( m_nSources < m_pList->m_nFilterSources ) return 0;
00191                 if ( m_pBest == NULL ) return 0;
00192 
00193                 if ( m_nFiltered == 1 || ! m_bExpanded )
00194                         return 1;
00195                 else
00196                         return m_nFiltered + 1;
00197         }
00198         
00199         inline int GetRating() const
00200         {
00201                 int nRating = 0;
00202                 
00203                 if ( m_bPush != TS_TRUE ) nRating += 4;
00204                 if ( m_bBusy != TS_TRUE ) nRating += 2;
00205                 if ( m_bStable == TS_TRUE ) nRating ++;
00206 
00207                 return nRating;
00208         }
00209         
00210         friend class CMatchList;
00211 };
00212 
00213 
00214 #endif // !defined(AFX_MATCHOBJECTS_H__3D4FE6DE_027F_44B9_A70E_A229D970D7A8__INCLUDED_)

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