/***************************************************************************
*                                                                          *
*  Copyright (C) Golaem S.A.  All Rights Reserved.                         *
*                                                                          *
****************************************************************************/

#pragma once

#include "glmTypes.h"
#include "glmIContext.h"
#include "glmICallBack.h"

namespace glm
{
	/**
	* \brief Behavior Context -> init / updates / finish behaviors of an entity
	*
	* \author Golaem <dev@golaem.com>
	*/
	class KBContext : public glm::IContext
	{
	public:

		GLM_CLASS_STAT_ID( glm::MemoryStatIds::Simulation);

		KBContext();
		virtual ~KBContext();

		// KB Context updates KB Array Entries to match entity & entitytype indices

		virtual bool registeredOnCreateEntityComponent() override { return true; }
		virtual void onCreateEntityComponent(int /*entityTypeIndex*/, int64_t /*entityIndex*/) override;

		virtual bool registeredOnCreateGroupComponent() override { return true; }
		virtual void onCreateGroupComponent(int /*groupTypeIndex*/, int64_t /*groupIndex*/) override;

		inline void addSimuToKBCallback(ICallBack* callback) { _simuToKbCallbacks.push_back(callback); }
		inline void addKBToSimuCallback(ICallBack* callback) { _kbToSimuCallbacks.push_back(callback); }

	protected:

		virtual void doInit() override {}
		virtual void doUpdate(Time) override;
		virtual void doFinish() override {}

		virtual void setContextType() override { _contextType = ContextType::KNOWLEDGE_BASE; }

	private:

		GLM_DISALLOW_COPY_AND_ASSIGN(KBContext);

		PODArray<ICallBack*> _kbToSimuCallbacks;
		PODArray<ICallBack*> _simuToKbCallbacks;
	};
}
