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


C++ SubscriptionList类代码示例

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


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

示例1: getOnDemandDataGroupName

int LocalNodeInfo::subscribe (uint16 ui16ClientId, const char *pszGroupName, Subscription *pSubscription)
{
    _m.lock (300);
    if (pszGroupName == NULL || pSubscription == NULL) {
        delete pSubscription;
        _m.unlock (300);
        return -1;
    }

    char *pszOnDemandDataGroupName = getOnDemandDataGroupName (pszGroupName);
    if (pszOnDemandDataGroupName == NULL) {
        // The on-demand subscription group name could not be generated
        delete pSubscription;
        _m.unlock (300);
        return -2;
    }

    Subscription *pOnDemandSubscription = pSubscription->getOnDemandSubscription();
    if (pOnDemandSubscription == NULL) {
        free (pszOnDemandDataGroupName);
        delete pSubscription;
        _m.unlock (300);
        return -3;
    }

    SubscriptionList *pSL = _localSubscriptions.get (ui16ClientId);
    if (pSL == NULL) {
        pSL = new SubscriptionList();
        _localSubscriptions.put (ui16ClientId, pSL);
    }

    if (pSL->addGroup (pszGroupName, pSubscription) != 0) {
        // The subscription could not be added
        free (pszOnDemandDataGroupName);
        delete pSubscription;
        delete pOnDemandSubscription;
        _m.unlock (300);
        return -4;
    }

    if (pSL->addGroup (pszOnDemandDataGroupName, pOnDemandSubscription) != 0) {
        // The on-demand subscription could not be added
        free (pszOnDemandDataGroupName);
        delete pOnDemandSubscription;
        pSL->removeGroup (pszGroupName, pSubscription);    // Should delete pSubscription
        _m.unlock (300);
        return -5;
    }

    // The subscription was added, check if the ConsolidateList needs to be modified too.
    updateConsolidateSubsciptionList (pszGroupName, pSubscription);

    // The subscription was added, check if the ConsolidateList needs to be modified too.
    updateConsolidateSubsciptionList (pszOnDemandDataGroupName, pOnDemandSubscription);
    free (pszOnDemandDataGroupName);

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

示例2:

Subscription * LocalNodeInfo::getSubscriptionForClient (uint16 ui16ClientId, const char *pszGroupName)
{
    SubscriptionList *pSL = _localSubscriptions.get (ui16ClientId);
    if (pSL == NULL) {
        return NULL;
    }
    return pSL->getSubscription (pszGroupName);
}
开发者ID:ihmc,项目名称:nomads,代码行数:8,代码来源:NodeInfo.cpp

示例3: 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

示例4: retrieveNodeInfo

int TopologyWorldState::updateSubscriptionState (StringHashtable<SubscriptionList> *pSubscriptionsTable, StringHashtable<uint32> *pNodesTable)
{
    // Updates the remote subscriptions with the pSubscriptionsTable and pNodesTable info
    _m.lock (131);
    for (StringHashtable<uint32>::Iterator iterator = pNodesTable->getAllElements(); !iterator.end(); iterator.nextElement()) {
        if (0 != stricmp (_pDisService->getNodeId(), iterator.getKey())) {
            RemoteNodeInfo * pRNI = (RemoteNodeInfo*) retrieveNodeInfo (iterator.getKey());
            if (pRNI) {
                uint32 *pui32RemoteSeqId = iterator.getValue();
                uint32 *pui32LocalSeqId = _subscriptionStateTable.get (iterator.getKey());
                if (!pui32LocalSeqId) {
                    pui32LocalSeqId = new uint32();
                }
                if ((*pui32RemoteSeqId) > (*pui32LocalSeqId)) {
                    pRNI->unsubscribeAll();
                    (*pui32LocalSeqId) = (*pui32RemoteSeqId);
                    _subscriptionStateTable.put (iterator.getKey(), pui32LocalSeqId);
                    continue;
                }
            }
        }
        pNodesTable->remove (iterator.getKey());
    }
    // Update _ui16SubscriptionStateCRC
    _crc.reset();
    for (StringHashtable<uint32>::Iterator iterator = _subscriptionStateTable.getAllElements(); !iterator.end(); iterator.nextElement()) {
        _crc.update ((const char *) iterator.getKey());
        _crc.update32 (iterator.getValue());
    }
    _ui16SubscriptionStateCRC = _crc.getChecksum();
    for (StringHashtable<SubscriptionList>::Iterator subIterator = pSubscriptionsTable->getAllElements(); !subIterator.end(); subIterator.nextElement()) {
        const char * nodeId = subIterator.getKey();
        if (pNodesTable->get (nodeId) != NULL) {
            SubscriptionList *pSubs = subIterator.getValue();
            RemoteNodeInfo * pRNI = (RemoteNodeInfo*) retrieveNodeInfo (nodeId);
            if (pRNI == NULL) {
                _m.unlock (131);
                return 0;
            }
            // Add subscriptions to pRNI
            for (StringHashtable<Subscription>::Iterator i = pSubs->getIterator(); !i.end(); i.nextElement()) {
                Subscription *pSub = i.getValue();
                Subscription *pSubAux = pSub->clone();
                pRNI->subscribe(i.getKey(), pSubAux);
            }
            SubscriptionList *pSubscriptions =  pRNI->getRemoteSubscriptionsCopy();
            sendSubscriptionStateMsg (pSubscriptions, nodeId, pNodesTable->get (nodeId));
        }
    }
    delete pSubscriptionsTable;
    pSubscriptionsTable = NULL;
    delete pNodesTable;
    pNodesTable = NULL;
    _m.unlock (131);
    return 0;
}
开发者ID:fpoltronieri,项目名称:nomads,代码行数:56,代码来源:TopologyWorldState.cpp

示例5: SubscriptionList

SubscriptionList * LocalNodeInfo::getConsolidatedSubscriptionsCopy (void)
{
    SubscriptionList *pConsolidatedSubscriptionsCopy = new SubscriptionList();
    if (pConsolidatedSubscriptionsCopy != NULL) {
        for (StringHashtable<Subscription>::Iterator i = _consolidatedSubscriptions.getIterator(); !i.end(); i.nextElement()) {
            pConsolidatedSubscriptionsCopy->addSubscription (i.getKey(), (i.getValue())->clone()); // Clone subscription before adding it
        }
    }
    return pConsolidatedSubscriptionsCopy;
}
开发者ID:ihmc,项目名称:nomads,代码行数:10,代码来源:NodeInfo.cpp

示例6: unsubscribeFromSymbols

/*
 * Unsubscribe from all specified symbols.
 */
void MamaEntitle::unsubscribeFromSymbols (void)
{
    SubscriptionList::const_iterator i;

    for (i = mSubscriptionList.begin (); i != mSubscriptionList.end (); i++)
    {
        ((MamaSubscription*)*i)->destroy();
        delete *i;
    }
}
开发者ID:MattMulhern,项目名称:OpenMamaCassandra,代码行数:13,代码来源:mamaentitlecpp.cpp

示例7: addAddFiltersToConsolidateList

void LocalNodeInfo::addAddFiltersToConsolidateList (const char *pszGroupName)
{
    _m.lock (328);
    // Get all the client subscribing the group
    DArray<uint16> *pSubClients = NULL;//getSubscribingClients (pszGroupName);
    Subscription *pSCons = _consolidatedSubscriptions.getSubscription (pszGroupName);
    if ((pSubClients == NULL) ||  (!((pSCons != NULL) && (pSCons->getSubscriptionType() == Subscription::GROUP_SUBSCRIPTION)))) {
        _m.unlock (328);
        return;
    }
    GroupSubscription *pGSCons = (GroupSubscription *) pSCons;

    // Look for the first subscribing client which subscribes by a GROUP_SUBSCRIPTION
    uint16 ui16ClientId;
    Subscription *pS = NULL;
    for (int i = 0; i <= pSubClients->getHighestIndex(); i++) {
        ui16ClientId = (*pSubClients)[i];
        SubscriptionList *pSL = NULL;
        if (((pSL = _localSubscriptions.get(ui16ClientId)) != NULL) && ((pS = pSL->getSubscription(pszGroupName)) != NULL)) {
            if (pS->getSubscriptionType() == Subscription::GROUP_SUBSCRIPTION) {
                break;
            }
            if (pS->getSubscriptionType() == Subscription::GROUP_PREDICATE_SUBSCRIPTION) {
                // I want every tag - remove them and return
                pGSCons->removeAllFilters();
                _m.unlock (328);
                return;
            }
        }
    }

    // match every filter against every other subscribing client's tag list.
    // Add it iff:
    // 1) Every other GROUP_SUBSCRIPTION has the same filter
    // 2) No one of the other GROUP_TAG_SUBSCRIPTION subscribe the tag
    // 3) There is not any GROUP_PREDICATE_SUBSCRIPTION for the group
    GroupSubscription *pGS = (GroupSubscription*) pS;
    DArray<uint16> *pTags = pGS->getAllFilters();

    for (int i = 0; i <= pTags->getHighestIndex(); i++) {
        bool bAddFilter = true;
        int16 ui16Tag = (*pTags)[i];
        for (int j = 0; j <= pSubClients->getHighestIndex(); j++) {
            Subscription *pS = NULL;
            if (pS->matches(ui16Tag)) {
                bAddFilter = false;
                break;
            }
        }
        if (bAddFilter) {
            pGSCons->addFilter((*pTags)[i]);
        }
    }
    _m.unlock (328);
}
开发者ID:ihmc,项目名称:nomads,代码行数:55,代码来源:NodeInfo.cpp

示例8: checkAndLogMsg

int TopologyWorldState::printWorldStateInfo (void) 
{
    // Prints information about local node, like subscriptions, alive neighbors, dead peers, etc
    _m.lock (141);
    checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "=========================================================================\n");
    checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "     PRINT WORLD STATE INFO\n");
    checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "     Node id: %s\n", _pDisService->getNodeId());
    if ((_pLocalNodeInfo->getConsolidatedSubscriptions())->getCount() == 0) {
        checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "     No subscribed groups\n");
    } else {
        _pLocalNodeInfo->printAllSubscribedGroups();
        // Print subscribing clients
        checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "     SUBSCRIBING CLIENTS:\n");
        DArray<uint16> *pSubClients = _pLocalNodeInfo->getAllSubscribingClients();
        for (int j = 0; j <= pSubClients->getHighestIndex(); j++) {
            checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "     SUB CLIENT N.%d:\n", (*pSubClients)[j]);
            SubscriptionList *pSubsForClient = _pLocalNodeInfo->getSubscriptionListForClient ((*pSubClients)[j]);
            _pLocalNodeInfo->releaseLocalNodeInfo();
            if (pSubsForClient && pSubsForClient->getCount() != 0) {
                for (StringHashtable<Subscription>::Iterator i = pSubsForClient->getIterator(); !i.end(); i.nextElement()) {
                    checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "     SUBSCRIPTION:\n");
                    checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "     groupname %s\n", i.getKey());
                    Subscription *pS = i.getValue();
                    pS->printInfo();                
                }
            }
        }
        // Print local consolidated subscriptions
        checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "     LOCAL CONSOLIDATED SUBSCRIPTIONS:\n");
        SubscriptionList *pSubscriptions = _pLocalNodeInfo->getConsolidatedSubscriptions();
        for (StringHashtable<Subscription>::Iterator i = pSubscriptions->getIterator(); !i.end(); i.nextElement()) {
            checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "     SUBSCRIPTION:\n");
            checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "     groupname %s\n", i.getKey());
            Subscription *pS = i.getValue();
            pS->printInfo();   
        }
    }
    checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "-------------------------------------------------------------------------\n");
    checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "     %d ACTIVE NEIGHBORS\n", _pLocalNodeInfo->getCount());
    for (StringHashtable<Thing>::Iterator iNeighbors = _pLocalNodeInfo->getAllElements(); !iNeighbors.end(); iNeighbors.nextElement()) {
        checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "-------------------------------------------------------------------------\n");
        RemoteNodeInfo *pRNI = (RemoteNodeInfo *) iNeighbors.getValue();
        pRNI->printRemoteNodeInfo();
    }
    checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "-------------------------------------------------------------------------\n");
    checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "     %d DEAD PEERS\n", _deadPeers.getCount());
    for (StringHashtable<RemoteNodeInfo>::Iterator iDead = _deadPeers.getAllElements(); !iDead.end(); iDead.nextElement()) {
        checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "-------------------------------------------------------------------------\n");
        RemoteNodeInfo *pRNI = (RemoteNodeInfo *) iDead.getValue();
        pRNI->printRemoteNodeInfo();
    }
    checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "=========================================================================\n");
    _m.unlock (141);
    return 0;
}
开发者ID:fpoltronieri,项目名称:nomads,代码行数:55,代码来源:TopologyWorldState.cpp

