本文整理汇总了C++中Subscription::matches方法的典型用法代码示例。如果您正苦于以下问题:C++ Subscription::matches方法的具体用法?C++ Subscription::matches怎么用?C++ Subscription::matches使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subscription
的用法示例。
在下文中一共展示了Subscription::matches方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例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;
}
示例3: isNodeInterested
bool RemoteNodeInfo::isNodeInterested (DisServiceDataMsg *pDSDMsg)
{
// Returns true if the node is interested in pDSDMsg
bool bFound = false;
const char * pszMsgGroupName = pDSDMsg->getMessageHeader()->getGroupName();
if (_pRemoteSubscriptions) {
for (StringHashtable<Subscription>::Iterator i = _pRemoteSubscriptions->getIterator(); !i.end(); i.nextElement()) {
const char *pszSubGroupName = i.getKey();
if (0 == stricmp (pszSubGroupName, pszMsgGroupName)) {
Subscription *pSub = i.getValue();
if ((pSub->getSubscriptionType() == Subscription::GROUP_PREDICATE_SUBSCRIPTION) || pSub->matches(pDSDMsg->getMessage())) {
bFound = true;
}
}
}
}
return bFound;
}