xme_status_t xme_core_directory_nodeRegistryController_addInterface ( xme_core_node_nodeId_t nodeId, xme_com_interface_address_t interfaceAddress ) { xme_hal_table_rowHandle_t handle; xme_core_node_nodeData_t* nodeItem; xme_com_interface_address_t* newInterfaceAddress; XME_CHECK(XME_CORE_NODE_INVALID_NODE_ID != nodeId, XME_STATUS_INVALID_PARAMETER); // Search for an existing item for this node handle = XME_HAL_TABLE_INVALID_ROW_HANDLE; nodeItem = NULL; XME_HAL_TABLE_GET_NEXT(xme_core_directory_nodeRegistryController_nodeTable, xme_hal_table_rowHandle_t, handle, xme_core_node_nodeData_t, nodeItem, nodeItem->nodeId == nodeId); // The node should already be registered XME_CHECK(XME_HAL_TABLE_INVALID_ROW_HANDLE != handle, XME_STATUS_NOT_FOUND); if (nodeItem != NULL) { if (0 != XME_HAL_TABLE_ITEM_COUNT(nodeItem->interfaces)) { xme_hal_table_rowHandle_t rh = XME_HAL_TABLE_INVALID_ROW_HANDLE; xme_com_interface_address_t *interfaceItem = NULL; XME_HAL_TABLE_GET_NEXT ( nodeItem->interfaces, xme_hal_table_rowHandle_t, rh, xme_com_interface_address_t, interfaceItem, interfaceItem->addressType == interfaceAddress.addressType ); while (NULL != interfaceItem) { if (0 == xme_hal_mem_compare(interfaceItem, &interfaceAddress, sizeof(xme_com_interface_address_t))) { return XME_STATUS_ALREADY_EXIST; } interfaceItem = NULL; XME_HAL_TABLE_GET_NEXT ( nodeItem->interfaces, xme_hal_table_rowHandle_t, rh, xme_com_interface_address_t, interfaceItem, interfaceItem->addressType == interfaceAddress.addressType ); } } handle = XME_HAL_TABLE_ADD_ITEM(nodeItem->interfaces); XME_CHECK(XME_HAL_TABLE_INVALID_ROW_HANDLE != handle, XME_STATUS_OUT_OF_RESOURCES); newInterfaceAddress = (xme_com_interface_address_t*) XME_HAL_TABLE_ITEM_FROM_HANDLE(nodeItem->interfaces, handle); XME_ASSERT(NULL != newInterfaceAddress); (void) xme_hal_mem_copy(newInterfaceAddress, &interfaceAddress, sizeof(xme_com_interface_address_t)); } return XME_STATUS_SUCCESS; }
xme_status_t xme_core_directory_nodeRegistryController_registerNode ( xme_core_node_nodeId_t nodeId, const char* nodeName, xme_core_node_guid_t guid ) { xme_hal_table_rowHandle_t handle; xme_core_node_nodeData_t* nodeItem; XME_CHECK(XME_CORE_NODE_INVALID_NODE_ID != nodeId, XME_STATUS_INVALID_PARAMETER); XME_CHECK(NULL != nodeName, XME_STATUS_INVALID_PARAMETER); XME_CHECK(0 != guid, XME_STATUS_INVALID_PARAMETER); // Search for an existing item for this node handle = XME_HAL_TABLE_INVALID_ROW_HANDLE; nodeItem = NULL; XME_HAL_TABLE_GET_NEXT ( xme_core_directory_nodeRegistryController_nodeTable, xme_hal_table_rowHandle_t, handle, xme_core_node_nodeData_t, nodeItem, nodeItem->nodeId == nodeId ); { // The node should not yet be registered XME_CHECK(XME_HAL_TABLE_INVALID_ROW_HANDLE == handle, XME_STATUS_ALREADY_EXIST); // Insert the node handle = XME_HAL_TABLE_ADD_ITEM(xme_core_directory_nodeRegistryController_nodeTable); XME_CHECK(XME_HAL_TABLE_INVALID_ROW_HANDLE != handle, XME_STATUS_OUT_OF_RESOURCES); nodeItem = (xme_core_node_nodeData_t*) XME_HAL_TABLE_ITEM_FROM_HANDLE(xme_core_directory_nodeRegistryController_nodeTable, handle); XME_ASSERT(NULL != nodeItem); nodeItem->nodeId = nodeId; xme_hal_safeString_strncpy(nodeItem->nodeName, nodeName, sizeof(nodeItem->nodeName)); nodeItem->guid = guid; XME_HAL_TABLE_INIT(nodeItem->interfaces); } return XME_STATUS_SUCCESS; }
xme_status_t xme_wp_marshal_marshaler_addConfig ( xme_wp_waypoint_instanceId_t* instanceId, xme_core_topic_t topic, xme_core_dataManager_dataPacketId_t inputPort, xme_core_dataManager_dataPacketId_t outputPort ) { xme_hal_table_rowHandle_t rowHandle; configurationItem_t* configurationItem; XME_CHECK ( xme_wp_marshal_marshaler_isSupported(topic), XME_STATUS_INVALID_PARAMETER ); rowHandle = XME_HAL_TABLE_ADD_ITEM(configurationTable); XME_CHECK ( XME_HAL_TABLE_INVALID_ROW_HANDLE != rowHandle, XME_STATUS_OUT_OF_RESOURCES ); configurationItem = XME_HAL_TABLE_ITEM_FROM_HANDLE ( configurationTable, rowHandle ); if (NULL == configurationItem) { return XME_STATUS_INTERNAL_ERROR; } configurationItem->topic = topic; configurationItem->inputPort = inputPort; configurationItem->outputPort = outputPort; // We use the row handle to identify this configuration *instanceId = (xme_wp_waypoint_instanceId_t)rowHandle; return XME_STATUS_SUCCESS; }
/*--------------------------------------------------------------------------*/ static xme_status_t xme_core_exec_dispatcher_addNewTaskDescriptor ( xme_core_exec_taskDescriptor_t** record1 ) { xme_core_exec_taskDescriptor_t* rec1 = NULL; xme_hal_table_rowHandle_t handle; XME_LOG(XME_LOG_DEBUG, MODULE_ACRONYM "> dispatcher_createTaskRecord()\n"); xme_hal_sync_enterCriticalSection(taskDescriptorsMutex); { handle = XME_HAL_TABLE_ADD_ITEM(taskDescriptorsTable); XME_CHECK_REC(XME_HAL_TABLE_INVALID_ROW_HANDLE != handle, XME_STATUS_INTERNAL_ERROR, { xme_hal_sync_leaveCriticalSection(taskDescriptorsMutex); });
xme_status_t addManipulation ( xme_core_dataManager_dataStoreID_t dataStoreID, uintptr_t address, uint32_t value ) { xme_core_dataHandler_database_manipulationItem_t* manipulationItem = NULL; xme_hal_table_rowHandle_t internalHandle = XME_HAL_TABLE_INVALID_ROW_HANDLE; // Obtain the next element. XME_HAL_TABLE_GET_NEXT ( manipulationsTable, xme_hal_table_rowHandle_t, internalHandle, xme_core_dataHandler_database_manipulationItem_t, manipulationItem, (manipulationItem->dataStoreID == dataStoreID && manipulationItem->address == (uintptr_t) address) ); if (XME_HAL_TABLE_INVALID_ROW_HANDLE == internalHandle) { // Create a new element. internalHandle = XME_HAL_TABLE_ADD_ITEM(manipulationsTable); XME_CHECK(XME_HAL_TABLE_INVALID_ROW_HANDLE != internalHandle, XME_STATUS_OUT_OF_RESOURCES); manipulationItem = XME_HAL_TABLE_ITEM_FROM_HANDLE(manipulationsTable, internalHandle); XME_ASSERT(NULL != manipulationItem); manipulationItem->dataStoreID = dataStoreID; manipulationItem->address = address; manipulationItem->value = value; } else { // Use existing element. manipulationItem->value = value; } return XME_STATUS_SUCCESS; }