Beispiel #1
0
    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);
    }
Beispiel #2
0
 void run() {
     OperationContextImpl txn;
     create();
     BSONObj b = bigObj();
     ASSERT( collection()->insertDocument( &txn, b, true ).isOK() );
     ASSERT_EQUALS( 1, nRecords() );
 }
Beispiel #3
0
            void run() {
                create();
                NamespaceDetails *nsd = collection()->detailsWritable();

                OperationContextImpl txn;
                // Set 2 & 54 as multikey
                nsd->setIndexIsMultikey(&txn, 2, true);
                nsd->setIndexIsMultikey(&txn, 54, true);
                ASSERT(nsd->isMultikey(2));
                ASSERT(nsd->isMultikey(54));

                // Flip 2 & 47
                nsd->setIndexIsMultikey(&txn, 2, false);
                nsd->setIndexIsMultikey(&txn, 47, true);
                ASSERT(!nsd->isMultikey(2));
                ASSERT(nsd->isMultikey(47));

                // Reset entries that are already true
                nsd->setIndexIsMultikey(&txn, 54, true);
                nsd->setIndexIsMultikey(&txn, 47, true);
                ASSERT(nsd->isMultikey(54));
                ASSERT(nsd->isMultikey(47));

                // Two non-multi-key
                nsd->setIndexIsMultikey(&txn, 2, false);
                nsd->setIndexIsMultikey(&txn, 43, false);
                ASSERT(!nsd->isMultikey(2));
                ASSERT(nsd->isMultikey(54));
                ASSERT(nsd->isMultikey(47));
                ASSERT(!nsd->isMultikey(43));
            }
Beispiel #4
0
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';
}
Beispiel #5
0
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);
}
 void start (collectiontype ct)
 {
     char ch = (ct == array) ? openbracket : openbrace;
     output ({&ch, 1});
     stack_.push (collection());
     stack_.top().type = ct;
 }
Beispiel #7
0
	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;
		}
	}
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();

  }
}
Beispiel #9
0
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);
    }
}
Beispiel #10
0
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';
	}
}
Beispiel #11
0
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';
	}
}
Beispiel #12
0
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;
}
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;
}
std::shared_ptr<OsmAnd::FavoriteLocationsGpxCollection> OsmAnd::FavoriteLocationsGpxCollection::tryLoadFrom(const QString& filename)
{
    std::shared_ptr<FavoriteLocationsGpxCollection> collection(new FavoriteLocationsGpxCollection());
    if (!collection->loadFrom(filename))
        return nullptr;

    return collection;
}
Beispiel #15
0
    /// 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;
    }
Beispiel #16
0
// 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()));
}
Beispiel #17
0
 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()));
 }