示例9: removeAllFilters

int LocalNodeInfo::removeAllFilters (uint16 ui16ClientId, const char *pszGroupName)
{
    _m.lock (304);
    SubscriptionList *pSL = _localSubscriptions.get (ui16ClientId);
    if ((pSL != NULL) && (pSL->removeAllFiltersFromGroup (pszGroupName) == 0)) {
        _consolidatedSubscriptions.removeAllFiltersFromGroup (pszGroupName);
        _m.unlock (304);
        return 0;
    }
    _m.unlock (304);
    return -1;
}
开发者ID:ihmc,项目名称:nomads,代码行数:12,代码来源:NodeInfo.cpp

示例10: modifyGroupPriority

int LocalNodeInfo::modifyGroupPriority (uint16 ui16ClientId, const char *pszGroupName, uint8 ui8NewPriority)
{
    _m.lock (302);
    SubscriptionList *pSL = _localSubscriptions.get (ui16ClientId);
    if (pSL == NULL) {
        _m.unlock (302);
        return -1;
    }
    int ret = pSL->modifyPriority (pszGroupName, 0,ui8NewPriority);
    _m.unlock (302);
    return ret;
}
开发者ID:ihmc,项目名称:nomads,代码行数:12,代码来源:NodeInfo.cpp

示例11: hasSubscription

