Example #1
0
Storage* Memory::alloc(const char* name, Result* cls)
{
	int size = strlen(cls->getStringValue());
	Storage* storage = this->alloc(name, size);
	storage->write((char*)cls->getStringValue(), size);
	return storage;
}
Example #2
0
Storage::Storage( unsigned int p_id ) {
    char sql[ZM_SQL_SML_BUFSIZ] = "";
	snprintf( sql, sizeof(sql), "SELECT Id, Name, Path from Storage WHERE Id=%d", p_id );
	if ( mysql_query( &dbconn, sql ) ) {
		Error( "Can't run query: %s", mysql_error( &dbconn ) );
		return;
	}
    MYSQL_RES *result = mysql_store_result( &dbconn );
    if ( !result ) {
        Error( "Can't use query result: %s", mysql_error( &dbconn ) );
		return;
    }
    int n_rows = mysql_num_rows( result );

    if ( n_rows != 1 ) {
        Warning( "Should not have returned more than 1 row for %d", p_id );
        return;
    }

    MYSQL_ROW dbrow = mysql_fetch_row( result );

    Storage *storage = new Storage( dbrow );
    Info( "Loaded Storage area '%s'", storage->getName() );

    mysql_free_result( result );
	return (storage);
}
void testArm26() {
    ForwardTool forward("arm26_Setup_Forward.xml");
	forward.run();

	Storage results("Results/arm26_states.sto");
	Storage* standard = new Storage();
    string statesFileName("std_arm26_states.sto");
    forward.loadStatesStorage( statesFileName, standard );
	StateVector* state = results.getStateVector(0);
	double time = state->getTime();
	Array<double> data;
	data.setSize(state->getSize());
	standard->getDataAtTime(time, state->getSize(), data);
	for (int j = 0; j < state->getSize(); ++j) {
		stringstream message;
		message << "t=" << time <<" state# "<< j << " " << standard->getColumnLabels()[j+1] << " std=" << data[j] <<"  computed=" << state->getData()[j] << endl;
        ASSERT_EQUAL(data[j], state->getData()[j], 1.0e-3, __FILE__, __LINE__, "ASSERT_EQUAL FAILED " + message.str());
		cout << "ASSERT_EQUAL PASSED " << message.str();
    }

	int i = results.getSize()-1;
    state = results.getStateVector(i);
    time = state->getTime();
	data.setSize(state->getSize());
	standard->getDataAtTime(time, state->getSize(), data);
	for (int j = 0; j < state->getSize(); ++j) {
        stringstream message;
		message << "t=" << time <<" state# "<< j << " " << standard->getColumnLabels()[j+1] << " std=" << data[j] <<"  computed=" << state->getData()[j] << endl;
        ASSERT_EQUAL(data[j], state->getData()[j], 1.0e-3, __FILE__, __LINE__, "ASSERT_EQUAL FAILED " + message.str());
		cout << "ASSERT_EQUAL PASSED " << message.str();
	}
}
Example #4
0
void storage_test()
{
    Block* data=new Block();
    Address address;
    address.database_name="zyh";
    address.file_name="friend";
    address.file_offset=8;
    Storage storage;
    try{
        storage.read_data(address,data);
        for (int i=0;i<8;i++)
        {
            std::cout << (*data)[i];
        }
    }
    catch( Error error)
    {
        error.print_error();
    }
    unsigned char newdata[BLOCK_SIZE];
    for (int i=0;i<BLOCK_SIZE;i++)
    {
        newdata[i]='s';
    }
    Block newblock(newdata);
    try{
        storage.write_data(address,&newblock);
    }
    catch( Error error)
    {
        error.print_error();
    }

}
Example #5
0
std::vector<Sequence> AnySuitCondition::GetVariants(const Sequence& applied_sequence,
                                                    Storage storage) const {
    if (applied_sequence.IsOccupied(position_)) {
        if (!inverse_ && applied_sequence.GetCard(position_).rank != rank_) {
            return {};
        }
        if (inverse_ && applied_sequence.GetCard(position_).rank == rank_) {
            return {};
        }
        return {
            Sequence(SimpleSequence{{applied_sequence.GetCard(position_)}, position_})};
    }
    std::vector<Card> cards;
    if (!inverse_) {
        for (auto& suit : storage.GetSuitsForRank(rank_)) {
            cards.push_back(Card{suit, rank_});
        }
    } else {
        for (auto& card : storage.GetAllAvailableCards()) {
            if (card.rank != rank_) {
                cards.push_back(card);
            }
        }
    }
    std::vector<Sequence> result;
    for (auto& card : cards) {
        result.emplace_back(SimpleSequence{{card}, position_});
    }
    return result;
}
Example #6
0
void Environment::TiXmlFileClose( void *pContext )
{
	Storage *pStorage = gInstance->getStorage();

	BoyFileHandle hFile = (BoyFileHandle)(long long)pContext;
	pStorage->FileClose( hFile );
}
        TEST_F(ExpressionTree, SoleDataOwner)
        {
            auto setup = GetSetup();
            ExpressionNodeFactory e(setup->GetAllocator(), setup->GetCode());

            Storage<int> empty;
            ASSERT_TRUE(empty.IsSoleDataOwner());

            auto s = e.Direct<int>();
            ASSERT_TRUE(s.IsSoleDataOwner());

            auto s2 = s;
            ASSERT_FALSE(s.IsSoleDataOwner());
            ASSERT_FALSE(s2.IsSoleDataOwner());

            s2.Reset();
            ASSERT_TRUE(s.IsSoleDataOwner());
            ASSERT_TRUE(s2.IsSoleDataOwner());

            // Different indirects that refer to stack are sole owners of their storage.
            auto stack1 = e.Temporary<int>();
            ASSERT_TRUE(stack1.IsSoleDataOwner());

            auto stack2 = e.Temporary<int>();
            ASSERT_TRUE(stack2.IsSoleDataOwner());
        }
