<commit_before>#pragma once

#include <string>
#include <d3d9.h>
#include <d3dx9effect.h>

template<typename T>
class EffectParameter
{
	std::string name;
	ID3DXEffect** effect;
	D3DXHANDLE handle;
	bool modified;
	T last;
	T data;

public:
	explicit EffectParameter(ID3DXEffect** effect, const std::string& name, const T& defaultValue)
		: name(name), effect(effect), handle(nullptr), modified(false), last(defaultValue), data(defaultValue)
	{
	}

	EffectParameter<T>& operator=(EffectParameter<T>&& inst) noexcept;

	void UpdateHandle();
	void ClearModified();
	void SetValue();
	void operator=(const T& value);
};


template <typename T>
EffectParameter<T>& EffectParameter<T>::operator=(EffectParameter<T>&& inst) noexcept
{
	name     = inst.name;
	effect   = inst.effect;
	handle   = inst.handle;
	modified = inst.modified;
	last     = inst.last;
	data     = inst.data;

	inst.effect = nullptr;
	return *this;
}

template <typename T>
void EffectParameter<T>::UpdateHandle()
{
	handle = (*effect)->GetParameterByName(nullptr, name.c_str());
	modified = true;
	SetValue();
}

template <typename T>
void EffectParameter<T>::ClearModified()
{
	last = data;
	modified = false;
}

template <typename T>
void EffectParameter<T>::SetValue()
{
	if (modified)
	{
		(*effect)->SetValue(handle, &data, sizeof(T));
		ClearModified();
	}
}

template <typename T>
void EffectParameter<T>::operator=(const T& value)
{
	modified = !!(last != value);
	data = value;
	SetValue();
}

template<> void EffectParameter<D3DXMATRIX>::operator=(const D3DXMATRIX& value);

template<> void EffectParameter<bool>::SetValue();
template<> void EffectParameter<int>::SetValue();
template<> void EffectParameter<float>::SetValue();
template<> void EffectParameter<D3DXVECTOR4>::SetValue();
template<> void EffectParameter<D3DXVECTOR3>::SetValue();
template<> void EffectParameter<D3DXCOLOR>::SetValue();
template<> void EffectParameter<D3DXMATRIX>::SetValue();
template<> void EffectParameter<IDirect3DTexture9*>::SetValue();<commit_msg>Removed generic SetValue from EffectParameter<commit_after>#pragma once

#include <string>
#include <d3d9.h>
#include <d3dx9effect.h>

template<typename T>
class EffectParameter
{
	std::string name;
	ID3DXEffect** effect;
	D3DXHANDLE handle;
	bool modified;
	T last;
	T data;

public:
	explicit EffectParameter(ID3DXEffect** effect, const std::string& name, const T& defaultValue)
		: name(name), effect(effect), handle(nullptr), modified(false), last(defaultValue), data(defaultValue)
	{
	}

	EffectParameter<T>& operator=(EffectParameter<T>&& inst) noexcept;

	void UpdateHandle();
	void ClearModified();
	void SetValue();
	void operator=(const T& value);
};


template <typename T>
EffectParameter<T>& EffectParameter<T>::operator=(EffectParameter<T>&& inst) noexcept
{
	name     = inst.name;
	effect   = inst.effect;
	handle   = inst.handle;
	modified = inst.modified;
	last     = inst.last;
	data     = inst.data;

	inst.effect = nullptr;
	return *this;
}

template <typename T>
void EffectParameter<T>::UpdateHandle()
{
	handle = (*effect)->GetParameterByName(nullptr, name.c_str());
	modified = true;
	SetValue();
}

template <typename T>
void EffectParameter<T>::ClearModified()
{
	last = data;
	modified = false;
}

template <typename T>
void EffectParameter<T>::operator=(const T& value)
{
	modified = !!(last != value);
	data = value;
	SetValue();
}

template<> void EffectParameter<D3DXMATRIX>::operator=(const D3DXMATRIX& value);

template<> void EffectParameter<bool>::SetValue();
template<> void EffectParameter<int>::SetValue();
template<> void EffectParameter<float>::SetValue();
template<> void EffectParameter<D3DXVECTOR4>::SetValue();
template<> void EffectParameter<D3DXVECTOR3>::SetValue();
template<> void EffectParameter<D3DXCOLOR>::SetValue();
template<> void EffectParameter<D3DXMATRIX>::SetValue();
template<> void EffectParameter<IDirect3DTexture9*>::SetValue();
{'fraction_non_alphanumeric': 0.15025641025641026, 'fraction_numerical': 0.008717948717948718, 'mean_word_length': 6.755467196819086, 'pattern_counts': {'":': 0, '<': 73, '<?xml version=': 0, '>': 76, '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': '7467580', 'n_tokens_mistral': 1269, 'n_tokens_neox': 1248, 'n_words': 292}