bool LocalNodeInfo::hasSubscription (uint16 ui16ClientId, Message *pMessage)
{
    _m.lock (318);
    SubscriptionList *pSL = _localSubscriptions.get (ui16ClientId);
    if (pSL == NULL) {
        _m.unlock (318);
        return false;
    }
    bool bRet = pSL->hasSubscriptionWild (pMessage);
    _m.unlock (318);
    return bRet;
}
开发者ID:ihmc,项目名称:nomads,代码行数:12,代码来源:NodeInfo.cpp

示例12: getMamdaSubscription

MamdaSubscription* BookPublisher::getMamdaSubscription (const char * symbol) 
{
    SubscriptionList::const_iterator i;
    
    for (i = mSubscriptionList.begin (); i != mSubscriptionList.end (); i++)
    {
        if  (strcmp(((MamdaSubscription*)*i)->getSymbol() , symbol)==0)
        {
            return (MamdaSubscription*)*i;
        }
    }
    return NULL; 
}   
开发者ID:antmd,项目名称:OpenMAMA,代码行数:13,代码来源:listenerBookPublisher.cpp

示例13: isInHistory

bool LocalNodeInfo::isInHistory (uint16 ui16ClientId, Message *pMsg, uint32 ui32LatestMsgRcvdPerSender)
{
    _m.lock (312);
    SubscriptionList *pSL = _localSubscriptions.get (ui16ClientId);
    if (pSL != NULL) {
        Subscription *pS = pSL->getSubscription (pMsg->getMessageInfo()->getGroupName());
        if (pS) {
            bool bRet = pS->isInHistory (pMsg, ui32LatestMsgRcvdPerSender);
            _m.unlock (312);
            return bRet;
        }
    }
    _m.unlock (312);
    return false;
}
开发者ID:ihmc,项目名称:nomads,代码行数:15,代码来源:NodeInfo.cpp

