diff --git a/src/iec61850/inc/iec61850_common.h b/src/iec61850/inc/iec61850_common.h index c3202ef3..b9a8d32e 100644 --- a/src/iec61850/inc/iec61850_common.h +++ b/src/iec61850/inc/iec61850_common.h @@ -31,6 +31,7 @@ extern "C" { #include "libiec61850_common_api.h" #include "logging_api.h" +#include "linked_list.h" /** * @defgroup iec61850_common_api_group IEC 61850 API common parts diff --git a/src/iec61850/inc/iec61850_model.h b/src/iec61850/inc/iec61850_model.h index 9c23f105..e0d54860 100644 --- a/src/iec61850/inc/iec61850_model.h +++ b/src/iec61850/inc/iec61850_model.h @@ -420,6 +420,36 @@ ModelNode_getObjectReferenceEx(ModelNode* node, char* objectReference, bool with LIB61850_API ModelNodeType ModelNode_getType(ModelNode* self); +/** + * \brief Get the name of the ModelNode + * + * \param self the ModelNode instance + * + * \return the name of the ModelNode + */ +LIB61850_API const char* +ModelNode_getName(ModelNode* self); + +/** + * \brief Get the parent ModelNode of this ModelNode instance + * + * \param self the ModelNode instance + * + * \return the parent instance, or NULL when the ModelNode has no parent + */ +LIB61850_API ModelNode* +ModelNode_getParent(ModelNode* self); + +/** + * \brief Get the list of direct child nodes + * + * \param self the ModelNode instance + * + * \return the list of private child nodes, or NULL when the node has no children + */ +LIB61850_API LinkedList +ModelNode_getChildren(ModelNode* self); + /** * \brief Set the name of the IED * diff --git a/src/iec61850/server/model/model.c b/src/iec61850/server/model/model.c index 5d98c7f5..3da07561 100644 --- a/src/iec61850/server/model/model.c +++ b/src/iec61850/server/model/model.c @@ -706,6 +706,37 @@ ModelNode_getType(ModelNode* self) return self->modelType; } +const char* +ModelNode_getName(ModelNode* self) +{ + return self->name; +} + +ModelNode* +ModelNode_getParent(ModelNode* self) +{ + return self->parent; +} + +LinkedList +ModelNode_getChildren(ModelNode* self) +{ + LinkedList childNodes = NULL; + + if (self->firstChild) + childNodes = LinkedList_create(); + + ModelNode* childNode = self->firstChild; + + while (childNode) { + LinkedList_add(childNodes, childNode); + + childNode = childNode->sibling; + } + + return childNodes; +} + LogicalNode* LogicalDevice_getLogicalNode(LogicalDevice* self, const char* nodeName) {