/** @file polledproxy.h
 *  MessageProxy compatible polled proxy for EA::Types::Functions
 *	@author Chris Burns (cburns@ea.com)
 *
 *	Core Technology UI
 *	(c) 2013 Electronic Arts Inc. 
 */

#ifndef EABASETYPESMESSAGE_TYPES_POLLEDPROXY_H_
#define EABASETYPESMESSAGE_TYPES_POLLEDPROXY_H_

#include "EASTLICA/hash_map.h"

#include "EABaseTypes/autoref.h"
#include "EABaseTypes/string.h"

#include "EABaseTypesPlus/refcounted.h"
#include "EABaseTypesPlus/refcountedica.h"

namespace EA
{
	namespace Types
	{
		class Factory;

		EABASETYPES_FORWARD_DECLARATION(class, Function)
		EABASETYPES_FORWARD_DECLARATION(class, Object)

		EABASETYPES_FORWARD_DECLARATION(class, IProxy)

		EABASETYPES_FORWARD_DECLARATION(class, Session)

		EABASETYPES_FORWARD_DECLARATION(class, PolledProxy)

		class PolledProxy : public RefCountedICA<RefCounted>
		{
		public:
		
			PolledProxy(Factory* factory,
						IProxyIn proxy);

			~PolledProxy();

			ObjectReturn ToObject();

			void Poll(FunctionIn callback, ObjectIn object);

		private:

			EA::Types::Factory*		mFactory;
			IProxyRef				mProxy;

			typedef EASTLICA::HashMap<EA::String, SessionRef> SessionMap;

			SessionMap mSessions;
		};
	}
}

#endif /* EABASETYPESMESSAGE_TYPES_POLLEDPROXY_H_ */
