Example #1
0
    Status Resolver::resolveCached(
            const vector<Address>&  addresses,
            vector<ExpandedNodeId>& expandedNodeIds,
            vector<Status>&         statuses,
            Mask&                   expandedNodeIdMask,
            Mask&                   relativePathMask)
    {
        logger_->debug("Resolving the addresses by querying the cache");

        // declare the return status
        Status ret(statuscodes::Good);

        // declare the number of addresses
        size_t noOfAddresses = addresses.size();

        // resize the masks
        expandedNodeIdMask.resize(noOfAddresses);
        relativePathMask.resize(noOfAddresses);

        // loop through the addresses
        for (size_t i=0; i<noOfAddresses; i++)
        {
            logger_->debug("Trying to find address %d in the cache", i);

            if (database_->addressCache.find(addresses[i], expandedNodeIds[i]))
            {
                statuses[i] = statuscodes::Good;
                logger_->debug("Address %d was already cached", i);
            }
            else
            {
                if (addresses[i].isExpandedNodeId())
                {
                    expandedNodeIdMask.set(i);
                    logger_->debug("Address %d is an ExpandedNodeId not found in the cache", i);
                }
                else if (addresses[i].isRelativePath())
                {
                    relativePathMask.set(i);
                    logger_->debug("Address %d is a RelativePath not found in the cache", i);
                }
                else
                {
                    ret = EmptyAddressError();
                    logger_->error("Address %d cannot be resolved since it's an empty address", i);
                    break;
                }
            }
        }

        return ret;
    }