The definition of the node specifies how it interacts with other nodes in the network. The node definition is written as part of the network by DSL_network::WriteFile and WriteString. For general chance node the definition consists of conditional probability table (CPT) and list of state names. To access it use DSL_node::Definition method, which returns a pointer to the instance of the class derived from the DSL_nodeDefinition.
int nodeHandle = …;
DSL_node *node = net.GetNode(nodeHandle);
DSL_nodeDefintion *def = node->Definition();
The definition object is managed by the network containing the node. SMILE provides a number of classes derived from DSL_nodeDefinition, specialized to represent different node types (CPT, Noisy-MAX, decision, etc.) The choice of the definition object class associated with given node is based on the node type parameter passed to DSL_network::AddNode. As SMILE is compiled with RTTI disabled, you cannot use dynamic_cast to check for actual type of the object returned by DSL_node::Definition. However, you can use DSL_nodeDefinition::GetType and GetTypeName methods:
int nodeHandle = net.AddNode(DSL_CPT, "myNodeId");
DSL_nodeDefinition *def = net.GetNode(nodeHandle)->Definition();
printf("Type of the definition: %d %s\n",
In the example above, the ‘def’ variable points to the object of the DSL_cpt class derived from DSL_nodeDefintion. While it is possible to static_cast (or use old-style C cast) and obtain an access to type-specific functionality of the object, SMILE provides general purpose virtual methods defined in DSL_nodeDefinition and overriden in derived classes, which makes casting unnecessary most of the time. Two of these methods are DSL_nodeDefinition::GetMatrix and GetOutcomesNames, which give access to node’s parameters and state names. Note that some of the node types do not support all of the operations. For example, the decision node does not have any numeric parameters, therefore its definition object of DSL_list class returns NULL from its GetMatrix method.