C
Christopher
My goal is to make maps where the key is a string name and the value
is a pair of data, one being a value, and one being a bool telling me
whether that value has been initialized to something meaningful.
How do I change these existing maps to take the AttributeValue struct
in the private section with T being a specific data type?
//----------------------------------------------------------------------------
/**
* Material
*
* Dynamic container of those variables relating to an effect.
*
* A Material first has to be created by an effect in order to allocate
the differant
* types of attributes the effect uses. It can then be set and given
back to the
* effect to set the values of the effect's variables.
*/
class Material
{
public:
/**
* Constructor
*/
Material();
/**
* Deconstructor
*/
~Material();
//-----
// Matrix type
//-----
/**
* Sets a matrix attribute
*
* If the attribute does not exist, it creates the attribute
*/
void SetMatrix(const std::string & name, const D3DXMATRIX & value);
/**
* Gets a matrix attribute
**/
const D3DXMATRIX & GetMatrix(const std::string & name) const;
//-----
// Float type
//-----
/**
* Sets a float attribute
*
* If the attribute does not exist, it creates the attribute
*/
void SetFloat(const std::string & name, const float value);
/**
* Gets a float attribute
**/
const float GetFloat(const std::string & name) const;
//-----
// Texture type
//-----
/**
* Sets a texture attribute
*
* If the attribute does not exist, it creates the attribute
*/
void SetTexture(const std::string & variableName, const std::string
& textureName);
/**
* Gets a texture attribute
*/
const std::string GetTexture(const std::string & variableName)
const;
private:
template <class T>
struct AttributeValue
{
bool m_initialized;
T m_value;
};
///////// HELP NEEDED HERE ////////////
/**
* Map of the matrix variables
*
* key - matrix variable name as it appears in the DirectX effect
* value - matrix
*/
typedef std::map<std::string, D3DXMATRIX> Matrices;
Matrices m_matrices;
/**
* Map of the single float variables
*
* key - float variable name as it appears in the DirectX effect
* value - float
*/
typedef std::map<std::string, float> Floats;
Floats m_floats;
/**
* Map of the texture variables
*
* key - texture variable name as it appears in the DirectX effect
* value - texture name as it appears in the texture manager
*/
typedef std::map<std::string, std::string> Textures;
Textures m_textures;
};
#endif
is a pair of data, one being a value, and one being a bool telling me
whether that value has been initialized to something meaningful.
How do I change these existing maps to take the AttributeValue struct
in the private section with T being a specific data type?
//----------------------------------------------------------------------------
/**
* Material
*
* Dynamic container of those variables relating to an effect.
*
* A Material first has to be created by an effect in order to allocate
the differant
* types of attributes the effect uses. It can then be set and given
back to the
* effect to set the values of the effect's variables.
*/
class Material
{
public:
/**
* Constructor
*/
Material();
/**
* Deconstructor
*/
~Material();
//-----
// Matrix type
//-----
/**
* Sets a matrix attribute
*
* If the attribute does not exist, it creates the attribute
*/
void SetMatrix(const std::string & name, const D3DXMATRIX & value);
/**
* Gets a matrix attribute
**/
const D3DXMATRIX & GetMatrix(const std::string & name) const;
//-----
// Float type
//-----
/**
* Sets a float attribute
*
* If the attribute does not exist, it creates the attribute
*/
void SetFloat(const std::string & name, const float value);
/**
* Gets a float attribute
**/
const float GetFloat(const std::string & name) const;
//-----
// Texture type
//-----
/**
* Sets a texture attribute
*
* If the attribute does not exist, it creates the attribute
*/
void SetTexture(const std::string & variableName, const std::string
& textureName);
/**
* Gets a texture attribute
*/
const std::string GetTexture(const std::string & variableName)
const;
private:
template <class T>
struct AttributeValue
{
bool m_initialized;
T m_value;
};
///////// HELP NEEDED HERE ////////////
/**
* Map of the matrix variables
*
* key - matrix variable name as it appears in the DirectX effect
* value - matrix
*/
typedef std::map<std::string, D3DXMATRIX> Matrices;
Matrices m_matrices;
/**
* Map of the single float variables
*
* key - float variable name as it appears in the DirectX effect
* value - float
*/
typedef std::map<std::string, float> Floats;
Floats m_floats;
/**
* Map of the texture variables
*
* key - texture variable name as it appears in the DirectX effect
* value - texture name as it appears in the texture manager
*/
typedef std::map<std::string, std::string> Textures;
Textures m_textures;
};
#endif