<commit_before>/*
 * ComponentNode.h
 *
 *  Created on: Dec 27, 2013
 *      Author: dawid
 */

#ifndef __COMPONENTNODE_H_
#define __COMPONENTNODE_H_

#include <type_traits>
#include "cocos2d.h"

#include "component/ComponentManager.h"

namespace KoalaComponent
{

MAKE_NOTIFICATION( OnEnter );
MAKE_NOTIFICATION( OnExit );
MAKE_NOTIFICATION( OnUpdateComponentNode, float );
MAKE_NOTIFICATION( OnVisitComponentNode, Utils::Callback<void ()>, bool* );

template <typename BaseClazz>
class ComponentNode : public BaseClazz
{
private:
	typedef BaseClazz inherited;
public:

	static ComponentNode* create()
	{
		static_assert( std::is_base_of<cocos2d::CCNode, BaseClazz>::value,
					   "ComponentNode can be only created with BaseClazz derived from CCNode" );
		ComponentNode* pRet = new ComponentNode();

		if( pRet )
		{
			pRet->autorelease();
			return pRet;
		}

		CC_SAFE_DELETE( pRet );
		return pRet = nullptr;
	}

	virtual ~ComponentNode()
	{
	}

	/**
	 * If you want add here overriden methods
	 */

	virtual void onEnter() override
	{
		inherited::onEnter();
		m_pNotifier.notify( getNotificationOnEnter() );
	}

	virtual void onExit() override
	{
		inherited::onExit();
		m_pNotifier.notify( getNotificationOnExit() );
	}

	virtual void update( float dt ) override
	{
		inherited::update( dt );
		m_pNotifier.notify( getNotificationOnUpdateComponentNode(), dt );
	}

	ComponentManager& getComponentManager()
	{
		return m_manager;
	}

	Notifier& getNotifier()
	{
		return m_pNotifier;
	}

	template<typename Type>
	inline Type* getComponent()
	{
		return m_manager.getComponent<Type>();
	}

protected:
	ComponentNode() :
		m_manager( this, m_pNotifier )
	{
	}

private:
	Notifier m_pNotifier;
	ComponentManager m_manager;
};

} /* namespace KoalaComponent */

#endif /* __COMPONENTNODE_H_ */<commit_msg>Changing prermission level to ComponentNode<commit_after>/*
 * ComponentNode.h
 *
 *  Created on: Dec 27, 2013
 *      Author: dawid
 */

#ifndef __COMPONENTNODE_H_
#define __COMPONENTNODE_H_

#include <type_traits>
#include "cocos2d.h"

#include "component/ComponentManager.h"

namespace KoalaComponent
{

MAKE_NOTIFICATION( OnEnter );
MAKE_NOTIFICATION( OnExit );
MAKE_NOTIFICATION( OnUpdateComponentNode, float );
MAKE_NOTIFICATION( OnVisitComponentNode, Utils::Callback<void ()>, bool* );

template <typename BaseClazz>
class ComponentNode : public BaseClazz
{
private:
	typedef BaseClazz inherited;
public:

	static ComponentNode* create()
	{
		static_assert( std::is_base_of<cocos2d::CCNode, BaseClazz>::value,
					   "ComponentNode can be only created with BaseClazz derived from CCNode" );
		ComponentNode* pRet = new ComponentNode();

		if( pRet )
		{
			pRet->autorelease();
			return pRet;
		}

		CC_SAFE_DELETE( pRet );
		return pRet = nullptr;
	}

	ComponentNode() :
		m_manager( this, m_pNotifier )
	{
	}

	virtual ~ComponentNode()
	{
	}

	/**
	 * If you want add here overriden methods
	 */

	virtual void onEnter() override
	{
		inherited::onEnter();
		m_pNotifier.notify( getNotificationOnEnter() );
	}

	virtual void onExit() override
	{
		inherited::onExit();
		m_pNotifier.notify( getNotificationOnExit() );
	}

	virtual void update( float dt ) override
	{
		inherited::update( dt );
		m_pNotifier.notify( getNotificationOnUpdateComponentNode(), dt );
	}

	ComponentManager& getComponentManager()
	{
		return m_manager;
	}

	Notifier& getNotifier()
	{
		return m_pNotifier;
	}

	template<typename Type>
	inline Type* getComponent()
	{
		return m_manager.getComponent<Type>();
	}

private:
	Notifier m_pNotifier;
	ComponentManager m_manager;
};

} /* namespace KoalaComponent */

#endif /* __COMPONENTNODE_H_ */
{'fraction_non_alphanumeric': 0.11227010705462531, 'fraction_numerical': 0.0043919846280538015, 'mean_word_length': 4.6061538461538465, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6175469', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1240, 'n_words': 277}