コード例 #1
0
ファイル: Subscription.cpp プロジェクト: fpoltronieri/nomads
Subscription * GroupTagSubscription::getOnDemandSubscription (void)
{
    UInt32Hashtable<TagInfo>::Iterator i = _ui16Tags.getAllElements();
    GroupTagSubscription *pGTS = new GroupTagSubscription (i.getKey(), i.getValue()->_parameters._ui8Priority,
                                                           false, true, false);
    for (; !i.end(); i.nextElement()) {
        pGTS->addTag (i.getKey(), i.getValue()->_parameters._ui8Priority, false, true, false);
    }
    return pGTS;
}
コード例 #2
0
ファイル: Subscription.cpp プロジェクト: fpoltronieri/nomads
Subscription * GroupTagSubscription::clone (void)
{
    UInt32Hashtable<TagInfo>::Iterator i = _ui16Tags.getAllElements();
    GroupTagSubscription *pGTS = new GroupTagSubscription (i.getKey(), i.getValue()->_parameters._ui8Priority,
                                                           i.getValue()->_parameters._bGrpReliable, i.getValue()->_parameters._bMsgReliable,
                                                           i.getValue()->_parameters._bSequenced);
    for (; !i.end(); i.nextElement()) {
        pGTS->addTag (i.getKey(), i.getValue()->_parameters._ui8Priority, i.getValue()->_parameters._bGrpReliable,
                      i.getValue()->_parameters._bMsgReliable, i.getValue()->_parameters._bSequenced);
    }
    return pGTS;
}
コード例 #3
0
ファイル: Subscription.cpp プロジェクト: fpoltronieri/nomads
bool GroupTagSubscription::includes (Subscription *pSubscription)
{
    if (pSubscription->getSubscriptionType() == GROUP_TAG_SUBSCRIPTION) {
        GroupTagSubscription *pGTS = (GroupTagSubscription*) pSubscription;
        LList<uint16> *pTags = pGTS->getTags();
        uint16 ui16Tag;
        pTags->getFirst (ui16Tag);
        for (int i = 0; i < pTags->length; i++) {
            if (!_ui16Tags.contains (ui16Tag)) {
                return false;
            }
            pTags->getNext (ui16Tag);
        }
        return true;
    }
    return false;
}
コード例 #4
0
ファイル: NodeInfo.cpp プロジェクト: ihmc/nomads
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;
}
コード例 #5
0
ファイル: Subscription.cpp プロジェクト: fpoltronieri/nomads
bool GroupTagSubscription::merge (Subscription *pSubscription)
{
    bool bRet = false;
    switch (pSubscription->getSubscriptionType()) {
        case GROUP_SUBSCRIPTION:
        {
            GroupSubscription *pGS = (GroupSubscription *) pSubscription;
            for (UInt32Hashtable<TagInfo>::Iterator i = _ui16Tags.getAllElements(); !i.end(); i.nextElement()) {
                if ((0 == pGS->removeFilter (i.getKey())) && !bRet) {
                    bRet = true;
                }
            }
            TagInfo *pTagInfo;
            for (UInt32Hashtable<TagInfo>::Iterator i = _ui16Tags.getAllElements(); !i.end(); i.nextElement()) {
                pTagInfo = i.getValue();
                if (pTagInfo->_parameters._ui8Priority  > pGS->getPriority()) {
                    pGS->setPriority (pTagInfo->_parameters._ui8Priority);
                    bRet = true;
                }
                if (pTagInfo->_parameters._bGrpReliable > pGS->isGroupReliable()) {
                    pGS->setGroupReliable (pTagInfo->_parameters._bGrpReliable);
                    bRet = true;
                }
                if (pTagInfo->_parameters._bMsgReliable > pGS->isMsgReliable()) {
                    pGS->setMsgReliable (pTagInfo->_parameters._bMsgReliable);
                    bRet = true;
                }
                if (pTagInfo->_parameters._bSequenced   > pGS->isSequenced()) {
                    pGS->setSequenced (pTagInfo->_parameters._bSequenced); bRet = true;
                }
            }
            break;
        }          
        case GROUP_PREDICATE_SUBSCRIPTION:
        {
            //TODO
            break;
        }  
        case GROUP_TAG_SUBSCRIPTION:
        {
            GroupTagSubscription *pGTS = (GroupTagSubscription *) pSubscription;
            TagInfo *pTagInfo;
            uint16 ui16Tag;
            for (UInt32Hashtable<TagInfo>::Iterator i = _ui16Tags.getAllElements(); !i.end(); i.nextElement()) {
                ui16Tag = i.getKey();
                if (pGTS->hasTag (ui16Tag)) {
                    pTagInfo = i.getValue();
                    if (pTagInfo->_parameters._ui8Priority  > pGTS->getPriority (ui16Tag)) {
                        pGTS->setPriority (pTagInfo->_parameters._ui8Priority, ui16Tag);
                        bRet = true;
                    }
                    if (pTagInfo->_parameters._bGrpReliable > pGTS->isGroupReliable (ui16Tag)) {
                        pGTS->setGroupReliable (pTagInfo->_parameters._bGrpReliable, ui16Tag);
                        bRet = true;
                    }
                    if (pTagInfo->_parameters._bMsgReliable > pGTS->isMsgReliable (ui16Tag)) {
                        pGTS->setMsgReliable (pTagInfo->_parameters._bMsgReliable, ui16Tag);
                        bRet = true;
                    }
                    if (pTagInfo->_parameters._bSequenced   > pGTS->isSequenced (ui16Tag)) {
                        pGTS->setSequenced (pTagInfo->_parameters._bSequenced, ui16Tag);
                        bRet = true;
                    }
                }
                else if ((0 == pGTS->addTag (i.getKey(), pTagInfo->_parameters._ui8Priority,
                          pTagInfo->_parameters._bGrpReliable, pTagInfo->_parameters._bMsgReliable,
                          pTagInfo->_parameters._bSequenced)) && !bRet) {
                    bRet = true;
                }
            }
            break;
        }
    }
    return bRet;
}