当前位置: 首页>>代码示例>>C++>>正文


C++ PtrLList类代码示例

本文整理汇总了C++中PtrLList的典型用法代码示例。如果您正苦于以下问题:C++ PtrLList类的具体用法?C++ PtrLList怎么用?C++ PtrLList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PtrLList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: switch

void AckController::newIncomingMessage (const void *, uint16, DisServiceMsg *pDisServiceMsg, uint32, const char *)
{
    switch (pDisServiceMsg->getType()) {
        case DisServiceMsg::DSMT_DataReq: {
            DisServiceDataReqMsg *pReqMsg = (DisServiceDataReqMsg*) pDisServiceMsg;
            PtrLList<DisServiceDataReqMsg::FragmentRequest> *pRequests = pReqMsg->getRequests();
            DisServiceDataReqMsg::FragmentRequest *pRequest;
            DisServiceDataReqMsg::FragmentRequest *pRequestTmp = pRequests->getFirst();
            // Call messageRequested() for each requested message 
            while ((pRequest = pRequestTmp) != NULL) {
                pRequestTmp = pRequests->getNext();
                messageRequested (pRequest->pMsgHeader->getMsgId(),
                                  pDisServiceMsg->getSenderNodeId());
            }
            break;
        }

        case DisServiceMsg::DSMT_AcknowledgmentMessage: {
            DisServiceAcknowledgmentMessage *pAckMsg = (DisServiceAcknowledgmentMessage*) pDisServiceMsg;
            messageAcknowledged (pAckMsg->getAckedMsgId(), pDisServiceMsg->getSenderNodeId());
            break;
        }

        default:
            break;
    }
}
开发者ID:agilecomputing,项目名称:nomads,代码行数:27,代码来源:AckController.cpp

示例2:

DArray<uint16> * LocalNodeInfo::getSubscribingClients (Message *pMsg)
{
    DArray<uint16> *pSubscribingClients = NULL;
    uint16 j = 0;
     _m.lock (314);
    for (UInt32Hashtable<SubscriptionList>::Iterator i = _localSubscriptions.getAllElements(); !i.end(); i.nextElement()) {
        PtrLList<Subscription> *pSubscriptions = i.getValue()->getSubscriptionWild (pMsg->getMessageHeader()->getGroupName());
        // Get every subscribed group that matches with the message's group
        if (pSubscriptions != NULL) {
            for (Subscription *pSub = pSubscriptions->getFirst(); pSub != NULL; pSub = pSubscriptions->getNext()) {
                if ((pSub->getSubscriptionType() == Subscription::GROUP_PREDICATE_SUBSCRIPTION) || pSub->matches(pMsg)) {
                    if (pSubscribingClients == NULL) {
                        pSubscribingClients = new DArray<uint16>();
                    }
                    bool bFound = false;
                    for (unsigned int k = 0; k < pSubscribingClients->size(); k++) {
                        if ((*pSubscribingClients)[k] == i.getKey()) {
                            bFound = true;
                            break;
                        }
                    }
                    if (!bFound) {
                        (*pSubscribingClients)[j] = i.getKey();
                        j++;
                    }
                }
            }
            delete pSubscriptions;
            pSubscriptions = NULL;
        }
    }
    _m.unlock (314);
    return pSubscribingClients;
}
开发者ID:ihmc,项目名称:nomads,代码行数:34,代码来源:NodeInfo.cpp

示例3: getId

/**
 * Add an event.
 */
int Cron::addEvent (Event *e)
{
    e->_id = getId ();
    PtrLList<Cron::Event> *pEventList = (PtrLList<Cron::Event>*) _pEventList;
    pEventList->append (e);  
    return e->_id;
}
开发者ID:agilecomputing,项目名称:nomads,代码行数:10,代码来源:Cron.cpp

示例4: String

