bool GroupSubscription::merge (Subscription *pSubscription) { bool bRet = false; switch (pSubscription->getSubscriptionType()) { case GROUP_SUBSCRIPTION: { GroupSubscription *pGS = (GroupSubscription *) pSubscription; DArray<uint16> *pFiltersInSubscription = pGS->getAllFilters(); if (pFiltersInSubscription != NULL) { for (unsigned int i = 0; i < pFiltersInSubscription->size(); i++) { uint16 ui16 = (*pFiltersInSubscription)[i]; if (_ui32HashFilteredTags.contains (ui16)) { pGS->removeFilter (ui16); bRet = true; } } } if (getPriority() > pGS->getPriority()) { pGS->setPriority (getPriority()); bRet = true; } if (isGroupReliable() > pGS->isGroupReliable()) { pGS->setGroupReliable (isGroupReliable()); bRet = true; } if (isMsgReliable() > pGS->isMsgReliable()) { pGS->setMsgReliable (isMsgReliable()); bRet = true; } if (isSequenced() > pGS->isSequenced()) { pGS->setSequenced (isSequenced()); bRet = true; } break; } case GROUP_PREDICATE_SUBSCRIPTION: { //TODO break; } case GROUP_TAG_SUBSCRIPTION: { //TODO break; } } return bRet; }
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; }