Example #1
0
int registryValidateAddChild(Node parent_,Node child_,char* arcName,int arcNameLength,int sessionId){
	VALIDATE(validateNode(child_));
	VALIDATE(validateNode(parent_));
	VALIDATE(validateSessionId(sessionId));
	VALIDATE(validateLock(parent_->locked,parent_->lockOwnerSessionId,sessionId));
	VALIDATE(validateLock(child_->locked,child_->lockOwnerSessionId,sessionId));
        VALIDATE(validateArck(parent_,arcName,arcNameLength,TRUE));
        return VALID;
}
Example #2
0
double NodeTree::nodeTimeElapsed(NodeID nodeID) const
{
    if(!validateNode(nodeID))
        return 0.0;

    return _nodes[nodeID].timeElapsed();
}
Example #3
0
char addAfterNode(void *dt,node *nd,list *lst)
{
	if(nd==NULL)
	{
		return '1';
	}
	if(validateNode(nd,lst)=='0')
	{
		return '2';
	}
	else
	{
		node *nw=(node*)malloc(sizeof(node));
		nw->data=dt;
		nw->prev=nd;
		node *tmp=nd->next;
		nw->next=tmp;
		if(tmp==NULL)
			lst->back=nw;
		else
			tmp->prev=nw;
		nd->next=nw;
	}
	return '0';
}
Example #4
0
NodeProperty NodeTree::nodeProperty(NodeID nodeID, PropertyID propID)
{
    if(!validateNode(nodeID))
        return NodeProperty();

    return _nodes[nodeID].property(propID);
}
Example #5
0
/*
 * Validate node deletion
 */