PtrLList<String> * TopologyWorldState::getInterestedRemoteNodes (DisServiceDataMsg *pDSDMsg)
{
    // Returns a list with the remote nodes interested in pDSDMsg
    _m.lock(143);
    PtrLList<String> *pInterestedRemoteNodes = NULL;
    // Alive nodes
    for (StringHashtable<Thing>::Iterator iNeighbors = _pLocalNodeInfo->getAllElements(); !iNeighbors.end(); iNeighbors.nextElement()) {
        RemoteNodeInfo *pRNI = (RemoteNodeInfo *) iNeighbors.getValue();
        if (pRNI->isNodeInterested (pDSDMsg)) {
            if (pInterestedRemoteNodes == NULL) {
                pInterestedRemoteNodes = new PtrLList<String>();
            }
            pInterestedRemoteNodes->insert (new String (pRNI->getNodeId()));
        }
    }
    // Dead peers
    for (StringHashtable<RemoteNodeInfo>::Iterator iDead = _deadPeers.getAllElements(); !iDead.end(); iDead.nextElement()) {
        RemoteNodeInfo *pRNI = (RemoteNodeInfo *) iDead.getValue();
        if (pRNI->isNodeInterested (pDSDMsg)) {
            if (pInterestedRemoteNodes == NULL) {
                pInterestedRemoteNodes = new PtrLList<String>();
            }
            pInterestedRemoteNodes->insert (new String (pRNI->getNodeId()));
        }
    }
    _m.unlock(143);
    return pInterestedRemoteNodes;
}
开发者ID:fpoltronieri,项目名称:nomads,代码行数:28,代码来源:TopologyWorldState.cpp

示例5: getAllSubscribedGroups

void RemoteNodeInfo::printAllSubscribedGroups (void)
{
    PtrLList<String> *pGroupNames = getAllSubscribedGroups();
    if (pGroupNames) {
        for (String *pGroupName = pGroupNames->getFirst(); pGroupName; pGroupName = pGroupNames->getNext()) {
            checkAndLogMsg ("RemoteNodeInfo::printAllSubscribedGroups", Logger::L_Info, "       Subscribed group: %s\n", pGroupName->c_str());
        }
    }
}
开发者ID:ihmc,项目名称:nomads,代码行数:9,代码来源:NodeInfo.cpp

示例6: CRC

void LocalNodeInfo::recomputeConsolidateSubsciptionList (void)
{
    // TODO CHECK: I don't think the includes applies anymore, so I commented it
    // In fact, even if the includes returns true,
    // I still need to merge subscriptions in terms of priority, reliability, sequenced, etc

    CRC * pCRC = new CRC();
    pCRC->init();
    for (StringHashtable<Subscription>::Iterator iterator = _consolidatedSubscriptions.getIterator(); !iterator.end(); iterator.nextElement()) {
        pCRC->update ((const char *)iterator.getKey());
        pCRC->update32 (iterator.getValue());
    }
    uint16 oldCRC = pCRC->getChecksum();

    // Delete the current Consolidate Subscription List and compute a new one
    _consolidatedSubscriptions.clear();

    // For each client
    for (UInt32Hashtable<SubscriptionList>::Iterator i = _localSubscriptions.getAllElements(); !i.end(); i.nextElement()) {
        SubscriptionList *pSL = i.getValue();
        if (pSL != NULL) {
            // Get all its subscriptions
            PtrLList<String> *pSubgroups = pSL->getAllSubscribedGroups();
            for (String *pSubGroupName = pSubgroups->getFirst(); pSubGroupName != NULL; pSubGroupName = pSubgroups->getNext()) {
                // For each group, get the subscription the client has
                const char *pszGroupName = pSubGroupName->c_str();
                Subscription *pClientSub = pSL->getSubscription (pszGroupName);
                // And the subscription in the consolidate subscription list if any
                Subscription *pSubInConsolidateList = _consolidatedSubscriptions.getSubscription (pszGroupName);
                if (pSubInConsolidateList == NULL) {
                    _consolidatedSubscriptions.addSubscription (pszGroupName, pClientSub->clone());
                }
                else {
                    /*if (pClientSub->includes (pSubInConsolidateList)) {
                        _consolidatedSubscriptions.removeGroup (pszGroupName);
                        _consolidatedSubscriptions.addSubscription (pszGroupName, pClientSub->clone());
                    }
                    else {*/
                        pClientSub->merge (pSubInConsolidateList);
                    /*}*/
                }
            }
        }
    }

    pCRC->reset();
    for (StringHashtable<Subscription>::Iterator iterator = _consolidatedSubscriptions.getIterator(); !iterator.end(); iterator.nextElement()) {
        pCRC->update ((const char *) iterator.getKey());
        pCRC->update32 (iterator.getValue());
    }
    uint16 newCRC = pCRC->getChecksum();
    if (oldCRC != newCRC) {
        ui32SubscriptionStateSeqID++;
        GroupSubscription *pSubscription = new GroupSubscription(); // Void subscription to respect method interface
        _notifier.modifiedSubscriptionForPeer (_pszId, pSubscription);
    }
}
开发者ID:ihmc,项目名称:nomads,代码行数:57,代码来源:NodeInfo.cpp

