ENH: Adding Template Support
Attribute Definition Processing has been split into 3 parts:
- processDefinitionAtts which processes all of the XML Attributes assigned on the Definition XML node
- prcoessDefinitionContents which processes all of the XML children nodes of the Definition XML node
- processDefinitionChildNode which will processes a single child of the Definition XML node
This will allow Definition to eventually use Template Blocks
Also refactored Category Processing into a similar pattern:
- processCategoryAtts - processes all of the XML Attributes on a Attribute/Item Definition XML Node
- processOldStyleCategoryNode - processes the content of an old style "Categories" node
- processItemDefCategoryInfoNode - processes the content of the current style "CategoryInfo" node
Added processItemDefCategoryInfoNode and processDefCategoryInfoNode for processing Category Information for Item and Attribute Definitions respectively
XmlDocV1Parser refactored the following methods:
-
processItemDef - split into the following:
- processItemDef
- processItemDefAtts - for processing XML Attributes on the ItemDefinition Node
- processItemDefContents - for processing the children nodes of the ItemDefinition Node
- processItemDefChildNode - for processing a child node of the ItemDefiniiton Node
-
processStringDef - split into the following:
- processStringDef
- processStringDefAtts - for processing XML Attributes on the StringItemDefinition Node
- processStringDefContents - for processing the children nodes of the StringItemDefinition Node
- processStringDefChildNode - for processing a child node of the StringItemDefinition Node
-
processDoubleDef - split into the following:
- processDoubleDef
- processDoubleDefContents - for processing the children nodes of the DoubleItemDefinition Node
- processDoubleDefChildNode - for processing a child node of the DoubleItemDefinition Node
-
processIntDef - split into the following:
- processIntDef
- processIntDefContents - for processing the children nodes of the IntItemDefinition Node
- processIntDefChildNode - for processing a child node of the IntItemDefinition Node
Renamed internal helper template function processDerivedValueDef to processDerivedValueDefChildNode which now returns a boolean
Also fixed sbt files that contained bad default value elements caught by these new changes.
Starting with Version 7 XML attribute template files, SMTK now supports Templates. Templates are an extension to the existing ItemBlock concept. The main difference between an ItemBlock and a Template is that a Template's contents can be parameterized. When a Template is instantiated, these parameters can be assigned different values and will thereby change the information being copied. a Template's parameter can also be given a default value.
Note All parameters that do not have a default value must be given values when the Template is instanced.
Here is an example:
<Templates>
<Template Name="SimpleStringDefault">
<Parameters>
<Param Name="a">dog</Param>
</Parameters>
<Contents>
<DefaultValue>{a}</DefaultValue>
</Contents>
</Template>
<Template Name="SimpleAttribute">
<Parameters>
<Param Name="type"/>
</Parameters>
<Contents>
<AttDef Type="{type}">
<ItemDefinitions>
<String Name="s1">
<Template Name="SimpleStringDefault">
<Param Name="a">cat</Param>
</Template>
</String>
<String Name="s2">
<Template Name="SimpleStringDefault"/>
</String>
<String Name="s3">
<Template Name="DiscreteStringInfo">
<Param Name="defaultIndex">1</Param>
</Template>
</String>
</ItemDefinitions>
</AttDef>
</Contents>
</Template>
</Templates>
<Definitions>
<Template Name="SimpleAttribute">
<Param Name="type">A</Param>
</Template>
</Definitions>
See data/attribute/attribute_collection/TemplateTest.sbt and smtk/attribute/testing/cxx/unitTemplates.cxx for examples. You can also read the discourse on the topic here: https://discourse.kitware.com/t/adding-parameterized-blocks-to-sbt-files/1013/4.