OpenWalnut  1.4.0
Public Types | Public Member Functions | Protected Member Functions | Private Attributes
WGEShaderDefineOptions Class Reference

This GLSL preprocessor is able to set one define from a list of defines depending on the active option. More...

#include <WGEShaderDefineOptions.h>

+ Inheritance diagram for WGEShaderDefineOptions:

List of all members.

Public Types

typedef boost::shared_ptr
< WGEShaderDefineOptions
SPtr
 Shared pointer for this class.
typedef boost::shared_ptr
< const WGEShaderDefineOptions
ConstSPtr
 A const shared pointer for this class.
typedef std::vector< size_tIdxList
 The type of the index list.

Public Member Functions

 WGEShaderDefineOptions (std::string first, std::string option2="", std::string option3="", std::string option4="", std::string option5="", std::string option6="", std::string option7="", std::string option8="", std::string option9="", std::string option10="")
 Create a new instance of this class.
 WGEShaderDefineOptions (std::vector< std::string > options)
 Create a new instance of this class.
virtual ~WGEShaderDefineOptions ()
 Destructor.
virtual std::string process (const std::string &file, const std::string &code) const
 Process the whole code.
const IdxListgetActiveOptions () const
 Returns the currently active option as index.
std::string getOptionName (size_t idx) const
 Returns the name of the specified option.
void activateOption (size_t idx, bool exclusive=true)
 Activates the option specified.
void deactivateOption (size_t idx)
 De-activates the specified option.
void activateAllOptions ()
 Activates all the options.
void deactivateAllOptions ()
 De-activates all the options.
void addOption (std::string opt)
 Adds the specified string as option which is inserted to the code as "#define NAME" if active.

Protected Member Functions

void setActivationList (const IdxList &newList)
 Sets the specified index list as the new activation list.

Private Attributes

std::vector< std::string > m_options
 The list of options.
IdxList m_idx
 The currently selected options.

Detailed Description

This GLSL preprocessor is able to set one define from a list of defines depending on the active option.

You should prefer this class instead of WGEShaderDefine if many mutual exclusive options should be handled comfortably.

Notes:
: operations on the option list are not thread-safe.

Definition at line 43 of file WGEShaderDefineOptions.h.


Member Typedef Documentation

typedef boost::shared_ptr< const WGEShaderDefineOptions > WGEShaderDefineOptions::ConstSPtr

A const shared pointer for this class.

Reimplemented from WGEShaderPreprocessor.

Reimplemented in WGEShaderPropertyDefineOptions< PropType, PropIndexAdapter >.

Definition at line 54 of file WGEShaderDefineOptions.h.

typedef std::vector< size_t > WGEShaderDefineOptions::IdxList

The type of the index list.

Definition at line 59 of file WGEShaderDefineOptions.h.

Shared pointer for this class.

Reimplemented from WGEShaderPreprocessor.

Reimplemented in WGEShaderPropertyDefineOptions< PropType, PropIndexAdapter >.

Definition at line 49 of file WGEShaderDefineOptions.h.


Constructor & Destructor Documentation

WGEShaderDefineOptions::WGEShaderDefineOptions ( std::string  first,
std::string  option2 = "",
std::string  option3 = "",
std::string  option4 = "",
std::string  option5 = "",
std::string  option6 = "",
std::string  option7 = "",
std::string  option8 = "",
std::string  option9 = "",
std::string  option10 = "" 
)

Create a new instance of this class.

The first option is mandatory and is set as default.

Parameters:
firstfist option. Is default.
option2another option
option3another option
option4another option
option5another option
option6another option
option7another option
option8another option
option9another option
option10another option

Definition at line 34 of file WGEShaderDefineOptions.cpp.

References m_options.

WGEShaderDefineOptions::WGEShaderDefineOptions ( std::vector< std::string >  options) [explicit]

Create a new instance of this class.

The first option is mandatory and is set as default.

Parameters:
optionsthe list of options. Must have a size greater 0.

Definition at line 81 of file WGEShaderDefineOptions.cpp.

Destructor.

Definition at line 89 of file WGEShaderDefineOptions.cpp.


Member Function Documentation

Activates all the options.

Definition at line 157 of file WGEShaderDefineOptions.cpp.

References m_idx, m_options, and WGEShaderPreprocessor::updated().

void WGEShaderDefineOptions::activateOption ( size_t  idx,
bool  exclusive = true 
)

Activates the option specified.

Parameters:
idxthe option index to activate
exclusiveif true, all active options get deactivated and the specified one will be the only active one afterwards

Definition at line 124 of file WGEShaderDefineOptions.cpp.

References m_idx, m_options, and WGEShaderPreprocessor::updated().

void WGEShaderDefineOptions::addOption ( std::string  opt)

Adds the specified string as option which is inserted to the code as "#define NAME" if active.

Must be a unique name. If it already exists in the list, nothing happens.

Parameters:
optthe option name.

Definition at line 175 of file WGEShaderDefineOptions.cpp.

References m_options, and WGEShaderPreprocessor::updated().

De-activates all the options.

Definition at line 168 of file WGEShaderDefineOptions.cpp.

References m_idx, and WGEShaderPreprocessor::updated().

De-activates the specified option.

If it is not activated, nothing happens.

Parameters:
idxthe option to deactivate

Definition at line 147 of file WGEShaderDefineOptions.cpp.

References m_idx, and WGEShaderPreprocessor::updated().

Returns the currently active option as index.

Returns:
the index of the active option

Definition at line 113 of file WGEShaderDefineOptions.cpp.

References m_idx.

std::string WGEShaderDefineOptions::getOptionName ( size_t  idx) const

Returns the name of the specified option.

Parameters:
idxthe index
Returns:
the name

Definition at line 118 of file WGEShaderDefineOptions.cpp.

References m_options.

Referenced by process().

std::string WGEShaderDefineOptions::process ( const std::string &  file,
const std::string &  code 
) const [virtual]

Process the whole code.

It is not allowed to modify some internal state in this function because it might be called by several shaders.

Parameters:
codethe code to process
filethe filename of the shader currently processed. Should be used for debugging output.
Returns:
the resulting new code

Implements WGEShaderPreprocessor.

Definition at line 94 of file WGEShaderDefineOptions.cpp.

References WGEShaderPreprocessor::getActive(), getOptionName(), and m_idx.

void WGEShaderDefineOptions::setActivationList ( const IdxList newList) [protected]

Sets the specified index list as the new activation list.

Triggers an update.

Parameters:
newListthe ne list getting copied to the internal activation list.

Definition at line 187 of file WGEShaderDefineOptions.cpp.

References m_idx, and WGEShaderPreprocessor::updated().


Member Data Documentation

std::vector< std::string > WGEShaderDefineOptions::m_options [private]

The list of options.

Definition at line 163 of file WGEShaderDefineOptions.h.

Referenced by activateAllOptions(), activateOption(), addOption(), getOptionName(), and WGEShaderDefineOptions().


The documentation for this class was generated from the following files: