/*****************************************************************************
 * $LastChangedDate: 2009-11-22 22:39:11 -0500 (Sun, 22 Nov 2009) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   Shader name.
 *//*
 * LEGAL:   COPYRIGHT (C) 2009 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#ifndef SHADER_SHADER_NAME_HH
#define SHADER_SHADER_NAME_HH 1

#include "shader/defs.hh"

namespace shader {

////////////////////////////////////////////////////////////////////////////////
/// @brief ID of a shader.
///
/// Default shader can be referenced by either Shader("default") or Shader().
/// Rationale is that Lua scripts could use "default" or omit name.
///
class ShaderName
{
public:
    ShaderName( void )
    : mName(SHADER_NAME_DEFAULT),
      mDefault(true)
    { }

    ShaderName( const string& name )
    : mName(name.empty() ? SHADER_NAME_DEFAULT : name),
      mDefault(mName == SHADER_NAME_DEFAULT)  // --ORDER-DEPENDENT-- in case default name passed as string
    { }

    bool            IfDefaultShader( void ) const { return mDefault; }
    const string&   GetString( void ) const { return mName; }

    friend bool operator<( const ShaderName& a, const ShaderName& b ) { return a.mName < b.mName; }
    friend bool operator==( const ShaderName& a, const ShaderName& b ) { return a.mName == b.mName; }
           bool operator==( const char* name ) const { return mName == name; }

private:
    const string    mName;
    const bool      mDefault;   ///< if name is of the default shader (no need to be tested by operator<())
};

} // namespace shader

#endif // SHADER_SHADER_NAME_HH