示例7: deleteEvent

/**
 * Delete an event, given the eventId
 */
int Cron::deleteEvent (int iEventId)
{
    Event *pEvent;
    PtrLList<Cron::Event> *pEventList = (PtrLList<Cron::Event>*) _pEventList;
    pEventList->resetGet();
    while ((pEvent = pEventList->getNext()) != NULL) {
        if (pEvent->_id == iEventId) {
            pEventList->remove (pEvent);
            return 1;
        }
    }
    return 0;
}
开发者ID:agilecomputing,项目名称:nomads,代码行数:16,代码来源:Cron.cpp

示例8: getHistoryRequest

int GroupTagSubscription::getHistoryRequest (const char * pszGroupName, PtrLList<HistoryRequest> &historyRequest)
{
    UInt32Hashtable<TagInfo>::Iterator i = _ui16Tags.getAllElements();
    TagInfo *pTI;
    History *pHistory;
    while (!i.end()) {
        pTI = i.getValue();
        pHistory = pTI->pHistory;
        if (pHistory) {
            if (pHistory->isExpired()) {
                delete pHistory;
                pHistory = NULL;
            }
            else {
                HistoryRequestGroupTag * pReq = new HistoryRequestGroupTag;
                pReq->_pHistory = pTI->pHistory;
                pReq->_pszGroupName = pszGroupName;
                pReq->_ui16Tag = (uint16) i.getKey();
                historyRequest.prepend(pReq);
            }
        }
        i.nextElement();
    }
    return 0;
}
开发者ID:fpoltronieri,项目名称:nomads,代码行数:25,代码来源:Subscription.cpp

示例9: requireSequentiality

bool LocalNodeInfo::requireSequentiality (const char *pszGroupName, uint16 ui16Tag)
{
    _m.lock (321);
    PtrLList<Subscription> *pSubscriptions = _consolidatedSubscriptions.getSubscriptionWild(pszGroupName);
    if (pSubscriptions != NULL) {
        for (Subscription *pSub = pSubscriptions->getFirst(); pSub != NULL; pSub = pSubscriptions->getNext()) {
            if (pSub->getSubscriptionType() == Subscription::GROUP_SUBSCRIPTION) {
                GroupSubscription *pGS = (GroupSubscription *) pSub;
                if (pGS->isSequenced()) {
                    delete pSubscriptions;
                    pSubscriptions = NULL;
                    _m.unlock (321);
                    return true;
                }
            }
            else if (pSub->getSubscriptionType() == Subscription::GROUP_TAG_SUBSCRIPTION) {
                GroupTagSubscription *pGTS = (GroupTagSubscription *) pSub;
                if (pGTS->isSequenced(ui16Tag)) {
                    delete pSubscriptions;
                    pSubscriptions = NULL;
                    _m.unlock (321);
                    return true;
                }
            }
            else if (pSub->getSubscriptionType() == Subscription::GROUP_PREDICATE_SUBSCRIPTION) {
                GroupPredicateSubscription *pGPS = (GroupPredicateSubscription *) pSub;
                if (pGPS->isSequenced()) {
                    delete pSubscriptions;
                    pSubscriptions = NULL;
                    _m.unlock (321);
                    return true;
                }
            }
        }

        delete pSubscriptions;
        pSubscriptions = NULL;
    }

    _m.unlock (321);
    return false;
}
开发者ID:ihmc,项目名称:nomads,代码行数:42,代码来源:NodeInfo.cpp

示例10: sendWaypointMessage

void DSProImpl::sendWaypointMessage (const void *pBuf, uint32 ui32BufLen)
{
    if (pBuf == NULL || ui32BufLen == 0) {
        return;
    }

    PtrLList<String> *pNeighborList = _pTopology->getNeighbors();
    if (pNeighborList == NULL) {
        return;
    }
    if (pNeighborList->getFirst () == NULL) {
        delete pNeighborList;
        return;
    }

    NodeIdSet nodeIdSet;
    PreviousMessageIds previousMessageIds;
    String *pszNextPeerId = pNeighborList->getFirst ();
    for (String *pszCurrPeerId; (pszCurrPeerId = pszNextPeerId) != NULL;) {
        pszNextPeerId = pNeighborList->getNext ();
        previousMessageIds.add (pszCurrPeerId->c_str (), _pScheduler->getLatestMessageReplicatedToPeer (pszCurrPeerId->c_str ()));
        nodeIdSet.add (pszCurrPeerId->c_str ());
        delete pNeighborList->remove (pszCurrPeerId);
    }
    delete pNeighborList;

    uint32 ui32TotalLen = 0;
    void *pData = WaypointMessageHelper::writeWaypointMessageForTarget (previousMessageIds, pBuf, ui32BufLen, ui32TotalLen);
    Targets **ppTargets = _pTopology->getNextHopsAsTarget (nodeIdSet);
    if ((ppTargets != NULL) && (ppTargets[0] != NULL)) {
        // Send the waypoint message on each available interface that reaches the recipients
        int rc = _adaptMgr.sendWaypointMessage (pData, ui32TotalLen, _nodeId, ppTargets);
        String sLatestMsgs (previousMessageIds);
        String sPeers (nodeIdSet);
        checkAndLogMsg ("DSPro::sendWaypointMessage", Logger::L_Info, "sending waypoint message "
            "to %s (%s); last message pushed to this node was %s.\n", sPeers.c_str (),
            (rc == 0 ? "succeeded" : "failed"), sLatestMsgs.c_str ());
    }
    Targets::deallocateTargets (ppTargets);
    free (pData);
}
开发者ID:fpoltronieri,项目名称:nomads,代码行数:41,代码来源:DSProImpl.cpp

示例11: getInterestedRemoteNodes

PtrLList<String> * TopologyWorldState::getTargetNodes (DisServiceDataMsg *pDSDMsg)
{
    // Returns a list with the target nodes for pDSDMsg
    _m.lock (145);
    PtrLList<String> *pInterestedNodes = getInterestedRemoteNodes (pDSDMsg);
    PtrLList<String> *pTargetNodes = NULL;
    if (pInterestedNodes) {
        for (String *pSubNode = pInterestedNodes->getFirst(); pSubNode; pSubNode = pInterestedNodes->getNext()) {
            bool bActiveTarget = isActiveNeighbor (pSubNode->c_str());
            const char *pszBestGW = NULL;
            if (bActiveTarget) {
                pszBestGW = pSubNode->c_str();
            } else {
                pszBestGW = getBestGateway (pSubNode->c_str());
            }
            if (pszBestGW) {
                if (pTargetNodes == NULL) {
                    pTargetNodes = new PtrLList<String>();
                }
                if (pTargetNodes->search (new String (pszBestGW)) == NULL) {
                    pTargetNodes->insert (new String (pszBestGW));
                }
            }
        }
    }
    _m.unlock (145);
    return pTargetNodes;
}
开发者ID:fpoltronieri,项目名称:nomads,代码行数:28,代码来源:TopologyWorldState.cpp

示例12: query

