Beispiel #1
0
BOOL CXmlItem::NameMatches(const CXmlItem* pXITest) const
{
	if (!pXITest)
		return FALSE;
	
	return NameMatches(pXITest->GetName());
}
Beispiel #2
0
    virtual bool  EatKey( const plKey& key )
    {
        if( key->GetUoid().GetClassType() == fClassType &&
            NameMatches( fObjName.c_str(), key->GetUoid().GetObjectName().c_str(), fSubstr ) )
        {
            fFoundKey = key;
            return false;
        }

        return true;
    }
Beispiel #3
0
/* Function that returns the address used by a device indicated by NAME 
 * pointed by the 'name' parameter. This function is not the fastest in 
 * the world since the tree used for the Address vs NAME relationship is
 * ordered by address (since the stack needs to search by address a lot).
 * In order to get the address based from the NAME the tree has to be 
 * scanned using preorder traversal.
 *
 * Inputs:
 *    handle        Stack where the pointed NAME resides
 *    name          Pointer to the NAME that we're looking for
 * Outputs:
 *    <returned>    Address used by device pointed by 'name' if it
 *                  was found, otherwise NMEA_NO_ADDRESS (254) is 
 *                  returned.
 */
tNad GetAddressFromName(tN2KHandle handle, tNmea2KName* name)
{
    tDeviceOnBusPtr node;           /* Pointer to a node */
    unsigned char   searchId = 0; // Initialise to prevent warning - this value won't be used
    tNad            address = NMEA_NO_ADDRESS;
    int i;

    assert( cAssertNDP2kStackIsLocked() );

    /* Start searching from the root of the tree */
    node = g_DeviceList[handle].root; 

    /* Set the search identifier */
    if(node != tNull)
    {
        /* Search Id is a sequence used as identifier to know if 
         * a node has been processed or not. A different sequence 
         * is used everytime so that we don't have to re-initialize
         * all the nodes before every search (since not all the 
         * nodes are necessarily processed when searching).
         */
        if(node->searchId > 250)
        {
            searchId = 0;
            
            for(i=0; i < addressVsNameSize[handle]; ++i)
            {
                g_DeviceList[handle].devices[i].searchId = 255;
            }
        }
        else
        {
            searchId = node->searchId + 1;
        }
    }

    while(node != tNull)
    {
        /* First thing is to check the node */
        if(node->searchId != searchId)
        {
            if(NameMatches(name, &node->name) == tTrue)
            {
                /* NAME found, get the address and force loop to stop */
                address = node->nad;
                node = tNull;
            }
            else
            {
                /* Mark the node as visited/processed */
                node->searchId = searchId; 
            }
        }        
        else if((node->left != tNull) && (node->left->searchId != searchId))
        {
            /* Check on the left children */
            node = node->left;
        }
        else if((node->right != tNull) && (node->right->searchId != searchId))
        {
            /* Check on the right children */
            node = node->right;
        }
        else
        {
            /* Return to the parent. If the current node is the root, then the loop will end. */
            node = node->parentNode;
        }
    }

    return address;
}