Example #8
0
int main (int, char **/*argv*/) try
{
  initTest();

  IOSize	n;
  char		buf [1024];
  Storage	*s = StorageFactory::get ()->open
    ("http://cmsdoc.cern.ch/cms.html", IOFlags::OpenRead);

  assert (s);
  while ((n = s->read (buf, sizeof (buf))))
    std::cout.write (buf, n);

  s->close();
  delete s;

  std::cerr << StorageAccount::summaryXML () << std::endl;
  return EXIT_SUCCESS;
} catch(cms::Exception const& e) {
  std::cerr << e.explainSelf() << std::endl;
  return EXIT_FAILURE;
} catch(std::exception const& e) {
  std::cerr << e.what() << std::endl;
  return EXIT_FAILURE;
}
Storage newStorageWithRemovedRows(const Storage& origSto,
        const std::set<int>& rowsToRemove) {
    Storage sto(1000);
    auto labels = origSto.getColumnLabels();
    auto numOrigColumns = origSto.getColumnLabels().getSize() - 1;

    // Remove in reverse order so it's easier to keep track of indices.
     for (auto it = rowsToRemove.rbegin(); it != rowsToRemove.rend(); ++it) {
         labels.remove(*it);
     }
    sto.setColumnLabels(labels);

    double time;
    for (int itime = 0; itime < origSto.getSize(); ++itime) {
        SimTK::Vector rowData(numOrigColumns);
        origSto.getData(itime, numOrigColumns, rowData);

        SimTK::Vector newRowData(numOrigColumns - (int)rowsToRemove.size());
        int iNew = 0;
        for (int iOrig = 0; iOrig < numOrigColumns; ++iOrig) {
            if (rowsToRemove.count(iOrig) == 0) {
                newRowData[iNew] = rowData[iOrig];
                ++iNew;
            }
        }

        origSto.getTime(itime, time);
        sto.append(time, newRowData);
    }
    return sto;
}
Example #10
0
int main(int argc, char *argv[])
{
    QScopedPointer<QGuiApplication> app(SailfishApp::application(argc, argv));
    app->setOrganizationName("org.kubler");
    app->setApplicationName("Reminders");

    QScopedPointer<QQuickView> view(SailfishApp::createView());

    //Storage *storage = new Storage();
    //ProjectsModel *foldersModel = new ProjectsModel();
    //FoldersModel *foldersModel = new FoldersModel();

    //view->rootContext()->setContextProperty("foldersModel", foldersModel);
    //view->rootContext()->setContextObject(controller);

    Storage *storage = new Storage();
    storage->openDB();

    qmlRegisterType<FoldersModel>("org.kubler.Reminders", 1, 0, "FoldersModel");
    qmlRegisterType<FilterProjectsModel>("org.kubler.Reminders", 1, 0, "ProjectsModel");

    view->setSource(SailfishApp::pathTo("qml/Reminders.qml"));
    view->showFullScreen();

    return app->exec();
}
/**
 * This method is called at the beginning of an analysis so that any
 * necessary initializations may be performed.
 *
 * This method is meant to be called at the beginning of an integration 
 *
 * This method should be overridden in the child class.  It is
 * included here so that the child class will not have to implement it if it
 * is not necessary.
 *
 * @param s current system state
 *
 * @return -1 on error, 0 otherwise.
 */
