本文整理汇总了C++中Subscription::getSubscriptionType方法的典型用法代码示例。如果您正苦于以下问题:C++ Subscription::getSubscriptionType方法的具体用法?C++ Subscription::getSubscriptionType怎么用?C++ Subscription::getSubscriptionType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subscription
的用法示例。
在下文中一共展示了Subscription::getSubscriptionType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例4: addHistoryInternal
int LocalNodeInfo::addHistoryInternal (uint16 ui16ClientId, const char *pszGroupName, History *pHistory)
{
Subscription *pSubscription = getSubscriptionForClient (ui16ClientId, pszGroupName);
if (pSubscription == NULL) {
return -1;
}
if (pSubscription->getSubscriptionType() != Subscription::GROUP_SUBSCRIPTION) {
return -2;
}
return pSubscription->addHistory (pHistory);
}
示例5: unsubscribe
int LocalNodeInfo::unsubscribe (uint16 ui16ClientId, const char *pszGroupName, uint16 ui16Tag)
{
char *pszOnDemandDataGroupName = getOnDemandDataGroupName (pszGroupName);
if (pszOnDemandDataGroupName == NULL) {
// The on-demand subscription group name could not be generated
return -1;
}
_m.lock (306);
SubscriptionList *pSL = _localSubscriptions.get (ui16ClientId);
int rc = 0;
if (pSL == NULL) {
rc = -2;
}
else {
Subscription *pSub = pSL->getSubscription (pszGroupName);
if (pSub == NULL) {
rc = -3;
}
else {
uint8 ui8SubscriptionType = pSub->getSubscriptionType();
if ((ui8SubscriptionType == Subscription::GROUP_SUBSCRIPTION) && (ui16Tag == 0)) {
if (pSL->removeGroup (pszGroupName)) {
rc = -4;
}
else {
if (pSL->removeGroup (pszOnDemandDataGroupName)) {
rc = -5;
}
}
}
else if ((ui8SubscriptionType == Subscription::GROUP_TAG_SUBSCRIPTION) && (ui16Tag != 0)) {
if (pSL->removeGroupTag (pszGroupName, ui16Tag)) {
rc = -6;
}
else {
if (pSL->removeGroupTag (pszOnDemandDataGroupName, ui16Tag)) {
rc = -7;
}
}
}
}
}
if (rc == 0) {
recomputeConsolidateSubsciptionList ();
}
free (pszOnDemandDataGroupName);
_m.unlock (306);
return rc;
}
示例6: addHistory
int LocalNodeInfo::addHistory (uint16 ui16ClientId, const char *pszGroupName, uint8 ui8PredicateType, const char *pszPredicate, History *pHistory)
{
_m.lock (309);
Subscription *pSubscription = getSubscriptionForClient (ui16ClientId, pszGroupName);
if (pSubscription == NULL) {
_m.unlock (309);
return -1;
}
if (pSubscription->getSubscriptionType() != Subscription::GROUP_PREDICATE_SUBSCRIPTION) {
_m.unlock (309);
return -2;
}
int rc = pSubscription->addHistory (pHistory);
_m.unlock (309);
return rc;
}
示例7: 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;
}
示例8: 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;
}