User properties

<< Click to Display Table of Contents >>

Navigation:  Using SMILE >

User properties

To integrate data that are specific to your application into SMILE models, you can use SMILE’s user properties. User properties are lists of key/value pairs available at the DSL_network and DSL_node level. While it’s possible to use data structure not managed by SMILE (like std::map<DSL_node *, YourObject>) to extend the set of attributes associated with the nodes, that external data is not written by DSL_network::WriteFile and WriteString. On the other hand, user properties are stored in the XDSL files.

DSL_node *node = net.GetNode(handle);

// if that node has user properties,

// the loop below will print them out

DSL_userProperties &props = node->Info().UserProperties();

for (int i = 0; i < props.GetNumberOfProperties(); i ++)

{

 printf("%s=%s\n",

         props.GetPropertyName(i),

         props.GetPropertyValue(i));

}

Note that the property name is unique for the set of properties defined in given node. Property name follows the convention of SMILE identifiers: it is case-sensitive, starts with a letter, and contains letters, digits, and underscores.

To get access to network-level user properties, call DSL_network::UserProperties method.