Module description for the LayoutLoader class. More...
#include <LayoutLoaderModules.hpp>
Public Member Functions | |
virtual void | apply (const std::vector< std::string > &arguments, const std::string &body, const std::string ¤tPath, std::vector< std::string > &dynamicPaths, std::map< std::string, HdlTextureFormat > &formatList, std::map< std::string, ShaderSource > &sourceList, std::map< std::string, GeometryModel > &geometryList, std::map< std::string, FilterLayout > &filterList, std::map< std::string, PipelineLayout > &pipelineList, std::string &mainPipelineName, const std::vector< std::string > &staticPaths, const std::map< std::string, HdlTextureFormat > &requiredFormatList, const std::map< std::string, ShaderSource > &requiredSourceList, const std::map< std::string, GeometryModel > &requiredGeometryList, const std::map< std::string, PipelineLayout > &requiredPipelineList, const std::map< std::string, LayoutLoaderModule * > &moduleList, const std::string &sourceName, const int startLine, const int bodyLine, std::string &executionSource, std::string &executionSourceName, int &executionStartLine)=0 |
Interface of the module : this function will be called on each corresponding token CALL for the LayoutLoader which has the module. More... | |
const std::string & | getName (void) const |
Get the name of the module. More... | |
const int & | getMinNumArguments (void) const |
Get the minimum number of arguments of the module. More... | |
const int & | getMaxNumArguments (void) const |
Get the maximum number of arguments of the module. More... | |
const char & | bodyPresenceTest (void) const |
Get the requirement on the body. More... | |
const std::string & | getDescription (void) const |
Get the description of the module. More... | |
const std::string & | getBodyDescription (void) const |
Get the description of the body of the module. More... | |
const std::vector< std::pair < std::string, std::string > > & | getArgumentsDescriptions (void) const |
Get the description of all the arguments of the module. More... | |
std::string | getManual (void) const |
Get the manual of the module. More... | |
virtual void | beginLoadLayout (void) |
Function called at the beginning of a loading session. | |
virtual void | endLoadLayout (void) |
Function called at the end of a loading session. | |
Static Public Member Functions | |
static void | addBasicModules (LayoutLoader &loader) |
Add the basic modules to a LayoutLoader. More... | |
static std::vector < LayoutLoaderModule * > | getBasicModulesList (void) |
Retrieve the list of standard modules. More... | |
static bool | getBoolean (const std::string &arg, const std::string &sourceName="", int line=1) |
Convert a keyword to a boolean. More... | |
static void | getCases (const std::string &body, std::string &trueCase, int &trueCaseStartLine, std::string &falseCase, int &falseCaseStartLine, const std::string &sourceName="", int bodyLine=1) |
Get true and false cases out of a body. More... | |
static std::vector< std::string > | findFile (const std::string &filename, const std::vector< std::string > &dynamicPaths) |
Find in which path a file can be found. More... | |
Protected Member Functions | |
LayoutLoaderModule (const std::string &_name, const std::string &_manual, const int &_minNumArguments, const int &_maxNumArguments, const char &_bodyPresence) | |
LayoutLoaderModule constructor. For simple modules you can just use the macro LAYOUT_LOADER_MODULE_APPLY. More... | |
Module description for the LayoutLoader class.
You can write a Module MyModule for a LayoutLoader object, load it, and allow the user to use CALL:MyModule. It will have limited access to the data of the LayoutLoader, and thus be able to create, modify or destroy formats, source codes, shaders, geometries, filters, pipelines, etc. Each Module has a name, a minimum and maximum number of arguments and the information on the need of a body or not.
In order to ease the creation of modules, you will find Macros for accessing data given to the Module.
Several modules are already created but need to be manually added to any LayoutLoader you would like to use via :
Example in a script file :
Example, creating a simple Module :
Use it in a script :
CALL:IF_MODULE_AVAILABLE(moduleName)
{
body
}
Check if the MODULE is available and can be used.
Argument | Description |
---|---|
moduleName | Name of the module to be used. |
Body : Cases corresponding to the test : TRUE{...} FALSE{...}.
CALL:IF_FORMAT_DEFINED(formatName)
{
body
}
Check if the FORMAT was defined.
Argument | Description |
---|---|
formatName | Name of the format to test. |
Body : Cases corresponding to the test : TRUE{...} FALSE{...}.
CALL:IF_SOURCE_DEFINED(sourceName)
{
body
}
Check if the SOURCE was defined.
Argument | Description |
---|---|
sourceName | Name of the source to test. |
Body : Cases corresponding to the test : TRUE{...} FALSE{...}.
CALL:IF_GEOMETRY_DEFINED(geometryName)
{
body
}
Check if the GEOMETRY was defined.
Argument | Description |
---|---|
geometryName | Name of the geometry to test. |
Body : Cases corresponding to the test : TRUE{...} FALSE{...}.
CALL:IF_FILTERLAYOUT_DEFINED(filterLayoutName)
{
body
}
Check if the FILTER_LAYOUT was defined.
Argument | Description |
---|---|
filterLayoutName | Name of the filter layout to test. |
Body : Cases corresponding to the test : TRUE{...} FALSE{...}.
CALL:IF_PIPELINELAYOUT_DEFINED(pipelineLayoutName)
{
body
}
Check if the PIPELINE_LAYOUT was defined.
Argument | Description |
---|---|
pipelineLayoutName | Name of the pipeline layout to test. |
Body : Cases corresponding to the test : TRUE{...} FALSE{...}.
CALL:IF_REQUIREDFORMAT_DEFINED(requiredFormatName)
{
body
}
Check if the REQUIRED_FORMAT was defined.
Argument | Description |
---|---|
requiredFormatName | Name of the required format to test. |
Body : Cases corresponding to the test : TRUE{...} FALSE{...}.
CALL:IF_REQUIREDGEOMETRY_DEFINED(requiredGeometryName)
{
body
}
Check if the REQUIRED_GEOMETRY was defined.
Argument | Description |
---|---|
requiredGeometryName | Name of the required geometry to test. |
Body : Cases corresponding to the test : TRUE{...} FALSE{...}.
CALL:IF_REQUIREDPIPELINE_DEFINED(requiredPipelineName)
{
body
}
Check if the REQUIRED_PIPELINE was defined.
Argument | Description |
---|---|
requiredPipelineName | Name of the required pipeline to test. |
Body : Cases corresponding to the test : TRUE{...} FALSE{...}.
CALL:FORMAT_CHANGE_SIZE(nameNew, nameOriginal, widthNew, heightNew)
Change the size of a format, save as a new format.
Argument | Description |
---|---|
nameNew | Name of the new format. |
nameOriginal | Name of the original format |
widthNew | New width. |
heightNew | New height. |
CALL:FORMAT_SCALE_SIZE(nameNew, nameOriginal, scaleFactor)
Scale a format by a scalar (or two), save as a new format. Will prevent to reach a 0x0 texture by ensuring that the size is at least 1 pixel in each dimension.
Argument | Description |
---|---|
nameNew | Name of the new format. |
nameOriginal | Name of the original format. |
scaleFactor | Scaling to be applied, can be splitted into X and Y. |
CALL:FORMAT_CHANGE_CHANNELS(nameNew, nameOriginal, channelNew)
Change the channels of a format, save as a new format.
Argument | Description |
---|---|
nameNew | Name of the new format. |
nameOriginal | Name of the original format. |
channelNew | New channel mode. |
CALL:FORMAT_CHANGE_DEPTH(nameNew, nameOriginal, depthNew)
Change the depth of a format, save as a new format.
Argument | Description |
---|---|
nameNew | Name of the new format. |
nameOriginal | Name of the original format. |
depthNew | New depth. |
CALL:FORMAT_CHANGE_FILTERING(nameNew, nameOriginal, minNew, magNew)
Change the filtering of a format, save as a new format.
Argument | Description |
---|---|
nameNew | Name of the new format. |
nameOriginal | Name of the original format. |
minNew | New minification filter. |
magNew | New magnification filter. |
CALL:FORMAT_CHANGE_WRAPPING(nameNew, nameOriginal, sNew, tNew)
Change the wrapping of a format, save as a new format.
Argument | Description |
---|---|
nameNew | Name of the new format. |
nameOriginal | Name of the original format. |
sNew | New S wrapping parameter. |
tNew | New T wrapping parameter. |
CALL:FORMAT_CHANGE_MIPMAP(nameNew, nameOriginal, mNew)
Change the mipmap level of a format, save as a new format.
Argument | Description |
---|---|
nameNew | Name of the new format. |
nameOriginal | Name of the original format. |
mNew | New maximum mipmap parameter. |
CALL:FORMAT_MINIMUM_WIDTH(nameNew, nameFormat1, nameFormat2 [, nameFormat3...])
Find the format having the smallest width, save as a new format.
Argument | Description |
---|---|
nameNew | Name of the new format. |
nameFormat1 | Name of the fist format. |
nameFormat2 | Name of the second format. |
nameFormat3... | Other formats. |
CALL:FORMAT_MAXIMUM_WIDTH(nameNew, nameFormat1, nameFormat2 [, nameFormat3...])
Find the format having the largest width, save as a new format.
Argument | Description |
---|---|
nameNew | Name of the new format. |
nameFormat1 | Name of the first format. |
nameFormat2 | Name of the second format. |
nameFormat3... | Other formats. |
CALL:FORMAT_MINIMUM_HEIGHT(nameNew, nameFormat1, nameFormat2 [, nameFormat3...])
Find the format having the smallest height, save as a new format.
Argument | Description |
---|---|
nameNew | Name of the new format. |
nameFormat1 | Name of the fist format. |
nameFormat2 | Name of the second format. |
nameFormat3... | Other formats. |
CALL:FORMAT_MAXIMUM_HEIGHT(nameNew, nameFormat1, nameFormat2 [, nameFormat3...])
Find the format having the largest height, save as a new format.
Argument | Description |
---|---|
nameNew | Name of the new format. |
nameFormat1 | Name of the fist format. |
nameFormat2 | Name of the second format. |
nameFormat3... | Other formats. |
CALL:FORMAT_MINIMUM_PIXELS(nameNew, nameFormat1, nameFormat2 [, nameFormat3...])
Find the format having the smallest number of pixels, save as a new format.
Argument | Description |
---|---|
nameNew | Name of the new format. |
nameFormat1 | Name of the fist format. |
nameFormat2 | Name of the second format. |
nameFormat3... | Other formats. |
CALL:FORMAT_MAXIMUM_PIXELS(nameNew, nameFormat1, nameFormat2 [, nameFormat3...])
Find the format having the largest number of pixels, save as a new format.
Argument | Description |
---|---|
nameNew | Name of the new format. |
nameFormat1 | Name of the fist format. |
nameFormat2 | Name of the second format. |
nameFormat3... | Other formats. |
CALL:FORMAT_MINIMUM_ELEMENTS(nameNew, nameFormat1, nameFormat2 [, nameFormat3...])
Find the format having the smallest number of elements (pixels times channels count), save as a new format.
Argument | Description |
---|---|
nameNew | Name of the new format. |
nameFormat1 | Name of the fist format. |
nameFormat2 | Name of the second format. |
nameFormat3... | Other formats. |
CALL:FORMAT_MAXIMUM_ELEMENTS(nameNew, nameFormat1, nameFormat2 [, nameFormat3...])
Find the format having the largest number of elements (pixels times channels count), save as a new format.
Argument | Description |
---|---|
nameNew | Name of the new format. |
nameFormat1 | Name of the fist format. |
nameFormat2 | Name of the second format. |
nameFormat3... | Other formats. |
CALL:FORMAT_SMALLER_POWER_OF_TWO(nameNew, nameFormat [, strict])
Generate a new format clamped to the closest smaller power of 2.
Argument | Description |
---|---|
nameNew | Name of the new format. |
nameFormat | Name of the original format. |
strict | Either TRUE or FALSE (default). |
CALL:FORMAT_LARGER_POWER_OF_TWO(nameNew, nameFormat [, strict])
Generate a new format clamped to the closest larger power of 2.
Argument | Description |
---|---|
nameNew | Name of the new format. |
nameFormat | Name of the original format. |
strict | Either TRUE or FALSE (default). |
CALL:FORMAT_SWAP_DIMENSIONS(nameNew, nameFormat)
Swap the width and height values, save as a new format.
Argument | Description |
---|---|
nameNew | Name of the new format. |
nameFormat | Name of the original format. |
CALL:IF_FORMAT_SETTING_MATCH(nameFormat, nameSetting, value)
{
body
}
Match if a format setting is equal to a value (unsigned integer or GL keyword).
Argument | Description |
---|---|
nameFormat | Name of the targeted format. |
nameSetting | Name of the setting. See the documentation of HdlAbstractTextureFormat. |
value | The unsigned integer value or GLenum name to test against. |
Body : Contains any or all of the blocks TRUE{...} and FALSE{...}. The right block will be exectuted following this test.
CALL:IF_FORMAT_SETTING_LARGERTHAN(nameFormat, nameSetting, value)
{
body
}
Match if a format setting is larger than a value (unsigned integer or GL keyword).
Argument | Description |
---|---|
nameFormat | Name of the targeted format. |
nameSetting | Name of the setting. See the documentation of HdlAbstractTextureFormat. |
value | The unsigned integer value or GLenum name to test against. |
Body : Contains any or all of the blocks TRUE{...} and FALSE{...}. The right block will be exectuted following this test.
CALL:GENERATE_SAME_SIZE_2D_GRID(nameNewGeometry, nameFormat [, normalized])
Create a 2D grid geometry of the same size as the format in argument (width and height).
Argument | Description |
---|---|
nameNewGeometry | Name of the new geometry. |
nameFormat | Name of the original format. |
normalized | Either TRUE or FALSE. If enabled, the vertices coordinates will be in the range [0,1]. |
CALL:GENERATE_SAME_SIZE_3D_GRID(nameNewGeometry, nameFormat [, normalized])
Create a 3D grid geometry of the same size as the format in argument (width, height and number of channels).
Argument | Description |
---|---|
nameNewGeometry | Name of the new geometry. |
nameFormat | Name of the original format. |
normalized | Either TRUE or FALSE. If enabled, the vertices coordinates will be in the range [0,1]. |
CALL:CHAIN_PIPELINES(nameNewPipelineLayout, isStrict, namePipelineLayout1, namePipelineLayout2 [, namePipelineLayout3...])
Create a pipeline by connecting the pipelines passed in arguments.
Argument | Description |
---|---|
nameNewPipelineLayout | Name of the new pipeline. |
isStrict | Either TRUE or FALSE. If enabled, the pipelines connection are enforced strictly (if outputs of the first pipeline are not equal to the number of input of the second pipeline, then the module will report an error. |
namePipelineLayout1 | Name of the first pipeline in the chain. |
namePipelineLayout2 | Name of the second pipeline in the chain. |
namePipelineLayout3... | Other pipelines. |
CALL:FORMAT_TO_CONSTANT(formatName [, sourceName])
Create a SOURCE containing a const ivec2 declaration describing the size of the texture passed in argument. For instance, can be used in a shader with : INSERT(name).
Argument | Description |
---|---|
formatName | Name of the texture format to be used. |
sourceName | Name of the source to be created. If not set, the name of the source will be the same as the name of the format. |
CALL:SINGLE_FILTER_PIPELINE(pipelineName, outputTextureFormat)
{
body
}
Create a pipeline with a single filter.
Argument | Description |
---|---|
pipelineName | Name of the new pipeline. |
outputTextureFormat | Name of the format to render to. |
Body : Source of the fragment shader to be implemented.
CALL:IF_GLSL_VERSION_MATCH(version)
{
body
}
Test the GLSL available available during compilation.
Argument | Description |
---|---|
version | The GLSL version name to be tested : 1.30, 3.30, etc. |
Body : Contains any or all of the blocks TRUE{...} and FALSE{...}. The right block will be exectuted following this test.
CALL:ABORT_ERROR(error)
[{
body
}]
Abort the Layout loading operation with a user defined error.
Argument | Description |
---|---|
error | Error description. |
Body : Optional, More complete description of the error.
CALL:GENERATE_FFT1D_PIPELINE(width, name [, options...])
[{
body
}]
Generate the 1D FFT Pipeline transformation.
Argument | Description |
---|---|
width | Width, can be either a numeral or the name of an existing format. |
name | Name of the new pipeline. |
options... | Options to be used by the FFT process : SHIFTED, INVERSED, ZERO_PADDING, COMPATIBILITY_MODE, NO_INPUT. |
Body : PRE{...} block contains a filtering function to be applied before the FFT. It must define a function vec4 pre(in vec4 colorFromTexture, in float x). POST{...} block contains a filtering function to be applied after the FFT. It must implement a function vec4 post(in vec4 colorAfterFFT, in float x). Both of these block can declare their own uniform variables.
CALL:GENERATE_FFT2D_PIPELINE(width, height [, name, options...])
[{
body
}]
Generate the 2D FFT Pipeline transformation.
Argument | Description |
---|---|
width | Width, can be either a numeral or the name of an existing format. |
height | Height, can be either a numeral or the name of an existing format. |
name | Name of the new pipeline. |
options... | Options to be used by the FFT process : SHIFTED, INVERSED, ZERO_PADDING, COMPATIBILITY_MODE, NO_INPUT. |
Body : PRE{...} block contains a filtering function to be applied before the FFT. It must define a function vec4 pre(in vec4 colorFromTexture, in vec2 x). POST{...} block contains a filtering function to be applied after the FFT. It must implement a function vec4 post(in vec4 colorAfterFFT, in vec2 x). Both of these block can declare their own uniform variables.
CALL:LOAD_OBJ_GEOMETRY(filename, geometryName [, strict])
Load a geometry from a Wavefront file (OBJ).
Argument | Description |
---|---|
filename | Name of the file to load. |
geometryName | Name of the new geometry. |
strict | Either TRUE or FALSE. If enabled, the loader will abort upon inding an unknown tag. |
CALL:LOAD_STL_GEOMETRY(filename, geometryName)
Load a geometry from a StereoLithography file (STL).
Argument | Description |
---|---|
filename | Name of the file to load |
geometryName | Name of the new geometry. |
|
protected |
LayoutLoaderModule constructor. For simple modules you can just use the macro LAYOUT_LOADER_MODULE_APPLY.
_name | Name of the module. |
_manual | Manual of the module, see extended description for formanting. |
_minNumArguments | Minimum number of arguments of the module. |
_maxNumArguments | Maximum number of arguments of the module (-1 for no limitation). |
_bodyPresence | Requirement on the body (-1 for no body, 0 for indifferent, 1 for needed). |
The Manual string can either be a simple string containin the description or a string containing the following elements (all optional) :
With this specific formating the documentation will be automatically generated in various formats (HTML, Command Line Help, etc.) with a coherent layout.
|
static |
Add the basic modules to a LayoutLoader.
loader | A LayoutLoader object. |
|
pure virtual |
Interface of the module : this function will be called on each corresponding token CALL for the LayoutLoader which has the module.
arguments | The arguments of the called, their number has already been checked. |
body | The body of the call (might be empty), its presence has already been checked. |
currentPath | The currentPath in which the LayoutLoader is operating. |
dynamicPaths | The list of paths dynamically built (only for the current load operation). |
formatList | The list of formats currently loaded. For easy access see ITERATOR_TO_FORMAT, CONST_ITERATOR_TO_FORMAT, FORMAT_MUST_EXIST, FORMAT_MUST_NOT_EXIST and APPEND_NEW_FORMAT. |
sourceList | The list of sources currently loaded. For easy access see ITERATOR_TO_SOURCE, CONST_ITERATOR_TO_SOURCE, SOURCE_MUST_EXIST, SOURCE_MUST_NOT_EXIST and APPEND_NEW_SOURCE. |
geometryList | The list of geometries currently loaded. For easy access see ITERATOR_TO_GEOMETRY, CONST_ITERATOR_TO_GEOMETRY, GEOMETRY_MUST_EXIST, GEOMETRY_MUST_NOT_EXIST and APPEND_NEW_GEOMETRY. |
filterList | The list of filters currently loaded. For easy access see ITERATOR_TO_FILTER, CONST_ITERATOR_TO_FILTER, FILTER_MUST_EXIST, FILTER_MUST_NOT_EXIST and APPEND_NEW_FILTER. |
pipelineList | The list of pipelines currently loaded. For easy access see ITERATOR_TO_PIPELINE, CONST_ITERATOR_TO_PIPELINE, PIPELINE_MUST_EXIST, PIPELINE_MUST_NOT_EXIST and APPEND_NEW_PIPELINE. |
mainPipelineName | The name of the current main pipeline, if already parsed. |
staticPaths | The list of static paths (known for all load operations). |
requiredFormatList | The list of static formats available. For easy access see CONST_ITERATOR_TO_REQUIREDFORMAT, REQUIREDFORMAT_MUST_EXIST, REQUIREDFORMAT_MUST_NOT_EXIST. |
requiredSourceList | The list of static sources available. For easy access see CONST_ITERATOR_TO_REQUIREDSOURCE, REQUIREDSOURCE_MUST_EXIST, REQUIREDSOURCE_MUST_NOT_EXIST. |
requiredGeometryList | The list of static geometries available. For easy access see CONST_ITERATOR_TO_REQUIREDGEOMETRY, REQUIREDGEOMETRY_MUST_EXIST, REQUIREDGEOMETRY_MUST_NOT_EXIST. |
requiredPipelineList | The list of static pipelines available. For easy access see CONST_ITERATOR_TO_REQUIREDPIPELINE, REQUIREDPIPELINE_MUST_EXIST, REQUIREDPIPELINE_MUST_NOT_EXIST. |
moduleList | The list of modules available. For easy access see CONST_ITERATOR_TO_MODULE, MODULE_MUST_EXIST, MODULE_MUST_NOT_EXIST. |
sourceName | Name of the source from which the call was extracted. |
startLine | Line index of the module call. |
bodyLine | Line index of the body for this module call. |
executionSource | The code which has to be run at after the function complete (leave it empty if no code needs to be run, the syntax of the code expected is the same as scripts). |
executionSourceName | The name of the source for the post-execution. |
executionStartLine | The first line number of the source for the post-execution. |
const char & LayoutLoaderModule::bodyPresenceTest | ( | void | ) | const |
Get the requirement on the body.
|
static |
Find in which path a file can be found.
filename | File name to be searched. |
dynamicPaths | List of paths in which to search. |
const std::vector< std::pair< std::string, std::string > > & LayoutLoaderModule::getArgumentsDescriptions | ( | void | ) | const |
Get the description of all the arguments of the module.
|
static |
Retrieve the list of standard modules.
const std::string & LayoutLoaderModule::getBodyDescription | ( | void | ) | const |
Get the description of the body of the module.
|
static |
Convert a keyword to a boolean.
arg | The keyword (expected to be either TRUE or FALSE). |
sourceName | Name of the source. |
line | Corresponding line number in the source. |
|
static |
Get true and false cases out of a body.
In a if-statement you can write :
body | Body to extract the data from. |
trueCase | Body of the true statement (not modified if not found). |
trueCaseStartLine | Line number where the body of the true case is starting (not modified if not found). |
falseCase | Body of the false statement (not modified if not found). |
falseCaseStartLine | Line number where the body of the false case is starting (not modified if not found). |
sourceName | Name of the source. |
bodyLine | Line counter start index. |
const std::string & LayoutLoaderModule::getDescription | ( | void | ) | const |
Get the description of the module.
std::string LayoutLoaderModule::getManual | ( | void | ) | const |
Get the manual of the module.
const int & LayoutLoaderModule::getMaxNumArguments | ( | void | ) | const |
Get the maximum number of arguments of the module.
const int & LayoutLoaderModule::getMinNumArguments | ( | void | ) | const |
Get the minimum number of arguments of the module.
const std::string & LayoutLoaderModule::getName | ( | void | ) | const |
Get the name of the module.