OpenWalnut  1.5.0dev
Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
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:
+ Collaboration diagram for WGEShaderDefineOptions:

Public Types

typedef std::shared_ptr< WGEShaderDefineOptionsSPtr
 Shared pointer for this class. More...
 
typedef std::shared_ptr< const WGEShaderDefineOptionsConstSPtr
 A const shared pointer for this class. More...
 
typedef std::vector< size_t > IdxList
 The type of the index list. More...
 
- Public Types inherited from WGEShaderPreprocessor
typedef std::shared_ptr< WGEShaderPreprocessorSPtr
 Shared pointer for this class. More...
 
typedef std::shared_ptr< const WGEShaderPreprocessorConstSPtr
 A const shared pointer for this class. More...
 

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. More...
 
 WGEShaderDefineOptions (std::vector< std::string > options)
 Create a new instance of this class. More...
 
virtual ~WGEShaderDefineOptions ()
 Destructor. More...
 
virtual std::string process (const std::string &file, const std::string &code) const
 Process the whole code. More...
 
const IdxListgetActiveOptions () const
 Returns the currently active option as index. More...
 
std::string getOptionName (size_t idx) const
 Returns the name of the specified option. More...
 
void activateOption (size_t idx, bool exclusive=true)
 Activates the option specified. More...
 
void deactivateOption (size_t idx)
 De-activates the specified option. More...
 
void activateAllOptions ()
 Activates all the options. More...
 
void deactivateAllOptions ()
 De-activates all the options. More...
 
void addOption (std::string opt)
 Adds the specified string as option which is inserted to the code as "#define NAME" if active. More...
 
- Public Member Functions inherited from WGEShaderPreprocessor
 WGEShaderPreprocessor ()
 Default constructor. More...
 
virtual ~WGEShaderPreprocessor ()
 Destructor. More...
 
virtual WCondition::SPtr getChangeCondition () const
 Returns the condition denoting a change in this preprocessor filter. More...
 
void setActive (bool active=true)
 (De-)activates the preprocessor. More...
 
bool getActive () const
 If the preprocessor is active, this returns true. More...
 

Protected Member Functions

void setActivationList (const IdxList &newList)
 Sets the specified index list as the new activation list. More...
 
- Protected Member Functions inherited from WGEShaderPreprocessor
virtual void updated ()
 Fires m_updateCondition which should denote an update in the preprocessor filter. More...
 

Private Attributes

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

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.

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

Definition at line 43 of file WGEShaderDefineOptions.h.

Member Typedef Documentation

◆ ConstSPtr

A const shared pointer for this class.

Definition at line 54 of file WGEShaderDefineOptions.h.

◆ IdxList

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

The type of the index list.

Definition at line 59 of file WGEShaderDefineOptions.h.

◆ SPtr

Shared pointer for this class.

Definition at line 49 of file WGEShaderDefineOptions.h.

Constructor & Destructor Documentation

◆ WGEShaderDefineOptions() [1/2]

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() [2/2]

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.

◆ ~WGEShaderDefineOptions()

WGEShaderDefineOptions::~WGEShaderDefineOptions ( )
virtual

Destructor.

Definition at line 89 of file WGEShaderDefineOptions.cpp.

Member Function Documentation

◆ activateAllOptions()

void WGEShaderDefineOptions::activateAllOptions ( )

Activates all the options.

Definition at line 157 of file WGEShaderDefineOptions.cpp.

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

+ Here is the call graph for this function:

◆ activateOption()

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().

+ Here is the call graph for this function:

◆ addOption()

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().

+ Here is the call graph for this function:

◆ deactivateAllOptions()

void WGEShaderDefineOptions::deactivateAllOptions ( )

De-activates all the options.

Definition at line 168 of file WGEShaderDefineOptions.cpp.

References m_idx, and WGEShaderPreprocessor::updated().

+ Here is the call graph for this function:

◆ deactivateOption()

void WGEShaderDefineOptions::deactivateOption ( size_t  idx)

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().

+ Here is the call graph for this function:

◆ getActiveOptions()

const WGEShaderDefineOptions::IdxList & WGEShaderDefineOptions::getActiveOptions ( ) const

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.

◆ getOptionName()

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().

+ Here is the caller graph for this function:

◆ 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.

+ Here is the call graph for this function:

◆ setActivationList()

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().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_idx

IdxList WGEShaderDefineOptions::m_idx
private

◆ m_options

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: