Loads and writes a set of uniforms variables values from a file or a string. More...
#include <UniformsLoader.hpp>
Classes | |
class | Node |
Container structure (filter, pipeline). More... | |
class | Resource |
Resource (variable) of a structure (filter, pipeline). More... | |
Public Types | |
enum | LoadingFilter { LoadAll, NewOnly, NewOnlySilent, ReplaceOnly, ReplaceOnlySilent } |
Flags used for loading data from pipelines, strings or files. More... | |
typedef std::map< const std::string, Node > ::const_iterator | NodeConstIterator |
Const iterator over the nodes (refers to a std::pair, use second to access the const UniformsLoader::Node& object). | |
typedef std::map< const std::string, Node >::iterator | NodeIterator |
Iterator over the nodes (refers to a std::pair, use second to access the UniformsLoader::Node& object). | |
typedef std::map< const std::string, Resource > ::const_iterator | ResourceConstIterator |
Const iterator over the resources (refers to a std::pair, use second to access the const UniformsLoader::Resource& object). | |
typedef std::map< const std::string, Resource > ::iterator | ResourceIterator |
Iterator over the resources (refers to a std::pair, use second to access the UniformsLoader::Resource& object). | |
Public Member Functions | |
UniformsLoader (void) | |
UniformsLoader constructor. | |
UniformsLoader (const UniformsLoader &cpy) | |
UniformsLoader copy constructor. More... | |
void | load (std::string source, LoadingFilter loadingFilter=LoadAll, int lineOffset=1) |
Loads a set of uniforms variables for one, or multiple, pipelines. More... | |
void | load (Pipeline &pipeline, LoadingFilter loadingFilter=LoadAll) |
Load the set of uniforms variables from a pipeline. More... | |
void | load (const UniformsLoader &subLoader, LoadingFilter loadingFilter=LoadAll) |
Load data from another UniformsLoader object. More... | |
bool | empty (void) const |
Test if this object has some data loaded. More... | |
void | clear (void) |
Clear the full set of data. | |
void | clear (const std::string &name) |
Clear the pipeline with the corresponding name. More... | |
bool | hasPipeline (const std::string &name) const |
Test if a pipeline has values attached in this UniformsLoader object (knowing its name). More... | |
std::vector< std::string > | getPipelinesTypeNames (void) const |
Get the layout names of all the pipelines which have data loaded. More... | |
const Node & | getRootNode (const std::string &name) const |
Access the container node of a pipeline type. More... | |
Node & | getRootNode (const std::string &name) |
Access the container node of a pipeline type. More... | |
NodeConstIterator | rootNodeBegin (void) const |
Get the 'begin' iterator on the nodes list. More... | |
NodeConstIterator | rootNodeEnd (void) const |
Get the 'end' iterator on the nodes list. More... | |
NodeIterator | rootNodeBegin (void) |
Get the 'begin' iterator on the nodes list. More... | |
NodeIterator | rootNodeEnd (void) |
Get the 'end' iterator on the nodes list. More... | |
int | applyTo (Pipeline &pipeline, bool forceWrite=true, bool silent=false) const |
Copy the possibly loaded set of uniforms variables to a pipeline (for the corresponding name of the Pipeline instance). More... | |
std::string | getCode (void) const |
Return the corresponding code for the current set of variables, for one, or multiple, pipelines. The format is human-readable. More... | |
std::string | getCode (const std::string &name) const |
Return the corresponding code of the corresponding pipeline. The format is human-readable. More... | |
void | writeToFile (const std::string &filename) const |
Write the corresponding code for the current set of variables, for one, or multiple, pipelines to a file. The format is human-readable. Note : in order to append, you must load the original first. More... | |
Static Public Member Functions | |
static const char * | getKeyword (UniformsLoaderKeyword k) |
Get the actual keyword string. More... | |
Loads and writes a set of uniforms variables values from a file or a string.
Load, store and manage set of uniforms values for one, or multiple pipelines. The code is set to be human readable :
Example :
Processing example :
Note that each UniformsLoader will index the pipelines by their layout name (see AbstractComponentLayout::getLayoutName()). Each can only have one set of pipeline uniform variables per layout name.
Flags used for loading data from pipelines, strings or files.
Enumerator | |
---|---|
LoadAll |
Load all the data, append new data, replace existing data. |
NewOnly |
Load only new data, throw an Exception if some data already exists. |
NewOnlySilent |
Load only new data, ignore data which already exists. |
ReplaceOnly |
Replace existing data only, throw an Exception if there is some new data. |
ReplaceOnlySilent |
Replace existing data only, ignore new data. |
UniformsLoader::UniformsLoader | ( | const UniformsLoader & | cpy | ) |
UniformsLoader copy constructor.
cpy | The object to be copied. |
int UniformsLoader::applyTo | ( | Pipeline & | pipeline, |
bool | forceWrite = true , |
||
bool | silent = false |
||
) | const |
Copy the possibly loaded set of uniforms variables to a pipeline (for the corresponding name of the Pipeline instance).
pipeline | The pipeline to which the data has to be copied (if relevant). |
forceWrite | If set to false, only the variable marked as modified will be loaded (see UniformsLoader::Resource::modified). |
silent | If true, no exception will be reported (aside from internal exception). |
void UniformsLoader::clear | ( | const std::string & | name | ) |
Clear the pipeline with the corresponding name.
name | The name of the pipeline to be erased. |
bool UniformsLoader::empty | ( | void | ) | const |
Test if this object has some data loaded.
std::string UniformsLoader::getCode | ( | void | ) | const |
Return the corresponding code for the current set of variables, for one, or multiple, pipelines. The format is human-readable.
std::string UniformsLoader::getCode | ( | const std::string & | name | ) | const |
Return the corresponding code of the corresponding pipeline. The format is human-readable.
name | The name of the pipeline to target. |
|
static |
Get the actual keyword string.
k | The index of the keyword. |
std::vector< std::string > UniformsLoader::getPipelinesTypeNames | ( | void | ) | const |
Get the layout names of all the pipelines which have data loaded.
const UniformsLoader::Node & UniformsLoader::getRootNode | ( | const std::string & | name | ) | const |
Access the container node of a pipeline type.
name | The layout name of the targeted pipeline. |
UniformsLoader::Node & UniformsLoader::getRootNode | ( | const std::string & | name | ) |
Access the container node of a pipeline type.
name | The layout name of the targeted pipeline. |
bool UniformsLoader::hasPipeline | ( | const std::string & | name | ) | const |
Test if a pipeline has values attached in this UniformsLoader object (knowing its name).
name | The name of the pipeline to test (see Component::getName()). |
void UniformsLoader::load | ( | std::string | source, |
LoadingFilter | loadingFilter = LoadAll , |
||
int | lineOffset = 1 |
||
) |
Loads a set of uniforms variables for one, or multiple, pipelines.
source | Either a filename or directly the source string (in this case it must contain at least one newline character '\n'). |
loadingFilter | Select a specific method of loading. |
lineOffset | Set the line number offset for error reporting. |
void UniformsLoader::load | ( | Pipeline & | pipeline, |
LoadingFilter | loadingFilter = LoadAll |
||
) |
Load the set of uniforms variables from a pipeline.
pipeline | The pipeline to extract the data from. |
loadingFilter | Select a specific method of loading. |
All the pipelines are stored according to their layout name. Only one pipeline per layout name is supported.
void UniformsLoader::load | ( | const UniformsLoader & | subLoader, |
LoadingFilter | loadingFilter = LoadAll |
||
) |
Load data from another UniformsLoader object.
subLoader | Other object. |
loadingFilter | Select a specific method of loading. |
UniformsLoader::NodeConstIterator UniformsLoader::rootNodeBegin | ( | void | ) | const |
Get the 'begin' iterator on the nodes list.
UniformsLoader::NodeIterator UniformsLoader::rootNodeBegin | ( | void | ) |
Get the 'begin' iterator on the nodes list.
UniformsLoader::NodeConstIterator UniformsLoader::rootNodeEnd | ( | void | ) | const |
Get the 'end' iterator on the nodes list.
UniformsLoader::NodeIterator UniformsLoader::rootNodeEnd | ( | void | ) |
Get the 'end' iterator on the nodes list.
void UniformsLoader::writeToFile | ( | const std::string & | filename | ) | const |
Write the corresponding code for the current set of variables, for one, or multiple, pipelines to a file. The format is human-readable. Note : in order to append, you must load the original first.
filename | The filename of the file to write to. |