示例14: MamdaOrderBook

void BookPublisher::subscribeToSymbols () 
{ 

    for (vector<const char*>::const_iterator i = mSymbolList.begin ();
         i != mSymbolList.end ();
         ++i)
    {   
        const char* symbol = *i;
        mBook = new MamdaOrderBook();
        // Turn on delta generation
        mBook->generateDeltaMsgs(true);
        MamdaSubscription*      aSubscription = new MamdaSubscription;
        MamdaOrderBookListener* aBookListener = new MamdaOrderBookListener(mBook);
        aSubscription->addMsgListener (aBookListener);
        aBookListener->setProcessEntries (mProcessEntries);

        BookTicker* aTicker = new BookTicker;
        aBookListener->addHandler (aTicker);
       
        aSubscription->setType (MAMA_SUBSC_TYPE_BOOK);
        aSubscription->setMdDataType (MAMA_MD_DATA_TYPE_ORDER_BOOK);
        mSubscriptionList.push_back (aSubscription);

        aSubscription->create (Mama::getDefaultEventQueue (mBridge), mSubSource, symbol, NULL);

    }
}
开发者ID:antmd,项目名称:OpenMAMA,代码行数:27,代码来源:listenerBookPublisher.cpp

示例15: addFilter

int LocalNodeInfo::addFilter (uint16 ui16ClientId, const char *pszGroupName, uint16 ui16Tag)
{
    _m.lock (301);
    SubscriptionList *pSL = _localSubscriptions.get (ui16ClientId);
    if (pSL == NULL) {
        _m.unlock (301);
        return -1;
    }
    if (pSL->addFilterToGroup (pszGroupName, ui16Tag) != 0) {
        _m.unlock (301);
        return -2;
    }
    bool bAddFilter = true;

    // I can add the filter to the ConsolidatedSubscriptions only if every client subscribing that group has the filter too
    for (UInt32Hashtable<SubscriptionList>::Iterator i = _localSubscriptions.getAllElements(); !i.end(); i.nextElement()) {
        SubscriptionList *pSL = i.getValue();
        Subscription *pS = pSL->getSubscription(pszGroupName);
        switch (pS->getSubscriptionType()) {
            case Subscription::GROUP_SUBSCRIPTION: {
                if (!((GroupSubscription *)pS)->hasFilter(ui16Tag)) {
                    bAddFilter = false;
                    break;
                }
                break;
            }
            case Subscription::GROUP_TAG_SUBSCRIPTION: {
                if (((GroupTagSubscription *)pS)->hasTag(ui16Tag)) {
                    bAddFilter = false;
                    break;
                }
                break;
            }
            case Subscription::GROUP_PREDICATE_SUBSCRIPTION :
                 bAddFilter = false;
                 break;
        }
    }
    if (bAddFilter) {
        _consolidatedSubscriptions.addFilterToGroup (pszGroupName, ui16Tag);
    }

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


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