Hey All,<br><br>Over the weekend, I took a little break from audio to work on some enhancements to dynamic node creation. With the included patch, nodes may be created through Player::createNode(typeString, argsPythonDictionary). (e.g. newNode = Player.createNode("video", {"href":"video.mpg"}) ). To support this, I have reworked how arguments are passed to node constructors, and created a generic registration mechanism for adding support for different types of nodes (also resulting in the ability to dynamically build/change the avg DTD). The changes are discussed below.<br>
<br>NodeDefinition<br>A NodeDefinition is basically represents all of the information formerly found in the avg DTD, that is information about what a type of node is. It is composed of a type string, all valid arguments and their default values, all valid child nodes, and a function that may be used to build a node of this type (Node::buildNode() is a generic template NodeBuilder function that can be used in most cases). NodeDefinitions may be extended by subclasses, making inheritance of arguments/child nodes simple. Each node type now implements a static getNodeDefinition() function which returns the information about the type.<br>
<br>NodeFactory<br>NodeDefinitions are registered with a NodeFactory, which can then construct nodes of the registered type. The NodeFactory handles validation of arguments passed to the create function based on the registered NodeDefinition of the type being created. Also, all unset args are replaced with the default values defined in the NodeDefinition for the type so the node constructor may safely request any arg defined in its NodeDefinition. Additionally, the NodeFactory can dynamically build a DTD from the complete set of NodeDefinitions currently registered with it. The DTD contains a single special entity called %anyNode; which contains a | separated list of all of the node types registered, and can be used for generic container nodes (e.g. avg and div). The dynamic nature of the DTD is very flexible, and has been designed with the idea of node plugins in mind, however, it is now less visible then before. It would be nice to make the full DTD available to the designer (should we add a Player::getDTD() that returns the current DTD string in python?).<br>
<br>Arg/ArgList<br>An ArgList is the structure passed to node constructors. It may be build from either an xmlNode or a python dictionary object. It provides a simple interface for getting arguments in various formats.<br>
<br>The dynamic node tests currently in place have been expanded to use both interfaces, and all still pass.<br><br>Well, thats all I have for now. Please let me know what you think of the attached patch.<br><br>Thanks,<br>
Nick Hebner<br><br>