int registryValidateDeleteNode(Node node,int sessionId){
	VALIDATE(validateNode(node));
	VALIDATE(validateSessionId(sessionId));
	VALIDATE(validateLock(node->locked,node->lockOwnerSessionId,sessionId));
	VALIDATE(validateRefferance(node));
        return VALID;
}
Example #6
0
bool NodeTree::removeNode(NodeID nodeID)
{
    if(!validateNode(nodeID))
        return false;

    // Tag nodes that are directly connected to the removed node
    for(const auto& nodeLink : _links)
    {
        if(nodeLink.fromNode == nodeID)
            tagNode(nodeLink.toNode);
    }

    // Remove any referring links
    auto removeFirstNodeLink = std::remove_if(
        std::begin(_links), std::end(_links),
        [&](const NodeLink& nodeLink)
        {
            return nodeLink.fromNode == nodeID ||
                   nodeLink.toNode   == nodeID;
        });
    _links.erase(removeFirstNodeLink, std::end(_links));

    // Keep links sorted
    std::sort(std::begin(_links), std::end(_links));

    // Finally remove the node
    deallocateNodeID(nodeID);

    return true;
}
Example #7
0
bool NodeTree::nodeSetProperty(NodeID nodeID, PropertyID propID, const NodeProperty& value)
{
    if(!validateNode(nodeID))
        return false;

    return _nodes[nodeID].setProperty(propID, value);
}
Example #8
0
int registryValidateRemoveChild(Node parent_,char* arcName,int arcNameLength,int sessionId){
	VALIDATE(validateArck(parent_,arcName,arcNameLength,FALSE));
	VALIDATE(validateNode(parent_));
	VALIDATE(validateSessionId(sessionId));
	VALIDATE(validateLock(parent_->locked,parent_->lockOwnerSessionId,sessionId));
        return VALID;
}
Example #9
0
void RangeImpl::selectNode(const DOM_Node& refNode)
{
    validateNode(refNode);
    if ( !isLegalContainedNode(refNode)) {
        throw DOM_RangeException(
            DOM_RangeException::INVALID_NODE_TYPE_ERR, null);
    }
    //First check for the text type node
    if (refNode.getNodeType() ==  DOM_Node::TEXT_NODE)
    {
        //The node itself is the container.
        fStartContainer = refNode;
        fEndContainer   = refNode;

        //Select all the contents of the node
        fStartOffset = 0;
        fEndOffset = ((DOM_Text &)refNode).getLength();
        return;
    }

    DOM_Node parent = refNode.getParentNode();
    if (parent != null ) // REVIST: what to do if it IS null?
    {
        fStartContainer = parent;
        fEndContainer = parent;

        unsigned int i = 0;
        for (DOM_Node n = parent.getFirstChild(); n!=null, n!=refNode; n = n.getNextSibling()) {
            i++;
        }

        fStartOffset = i;
        fEndOffset = fStartOffset+1;
    }
}
Example #10
0
const NodeConfig* NodeTree::nodeConfigurationPtr(NodeID nodeID) const
{
    if(!validateNode(nodeID))
        return nullptr;

    return &_nodes[nodeID].config();
}
Example #11
0
void NodeTree::tagNode(NodeID nodeID)
{
    if(!validateNode(nodeID))
        return;

    _nodes[nodeID].setFlag(ENodeFlags::Tagged);
    _executeListDirty = true;
}
Example #12
0
// Internally uses DFS for graph traversal (in fact it's topological sort)
void NodeTree::prepareListImpl()
{
    // Initialize color map with white color
    std::vector<ENodeColor> colorMap(_nodes.size(), ENodeColor::White);

    _executeList.clear();

    // For each invalid nodes (in terms of executable) mark them black
    // so "true" graph traversal can skip them
    for(NodeID nodeID = 0; nodeID < NodeID(_nodes.size()); ++nodeID)
    {
        if(!validateNode(nodeID))
            continue;

        if(colorMap[nodeID] != ENodeColor::White)
            continue;

        if(isNodeExecutable(nodeID))
            continue;

        if(!depthFirstSearch(nodeID, colorMap))
            return;
    }	

    // For each tagged and valid nodes that haven't been visited yet do ..
    for(NodeID nodeID = 0; nodeID < NodeID(_nodes.size()); ++nodeID)
    {
        if(!validateNode(nodeID))
            continue;

        if(colorMap[nodeID] != ENodeColor::White)
            continue;

        if(!_nodes[nodeID].flag(ENodeFlags::Tagged))
            continue;

        if(!depthFirstSearch(nodeID, colorMap, &_executeList))
        {
            _executeList.clear();
            return;
        }
    }

    // Topological sort gives result in inverse order
    std::reverse(std::begin(_executeList), std::end(_executeList));
}
Example #13
0
const std::string& NodeTree::nodeExecuteInformation(NodeID nodeID) const
{
    static const std::string empty;
    if(!validateNode(nodeID))
        return empty;

    return _nodes[nodeID].executeInformation();
}
Example #14
0
const NodeFlowData& NodeTree::inputSocket(NodeID nodeID, SocketID socketID) const
{
    if(!validateNode(nodeID))
        throw BadNodeException();

    SocketAddress outputAddr = connectedFrom(
        SocketAddress(nodeID, socketID, false));
    // outputSocket verifies outputAddr
    return outputSocket(outputAddr.node, outputAddr.socket);
}
Example #15
0
bool NodeTree::validateLink(SocketAddress& from, SocketAddress& to)
{
    if(from.isOutput == to.isOutput)
        return false;

    // A little correction
    if(!from.isOutput)
        std::swap(from, to);

    if(!validateNode(from.node) || 
        !_nodes[from.node].validateSocket(from.socket, from.isOutput))
        return false;

    if(!validateNode(to.node) ||
        !_nodes[to.node].validateSocket(to.socket, to.isOutput))
        return false;

    return true;
}
Example #16
0
char deleteData(void *dt,list *lst,char (comp)(void *dt1,void *dt2))
{
	node *tmpnd=searchDataNode(dt,lst,comp);
	if(validateNode(tmpnd,lst)=='1')
	{
		deleteNode(tmpnd,lst);
		return '0';
	}
	else
		return '1';
}
Example #17
0
char addAfterData(void *dt,void *dt2,list *lst,char (comp)(void *dt1,void *dt2))
{
	node *tmpnd=searchDataNode(dt2,lst,comp);
	if(validateNode(tmpnd,lst)=='1')
	{
		addAfterNode(dt,tmpnd,lst);
		return '0';
	}
	else
		return '1';
}
Example #18
0
void NodeTree::untagNode(NodeID nodeID)
{
    if(!validateNode(nodeID))
        return;

    auto& node = _nodes[nodeID];

    if(node.flag(ENodeFlags::Tagged))
    {
        node.unsetFlag(ENodeFlags::Tagged);
        _executeListDirty = true;
    }
}
Example #19
0
void NodeTree::notifyFinish()
{
    for(NodeID nodeID = 0; nodeID < NodeID(_nodes.size()); ++nodeID)
    {
        if(!validateNode(nodeID))
            continue;

        _nodes[nodeID].finish();

        // Finally, tag node that need to be auto-tagged
        if(_nodes[nodeID].flag(ENodeFlags::AutoTag))
            tagNode(nodeID);
    }
}
Example #20
0
const NodeFlowData& NodeTree::outputSocket(NodeID nodeID, SocketID socketID) const
{
    if(!validateNode(nodeID))
        throw BadNodeException();

    if(!allRequiredInputSocketConnected(nodeID))
    {
        /// TODO: Transform this to a method (same as NodeType::readSocket())
        static NodeFlowData _default = NodeFlowData();
        return _default;
    }

    // outputSocket verifies socketID
    return _nodes[nodeID].outputSocket(socketID);
}
Example #21
0
void NodeTree::deallocateNodeID(NodeID id)
{
    if(!validateNode(id))
        return;

    // Remove mapping from node name to node ID
    _nodeNameToNodeID.erase(_nodes[id].nodeName());

    untagNode(id);

    // Invalidate node
    _nodes[id] = Node();

    // Add NodeID to recycled ones
    _recycledIDs.push_back(id);
}
Example #22
0
bool NodeTree::allRequiredInputSocketConnected(NodeID nodeID) const
{
    if(!validateNode(nodeID))
        return false;

    const auto& node = _nodes[nodeID];

    for(SocketID socketID = 0; socketID < node.numInputSockets(); ++socketID)
    {
        SocketAddress outputAddr = connectedFrom(SocketAddress(nodeID, socketID, false));
        if(outputAddr.node == InvalidNodeID || outputAddr.socket == InvalidSocketID)
            return false;
    }

    return true;
}
Example #23
0
void NodeTree::setNodeEnable(NodeID nodeID, bool enable)
{
    if(!validateNode(nodeID))
        return;

    auto& node = _nodes[nodeID];

    if(node.flag(ENodeFlags::Disabled) == enable)
    {
        _executeListDirty = true;

        if(enable)
            node.unsetFlag(ENodeFlags::Disabled);
        else
            node.setFlag(ENodeFlags::Disabled);
    }
}
void DetailsViewer::setNode(Node *node) {
    if (!node)
        return;

    m_title->setText(node->fqdn());

    m_table->clearContents();
    m_rowCount = 0;

    QMapIterator<QString, DNSData *> iterator(node->getAllSubData());
    while(iterator.hasNext()) {
        iterator.next();

        addRow(iterator.key(), iterator.value());
    }
    connect(m_mapper, SIGNAL(mapped(QString)), this, SLOT(validateNode(QString)));
    m_table->resizeColumnsToContents();
}
Example #25
0
char deleteNode(node *nd,list *lst)
{
	if(nd==NULL)
		return '1';
	else if(lst==NULL)
		return '2';
	else if(lst->front==NULL || lst->back==NULL)
		return '3';
	else if(validateNode(nd,lst)=='0')
		return '4';
	else if(lst->front==lst->back)
	{
		node *tmpnd=lst->front;
		lst->front=NULL;
		lst->back=NULL;
		free(tmpnd);
	}
	else if(nd==lst->front)
	{
		lst->front=nd->next;
		lst->front->prev=NULL;
		node *tmp=nd;
		free(tmp);
	}
	else if(nd==lst->back)
	{
		lst->back=nd->prev;
		lst->back->next=NULL;
		node *tmp=nd;
		free(tmp);
	}
	else
	{
		node *tmp1,*tmp2,*tmp3;
		tmp3=nd;
		tmp2=nd->next;
		tmp1=nd->prev;
		tmp1->next=tmp2;
		tmp2->prev=tmp1;
		free(tmp3);
	}
	return '0';
}
Example #26
0
NodeID NodeTree::duplicateNode(NodeID nodeID)
{
    if(!validateNode(nodeID))
        return InvalidNodeID;
    NodeTypeID typeID = _nodes[nodeID].nodeTypeID();

    // Generate unique name
    std::string newNodeTitle = generateNodeName(typeID);

    // Create node of the same typeID
    NodeID newNodeID = createNode(typeID, newNodeTitle);
    if(newNodeID == InvalidNodeID)
        return InvalidNodeID;

    // Set properties
    for(const auto& prop : _nodes[nodeID].config().properties())
        _nodes[newNodeID].setProperty(prop.propertyID(), _nodes[nodeID].property(prop.propertyID()));

    return newNodeID;
}
Example #27
0
void RangeImpl::setEnd(const DOM_Node& refNode, unsigned int offset)
{
    validateNode(refNode);
    checkIndex(refNode, offset);

    fEndContainer   = refNode;
    fEndOffset      = offset;

    if ((fDocument != refNode.getOwnerDocument() )
            && (refNode.getOwnerDocument().fImpl != 0) )
    {
        fDocument = refNode.getOwnerDocument();
        collapse(false);
    }

    //compare the start and end boundary point
    //collapse if start point is after the end point
    if(compareBoundaryPoints(DOM_Range::END_TO_START, this) == 1)
        collapse(false); //collapse the range positions to end
    else
        fCollapsed = false;
}
Example #28
0
char deleteAfterNode(node *nd,list *lst)
{
	if(nd==NULL)
		return '1';
	else if(lst==NULL)
		return '2';
	else if(validateNode(nd,lst)=='0')
		return '3';
	else if(nd->next==NULL)
		return '4';
	else
	{
		node *tmpnod=nd->next;
		node *tmpnd2=tmpnod->next;
		nd->next=tmpnd2;
		if(tmpnd2==NULL)
			lst->back=nd;
		else
			tmpnd2->prev=nd;
		free(tmpnod);
	}
	return '0';
}
Example #29
0
void RangeImpl::selectNodeContents(const DOM_Node& node)
{
    validateNode(node);

    fStartContainer = node;
    fEndContainer = node;

    fStartOffset = 0;
    if (node.getNodeType() == DOM_Node::TEXT_NODE ) {
        fEndOffset = ((DOM_Text &)node).getLength();
        return;
    }

    DOM_Node first = node.getFirstChild();
    if (first == null) {
        fEndOffset = 0;
        return;
    }
    unsigned int i = 0;
    for (DOM_Node n = first; n!=null; n = n.getNextSibling()) {
        i++;
    }
    fEndOffset = i;
}
Example #30
0
int registryValidateAddRemoveAttributes(Node node,int sessionId){
        VALIDATE(validateNode(node));
	VALIDATE(validateSessionId(sessionId));
	VALIDATE(validateLock(node->locked,node->lockOwnerSessionId,sessionId));
        return VALID;
}