MultipleSubTemplates

MultipleSubTemplates#

Utility template for calling an other class template multiple times.

Listing 10 Include this file this file to use#
#include "<AMMR_TOOLS>\Lib/classtools/MultipleSubTemplates.any"`

#MultipleSubTemplates#

A generic class template which can call another class template multiple times.

The sub template must follow a specific call signature in its arguments to be used with this generic class. Specifically it must have a IDX argument to receive its index. A number of generic arguments ARG1, ARG2, ARG3, ARG4, can also be defined to pass from the outer to the internal template that is wrapped.

Usage

/// Template which we want to evoke multiple times
 #class_template SubTemplate (IDX=0, ARG1="", ARG2="", ARG3="", ARG4="") = { };
 };

 MultipleSubTemplates WrapSubTemplates(
     NUM=3,
     CLASS_TEMPLATE = "SubTemplate",
     NAME_PREFIX=SubFolder,
 ) = { };

The example above will create a folder structure like this:

WrapSubTemplates = {
  SubFolder_000 = { };
  SubFolder_001 = { };
  SubFolder_002 = { };
};

Full signature

MultipleSubTemplates <ObjectName>(
  NUM=<required>,
  CLASS_TEMPLATE=<required>,
  NAME_PREFIX=ELEM,
  ARG1=0,
  ARG2=0,
  ARG3=0,
  ARG4=0,
) = {};

Arguments

__CLASS__:

AnyFolder

NUM:

Specifies the number of times the sub template should be called. (Required)

CLASS_TEMPLATE:

Specifies the name of the sub template to call. (Required)

NAME_PREFIX:

Specifies the name prefix of the sub template which will be created. The final name will be NAME_PREFIX_000, NAME_PREFIX_001, NAME_PREFIX_002, etc. (Default: ELEM)

ARG1:

A generic argument which will be passed to the sub template. (Default: 0)

ARG2:

A generic argument which will be passed to the sub template. (Default: 0)

ARG3:

A generic argument which will be passed to the sub template. (Default: 0)

ARG4:

A generic argument which will be passed to the sub template. (Default: 0)