本文整理汇总了C++中DataStore::notificationCollector方法的典型用法代码示例。如果您正苦于以下问题:C++ DataStore::notificationCollector方法的具体用法?C++ DataStore::notificationCollector怎么用?C++ DataStore::notificationCollector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataStore
的用法示例。
在下文中一共展示了DataStore::notificationCollector方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseStream
bool Link::parseStream()
{
Protocol::LinkItemsCommand cmd(m_command);
const Collection collection = HandlerHelper::collectionFromScope(cmd.destination(), connection());
if (!collection.isVirtual()) {
return failureResponse("Can't link items to non-virtual collections");
}
/* FIXME BIN
Resource originalContext;
Scope::SelectionScope itemSelectionScope = Scope::selectionScopeFromByteArray(m_streamParser->peekString());
if (itemSelectionScope != Scope::None) {
m_streamParser->readString();
// Unset Resource context if destination collection is specified using HRID/RID,
// because otherwise the Resource context is relative to the destination collection
// instead of the source collection (collection context)
if ((mDestinationScope.scope() == Scope::HierarchicalRid || mDestinationScope.scope() == Scope::Rid) && itemSelectionScope == Scope::Rid) {
originalContext = connection()->context()->resource();
connection()->context()->setResource(Resource());
}
}
Scope itemScope(itemSelectionScope);
itemScope.parseScope(m_streamParser);
*/
SelectQueryBuilder<PimItem> qb;
ItemQueryHelper::scopeToQuery(cmd.items(), connection()->context(), qb);
/*
if (originalContext.isValid()) {
connection()->context()->setResource(originalContext);
}
*/
if (!qb.exec()) {
return failureResponse("Unable to execute item query");
}
const PimItem::List items = qb.result();
DataStore *store = connection()->storageBackend();
Transaction transaction(store);
PimItem::List toLink, toUnlink;
const bool createLinks = (cmd.action() == Protocol::LinkItemsCommand::Link);
for (const PimItem &item : items) {
const bool alreadyLinked = collection.relatesToPimItem(item);
bool result = true;
if (createLinks && !alreadyLinked) {
result = collection.addPimItem(item);
toLink << item;
} else if (!createLinks && alreadyLinked) {
result = collection.removePimItem(item);
toUnlink << item;
}
if (!result) {
return failureResponse("Failed to modify item reference");
}
}
if (!toLink.isEmpty()) {
store->notificationCollector()->itemsLinked(toLink, collection);
} else if (!toUnlink.isEmpty()) {
store->notificationCollector()->itemsUnlinked(toUnlink, collection);
}
if (!transaction.commit()) {
return failureResponse("Cannot commit transaction.");
}
return successResponse<Protocol::LinkItemsResponse>();
}