int MuscleAnalysis::begin(const SimTK::State&s )
{
    if(!proceed()) return 0;

    allocateStorageObjects();

    // RESET STORAGE
    Storage *store;
    int size = _storageList.getSize();
    for(int i=0;i<size;i++) {
        store = _storageList[i];
        if(store==NULL) continue;
        store->purge();
    }

    // RECORD
    int status = 0;
    // Make sure coordinates are not locked
    if (_computeMoments){
    // LOOP OVER ACTIVE MOMENT ARM STORAGE OBJECTS
        Coordinate *q = NULL;
        int nq = _momentArmStorageArray.getSize();
        for(int i=0; i<nq; i++) {
            q = _momentArmStorageArray[i]->q;
            if (q->getLocked(s))
                cout << "MuscleAnalysis: WARNING - coordinate " << q->getName() << " is locked and can't be varied." << endl; 
        }
    }
    if(_storageList.getSize()> 0 && _storageList.get(0)->getSize() <= 0) status = record(s);

    return status;
}
// Helper function to get a state variable value from a storage file.
Real getStorageEntry(const Storage& sto,
        const int timeIndex, const std::string& columnName) {
    Real value;
    const int columnIndex = sto.getStateIndex(columnName);
    sto.getData(timeIndex, columnIndex, value);
    return value;
}
Example #13
0
void SettingsTechnicalInfo::fillInfo(){

    qDebug() << Q_FUNC_INFO;
    DeviceInfo *deviceInfo = DeviceInfo::getInstance();
    Storage *storageInfo = Storage::getInstance();
    Wifi *wifiInfo = Wifi::getInstance();

    MACaddressValLbl->setText(wifiInfo->getMacAddress());
    internalMemValLbl->setText(human_readable_filesize(storageInfo->getTotalInternalMemory(), 2));
    if (storageInfo->getRemovablePartition() && storageInfo->getRemovablePartition()->isMounted())
        externalMemValLbl->setText(human_readable_filesize(storageInfo->getTotalExternalMemory(), 2));
    else
        externalMemValLbl->setText("--");

    batteryValLbl->setText(QString::number(battery->getLevel()) + "%");

    QHash<QString, QString> extraInformation = deviceInfo->getSpecificDeviceInfo();

    qDebug() << extraInformation;

    QHash<QString, QString> specificInfo = deviceInfo->getSpecificDeviceInfo();

    internalVersionValLbl->setText(specificInfo.value("Internal Revision"));
    rootFsValLbl->setText(specificInfo.value("Static rootfs version")
                            + "/" + specificInfo.value("Actual rootfs version")
                            + "/" + specificInfo.value("Private repo version"));
    kernelVersionVaLbl->setText(specificInfo.value("Kernel version"));
    softwareValLbl->setText(specificInfo.value("Software version"));
    QString serialNum = deviceInfo->getSerialNumber();
    if(serialNum.startsWith("SN-")) // Remove prefix if present
        serialNum.remove(0,3);
    idDeviceValLbl->setText(serialNum);
}
Example #14
0
/**
 * Store the marker data in an Storage object. The object
 * is emptied before adding the marker data.
 *
 * @param aStorage storage block to fill in with marker data.
 */
