void ListGroups(const DataStore& ds){ int i; for(i=0;i<ds.group_size();i++){ const DataGroup& dg = ds.group(i); ListValues(dg); } }
//--------------------------------------------------------------------------------------------------- Ptr<DataStore> DataStore::Create(LPCTSTR Filename, BLOCKADDRESS BlockSize) { DataStore* pStore = new DataStore(); if (BlockSize < sizeof(STOREHEADER)) throw DataStoreException(pStore, "The BlockSize must be at least as large as the size of the header"); pStore->m_pFile = MemoryMappedFile::Open(Filename, FileMode::CREATE); pStore->m_pFile->Resize(10 * BlockSize); pStore->m_pView = pStore->m_pFile->CreateView(); pStore->m_pHeader = (STOREHEADER*)pStore->m_pView->GetBasePointer(); ZeroMemory(pStore->m_pHeader, sizeof(STOREHEADER)); pStore->m_pHeader->DataStoreVersion = DATASTOREVERSION; pStore->m_pHeader->BlockAllocationIndex0 = 1; pStore->m_pHeader->BlockCount = 10; pStore->m_pHeader->BlockSize = BlockSize; pStore->m_pHeader->FreeBlockCount = 6; //pStore->m_pHeader->MetaDataTable.BlockCount = 0; //pStore->m_pHeader->MetaDataTable.BlockDirectory = 0; pStore->m_pBlockAllocationIndex0 = (BLOCKADDRESS*)pStore->GetBlock(1); pStore->m_pBlockBitmaps = new DWORD*[BlockSize / sizeof(BLOCKADDRESS)]; ZeroMemory(pStore->m_pBlockBitmaps, sizeof(DWORD*) * BlockSize / sizeof(BLOCKADDRESS)); pStore->m_pBlockAllocationIndex0[0] = 2; pStore->m_pBlockBitmaps[0] = (DWORD*)pStore->GetBlock(2); pStore->m_pBlockAllocationIndex0[1] = 3; pStore->m_pBlockBitmaps[1] = (DWORD*)pStore->GetBlock(3); pStore->m_pBlockBitmaps[0][0] = 0xf; return pStore; }
int main() { DataStore ds; ds.save("one", "../TESTFOLDER"); ds.save("two", "../TESTFOLDER/Dir1"); ds.save("one", "../TESTFOLDER/Dir1"); map<string,set<string>> catalog=ds.fetch(); ostream_iterator< string > output(cout, "\n|"); map<string, set<string>>::iterator it; for (it = catalog.begin(); it != catalog.end(); ++it) { set<string> value = catalog[it->first]; cout << "_______________________________________" << endl; cout << "| " << "FileName: " << it->first << endl; cout << "----------------------------------------" << endl; cout << "|" << "Path:\n|"; copy(value.begin(), value.end(), output); cout << "----------------------------------------" << endl; } std::cout << "\n\n"; return 0; }
//--------------------------------------------------------------------------------------------------- Ptr<DataStore> DataStore::Open(LPCTSTR Filename) { DataStore* pStore = new DataStore(); pStore->m_pFile = MemoryMappedFile::Open(Filename, FileMode::OPEN); pStore->m_pView = pStore->m_pFile->CreateView(); pStore->m_pHeader = (STOREHEADER*)pStore->m_pView->GetBasePointer(); if (pStore->m_pHeader->DataStoreVersion != DATASTOREVERSION) throw DataStoreException(pStore, "The DataStore version number is unknown"); pStore->m_pBlockAllocationIndex0 = (BLOCKADDRESS*)pStore->GetBlock(pStore->m_pHeader->BlockAllocationIndex0); pStore->m_pBlockBitmaps = new DWORD*[pStore->m_pHeader->BlockSize / sizeof(BLOCKADDRESS)]; for (SIZE_T i=0; i<pStore->m_pHeader->BlockSize / sizeof(BLOCKADDRESS); i++) { if (pStore->m_pBlockAllocationIndex0[i] != 0) pStore->m_pBlockBitmaps[i] = (DWORD*)pStore->GetBlock(pStore->m_pBlockAllocationIndex0[i]); else pStore->m_pBlockBitmaps[i] = 0; } return pStore; }
int main(int argc, char **argv){ // Verify that the version of the library that we linked against is // compatible with the version of the headers we compiled against. GOOGLE_PROTOBUF_VERIFY_VERSION; DataStore ds; fstream input; if (argc != 2) { cerr << "Usage: " << argv[0] << " DATA_STORE_FILE" << endl; return -1; } { // Read the existing address book. input.open(argv[1], ios::in | ios::binary); if (!ds.ParseFromIstream(&input)) { cerr << "Failed to parse address book." << endl; return -1; } input.close(); } ListGroups(ds); // Optional: Delete all global objects allocated by libprotobuf. google::protobuf::ShutdownProtobufLibrary(); return 0; }
void DataStore::printTree(){ std::cout << m_path << std::endl; std::map<std::string, IDataBlockPtr>::iterator it; DataStore* ds; for(it=m_map.begin();it!=m_map.end();it++){ ds = dynamic_cast<DataStore*>(it->second.get()); if(ds) ds->printTree(); //else std::cout << ("/"==m_path)?m_path+it->first:m_path+"/"+it->first << std::endl; } };
bool Store::addFlags(const PimItem::List &items, const QSet<QByteArray> &flags, bool &flagsChanged) { const Flag::List flagList = HandlerHelper::resolveFlags(flags); DataStore *store = connection()->storageBackend(); if (!store->appendItemsFlags(items, flagList, &flagsChanged)) { qCDebug(AKONADISERVER_LOG) << "Store::addFlags: Unable to add new item flags"; return false; } return true; }
bool MIQPSolver::addLinks(const DataStore &store) { int num = 0; for (DataStore::LinkMap::const_iterator it = store.Begin(); it != store.End(); it++) { if (!addLink(num, it->first.first, it->first.second, it->second)) return false; ++num; } return true; }
bool Delete::deleteRecursive(Collection &col) { Collection::List children = col.children(); for (Collection &child : children) { if (!deleteRecursive(child)) { return false; } } DataStore *db = connection()->storageBackend(); return db->cleanupCollection(col); }
IDataBlockPtr DataStore::find(std::string name){ vector<std::string> dividedName; vector<std::string>::iterator itName; boost::split(dividedName, name, boost::is_any_of("/"), boost::token_compress_on); DataStore* current = (0==name.find("/"))?m_root.get():this; IDataBlockPtr db; for(itName=dividedName.begin(); itName !=dividedName.end(); itName++){ if(0==(*itName).size()) continue; db = current->retrieveObject(*itName); current = dynamic_cast<DataStore*>(db.get()); if(not current)return db; } return db; }
int main() { DataStore ds; ds.addFile("demo.txt", "path1"); ds.addFile("demo.txt", "path2"); ds.addFile("demo1.txt", "path1"); ds.addFile("demo1.txt", "path2"); ds.addFile("demo2.txt", "path1"); ds.addFile("demo2.txt", "path2"); ds.addFile("demo2.txt", "path3"); std::cout << "\n"; }
void ResourceManager::removeResourceInstance(const QString &name) { DataStore *db = DataStore::self(); // remove items and collections Resource resource = Resource::retrieveByName(name); if (resource.isValid()) { const QVector<Collection> collections = resource.collections(); Q_FOREACH (/*sic!*/ Collection collection, collections) { db->cleanupCollection(collection); } // remove resource resource.remove(); }
void fillToTheBrim(DataStore &data_store, PointType point_type, T value) { for (int i(0); i < RTIMDB_POINT_COUNT; ++i) { data_store.insert(point_type, PointValue(value), Flags(), Timestamp()); } }
bool ColMove::parseStream() { Protocol::MoveCollectionCommand cmd(m_command); Collection source = HandlerHelper::collectionFromScope(cmd.collection(), connection()); if (!source.isValid()) { return failureResponse("Invalid collection to move"); } Collection target; if (cmd.destination().isEmpty()) { target.setId(0); } else { target = HandlerHelper::collectionFromScope(cmd.destination(), connection()); if (!target.isValid()) { return failureResponse("Invalid destination collection"); } } if (source.parentId() == target.id()) { return successResponse<Protocol::MoveCollectionResponse>(); } CacheCleanerInhibitor inhibitor; // retrieve all not yet cached items of the source ItemRetriever retriever(connection()); retriever.setCollection(source, true); retriever.setRetrieveFullPayload(true); if (!retriever.exec()) { return failureResponse(retriever.lastError()); } DataStore *store = connection()->storageBackend(); Transaction transaction(store); if (!store->moveCollection(source, target)) { return failureResponse("Unable to reparent collection"); } if (!transaction.commit()) { return failureResponse("Cannot commit transaction."); } return successResponse<Protocol::MoveCollectionResponse>(); }
int main() { std::cout << "\n Testing DataStore"; DataStore ds; ds.save("one"); ds.save("two"); ds.save("three"); DataStore::iterator iter = ds.begin(); std::cout << "\n " << (*iter).c_str(); for (auto item : ds) { std::cout << "\n " << item.c_str(); } std::cout << "\n\n"; }
int main() { DataStore ds; ds.addFile("demo.txt", "path1"); ds.addFile("demo.txt", "path2"); ds.addFile("demo1.txt", "path1"); ds.addFile("demo1.txt", "path2"); ds.addFile("demo2.txt", "path1"); ds.addFile("demo2.txt", "path2"); ds.addFile("demo2.txt", "path3"); DisplayData::title("\n Demonstrate DataStore Package "); DisplayData::title("\n Save data in std::map<std::string,std::list < std::set < std::string >::iterator > > and print", '-'); DisplayData::showFileCatalouge(ds); std::cout << "\n"; }
Errors fillToTheBrim(DataStore &data_store, PointType point_type, T value) { for (int i(0); i < RTIMDB_POINT_COUNT; ++i) { auto insert_result(data_store.insert(point_type, PointValue(value), Flags(), Timestamp())); if (Errors::no_error__ != insert_result.second) return insert_result.second; } return Errors::no_error__; }
bool DBParser::parse(string db_filename, DataStore& ds) { int numProds = 0; int numUsers = 0; int numReviews = 0; /* #ifdef DEBUG cout << "Starting parsing" << endl; #endif */ cout << db_filename << endl; ifstream ifile(db_filename.c_str()); if(ifile.fail()){ return true; } lineno_ = 1; string line; PState state = INIT; while(!ifile.fail() && !error_){ getline(ifile, line); #ifdef DEBUG cout << "Line: " << line << endl; #endif stringstream ss(line); string token; if(state == INIT){ if( ss >> token ){ if(token == "<products>"){ #ifdef DEBUG cout << "Found product" << endl; #endif state = PRODUCTS; } } } else if( state == PRODUCTS ){ if( ss >> token) { if( token == "</products>" ){ #ifdef DEBUG cout << "Found /product" << endl; #endif state = FIND_USERS; } else { Product* p = parseProduct(token, ifile); if(!error_ && p != NULL){ ds.addProduct(p); numProds++; } } } } else if( state == FIND_USERS){
bool Protocol::onRegist(Packet& inPacket) { RegistPacket Register(inPacket); DataStore data; RegistResponsePacket::REGIST_RESULT_CODE result = RegistResponsePacket::REGISTE_OK; DataStore::Vehicle_Record record; do { if (!data.FindTerminalRecord(Register.GetTerminalID().c_str())) { result = RegistResponsePacket::NO_RECORED_VEHICLE; break; } if (!data.FindVechileRecord(Register.GetTerminalVIN().c_str())) { result = RegistResponsePacket::NO_RECORDER_TERMINAL; break; } if (data.GetVechicleRecord(record)) { if (record.TerminalID.empty()) { setRegisterRecord(Register, record); if (!data.RegisteTerminal(record)) result = RegistResponsePacket::DUP_REGISTED_TERMINAL; } else result = RegistResponsePacket::DUP_REGISTED_VEHICLE; } } while (false); RegistResponsePacket response(inPacket.GetSerialNumber(), inPacket.GetMobileNumber().c_str(), result, record.strAuthCode.c_str()); outQueue.Push(response); return true; }
int DataStoreSet::deleteDataStore (struct ClientInfo *cinfo, ClientSet *cset, char *name) { int i; int retValue = 0; DataStore *ds; if(pthread_mutex_lock(&dsMutex)){ printf ("Unable to lock data store set.\n"); return -1; } for (i=0; i < count; i++){ if (strcmp(name, dataStoreList[i]->name) == 0){ // Clients get a handle to a data store by locking DataStoreSet first. // DataStoreSet is locked above, so no additional client can get a handle on this data store. // Now we can check if any client is using this data store. If in use, we can not delete this data store. if (cset->isDataStoreInUse (dataStoreList[i])){ printf ("Data Store %s is in use, can not be deleteted.\n", name); retValue = -1; break; } if (dataStoreList[i]->lockDS(cinfo)){ retValue = -1; break; } // remove from the list ds = dataStoreList[i]; dataStoreList[i] = NULL; // shift array up if (i < count -1){ memmove (&(dataStoreList[i]), &(dataStoreList[i+1]), sizeof (DataStore *)* (count - i - 1)); } count --; ds->unlockDS(cinfo); delete (ds); retValue = 1; break; } } pthread_mutex_unlock(&dsMutex); return retValue; }
bool ChipStreamDataTransform::transformData(PsBoard &board, const DataStore &in, DataStore &out) { bool needTwoPass = false; if((InstanceOf(m_ChipStream, SketchQuantNormTran) && board.getOptions()->getOpt("target-sketch").empty()) || InstanceOf(m_ChipStream, ArtifactReduction)) { Verbose::out(1, "Doing two passes."); needTwoPass = true; } /* Send the chip data through the chipstream object. */ int numDataSets = in.getCelDataSetCount(); Verbose::progressBegin(1, ToStr("Processing Chips"), numDataSets, 1, numDataSets); std::vector<float> data; for(int chipIx = 0; chipIx < in.getCelDataSetCount(); chipIx++) { Verbose::progressStep(1); data.clear(); // Verbose::out(3, "Reading " + m_ChipStream->getDocName() + " for chip: " + ToStr(chipIx)); in.fillInCelData(chipIx, data); m_ChipStream->newChip(data); if(!needTwoPass) { for(int probeIx = 0; probeIx < data.size(); probeIx++) { data[probeIx] = m_ChipStream->transform(probeIx, chipIx, data[probeIx], board); } out.writeColumn(chipIx, in.getCelName(chipIx), data); } } Verbose::progressEnd(1, ToStr("Done.")); if(needTwoPass) { m_ChipStream->finishedChips(); Verbose::progressBegin(1, ToStr("Processing Stage Two Chips"), numDataSets, 1, numDataSets); /* Do the chipstream transformation and store the new intensities. */ for(int chipIx = 0; chipIx < in.getCelDataSetCount(); chipIx++) { Verbose::progressStep(1); // Verbose::out(3, "Applying " + m_ChipStream->getDocName() + " to chip: " + ToStr(chipIx)); std::vector<float> data; in.fillInCelData(chipIx, data); for(int probeIx = 0; probeIx < data.size(); probeIx++) { data[probeIx] = m_ChipStream->transform(probeIx, chipIx, data[probeIx]); } out.writeColumn(chipIx, in.getCelName(chipIx), data); } Verbose::progressEnd(1, ToStr("Done.")); } return true; }
bool Store::deleteFlags(const PimItem::List &items, const QSet<QByteArray> &flags, bool &flagsChanged) { DataStore *store = connection()->storageBackend(); QVector<Flag> flagList; flagList.reserve(flags.size()); for (auto iter = flags.cbegin(), end = flags.cend(); iter != end; ++iter) { Flag flag = Flag::retrieveByName(QString::fromUtf8(*iter)); if (!flag.isValid()) { continue; } flagList.append(flag); } if (!store->removeItemsFlags(items, flagList, &flagsChanged)) { qCDebug(AKONADISERVER_LOG) << "Store::deleteFlags: Unable to remove item flags"; return false; } return true; }
int main(int argc, char ** argv) { QSettings settings("Swim","Poolmate"); // Do we have a datafile? // settings.setValue("test", 1); QString path = settings.value("dataFile").toString(); if (path.isEmpty()) { QString username = qgetenv("USER").constData(); QString home = qgetenv("HOME").constData(); path = QString("%1/poolmate-%2.csv").arg(home).arg(username); settings.setValue("dataFile", path); } const bool backup = settings.value("backup").toBool(); DataStore d; d.setFile(path); d.setBackup(backup); d.load(); QApplication app( argc, argv ); SummaryImpl win; win.setDataStore( &d ); //TODO tidy this!, for now refill grid and data from datastore. if (d.Workouts().size()) win.fillWorkouts(d.Workouts()); win.show(); app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) ); return app.exec(); }
bool DataStoreWriter::Write(const DataStore &store) { if (out == NULL) return false; int nContigs = store.ContigCount; int nGroups = store.GroupCount; int nLink = store.LinkCount; fprintf(out, "%i\t%i\t%i\n", nContigs, nGroups, nLink); for (int i = 0; i < nContigs; i++) { fprintf(out, "%i\t%s\n", store[i].GetID(), store[i].Sequence.Comment.c_str()); fprintf(out, "%s\n", store[i].Sequence.Nucleotides.c_str()); } for (int i = 0; i < nGroups; i++) { const LinkGroup &group = store.GetGroup(i); fprintf(out, "%i\t%s\t%s\n", group.GetID(), group.Name.c_str(), group.Description.c_str()); } for (DataStore::LinkMap::const_iterator it = store.Begin(); it != store.End(); it++) fprintf(out, "%i\t%i\t%i\t%i\t%i\t%lf\t%lf\t%i\t%lf\t%s\n", it->second.GetGroupID(), it->first.first, it->first.second, (it->second.EqualOrientation ? 1 : 0), (it->second.ForwardOrder ? 1 : 0), it->second.Mean, it->second.Std, (it->second.Ambiguous ? 1 : 0), it->second.Weight, it->second.Comment.c_str()); return true; }
int main() { DataStore ds; int argc = 4; char* argv[] = { "C://filename.cpp", "/s", "*.cpp", "*.h" }; FileManager fm(ds, argc, argv); fm.processInput(); fm.search(); DataStore::iterator iter = ds.begin(); using pathref = DataStore::pathIterator; std::cout << "\n FILE NAME \t\t PATH \n"; std::cout << "------------------------------------------------\n\n"; for (iter = ds.begin(); iter != ds.end(); iter++) { std::cout << iter->first << "\n"; std::list<pathref> itss = iter->second; std::list<pathref>::iterator itssr; for (itssr = itss.begin(); itssr != itss.end(); itssr++) { std::cout << "\t\t\t" << (*(*itssr)) << "\n"; } } std::cout << "\n\n"; Catalogue c(ds); c.processTextInput("include"); std::set<std::string> inputSet = c.getFileSet(); for (auto element : inputSet) { unsigned found = element.find_last_of("/\\"); std::string path = element.substr(0, found); std::string file = element.substr(found + 1); std::cout << "File : " << file << "\n"; std::cout << "Path : " << path << "\n\n"; } std::cout << "\n\n"; }
AutoOnline::AutoOnline(DataStore &data, DataStore &sensitive_data) : data_(data), sensitive_data_(sensitive_data), enabled_(data_.GetBool("online_enabled")), url_(sensitive_data_.Get("online_url")), process_script_(data.Get("process_script")), previous_status_(true) // set to true to force first refresh { timer_.setInterval(kOnlineCheckInterval); connect(&timer_, &QTimer::timeout, this, &AutoOnline::Check); if (enabled_) { timer_.start(); Check(); } }
//----< Calling DataStore Main >------------------------------------------- int main(int argc, char* argv[]) { try{ printHeader("Testing Datastore : "); DataStore ds; std::cout << "\nSaving File one.txt in C:/TextDir "; std::cout << "\nSaving File one.txt in E:/CppFiles "; std::cout << "\nSaving File two.h in D:/HeaderFileDir/HeaderFiles "; std::cout << "\nSaving File three.cppt in E:/CppFiles "; std::cout << "\nSaving File two.h in C:/TextDir "; std::cout << "\nSaving File two.h in E:/CppFiles \n"; ds.savingData("one.txt", "C:/TextDir"); ds.savingData("one.txt", "E:/CppFiles"); ds.savingData("two.h", "D:/HeaderFileDir/HeaderFiles"); ds.savingData("three.cpp", "E:/CppFiles"); ds.savingData("two.h", "C:/TextDir"); ds.savingData("two.h", "E:/CppFiles"); std::cout << "\nShowing PathStore at Single time only \n"; std::vector<ElementDisplay> pathVec = ds.printPathStoreMap(); for (auto pathVecItr : pathVec){ std::cout << pathVecItr.showPath(); } std::cout << "\n\nShowing FileStore with respected PathsRefernce in DataStoreMAP \n"; std::vector<ElementDisplay> dataStoreVec = ds.printDataStoreMap(); for (auto dataStoreVecItr : dataStoreVec){ std::cout << dataStoreVecItr.showFileAndPaths(); } printHeader("Testing Datastore End:: "); } catch (std::exception& ex){ std::cout << "\n\n " << ex.what() << "\n\n"; } return 0; }
int main(){ DisplayHelper DH; DataStore DS; DH.title("Test DataStore's save method with two parameters", '='); DS.save("test1.txt", "D:\\"); DS.save("test1.txt", "D:\\FolderA"); DS.save("test2.txt", "D:\\FolderA"); for (auto ds : DS){ DH.displayFilename(ds.first); for (auto p : ds.second){ DH.displayPath(*p); } DH.displayInfo(""); } DH.title("Test DataStore's save method with one parameter", '='); DS.save("D:\\newtest1.txt"); DS.save("D:\\FolderA\\newtest2.txt"); for (auto ds : DS){ DH.displayFilename(ds.first); for (auto p : ds.second){ DH.displayPath(*p); } } DH.title("Test DataStore's findFile method", '='); DataStore::iterator it = DS.findFile("test1.txt"); DH.displayFilename(it->first); for (list<DataStore::PathsIter>::iterator lit = (it->second).begin(); lit != (it->second).end(); lit++) DH.displayPath(**lit); DH.title("Test DataStore's findPathIter method", '='); string filename = "test2.txt", path1 = "D:\\FolderA", path2 = "D:\\"; string info1 = "The PathIter from " + filename + " to " + path1 + (DS.findPathIter(filename, path1) ? " exists" : " doesn't exist"); DH.displayInfo(info1); string info2 = "The PathIter from " + filename + " to " + path2 + (DS.findPathIter(filename, path2) ? " exists" : " doesn't exist"); DH.displayInfo(info2); DH.displayInfo("\n"); return 0; }
int main() { title("Testing DataStore"); DataStore ds; ds.save("firstFile","firstPath"); ds.save("secondFile", "firstPath"); ds.save("secondFile", "secondPath"); std::cout << "\n " << ds.numberOfFiles() << " Files in " << ds.numberOfPaths() << " directories\n"; for (auto item : ds) { std::cout << "\n " << (item).first.c_str()/* << " on " << (item).second.c_str()*/; DataStore::PathCollection paths = ds.getPaths(item.first); for (auto path : paths) std::cout << "\n " << path; } std::cout << "\n\n"; }
int main(int argc, char *argv[]) { banner(); srand((unsigned int)time(NULL)); if (config.ProcessCommandLine(argc, argv)) { if (!store.ReadContigs(config.InputFileName)) { cerr << "[-] Unable to read contigs from file (" << config.InputFileName << ")." << endl; return -2; } cerr << "[+] Read input contigs from file (" << config.InputFileName << ")." << endl; cerr << "[i] Processing paired reads." << endl; if (!processPairs(config, store, config.PairedReadInputs, coverage)) return -3; if (!processSequences(config, store, config.SequenceInputs)) return -4; if (!writeStore(store, config.OutputFileName)) { cerr << "[-] Unable to output generated links into file (" << config.OutputFileName << ")." << endl; return -5; } cerr << "[+] Output generated link into file (" << config.OutputFileName << ")." << endl; if (!config.ReadCoverageFileName.empty()) { if (!writeCoverage(coverage, config.ReadCoverageFileName)) { cerr << "[-] Unable to output read coverage statistics into file (" << config.ReadCoverageFileName << ")." << endl; return -6; } cerr << "[+] Output read coverage into file (" << config.ReadCoverageFileName << ")." << endl; } return 0; } cerr << config.LastError; return -1; }