DSL_node

<< Click to Display Table of Contents >>

Navigation:  Reference Manual >

DSL_node

Header file: node.h

DSL_node objects are always created and destroyed by their parent DSL_network. While DSL_node class implements copy constructor and operator=, these members should never be used directly. Never use delete on a node pointer.

To convert an integer node handle to a DSL_node pointer, use DSL_network::GetNode(int) function.

To convert a node identifier to DSL_node pointer directly, use DSL_network::GetNode(const char*) function. Alternatively, use DSL_network::FindNode(const char*) first, followed by DSL_network::GetNode(int).


int Handle();

Returns node's handle. The handle does not change during the lifetime of the node.


DSL_network* Network();

const DSL_network* Network() const;

Returns a pointer to node’s network. The network does not change during the lifetime of the node.


const char* GetId() const;

Returns node's identifier.


int SetId(const char *newId);

Sets node's identifier. Returns DSL_OKAY on success, or a negative error code on failure.


const char* GetName() const;

int SetName(const char *newName);

Gets/sets node's name. The name is only used for display purposes, it is not validated for uniqueness, etc.


const char* GetComment() const;

int SetComment(const char *newComment);

Gets/sets node's description. Description is only used for display purposes.


DSL_nodeInfo &Info();
const DSL_nodeInfo& Info() const { return info; }

Returns a reference to a DSL_nodeInfo structure containing node attributes that are not directly related to calculations, including identifier, name, comment, screen position, etc. In SMILE 1.x, access to node name and description was possible only through Info(), SMILE 2 has methods for direct access, like SetName. The implementation still uses the DSL_nodeInfo, which means that SMILE 1.x code should compile and run correctly.


int ChangeType(int newType);

Changes node type. The newType is an integer node type identifier (see Node types). After successful type change, node's definition and value objects change, but node handle remains unchanged. Some incoming and outgoing arcs may be removed during type change, when the new type is not compatible with existing node parents and children.

Returns DSL_OKAY on success, or a negative error code on failure.


DSL_nodeDef* Def();

const DSL_nodeDef* Def() const;

template <class defT> defT* Def();

template <class defT> const defT* Def() const;

Returns a pointer to the node’s definition. The definition object is managed by the node and should never be created or deleted explicitly. The templated methods do not perform any runtime type checking for defT, they are just calling static_cast internally.


DSL_nodeVal* Val();

const DSL_nodeVal* Val() const;

template <class valT> valT* Val();

template <class valT> const valT* Val() const;

Returns a pointer to node’s definition. The definition object is managed by the node and should never be created or deleted explicitly. The templated methods do not perform any runtime type checking for valT, they are just calling static_cast internally.


DSL_nodeDef* Definition();

DSL_nodeVal* Value();

BACKWARD COMPATIBILITY ONLY. Available when SMILE_NO_V1_COMPATIBILITY is not defined.


dsl_diagType GetDiagType() const;

int SetDiagType(dsl_diagType diagType);

Gets/sets node's diagnostic role. The dsl_diagType is defined as enum dsl_diagType { dsl_diagFault, dsl_diagObservation, dsl_diagAux };


bool IsDiagRanked() const;

bool IsDiagMandatory() const;

void SetDiagRanked(bool ranked);

void SetDiagMandatory(bool ranked);

Get/set node's diagnostic ranked and mandatory flags.


const DSL_Dmatrix& GetCosts() const;

Gets node's observation cost matrix. Observation cost is optional. If present, it is used during the calculation of the diagnostic value for ranked observations. The cost can be conditional. To make the cost conditional, use DSL_network::AddArc with dsl_costObserve as the arc layer.


int SetCosts(const DSL_doubleArray& costs);

int SetCosts(const DSL_Dmatrix& costs);

int SetCosts(const std::vector<double>& costs);

Set node's observation cost. Returns DSL_OKAY on success, or a negative error code on failure.


const char* GetDiagQuestion() const { return diagQuestion; }

void SetDiagQuestion(const char* question);

Gets/sets node's diagnostic question. The diagnostic question is only used for display purposes.