Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
1.8 KiB

  1. //========= Copyright � 1996-2009, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=====================================================================================//
  6. #ifndef _SEARCHMANAGER_H_
  7. #define _SEARCHMANAGER_H_
  8. #include "utlvector.h"
  9. #include "utlmap.h"
  10. class CMatchSearcher;
  11. class CSearchManager :
  12. public ISearchManager,
  13. public IMatchEventsSink
  14. {
  15. public :
  16. explicit CSearchManager( KeyValues *pSearchParams );
  17. virtual ~CSearchManager();
  18. //
  19. // ISearchManager implementation
  20. //
  21. public:
  22. //
  23. // EnableResultsUpdate
  24. // controls whether server data is being updated in the background
  25. //
  26. virtual void EnableResultsUpdate( bool bEnable, KeyValues *pSearchParams = NULL );
  27. //
  28. // GetNumResults
  29. // returns number of results discovered and for which data is available
  30. //
  31. virtual int GetNumResults();
  32. //
  33. // GetResultByIndex / GetResultByOnlineId
  34. // returns result interface to the given result or NULL if result not found or not available
  35. //
  36. virtual IMatchSearchResult* GetResultByIndex( int iResultIdx );
  37. virtual IMatchSearchResult* GetResultByOnlineId( XUID xuidResultOnline );
  38. //
  39. // Destroy
  40. // destroys the search manager and all its results
  41. //
  42. virtual void Destroy();
  43. // IMatchEventsSink
  44. public:
  45. virtual void OnEvent( KeyValues *pEvent );
  46. //
  47. // Interface for match system
  48. //
  49. public:
  50. static void UpdateAll();
  51. void Update();
  52. void OnSearchDone();
  53. protected:
  54. IMatchSearchResult * GetResultById( CUtlVector< IMatchSearchResult * > &arr, XUID id );
  55. void ClearResults( CUtlVector< IMatchSearchResult * > &arr );
  56. protected:
  57. KeyValues *m_pSettings;
  58. CMatchSearcher *m_pSearcher;
  59. float m_flNextSearchTime;
  60. CUtlVector< IMatchSearchResult * > m_arrResults;
  61. enum State_t
  62. {
  63. STATE_IDLE,
  64. STATE_SEARCHING,
  65. STATE_SEARCHING_CRITERIA_UPDATED,
  66. STATE_PAUSED,
  67. };
  68. State_t m_eState;
  69. };
  70. #endif // _SEARCHMANAGER_H_