void MarkerData::makeRdStorage(Storage& rStorage)
{
	/* First clear any existing frames. */
	rStorage.reset(0);

	/* Make the column labels. */
	Array<string> columnLabels;
	columnLabels.append("time");
	for (int i = 0; i < _numMarkers; i++)
	{
		columnLabels.append(_markerNames[i] + "_tx");
		columnLabels.append(_markerNames[i] + "_ty");
		columnLabels.append(_markerNames[i] + "_tz");
	}
	rStorage.setColumnLabels(columnLabels);

	/* Store the marker coordinates in an array of doubles
	 * and add it to the Storage.
	 */
	int numColumns = _numMarkers * 3;
	double* row = new double [numColumns];

	for (int i = 0; i < _numFrames; i++)
	{
		for (int j = 0, index = 0; j < _numMarkers; j++)
		{
			SimTK::Vec3& marker = _frames[i]->updMarker(j);
			for (int k = 0; k < 3; k++)
				row[index++] = marker[k];
		}
		rStorage.append(_frames[i]->getFrameTime(), numColumns, row);
	}

	delete [] row;
}
Example #15
0
void StorageAreaMap::dispatchSessionStorageEvent(uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString)
{
    ASSERT(storageType() == SessionStorage);

    // Namespace IDs for session storage namespaces are equivalent to web page IDs
    // so we can get the right page here.
    WebPage* webPage = WebProcess::singleton().webPage(m_storageNamespaceID);
    if (!webPage)
        return;

    Vector<RefPtr<Frame>> frames;

    Page* page = webPage->corePage();
    for (Frame* frame = &page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
        Document* document = frame->document();
        if (!document->securityOrigin()->equal(m_securityOrigin.ptr()))
            continue;

        Storage* storage = document->domWindow()->optionalSessionStorage();
        if (!storage)
            continue;

        StorageAreaImpl& storageArea = static_cast<StorageAreaImpl&>(storage->area());
        if (storageArea.storageAreaID() == sourceStorageAreaID) {
            // This is the storage area that caused the event to be dispatched.
            continue;
        }

        frames.append(frame);
    }

    StorageEventDispatcher::dispatchLocalStorageEventsToFrames(page->group(), frames, key, oldValue, newValue, urlString, m_securityOrigin.ptr());
}
Example #16
0
void StorageAreaMap::dispatchLocalStorageEvent(uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString)
{
    ASSERT(storageType() == LocalStorage);

    Vector<RefPtr<Frame>> frames;

    PageGroup& pageGroup = *WebProcess::singleton().webPageGroup(m_storageNamespaceID)->corePageGroup();
    const HashSet<Page*>& pages = pageGroup.pages();
    for (HashSet<Page*>::const_iterator it = pages.begin(), end = pages.end(); it != end; ++it) {
        for (Frame* frame = &(*it)->mainFrame(); frame; frame = frame->tree().traverseNext()) {
            Document* document = frame->document();
            if (!document->securityOrigin()->equal(m_securityOrigin.ptr()))
                continue;

            Storage* storage = document->domWindow()->optionalLocalStorage();
            if (!storage)
                continue;

            StorageAreaImpl& storageArea = static_cast<StorageAreaImpl&>(storage->area());
            if (storageArea.storageAreaID() == sourceStorageAreaID) {
                // This is the storage area that caused the event to be dispatched.
                continue;
            }

            frames.append(frame);
        }
    }

    StorageEventDispatcher::dispatchLocalStorageEventsToFrames(pageGroup, frames, key, oldValue, newValue, urlString, m_securityOrigin.ptr());
}
	WidgetDataCompCreate * create(const QString & name) const
	{
		Storage::const_iterator itS = storage_.find(name);
		if(itS != storage_.end())
			return (*itS->second)();
		else
			THROW_EXCEPTION(Sim::Exception, OSS("Unknown widget data \"" << name.toStdString().c_str() << "\""));
	}
