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

#pragma once

#include "glmAbstractAttribute.h"
#include "glmAssert.h"

namespace glm
{
	//-------------------------------------------------------------------------
	// getAttributeValue
	//-------------------------------------------------------------------------
	template < class TValue, class TOwner >
	inline TValue
		getAttributeValue( const TOwner& owner, unsigned int attributeNumber )
	{
		const AbstractAttribute* attribute( owner.getRTTI().getAttribute( attributeNumber ) ) ;
		GLM_ASSERT_MSG( attribute != NULL, "attribute number out of range" ) ;
		return attribute->getValue<TValue>( owner ) ;
	}

	//-------------------------------------------------------------------------
	// getAttributeValue
	//-------------------------------------------------------------------------
	template < class TValue, class TOwner >
	inline TValue
		getAttributeValue( const TOwner& owner, const char* name )
	{
		const AbstractAttribute* attribute( owner.getRTTI().getAttribute( name ) ) ;
		GLM_ASSERT_MSG( attribute != NULL, "attribute name does not exist" ) ;
		return attribute->getValue<TValue>( owner ) ;
	}

	//-------------------------------------------------------------------------
	// setAttributeValue
	//-------------------------------------------------------------------------
	template < class TValue, class TOwner >
	inline void
		setAttributeValue( TOwner& owner, unsigned int attributeNumber, TValue value )
	{
		const AbstractAttribute* attribute( owner.getRTTI().getAttribute( attributeNumber ) ) ;
		GLM_ASSERT_MSG( attribute != NULL, "attribute number out of range" ) ;
		attribute->setValue<TValue>( owner, value ) ;
	}


	//-------------------------------------------------------------------------
	// setAttributeValue
	//-------------------------------------------------------------------------
	template < class TValue, class TOwner >
	inline void
		setAttributeValue( TOwner& owner, const char* name, TValue value )
	{
		const AbstractAttribute* attribute ( owner.getRTTI().getAttribute( name ) ) ;
		GLM_ASSERT_MSG( attribute != NULL, "attribute name does not exist" ) ;
		attribute->setValue<TValue>( owner, value ) ;
	}
}
