本文整理汇总了C++中collection函数的典型用法代码示例。如果您正苦于以下问题:C++ collection函数的具体用法?C++ collection怎么用?C++ collection使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了collection函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shouldCreateCollections
void shouldCreateCollections()
{
// GIVEN
auto data = Testlib::AkonadiFakeData();
QScopedPointer<Akonadi::MonitorInterface> monitor(data.createMonitor());
QSignalSpy spy(monitor.data(), &Akonadi::MonitorInterface::collectionAdded);
auto c1 = Akonadi::Collection(42);
c1.setName(QStringLiteral("42"));
auto c2 = Akonadi::Collection(43);
c2.setName(QStringLiteral("43"));
const auto colSet = QSet<Akonadi::Collection>() << c1 << c2;
// WHEN
data.createCollection(c1);
data.createCollection(c2);
// THEN
QCOMPARE(data.collections().toList().toSet(), colSet);
QCOMPARE(data.collection(c1.id()), c1);
QCOMPARE(data.collection(c2.id()), c2);
QCOMPARE(spy.size(), 2);
QCOMPARE(spy.takeFirst().at(0).value<Akonadi::Collection>(), c1);
QCOMPARE(spy.takeFirst().at(0).value<Akonadi::Collection>(), c2);
}
示例2: run
void run() {
OperationContextImpl txn;
create();
BSONObj b = bigObj();
ASSERT( collection()->insertDocument( &txn, b, true ).isOK() );
ASSERT_EQUALS( 1, nRecords() );
}
示例3: actionQueryGlobalStat
void actionQueryGlobalStat(const std::string &kindName, const std::string &filename)
{
MeasurementSet *ms = new MeasurementSet(filename);
const unsigned polarizationCount = ms->GetPolarizationCount();
const BandInfo band = ms->GetBandInfo(0);
delete ms;
const QualityTablesFormatter::StatisticKind kind = QualityTablesFormatter::NameToKind(kindName);
QualityTablesFormatter formatter(filename);
StatisticsCollection collection(polarizationCount);
collection.Load(formatter);
DefaultStatistics statistics(polarizationCount);
collection.GetGlobalCrossBaselineStatistics(statistics);
StatisticsDerivator derivator(collection);
double start = band.channels.begin()->frequencyHz;
double end = band.channels.rbegin()->frequencyHz;
std::cout << round(start/10000.0)/100.0 << '\t' << round(end/10000.0)/100.0;
for(unsigned p=0;p<polarizationCount;++p)
{
long double val = derivator.GetStatisticAmplitude(kind, statistics, p);
std::cout << '\t' << val;
}
std::cout << '\n';
}
示例4: collection
NoteEditTest::NoteEditTest()
{
qRegisterMetaType<Akonadi::Collection>();
qRegisterMetaType<KMime::Message::Ptr>();
QStandardPaths::setTestModeEnabled(true);
QStandardItemModel *model = new QStandardItemModel;
for (int id = 42; id < 51; ++id) {
Akonadi::Collection collection(id);
collection.setRights(Akonadi::Collection::AllRights);
collection.setName(QString::number(id));
collection.setContentMimeTypes(QStringList() << Akonadi::NoteUtils::noteMimeType());
QStandardItem *item = new QStandardItem(collection.name());
item->setData(QVariant::fromValue(collection),
Akonadi::EntityTreeModel::CollectionRole);
item->setData(QVariant::fromValue(collection.id()),
Akonadi::EntityTreeModel::CollectionIdRole);
model->appendRow(item);
}
MessageViewer::_k_noteEditStubModel = model;
// Fake a default-selected collection for shouldHaveDefaultValuesOnCreation test
MessageViewer::MessageViewerSettingsBase::self()->setLastNoteSelectedFolder(43);
}
示例5: start
void start (collectiontype ct)
{
char ch = (ct == array) ? openbracket : openbrace;
output ({&ch, 1});
stack_.push (collection());
stack_.top().type = ct;
}
示例6: GetContactListModel
void SearchModel::searchPatternChanged(QString p)
{
SearchPatterns_ = Utils::GetPossibleStrings(p);
if (p.isEmpty())
{
unsigned size = (unsigned)Match_.size();
Match_ = GetContactListModel()->getSearchedContacts();
emit dataChanged(index(0), index(size));
return;
}
if (!SearchRequested_)
{
QTimer::singleShot(200, [this]()
{
SearchRequested_ = false;
Ui::gui_coll_helper collection(Ui::GetDispatcher()->create_collection(), true);
core::ifptr<core::iarray> patternsArray(collection->create_array());
patternsArray->reserve(SearchPatterns_.size());
for (auto iter = SearchPatterns_.begin(); iter != SearchPatterns_.end(); ++iter)
{
core::coll_helper coll(collection->create_collection(), true);
coll.set_value_as_string("pattern", iter->toUtf8().data(), iter->toUtf8().size());
core::ifptr<core::ivalue> val(collection->create_value());
val->set_as_collection(coll.get());
patternsArray->push_back(val.get());
}
collection.set_value_as_array("search_patterns", patternsArray.get());
Ui::GetDispatcher()->post_message_to_core("search", collection.get());
});
SearchRequested_ = true;
}
}
示例7: collection
void ArchiveJob::execute()
{
if(mInfo) {
MailCommon::BackupJob *backupJob = new MailCommon::BackupJob();
Akonadi::Collection collection(mInfo->saveCollectionId());
backupJob->setRootFolder( MailCommon::Util::updatedCollection(collection) );
const QString realPath = MailCommon::Util::fullCollectionPath(collection);
backupJob->setSaveLocation( mInfo->realUrl(realPath) );
backupJob->setArchiveType( mInfo->archiveType() );
backupJob->setDeleteFoldersAfterCompletion( false );
backupJob->setRecursive( mInfo->saveSubCollection() );
backupJob->setDisplayMessageBox(false);
const QString summary = i18n("Start to archive %1",realPath );
const QPixmap pixmap = KIcon( "kmail" ).pixmap( KIconLoader::SizeSmall, KIconLoader::SizeSmall );
KNotification::event( QLatin1String("archivemailstarted"),
summary,
pixmap,
0,
KNotification::CloseOnTimeout,
KGlobal::mainComponent());
connect(backupJob,SIGNAL(backupDone(QString)),this,SLOT(slotBackupDone(QString)));
connect(backupJob,SIGNAL(error(QString)),this,SLOT(slotError(QString)));
backupJob->start();
}
}
示例8: GetControllerId
void
HdStreamTaskController::_CreateRenderTasks()
{
// Create two render tasks, one to create a color render, the other
// to create an id render (so we don't need to thrash params).
_renderTaskId = GetControllerId().AppendChild(_tokens->renderTask);
_idRenderTaskId = GetControllerId().AppendChild(_tokens->idRenderTask);
HdxRenderTaskParams renderParams;
renderParams.camera = _cameraId;
renderParams.viewport = GfVec4d(0,0,1,1);
HdRprimCollection collection(HdTokens->geometry, HdTokens->smoothHull);
collection.SetRootPath(SdfPath::AbsoluteRootPath());
SdfPath const renderTasks[] = {
_renderTaskId,
_idRenderTaskId,
};
for (size_t i = 0; i < sizeof(renderTasks)/sizeof(renderTasks[0]); ++i) {
GetRenderIndex()->InsertTask<HdxRenderTask>(&_delegate,
renderTasks[i]);
_delegate.SetParameter(renderTasks[i], HdTokens->params,
renderParams);
_delegate.SetParameter(renderTasks[i], HdTokens->children,
SdfPathVector());
_delegate.SetParameter(renderTasks[i], HdTokens->collection,
collection);
}
}
示例9: actionQueryTime
void actionQueryTime(const std::string &kindName, const std::string &filename)
{
const unsigned polarizationCount = MeasurementSet::GetPolarizationCount(filename);
const QualityTablesFormatter::StatisticKind kind = QualityTablesFormatter::NameToKind(kindName);
QualityTablesFormatter formatter(filename);
StatisticsCollection collection(polarizationCount);
collection.Load(formatter);
const std::map<double, DefaultStatistics> &timeStats = collection.TimeStatistics();
StatisticsDerivator derivator(collection);
std::cout << "TIME";
for(unsigned p=0;p<polarizationCount;++p)
std::cout << '\t' << kindName << "_POL" << p << "_R\t" << kindName << "_POL" << p << "_I" ;
std::cout << '\n';
for(std::map<double, DefaultStatistics>::const_iterator i=timeStats.begin();i!=timeStats.end();++i)
{
const double time = i->first;
std::cout << time;
for(unsigned p=0;p<polarizationCount;++p)
{
const std::complex<long double> val = derivator.GetComplexStatistic(kind, i->second, p);
std::cout << '\t' << val.real() << '\t' << val.imag();
}
std::cout << '\n';
}
}
示例10: actionQueryBaselines
void actionQueryBaselines(const std::string &kindName, const std::string &filename)
{
MeasurementSet *ms = new MeasurementSet(filename);
const unsigned polarizationCount = ms->GetPolarizationCount();
delete ms;
const QualityTablesFormatter::StatisticKind kind = QualityTablesFormatter::NameToKind(kindName);
QualityTablesFormatter formatter(filename);
StatisticsCollection collection(polarizationCount);
collection.Load(formatter);
const std::vector<std::pair<unsigned, unsigned> > &baselines = collection.BaselineStatistics().BaselineList();
StatisticsDerivator derivator(collection);
std::cout << "ANTENNA1\tANTENNA2";
for(unsigned p=0;p<polarizationCount;++p)
std::cout << '\t' << kindName << "_POL" << p << "_R\t" << kindName << "_POL" << p << "_I" ;
std::cout << '\n';
for(std::vector<std::pair<unsigned, unsigned> >::const_iterator i=baselines.begin();i!=baselines.end();++i)
{
const unsigned antenna1 = i->first, antenna2 = i->second;
std::cout << antenna1 << '\t' << antenna2;
for(unsigned p=0;p<polarizationCount;++p)
{
const std::complex<long double> val = derivator.GetComplexBaselineStatistic(kind, antenna1, antenna2, p);
std::cout << '\t' << val.real() << '\t' << val.imag();
}
std::cout << '\n';
}
}
示例11: assert
Field GroupOperation::PerformAggregation(std::vector<Record> const &vRecords, Field::Name const name, Aggregate const aggr) const
{
Field newField;
std::set<std::string> setUniqueValues;
if (aggr == Aggregate::NONE) {
assert(!vRecords.empty());
return vRecords.front().GetField(name);
}
for (Record const &rec : vRecords) {
Field const field(rec.GetField(name));
switch (aggr) {
case Aggregate::MIN: {
try {
newField = (newField.IsValid() ? (newField < field ? newField : field)
: field);
} catch(...) {
throw std::runtime_error("Failed to apply aggregate MIN to field " + Field::ToString(name));
}
break;
}
case Aggregate::MAX: {
try {
newField = (newField.IsValid() ? (newField > field ? newField : field)
: field);
} catch(...) {
throw std::runtime_error("Failed to apply aggregate MAX to field " + Field::ToString(name));
}
break;
}
case Aggregate::SUM: {
try {
newField = (newField.IsValid() ? newField + field : field);
} catch(...) {
throw std::runtime_error("Failed to apply aggregate SUM to field " + Field::ToString(name));
}
break;
}
case Aggregate::COUNT: {
setUniqueValues.insert(field.GetValue());
newField = Field(name, std::to_string(setUniqueValues.size()));
break;
}
case Aggregate::COLLECT: {
std::string collection(newField.IsValid() ? newField.GetValue() : "");
collection = (collection.empty() ? "[" + field.GetValue() + "]"
: collection.substr(0, collection.size() - 1) + "," + field.GetValue() + "]");
newField = Field(name, collection);
break;
}
default:
throw std::runtime_error("Unknown aggregate token");
}
}
return newField;
}
示例12: collection
std::shared_ptr<OsmAnd::FavoriteLocationsGpxCollection> OsmAnd::FavoriteLocationsGpxCollection::tryLoadFrom(QXmlStreamReader& reader)
{
std::shared_ptr<FavoriteLocationsGpxCollection> collection(new FavoriteLocationsGpxCollection());
if (!collection->loadFrom(reader))
return nullptr;
return collection;
}
示例13: h
/// Method for generating hit(s) using the information of G4Step object.
template <> bool Geant4GenericSD<Calorimeter>::buildHits(G4Step* step,G4TouchableHistory*) {
StepHandler h(step);
Position pos = 0.5 * (h.prePos() + h.postPos());
HitContribution contrib = Geant4Hit::extractContribution(step);
Geant4CalorimeterHit* hit=find(collection(0),HitPositionCompare<Geant4CalorimeterHit>(pos));
// G4cout << "----------- Geant4GenericSD<Calorimeter>::buildHits : position : " << pos << G4endl;
if ( !hit ) {
hit = new Geant4CalorimeterHit(pos);
hit->cellID = getCellID( step );
collection(0)->insert(hit);
}
hit->truth.push_back(contrib);
hit->energyDeposit += contrib.deposit;
return true;
}
示例14: TEST_F
// Tests if the crate filter works along with other filters (artist)
TEST_F(SearchQueryParserTest, CrateFilterWithOther){
QStringList searchColumns;
searchColumns << "artist"
<< "album";
// User's search term
QString searchTerm = "test";
// Parse the user query
auto pQuery(m_parser.parseQuery(QString("crate: %1 artist: asdf").arg(searchTerm),
QStringList(), ""));
// locations for test tracks
const QString kTrackALocationTest(QDir::currentPath() %
"/src/test/id3-test-data/cover-test-jpg.mp3");
const QString kTrackBLocationTest(QDir::currentPath() %
"/src/test/id3-test-data/cover-test-png.mp3");
// Create new crate and add it to the collection
Crate testCrate;
testCrate.setName(searchTerm);
CrateId testCrateId;
collection()->insertCrate(testCrate, &testCrateId);
// Add the tracks in the collection
TrackId trackAId = addTrackToCollection(kTrackALocationTest);
TrackPointer pTrackA(Track::newDummy(kTrackALocationTest, trackAId));
TrackId trackBId = addTrackToCollection(kTrackBLocationTest);
TrackPointer pTrackB(Track::newDummy(kTrackBLocationTest, trackBId));
// Add trackA to the newly created crate
QList<TrackId> trackIds;
trackIds << trackAId;
collection()->addCrateTracks(testCrateId, trackIds);
pTrackA->setArtist("asdf");
pTrackB->setArtist("asdf");
EXPECT_TRUE(pQuery->match(pTrackA));
EXPECT_FALSE(pQuery->match(pTrackB));
EXPECT_STREQ(
qPrintable("(" + m_crateFilterQuery.arg(searchTerm) +
") AND ((artist LIKE '%asdf%') OR (album_artist LIKE '%asdf%'))"),
qPrintable(pQuery->toSql()));
}
示例15: setupFromQuery
void setupFromQuery(const BSONObj& query) {
CanonicalQuery* cq;
Status s = CanonicalQuery::canonicalize(ns(), query, &cq);
ASSERT(s.isOK());
_cq.reset(cq);
_oplogws.reset(new WorkingSet());
_stage.reset(new OplogStart(collection(), _cq->root(), _oplogws.get()));
}