Beispiel #18
0
TEST_F(SearchQueryParserTest, ShortCrateFilter) {
    // User's search term
    QString crateName = "somecrate";
    QString searchTerm = "ecrat";
    QStringList searchColumns;
    searchColumns << "crate"
                  << "artist"
                  << "comment";

    // Parse the user query
    auto pQuery(m_parser.parseQuery(QString("%1").arg(searchTerm),
                                    searchColumns, ""));

    // 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");
    const QString kTrackCLocationTest(QDir::currentPath() %
                  "/src/test/id3-test-data/artist.mp3");

    // Create new crate and add it to the collection
    Crate testCrate;
    testCrate.setName(crateName);
    CrateId testCrateId;
    collection()->insertCrate(testCrate, &testCrateId);

    // Add the track in the collection
    TrackId trackAId = addTrackToCollection(kTrackALocationTest);
    TrackPointer pTrackA(Track::newDummy(kTrackALocationTest, trackAId));
    TrackId trackBId = addTrackToCollection(kTrackBLocationTest);
    TrackPointer pTrackB(Track::newDummy(kTrackBLocationTest, trackBId));
    TrackId trackCId = addTrackToCollection(kTrackCLocationTest);
    TrackPointer pTrackC(Track::newDummy(kTrackCLocationTest, trackCId));
    pTrackC->setComment("garbage somecrate garbage");

    // Add track A to the newly created crate
    QList<TrackId> trackIds;
    trackIds << trackAId;
    collection()->addCrateTracks(testCrateId, trackIds);

    EXPECT_TRUE(pQuery->match(pTrackA));
    EXPECT_FALSE(pQuery->match(pTrackB));
    EXPECT_TRUE(pQuery->match(pTrackC));
}
Beispiel #19
0
    void shouldRemoveCollections()
    {
        // GIVEN
        auto data = Testlib::AkonadiFakeData();
        QScopedPointer<Akonadi::MonitorInterface> monitor(data.createMonitor());
        QSignalSpy spy(monitor.data(), &Akonadi::MonitorInterface::collectionRemoved);

        auto c1 = Akonadi::Collection(42);
        c1.setName(QStringLiteral("42"));
        data.createCollection(c1);

        auto c2 = Akonadi::Collection(43);
        c2.setName(QStringLiteral("43"));
        c2.setParentCollection(Akonadi::Collection(42));
        data.createCollection(c2);

        auto c3 = Akonadi::Collection(44);
        c3.setName(QStringLiteral("44"));
        c3.setParentCollection(Akonadi::Collection(43));
        data.createCollection(c3);

        auto i1 = Akonadi::Item(42);
        i1.setPayloadFromData("42");
        i1.setParentCollection(Akonadi::Collection(43));
        data.createItem(i1);

        auto i2 = Akonadi::Item(43);
        i2.setPayloadFromData("43");
        i2.setParentCollection(Akonadi::Collection(44));
        data.createItem(i2);

        // WHEN
        data.removeCollection(c2);

        // THEN
        QCOMPARE(data.collections().size(), 1);
        QCOMPARE(data.collections().at(0), c1);

        QVERIFY(!data.collection(c2.id()).isValid());
        QVERIFY(!data.collection(c3.id()).isValid());

        QVERIFY(data.childCollections(c1.id()).isEmpty());
        QVERIFY(data.childCollections(c2.id()).isEmpty());
        QVERIFY(data.childCollections(c3.id()).isEmpty());

        QVERIFY(data.items().isEmpty());

        QVERIFY(!data.item(i1.id()).isValid());
        QVERIFY(!data.item(i2.id()).isValid());

        QVERIFY(data.childItems(c2.id()).isEmpty());
        QVERIFY(data.childItems(c3.id()).isEmpty());

        QCOMPARE(spy.size(), 2);
        QCOMPARE(spy.takeFirst().at(0).value<Akonadi::Collection>(), c3);
        QCOMPARE(spy.takeFirst().at(0).value<Akonadi::Collection>(), c2);
    }
Beispiel #20
0
 std::vector<Utterance>  Engine::answers(const String& inName)
 {
   auto optState = collection().states().optionalObjectWithName(inName);
   return (!optState)
          ? std::vector<Utterance>()
          : std::vector<Utterance>(
     optState->answers().utterances().begin(),
     optState->answers().utterances().end());
 }
Beispiel #21
0
bool KSecretUnlockCollectionJob::isImmediate() const
{
    // unlocked collections don't need a job to open
    if(!collection()->isLocked()) {
        return true;
    } else {
        return false;
    }
}
Beispiel #22
0
    void run() {
        auto indexCatalog = collection()->getIndexCatalog();

        ASSERT_BSONOBJ_EQ(BSON("x" << 1), indexCatalog->fixIndexKey(BSON("x" << 1)));

        ASSERT_BSONOBJ_EQ(BSON("_id" << 1), indexCatalog->fixIndexKey(BSON("_id" << 1)));

        ASSERT_BSONOBJ_EQ(BSON("_id" << 1), indexCatalog->fixIndexKey(BSON("_id" << true)));
    }