Example #18
0
void parse_yaml_file(Storage& storage) {
    YAML::Node config = YAML::LoadFile("input.yaml");
    storage.set_filename(config["filename"].as<std::string>());
    storage.set_alpha(config["alpha"].as<double>());
    
    
    std::cout << "Read configuration file...\n";
}
Example #19
0
int Environment::TiXmlFileSize( void *pContext )
{
	Storage *pStorage = gInstance->getStorage();

	BoyFileHandle hFile = (BoyFileHandle)(long long)pContext;
	int size = pStorage->FileGetSize( hFile );
	return size;
}
        TEST_F(ExpressionTree, RegisterSpillingInteger)
        {
            auto setup = GetSetup();
            ExpressionNodeFactory e(setup->GetAllocator(), setup->GetCode());
            std::vector<Storage<int>> storages;
            const unsigned totalRegisterCount = RegisterBase::c_maxIntegerRegisterID + 1;

            // Try to obtain totalRegisterCount direct registers.
            for (unsigned i = 0; i < totalRegisterCount; ++i)
            {
                storages.push_back(e.Direct<int>());
                ASSERT_EQ(storages.back().GetStorageClass(), StorageClass::Direct);
            }

            // There won't be enough registers for all storages to stay
            // direct since reserved base pointers can't be obtained. Thus,
            // some of the storages should have their registers spilled.

            // Three reserved registers are RBP, RSP and RIP. Note: this
            // assumes that RBP is a base register - if RSP is used instead
            // of RBP, the test will need to be adjusted.
            // Alternatively, ExpressionTree::IsAnyBaseRegister could be
            // made accessible and used to count the reserved registers.
            const unsigned reservedRegisterCount = 3;
            unsigned directCount = 0;
            unsigned indirectCount = 0;
            unsigned indexOfFirstDirect = 0;

            for (unsigned i = 0; i < storages.size(); ++i)
            {
                if (storages[i].GetStorageClass() == StorageClass::Direct)
                {
                    directCount++;

                    if (directCount == 1)
                    {
                        indexOfFirstDirect = i;
                    }
                }
                else
                {
                    indirectCount++;
                }
            }

            // Most storages should be direct, some corresponding to the
            // reserved registers should not.
            ASSERT_EQ(totalRegisterCount - reservedRegisterCount, directCount);
            ASSERT_EQ(reservedRegisterCount, indirectCount);

            // A new direct storage should cause the oldest reserved register
            // to be spilled (note: this assumes current allocation strategy).
            ASSERT_EQ(storages[indexOfFirstDirect].GetStorageClass(), StorageClass::Direct);
            Storage<int> spillTrigger = e.Direct<int>();

            ASSERT_EQ(spillTrigger.GetStorageClass(),  StorageClass::Direct);
            ASSERT_EQ(storages[indexOfFirstDirect].GetStorageClass(), StorageClass::Indirect);
        }
Example #21
0
 // Creates and opens a database, performs a bunch
 // of inserts, then fetches all of them to make sure
 // they are there. Uses a fail_file that causes the n-th
 // I/O to fail, causing an exception.
 void
 do_work (std::size_t count, float load_factor,
     nudb::path_type const& path, fail_counter& c)
 {
     auto const dp = path + ".dat";
     auto const kp = path + ".key";
     auto const lp = path + ".log";
     test_api::file_type::erase (dp);
     test_api::file_type::erase (kp);
     test_api::file_type::erase (lp);
     expect(test_api::create (
         dp, kp, lp, appnum, salt, sizeof(key_type),
             block_size(path), load_factor), "create");
     test_api::fail_store db;
     if (! expect(db.open(dp, kp, lp,
         arena_alloc_size, c), "open"))
     {
         // VFALCO open should never fail here, we need
         //        to report this and terminate the test.
     }
     expect (db.appnum() == appnum, "appnum");
     Sequence seq;
     for (std::size_t i = 0; i < count; ++i)
     {
         auto const v = seq[i];
         expect(db.insert(&v.key, v.data, v.size),
             "insert");
     }
     Storage s;
     for (std::size_t i = 0; i < count; ++i)
     {
         auto const v = seq[i];
         if (! expect(db.fetch (&v.key, s),
                 "fetch"))
             break;
         if (! expect(s.size() == v.size, "size"))
             break;
         if (! expect(std::memcmp(s.get(),
                 v.data, v.size) == 0, "data"))
             break;
     }
     db.close();
     verify_info info;
     try
     {
         info = test_api::verify(dp, kp);
     }
     catch(...)
     {
         print(log, info);
         throw;
     }
     test_api::file_type::erase (dp);
     test_api::file_type::erase (kp);
     test_api::file_type::erase (lp);
 }
