
// DWBS ------------------------------------------------------------------ DWBS
//
// PLATFORM		: ALL
// PRODUCT		: BIT_DEMON
// VISIBILITY	: PUBLIC
//
// DWBS ------------------------------------------------------------------ DWBS

// PURPOSE:

#ifndef BD_MATCHMAKING_QUERIES_H
#define BD_MATCHMAKING_QUERIES_H

#include <bdLobby/bdLobbyCommon/bdCustomQueryParams.h>
#include "CustomMatchMakingInfo.h"

#define BD_MAX_SEARCH_RESULTS (20u)
#define BD_MAX_FINDSESSIONSBYGAMETYPE_RESULTS (25u)

enum bdSearchId
{
	BD_FINDSESSIONSBYGAMETYPE = 1,
	BD_FIND_SESSIONS_BY_PUBLIC_OPEN = 2
};

/// Encapsulates and handles matchmaking results for a query by session ID.
class bdFindSessionByIDResult : public bdQueryResult
{
	public :
		BD_DECLARE_NEW_AND_DELETE_OPERATORS

		bdFindSessionByIDResult();

		virtual bdBool handleResult(bdUInt numReplies, bdBitBufferRef buffer);

		CustomMatchMakingInfo m_customMMInfo;

		// if game info is present in m_customMMInfo
		bdBool m_gotResult;
};

/// Encapsulates a matchmaking query.
class bdFindSessionsByGameType : public bdCustomQueryParams
{
	public:
		BD_DECLARE_NEW_AND_DELETE_OPERATORS

		bdFindSessionsByGameType (bdUInt maxNumResults,
						 	 bdInt pGameType);

		virtual void serialize(bdBitBuffer &buffer);

	protected:

		bdInt m_pGameType;
};

/// Encapsulates and handles results from the query.
class bdFindSessionsByGameTypeResult : public bdQueryResult
{
	public:
		BD_DECLARE_NEW_AND_DELETE_OPERATORS

		bdFindSessionsByGameTypeResult();

		virtual bdBool handleResult(bdUInt numReplies, bdBitBufferRef buffer);

		bdUInt m_numResults;

		CustomMatchMakingInfo m_customMMInfo[BD_MAX_FINDSESSIONSBYGAMETYPE_RESULTS];
};

/// Encapsulates a matchmaking query.
/// This searches for matchmaking sessions that have the given number of open
/// slots available.
class bdFindSessionsByPublicOpen : public bdCustomQueryParams
{
public:

	BD_DECLARE_NEW_AND_DELETE_OPERATORS

	bdFindSessionsByPublicOpen(bdUInt maxNumResults,
							   bdUInt publicOpen);

	virtual void serialize(bdBitBuffer &buffer);

protected:

	bdUInt m_publicOpen;
};

/// Encapsulates and handles results from the bdFindSessionsByPublicOpen query.
class bdFindSessionsByPublicOpenResult : public bdQueryResult
{
public:

	BD_DECLARE_NEW_AND_DELETE_OPERATORS

	bdFindSessionsByPublicOpenResult();

	virtual bdBool handleResult(bdUInt numRows, bdBitBufferRef buffer);

	bdUInt m_numResults;

	CustomMatchMakingInfo m_MMInfo[BD_MAX_SEARCH_RESULTS];
};

#endif // BD_MATCHMAKING_QUERIES_H
