//////////////////////////////////////////////////////////////////////////////
//
// Asura_PS3_NP_RoomFinder.h
//
// Copyright (c) 2008 Rebellion. All rights reserved.
//
// Description:
//
//     class to manage searching for PSN Rooms. This class is intended to be
//     completely independent of Asura_Lobby.
//
//////////////////////////////////////////////////////////////////////////////

// B E G I N   F I L E   W R A P P E R ///////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif

#ifndef ASURA_PS3_NP_ROOMFINDER_H___
#define ASURA_PS3_NP_ROOMFINDER_H___ 1

#include <np.h>

struct Asura_PS3_SearchRoom_CallbackData 
{
	bool m_bDone;
	bool m_bError;
};

class Asura_PS3_NP_RoomFinder
{
public:

	Asura_PS3_NP_RoomFinder( u_int uMaxResults );
	~Asura_PS3_NP_RoomFinder();

	bool BeginSearch(const SceNpMatching2IntSearchFilter* pxSearchFilters, 
		u_int uNumSearchFilters, u_int uNumAttributesToFetch);
	bool IsSearchComplete() const { return s_xCallbackData.m_bDone; }

	u_int GetNumSearchResults() const;
	const SceNpMatching2RoomDataExternal& GetResult( u_int uIndex ) const;

private:

	// static functions
	static void SearchRoomCallback(SceNpMatching2ContextId xCtxId, 
		SceNpMatching2RequestId xReqId, 
		SceNpMatching2Event usEvent,
		SceNpMatching2EventKey xEventKey,
		int iErrorCode, 
		size_t uDataSize, 
		void* pArg);

	// member data
	u_int m_uMaxResults;
	SceNpMatching2RequestId m_xAssignedReqID;
	SceNpMatching2SearchRoomResponse* m_pxResponseData;

	// static class data
	static u_int s_uRequestSequenceNumber;
	static Asura_PS3_SearchRoom_CallbackData s_xCallbackData;
	static Asura_PS3_NP_RoomFinder* s_pxThis;
};


// E N D   F I L E   W R A P P E R ///////////////////////////////////////////

#endif // #ifndef ASURA_PS3_NP_ROOMFINDER_H___