Example #22
0
int main (int argc, char* argv[])
{
    // We create a command line parser.
    OptionsParser parser ("SortingCount");
    parser.push_back (new OptionOneParam (STR_URI_INPUT, "sorting count input", true));

    try
    {
        // Shortcuts.
        typedef Kmer<>::Count Count;
        typedef Kmer<>::Type  Type;

        // We parse the user options.
        IProperties* options = parser.parse (argc, argv);

        // We load the object storing the couples [kmer,abundance]
        Storage* storage = StorageFactory(STORAGE_HDF5).load (options->getStr(STR_URI_INPUT));   LOCAL (storage);

        // We get the group inside the storage object
        Group& dskGroup = storage->getGroup("dsk");

        // We retrieve the partition holding the couples [kmer,abundance]
        Partition<Count>& solidKmers = dskGroup.getPartition<Count> ("solid");

        // Now, we read the couples in two ways, computing a checksum in each case.
        Type checksum1, checksum2;

        // CASE 1: we read the couples [kmer,abundance] with an iterator over the whole partition
        Iterator<Count>* it = solidKmers.iterator();  LOCAL (it);
        for (it->first(); !it->isDone(); it->next())   {   checksum1 = checksum1 + it->item().value;  }

        // CASE 2: we read the couples [kmer,abundance] with an iterator over each collection of the partition
        for (size_t i=0; i<solidKmers.size(); i++)
        {
            // We get the current collection inside the partition
            Collection<Count>& collection = solidKmers [i];

            Iterator<Count>* it = collection.iterator();  LOCAL (it);
            for (it->first(); !it->isDone(); it->next())   {   checksum2 = checksum2 + it->item().value;  }
        }

        // We check that we got the same checksum
        cout << "checksum1=" << checksum1 << endl;
        cout << "checksum2=" << checksum1 << endl;
    }
    catch (OptionFailure& e)
    {
        return e.displayErrors (std::cout);
    }
    catch (Exception& e)
    {
        std::cerr << "EXCEPTION: " << e.getMessage() << std::endl;
    }

    return EXIT_SUCCESS;
}
static v8::Handle<v8::Value> storageGetter(v8::Local<v8::String> v8Name, const v8::AccessorInfo& info)
{
    Storage* storage = V8Storage::toNative(info.Holder());
    String name = toWebCoreString(v8Name);

    if (storage->contains(name) && name != "length")
        return v8String(storage->getItem(name));

    return notHandledByInterceptor();
}
//---------------------------------------------------------------------
void TraCIClient::send_command( CommandId command, const traci::TraciType & content ) const
throw( tcpip::SocketException )
{
    Storage answer;
    send_command( command, content, answer );

    // more data in answer?
    if ( answer.valid_pos() )
        throw std::runtime_error( "traci::TraCIClient::send_command: unexpected response content" );
}
Example #25
0
Storage *Storage::create(const std::string &rFileName)
{
    Storage *pStorage = new Storage(rFileName);
    if(pStorage->Init() == false)
    {
        delete pStorage;
        return NULL;
    }
    return pStorage;
}
Example #26
0
static v8::Handle<v8::Value> storageGetter(v8::Local<v8::String> v8Name, const v8::AccessorInfo& info)
{
    Storage* storage = V8DOMWrapper::convertToNativeObject<Storage>(V8ClassIndex::STORAGE, info.Holder());
    String name = toWebCoreString(v8Name);

    if (storage->contains(name))
        return v8String(storage->getItem(name));

    return notHandledByInterceptor();
}
Example #27
0
void storageTest() {
	Storage *ins = Storage::getInstance();
	User u1("Luffy", "123", "*****@*****.**", "110");
	User u2("Zoro", "123", "*****@*****.**", "119");
	User u3("Chopper", "123", "*****@*****.**", "120");
	User u4("Nami", "123", "*****@*****.**", "114");
	cout << "***********************Class Storage***************************" << endl;
	cout << "--------------------------UserCRUD-----------------------------" << endl;
	ins -> createUser(u1);
	ins -> createUser(u2);
	ins -> createUser(u3);
	cout << "Create case:Query Nami is faild before create the user." << endl;
	cmp(ins->queryUser([](const User& u){return u.getName() == "Nami";}).size() == 0, true);
	ins->createUser(u4);
	cout << "Retrieve case:Query Nami is successd after create the user." << endl;
	cmp(ins->queryUser([](const User& u){return u.getName() == "Nami";}).size() != 0, true);
	ins -> updateUser([](const User& u){return true;}, [](User& u){u.setPhone("112");});
	cout << "Update case:Query who's phone number is 112 is successd after update all users' phone to 112." << endl;
	cmp(ins->queryUser([](const User& u){return u.getPhone() == "112";}).size() != 0, true);
	ins -> deleteUser([](const User& u){return u.getName() == "Nami";});
	cout << "Delete case:Query Nami is faild after delete the user." << endl;
	cmp(ins->queryUser([](const User& u){return u.getName() == "Nami";}).size() == 0, true);
	cout << "--------------------------FileCheck----------------------------" << endl;
	ins->sync();
	delete ins;
	ins = Storage::getInstance();
	cout << "case:User list should't be empty." << endl;
	cmp(ins->queryUser([](const User& u){return true;}).size() != 0, true);
	cout << "case:Meeting list should be empty." << endl;
	cmp(ins->queryMeeting([](const Meeting& m){return true;}).size() == 0, true);
	cout << "***************************************************************" << endl;
    delete ins;
}
Example #28
0
Storage layerTransform(const Storage& stor,matrixfftw& a,matrixfftw& b, plan& pl){
    Storage stor_res(stor.height(),stor.depth(),stor.width());
    for (int i=0; i<(PlaneWave::getDimensions()); i++){
        for (int p=0; p<(stor.depth()); p++){
            for (int q=0; q<(stor.width()); q++){
                a(p,q)=stor(i,p,q);
            }
        }
        pl.exec();
        for (int p=0; p<(stor.depth()); p++){
            for (int q=0; q<(stor.width()); q++){
                stor_res(i,p,q)=b(p,q)/double(stor.depth()*stor.width());
            }
        }

    }
 /*   matrixfftw testSour(stor.depth(),stor.width());
    matrixfftw testDest(stor.depth(),stor.width());
    plan test(testSour,testDest,FFTW_FORWARD,FFTW_ESTIMATE);
    for (int p=0; p<(stor.depth()); p++){
        for (int q=0; q<(stor.width()); q++){
            testSour(p,q)=b(p,q);
        }
    }
    test.exec();
    cout<<endl<<endl;
    cout<<testDest<<endl;*/
    return stor_res;
}
Example #29
0
TEST(StorageTest, CRUD) {
    Storage* i = Storage::getInstance();
    User user("ly", "ly", "ly", "ly");
    i->createUser(user);
    i->createUser(user);
    i->createUser(user);
    i->createUser(user);
    Date date1(1999, 2, 2, 2, 2);
    Meeting mt("ly", "ly", date1, date1, "ly");
    i->createMeeting(mt);
    i->createMeeting(mt);
    i->createMeeting(mt);
    i->createMeeting(mt);
    EXPECT_TRUE(i->queryUser([](const User& u){
        return u.getName() == "ly";
    }).size() == 5);
    EXPECT_TRUE(i->updateUser([](const User& u){
        return u.getName() == "ly";
    }, [](User& pp){
        pp.setName("2333");
    }) == 5);
    EXPECT_TRUE(i->deleteUser([](const User& u){
        return u.getName() == "2333";
    }) == 5);
    EXPECT_TRUE(i->deleteMeeting([](const Meeting& m){
        return m.getTitle() == "ly"; 
    }) == 4);
    delete i;
}
void InspectorDOMStorageResource::handleEvent(ScriptExecutionContext*, Event* event)
{
    ASSERT(m_frontend);
    ASSERT(eventNames().storageEvent == event->type());
    StorageEvent* storageEvent = static_cast<StorageEvent*>(event);
    Storage* storage = storageEvent->storageArea();
    ExceptionCode ec = 0;
    bool isLocalStorage = (storage->frame()->domWindow()->localStorage(ec) == storage && !ec);
    if (isSameHostAndType(storage->frame(), isLocalStorage))
        m_frontend->updateDOMStorage(m_id);
}