Beispiel #23
0
void KSecretUnlockCollectionJob::askPasswordJobResult(KJob *job)
{
    AbstractAskPasswordJob *apj = qobject_cast<AbstractAskPasswordJob*>(job);
    Q_ASSERT(apj);

    if(apj->cancelled()) {
        setResult(false);
        setError(BackendErrorOther, i18n("Unlocking the secret collection was canceled by the user."));
        emitResult();
        return;
    }

    KSecretCollection *ksecretColl = dynamic_cast< KSecretCollection* >(collection());
    BackendReturn<bool> rc = ksecretColl->tryUnlockPassword(apj->password());
    if(rc.isError()) {
        setResult(false);
        setError(rc.error(), rc.errorMessage());
        emitResult();
    } else if(!rc.value()) {
        // try again the password
        createAskPasswordJob();
    } else {
        m_passwordAsked = true;
    
        m_collectionPerm = collection()->applicationPermission( unlockInfo().m_peer.exePath() );
        if ( m_collectionPerm == PermissionUndefined ) {
            // ask for the ACL preference if the application is unknown by this collection
            AbstractUiManager *uiManager = BackendMaster::instance()->uiManager();
            AbstractAskAclPrefsJob* askAclPrefsJob = uiManager->createAskAclPrefsJob(unlockInfo());
            connect(askAclPrefsJob, SIGNAL(result(KJob*)), SLOT(askAclPrefsJobResult(KJob*)));
            if ( addSubjob( askAclPrefsJob ) ) {
                askAclPrefsJob->start();        
            }
            else {
                setResult(false);
                emitResult();
            }
        }
        else {
            setResult(true);
            emitResult();
        }
    }
}
Beispiel #24
0
    /// Method for generating hit(s) using the information of G4Step object.
    template <> bool Geant4SensitiveAction<CalorimeterWithPreShowerLayer>::process(G4Step* step,G4TouchableHistory*) {
      typedef CalorimeterWithPreShowerLayer::Hit Hit;
      Geant4StepHandler h(step);
      HitContribution contrib = Hit::extractContribution(step);

      long long int cell;
      try {
        cell = cellID(step);
      } catch(std::runtime_error &e) {
        std::stringstream out;
        out << std::setprecision(20) << std::scientific;
        out << "ERROR: " << e.what()  << std::endl;
        out << "Position: "
            << "Pre (" << std::setw(24) << step->GetPreStepPoint()->GetPosition() << ") "
            << "Post (" << std::setw(24) << step->GetPostStepPoint()->GetPosition() << ") "
            << std::endl;
        out << "Momentum: "
            << " Pre (" <<std::setw(24) << step->GetPreStepPoint() ->GetMomentum()  << ") "
            << " Post (" <<std::setw(24) << step->GetPostStepPoint()->GetMomentum() << ") "
            << std::endl;

        std::cout << out.str();

        return true;
      }

      // get the layer number by decoding the cellID
      IDDescriptor idspec = m_sensitive.readout().idSpec() ;
      const DDSegmentation::BitFieldCoder& bc = *idspec.decoder() ;
      int layer = bc.get(cell, "layer") ;
      
      Geant4HitCollection*  coll = ( layer== m_userData._firstLayerNumber ?  collection( m_userData._preShowerCollectionID ) : collection(m_collectionID) ) ;
      
      Hit* hit = coll->find<Hit>(CellIDCompare<Hit>(cell));
      if ( h.totalEnergy() < std::numeric_limits<double>::epsilon() )  {
        return true;
      }
      else if ( !hit ) {
        Geant4TouchableHandler handler(step);
        DDSegmentation::Vector3D pos = m_segmentation.position(cell);
        Position global = h.localToGlobal(pos);
        hit = new Hit(global);
        hit->cellID = cell;
        coll->add(hit);
        printM2("%s> CREATE hit with deposit:%e MeV  Pos:%8.2f %8.2f %8.2f  %s",
                c_name(),contrib.deposit,pos.X,pos.Y,pos.Z,handler.path().c_str());
        if ( 0 == hit->cellID )  { // for debugging only!
          hit->cellID = cellID(step);
          except("+++ Invalid CELL ID for hit!");
        }
      }
      hit->truth.push_back(contrib);
      hit->energyDeposit += contrib.deposit;
      mark(step);
      return true;
    }
void MoveCollectionTask::doRename(KIMAP::Session *session)
{
    // collection.remoteId() already includes the separator
    const QString oldMailBox = mailBoxForCollections(sourceCollection(), collection());
    const QString newMailBox = mailBoxForCollections(targetCollection(), collection());

    if (oldMailBox != newMailBox) {
        KIMAP::RenameJob *job = new KIMAP::RenameJob(session);
        job->setSourceMailBox(oldMailBox);
        job->setDestinationMailBox(newMailBox);

        connect(job, &KIMAP::RenameJob::result, this, &MoveCollectionTask::onRenameDone);

        job->start();

    } else {
        changeProcessed();
    }
}
Beispiel #26
0
	void LoginPage::sendCode()
	{
		timer_->stop();
		gui_coll_helper collection(GetDispatcher()->create_collection(), true);
		collection.set_value_as_qstring("country", country_code_->text());
		collection.set_value_as_qstring("phone", phone_->text());
        collection.set_value_as_qstring("locale", Utils::GetTranslator()->getCurrentLang());
		GetDispatcher()->post_message_to_core("login_get_sms_code", collection.get());
		remaining_seconds_ = 60;
		updateTimer();
	}