int DSProQueryController::doSQLQueryOnMetadata (const char *pszGroupName, const void *pQuery, unsigned int uiQueryLen,
                                                const char *, InformationStore *pInfoStore,
                                                PtrLList<const char> *pResultsList)
{
    const char *pszMethodName = "DSProQueryController::doSQLQueryOnMetadata";

    String query ((char *) pQuery, uiQueryLen);

    /*const char *pszSqlConstraints = nullptr;

    char *pszTemp = nullptr;
    char *pszToken = nullptr;
    pszToken = strtok_mt (query.c_str(), "WHERE ", &pszTemp);
    if (pszToken == nullptr) {
        checkAndLogMsg (pszMethodName, Logger::L_Warning, "Error in parsing the char * containing the sql query\n");
        return -1;
    }
    pszSqlConstraints = strtok_mt (nullptr, "WHERE ", &pszTemp);
    if (pszSqlConstraints == nullptr) {
        checkAndLogMsg (pszMethodName, Logger::L_Warning, "No where conditions\n");
        return -2;
    }*/

    PtrLList<const char> *ptmp = pInfoStore->getMessageIDs (pszGroupName, query);
    if (ptmp == nullptr) {
        checkAndLogMsg (pszMethodName, Logger::L_Warning, "Error in retrieving the messageIds\n");
        return -3;
    }
    if (pResultsList != nullptr) {
        const char *pszId = ptmp->getFirst();
        for (; pszId != nullptr; pszId = ptmp->getNext()) {
            pResultsList->prepend (pszId);
        }
        ptmp->removeAll (false);
        delete ptmp;
    }

    return 0;
}
开发者ID:ihmc,项目名称:nomads,代码行数:39,代码来源:DSProQueryController.cpp

示例13: while

/**
 * The run method. Sits in a while loop checking to 
 * see if any of the events in the list are at a time
 * when they should fire
 */
int Cron::run (void)
{
    while (1) {
        Event *pEvent; // temporary event
        PtrLList<Cron::Event> *pEventList = (PtrLList<Cron::Event>*) _pEventList;
        pEventList->resetGet(); // start at the beginning of the list
        
        // Go through the list
        while ((pEvent = pEventList->getNext()) != NULL) {
            ATime currentTime; // get the current time
            // check to see if the event should happen at this time
            if (pEvent->getStartTime() == currentTime) {
                
                // if the event should happen at this time, check to see whether
                // the event should happen on this day
                int dayOfMonth = currentTime.dayOfMonth();
                int dayOfWeek = currentTime.dayOfWeek();

                if ((pEvent->getDaysOfMonth() & ((0x00000001UL) << (dayOfMonth - 1))) > 0) {
                    if ((pEvent->getDaysOfWeek() & ((0x01) << (dayOfWeek - 1))) > 0) {
                        (*pEvent->getEventCallback()) (pEvent); // call the function
                        // check the count
                        if (pEvent->getCurrentCount() == pEvent->getCount()) {
                            deleteEvent (pEvent->_id); 
                        } else {
                            pEvent->incrCount();
                        }
                        // update the time
                        ATime tmpTime = pEvent->getStartTime() + pEvent->getPeriod();
                        pEvent->setTime(tmpTime);
                    }
                }
            } 
        } 

        sleepForMilliseconds (60000);
      
    }
}
开发者ID:agilecomputing,项目名称:nomads,代码行数:44,代码来源:Cron.cpp

示例14: br

