Whats a good design pattern for class that wraps shader parameter values
<p>I am trying to design a class that would wrap shader parameter in such way that it would enable the user to easily set and get its value without a need to write a tonne of validation code outside of this class implementation. </p>

<p>The problem is that obviously the shader parameter values can be of different types, and whether I use templates or method overloading it results in a lot of messy code that if one was to use this class it would probably not be a very pleasant experience.</p>

<p>Is there some clever design pattern that once implemented would render the usage of said class to be more straightforward? I wouldn't mind if the mechanism was more complex as long as its implementation is not exposed to the user of this class.</p>

<p>Also just to be more clear, this shader parameter class is somewhat abstract in that its purpose is only to store the parameter for easier editing and handling across my code base. It does not interact or have any knowledge about the actual shader.</p>

<p><strong>Edit 1:</strong>
Here's how I attempted to solve the issue before with templates and why I failed:</p>

<p>My template values were derived from a non template base class that I used to store them in a STL containers, but I have run into issues when retrieving the values and being unable to up cast them back into their template values, another issue was the amount of code needed to set and get the values when using this class implementation </p>

<p><strong>Edit 2:</strong></p>

<p>The ideal usage would be :</p>

<pre><code>ShaderParameter* param = ShaderParameterCollection.GetParameter("color_param");
ShaderParameterCollection-&gt;GetParameter("property_name")-&gt;Set(vec3());
ShaderParameterCollection-&gt;GetParameter("property_name")-&gt;Get(&amp;out);
ShaderParameterCollection-&gt;AddParameter("property_name", FLOAT_VEC3, vec3());
</code></pre>

<p>ShaderParamterCollection is just a storage class that internally uses STL container, does mapping and validation, I already have that one sorted.</p>