static std::unique_ptr<TraceCollection>
CreateTestCollection(float startTimeSec=0.0)
{
    std::unique_ptr<TraceCollection> collection(new TraceCollection);
    collection->AddToCollection(
        TraceThreadId("MainThread"),
        CreateTestEvents(ArchSecondsToTicks(startTimeSec)));
    collection->AddToCollection(TraceThreadId("Thread 1"), 
        CreateTestEvents(ArchSecondsToTicks(startTimeSec + 0.001)));
    return collection;
}
Beispiel #28
0
 void run() {
     // It's necessary to index sufficient keys that a RARELY condition will be triggered.
     int32_t nDocs = 130;
     // Add some data to the collection.
     for( int32_t i = 0; i < nDocs; ++i ) {
         _client.insert( _ns, BSON( "a" << i ) );
     }
     IndexDescriptor* id = addIndexWithInfo();
     // Create a SortPhaseOne.
     SortPhaseOne phaseOne;
     ProgressMeterHolder pm (cc().curop()->setMessage("InterruptAddKeysToPhaseOne",
                                                      "InterruptAddKeysToPhaseOne Progress",
                                                      nDocs,
                                                      nDocs));
     // Register a request to kill the current operation.
     cc().curop()->kill();
     if ( _mayInterrupt ) {
         // Add keys to phaseOne.
         ASSERT_THROWS( BtreeBasedBuilder::addKeysToPhaseOne( collection(),
                                                              id,
                                                              BSON( "a" << 1 ),
                                                              &phaseOne,
                                                              pm.get(),
                                                              _mayInterrupt ),
                        UserException );
         // Not all keys were added to phaseOne due to the interrupt.
         ASSERT( static_cast<uint64_t>( nDocs ) > phaseOne.n );
     }
     else {
         // Add keys to phaseOne.
         BtreeBasedBuilder::addKeysToPhaseOne( collection(),
                                               id,
                                               BSON( "a" << 1 ),
                                               &phaseOne,
                                               pm.get(),
                                               _mayInterrupt );
         // All keys were added to phaseOne despite to the kill request, because
         // mayInterrupt == false.
         ASSERT_EQUALS( static_cast<uint64_t>( nDocs ), phaseOne.n );
     }
 }
Beispiel #29
0
        /** @return IndexDetails for a new index on a:1, with the info field populated. */
        IndexDescriptor* addIndexWithInfo() {
            BSONObj indexInfo = BSON( "v" << 1 <<
                                      "key" << BSON( "a" << 1 ) <<
                                      "ns" << _ns <<
                                      "name" << "a_1" );
            int32_t lenWHdr = indexInfo.objsize() + Record::HeaderSize;
            const char* systemIndexes = "unittests.system.indexes";
            DiskLoc infoLoc = allocateSpaceForANewRecord( systemIndexes,
                                                          nsdetails( systemIndexes ),
                                                          lenWHdr,
                                                          false );
            Record* infoRecord = reinterpret_cast<Record*>( getDur().writingPtr( infoLoc.rec(),
                                                                                 lenWHdr ) );
            memcpy( infoRecord->data(), indexInfo.objdata(), indexInfo.objsize() );
            addRecordToRecListInExtent( infoRecord, infoLoc );

            IndexCatalog::IndexBuildBlock blk( collection()->getIndexCatalog(), "a_1", infoLoc );
            blk.success();

            return collection()->getIndexCatalog()->findIndexByName( "a_1" );
        }
KJS::Value KstBindWindowCollection::extract(KJS::ExecState *exec, unsigned item) const {
  QStringList wl = collection(exec);
  if (item >= wl.count()) {
    return KJS::Undefined();
  }

  KstViewWindow *w = dynamic_cast<KstViewWindow*>(KstApp::inst()->findWindow(wl[item]));
  if (w) {
    return KJS::Object(new KstBindWindow(exec, w));
  }
  return KJS::Undefined();
}