PtrLList<Chunker::Fragment> * Chunker::fragmentBuffer (const void *pBuf, uint32 ui32Len, Type inputObjectType, uint8 ui8NoOfChunks, Type outputChunkType, uint8 ui8ChunkCompressionQuality)
{
    BMPImage *pBMPImage = NULL;
    if (inputObjectType == Chunker::BMP) {
        BufferReader br (pBuf, ui32Len, false);
        int rc;
        pBMPImage = new BMPImage();
        if (0 != (rc = pBMPImage->readHeaderAndImage (&br))) {
            checkAndLogMsg ("Chunker::fragmentBuffer", Logger::L_MildError,
                            "failed to read BMP image; rc = %d\n", rc);
            delete pBMPImage;
            return NULL;
        }
    }
    else if (inputObjectType == Chunker::JPEG) {
        pBMPImage = JPEGLibWrapper::convertJPEGToBMP (pBuf, ui32Len);
        if (pBMPImage == NULL) {
            checkAndLogMsg ("Chunker::fragmentBuffer", Logger::L_MildError,
                            "failed to convert JPEG image to BMP\n");
            return NULL;
        }
    }
    else if (inputObjectType == Chunker::JPEG2000) {
        #if defined (ANDROID)
            checkAndLogMsg ("Chunker::fragmentBuffer", Logger::L_MildError,
                            "JPEG2000 not supported on the Android platform\n");
            return NULL;
        #else
            BufferReader *pReader = JasperWrapper::convertToBMP (pBuf, ui32Len);
            if (pReader == NULL) {
                checkAndLogMsg ("Chunker::fragmentBuffer", Logger::L_MildError,
                                "failed to convert JPEG2000 image to BMP\n");
                return NULL;
            }
            int rc;
            pBMPImage = new BMPImage();
            if (0 != (rc = pBMPImage->readHeaderAndImage (pReader))) {
                checkAndLogMsg ("Chunker::fragmentBuffer", Logger::L_MildError,
                                "failed to read BMP image after converting JPEG2000 to BMP; rc = %d\n", rc);
                delete pBMPImage;
                delete pReader;
                return NULL;
            }
            delete pReader;
        #endif
    }
    else if (inputObjectType == Chunker::PNG) {
        #if defined (ANDROID)
            checkAndLogMsg ("Chunker::fragmentBuffer", Logger::L_MildError,
                            "JPEG2000 not supported on the Android platform\n");
            return NULL;
        #else
            pBMPImage = PNGLibWrapper::convertPNGToBMP (pBuf, ui32Len);
            if (pBMPImage == NULL) {
                checkAndLogMsg ("Chunker::fragmentBuffer", Logger::L_MildError,
                                "failed to convert PNG image to BMP\n");
                return NULL;
            }
        #endif
    }
    else {
        checkAndLogMsg ("Chunker::fragmentBuffer", Logger::L_MildError,
                        "unsupported input type %d\n", (int) inputObjectType);
        return NULL;
    }
    PtrLList<Fragment> *pFragments = new PtrLList<Fragment>;
    for (uint8 ui8CurrentChunk = 1; ui8CurrentChunk <= ui8NoOfChunks; ui8CurrentChunk++) {
        BMPImage *pBMPChunk = BMPChunker::fragmentBMP (pBMPImage, ui8CurrentChunk, ui8NoOfChunks);
        if (pBMPChunk == NULL) {
            checkAndLogMsg ("Chunker::fragmentBuffer", Logger::L_MildError,
                            "failed to fragment BMP to create chunk %d of %d\n", (int) ui8CurrentChunk, (int) ui8NoOfChunks);
            delete pFragments;
            return NULL;
        }
        int rc;
        Fragment *pFragment = new Fragment();
        pFragment->src_type = inputObjectType;
        if (outputChunkType == Chunker::BMP) {
            BufferWriter bw (pBMPChunk->getTotalSize(), 1024);
            if (0 != (rc = pBMPChunk->writeHeaderAndImage (&bw))) {
                checkAndLogMsg ("Chunker::fragmentBuffer", Logger::L_MildError,
                                "failed to write chunk BMP into buffer; rc = %d\n", rc);
                delete pFragments;
                return NULL;
            }
            uint32 ui32ChunkLen = bw.getBufferLength();
            pFragment->pReader = new BufferReader (bw.relinquishBuffer(), ui32ChunkLen, true);
            pFragment->ui64FragLen = ui32ChunkLen;
        }
        else if (outputChunkType == Chunker::JPEG) {
            BufferReader *pReader = JPEGLibWrapper::convertBMPToJPEG (pBMPChunk, ui8ChunkCompressionQuality);
            if (pReader == NULL) {
                checkAndLogMsg ("Chunker::fragmentBuffer", Logger::L_MildError,
                                "failed to encode BMP chunk into JPEG\n");
                delete pFragments;
                return NULL;
            }
            pFragment->pReader = pReader;
            pFragment->ui64FragLen = pReader->getBytesAvailable();
        }
//.........这里部分代码省略.........
开发者ID:agilecomputing,项目名称:nomads,代码行数:101,代码来源:Chunker.cpp

示例15: checkAndLogMsg

PtrLList<Message> * NetworkTrafficMemory::filterRecentlySent (Message *pMsg, int64 i64RequestArrivalTime)
{
    _m.lock (186);
    MessageHeader *pMH = pMsg->getMessageHeader();
    if (pMH == NULL) {
        checkAndLogMsg ("NetworkTrafficMemory::filterRecentlySent", Logger::L_Warning,
                        "Message object does not contain message header.\n");
    }

    PtrLList<Message> *pRet = new PtrLList<Message>();
    if (pRet == NULL) {
        checkAndLogMsg ("NetworkTrafficMemory::filterRecentlySent", memoryExhausted);
        _m.unlock (186);
        return NULL;
    }

    if (_ui16IgnoreRequestTime == 0) {
        pRet->insert (new Message (pMH->clone(), pMsg->getData()));
         _m.unlock (186);
        return pRet;
    }

    MessagesByGroup *pBG = _messageByGroup.get (pMH->getGroupName());
    if (pBG == NULL) {
        pRet->insert (new Message (pMH->clone(), pMsg->getData()));
         _m.unlock (186);
        return pRet;
    }

    MessagesBySender *pMS = pBG->messageBySender.get (pMH->getPublisherNodeId());
    if (pMS == NULL) {
        pRet->insert (new Message (pMH->clone(), pMsg->getData()));
         _m.unlock (186);
        return pRet;
    }

    FragmentedMessageHeader *pFMH = pMS->messageBySeqId.get (pMH->getMsgSeqId());
    if (pFMH == NULL) {
        pRet->insert (new Message (pMH->clone(), pMsg->getData()));
         _m.unlock (186);
        return pRet;
    }

    if (pMH->isChunk()) {
        FragmentedChunk *pFC = ((FragmentedMessage *) pFMH)->chunksByChunkId.get (pMsg->getChunkMsgInfo()->getChunkId());
        if (pFC == NULL) {
            pRet->insert (new Message (pMH->clone(), pMsg->getData()));
            _m.unlock (186);
            return pRet;
        }
        else {
            pFMH = pFC;
        }
    }

    char *psFragToSendData;
    psFragToSendData = (char *) pMsg->getData();
    uint32 ui32FragToSendStart = pMH->getFragmentOffset();
    uint32 ui32FragToSendEnd = ui32FragToSendStart + pMH->getFragmentLength();

    MessageHeader *pTmpMI;

    for (FragmentWrapper *pFW = pFMH->fragments.getFirst(); (pFW != NULL) && (ui32FragToSendEnd > pFW->ui32Offset); pFW = pFMH->fragments.getNext()) {
        if (pFW->overlaps (ui32FragToSendStart, ui32FragToSendEnd)) {
            if ((i64RequestArrivalTime - pFW->i64LastServingTime) < _ui16IgnoreRequestTime) {
                // I need to split
                // write everything before pFW->ui32Offset
                uint32 ui32TmpFragLength = (ui32FragToSendStart < pFW->ui32Offset ? pFW->ui32Offset - ui32FragToSendStart : (uint32) 0);
                if (ui32TmpFragLength > 0) {
                    pTmpMI = pMH->clone();
                    pTmpMI->setFragmentOffset (ui32FragToSendStart);
                    pTmpMI->setFragmentLength (ui32TmpFragLength);
                    pRet->insert (new Message (pTmpMI, psFragToSendData));
                }
                // ui32FragToSendStart = pFW->ui32End;
                // psFragToSendData = psFragToSendData + ui32TmpFragLength;
                ui32TmpFragLength = minimum (pFW->ui32End, ui32FragToSendEnd) - ui32FragToSendStart;
                ui32FragToSendStart += ui32TmpFragLength;
                psFragToSendData += ui32TmpFragLength;
            }
        }
    }
    // Add the remaining part
    if (ui32FragToSendStart < ui32FragToSendEnd) {
        pTmpMI = pMH->clone();
        pTmpMI->setFragmentOffset (ui32FragToSendStart);
        pTmpMI->setFragmentLength (ui32FragToSendEnd - ui32FragToSendStart);
        pRet->insert (new Message (pTmpMI, psFragToSendData));
    }
    _m.unlock (186);
    return pRet;
}
开发者ID:agilecomputing,项目名称:nomads,代码行数:92,代码来源:NetworkTrafficMemory.cpp


注:本文中的PtrLList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。