void pde(double t, double ****f, double ****df) { int i,j,k,l,m; double dv1[3][3],dv2[3][3],dp1[3],dp2[3],dn1[3]; boundary_conditions(f); for(i=ghost;i<mm1;i++) for(j=ghost;j<mm2;j++) for(k=ghost;k<mm3;k++) { for(l=0;l<3;l++) for(m=0;m<3;m++) { dv1[l][m]=dr(f[l],i,j,k,m+1,0,dx[m],ghost, approx); dv2[l][m]=dr(f[l],i,j,k,m+1,1,dx[m]*dx[m],ghost, approx); } for(m=0;m<3;m++) { dp1[m]=dr(f[3],i,j,k,m+1,0,dx[m],ghost, approx); dn1[m]=dr(nut,i,j,k,m+1,0,dx[m],ghost, approx); } for(l=0;l<3;l++) df[l][i][j][k]= (dv2[l][0] + dv2[l][1] + dv2[l][2])*nut[i][j][k] - dp1[l] + (dn1[0]-f[0][i][j][k])*dv1[l][0] + (dn1[1]-f[1][i][j][k])*dv1[l][1] + (dn1[2]-f[2][i][j][k])*dv1[l][2]; df[3][i][j][k]= (-(dv1[0][0] + dv1[1][1] + dv1[2][2]))/Gamma; } return; }
IServerSPtr ServersManager::createServer(IConnectionSettingsBaseSPtr settings) { DCHECK(settings); IServerSPtr result; connectionTypes conT = settings->connectionType(); IServerSPtr ser = findServerBySetting(settings); if(conT == REDIS){ RedisServer *newRed = NULL; if(!ser){ IDriverSPtr dr(new RedisDriver(settings)); dr->start(); newRed = new RedisServer(dr, true); } else{ newRed = new RedisServer(ser->driver(), false); } result.reset(newRed); servers_.push_back(result); } else if(conT == MEMCACHED){ MemcachedServer *newMem = NULL; if(!ser){ IDriverSPtr dr(new MemcachedDriver(settings)); dr->start(); newMem = new MemcachedServer(dr, true); } else{ newMem = new MemcachedServer(ser->driver(), false); } result.reset(newMem); servers_.push_back(result); } else if(conT == SSDB){ SsdbServer *newSsdb = NULL; if(!ser){ IDriverSPtr dr(new SsdbDriver(settings)); dr->start(); newSsdb = new SsdbServer(dr, true); } else{ newSsdb = new SsdbServer(ser->driver(), false); } result.reset(newSsdb); servers_.push_back(result); } DCHECK(result); if(ser && syncServers_){ result->syncWithServer(ser.get()); } return result; }
int equal_partial_tuplefn(oidtype x, oidtype y) { // Standard comparison function struct ptcell *dx = dr(x, ptcell), *dy = dr(y, ptcell); int k; if (dx->size != dy->size) return FALSE; for (k = 0; k < dx->size; k++) if (!equal(a_getelem(dx->tuple, k, FALSE), a_getelem(dy->tuple, k, FALSE))) return FALSE; return TRUE; }
void PZStability::set(const rscf_t & sol, const arma::uvec & drop, bool cplx_, bool can, bool oo) { cplx=cplx_; cancheck=can; oocheck=oo; Checkpoint *chkptp=solverp->get_checkpoint(); arma::cx_mat CW; chkptp->cread("CW",CW); chkptp->read(basis); grid=DFTGrid(&basis,true,method.lobatto); nlgrid=DFTGrid(&basis,true,method.lobatto); // Update solution rsol=sol; rsol.cC.cols(0,CW.n_cols-1)=CW; // Drop orbitals if(!cancheck) { arma::uvec dr(arma::sort(drop,"descend")); for(size_t i=0;i<dr.n_elem;i++) { rsol.cC.shed_col(dr(i)); CW.shed_col(0); } } // Update size parameters restr=true; oa=ob=CW.n_cols; va=vb=rsol.cC.n_cols-oa; fprintf(stderr,"\noa = %i, ob = %i, va = %i, vb = %i\n",(int) oa, (int) ob, (int) va, (int) vb); fprintf(stderr,"There are %i parameters.\n",(int) count_params()); fflush(stdout); // Reconstruct DFT grid if(method.adaptive) grid.construct(CW,method.gridtol,method.x_func,method.c_func); else { bool strict(false); grid.construct(method.nrad,method.lmax,method.x_func,method.c_func,strict); if(method.nl) nlgrid.construct(method.nlnrad,method.nllmax,true,false,strict,true); } // Update reference arma::vec x(count_params()); x.zeros(); eval(x,-1); }
void query(const scalar_type* q, int k0, int emax, double* dist, int* results) { cv::AutoBuffer<int> tmp(emax); typedef std::pair<int, accum_type> dr_type; // * swap int and accum_type here, for naming consistency cv::AutoBuffer<dr_type> dr(k0); int k1 = 0; // * handle k0 >= emax, in which case don't track max distance for (int l = 0; l < L && emax > 0; ++l) { lsh_hash h = (*g[l])(q); int m = ops->hash_lookup(h, l, tmp, emax); for (int j = 0; j < m && emax > 0; ++j, --emax) { int i = tmp[j]; const scalar_type* p = (const scalar_type*)ops->vector_lookup(i); accum_type pd = (*g[l]).distance(p, q); if (k1 < k0) { dr[k1++] = std::make_pair(i, pd); std::push_heap(&dr[0], &dr[k1], comp_dist); } else if (pd < dr[0].second) { std::pop_heap(&dr[0], &dr[k0], comp_dist); dr[k0 - 1] = std::make_pair(i, pd); std::push_heap(&dr[0], &dr[k0], comp_dist); } } } for (int j = 0; j < k1; ++j) dist[j] = dr[j].second, results[j] = dr[j].first; std::fill(dist + k1, dist + k0, 0); std::fill(results + k1, results + k0, -1); }
void _rundocker(std::string src, std::string dst, std::string passwd, std::string ctrcmd, const params &p) { std::string cmd("docker"); std::vector<std::string> args; args.push_back(cmd); args.push_back("run"); args.push_back("-i"); args.push_back("--name=\"dr_compress\""); if (passwd.length() > 0) { logmsg(kLDEBUG, "Using password supplied.", p); args.push_back("-e"); args.push_back("PASS=\"" + passwd + "\""); } args.push_back("-v"); args.push_back(src + ":/src"); args.push_back("-v"); args.push_back(dst + ":/dst"); args.push_back("drunner/rootutils"); args.push_back("bash"); args.push_back("-c"); args.push_back(ctrcmd); utils::dockerrun dr(cmd, args, "dr_compress", p); }
// Uses an input file for now, should eventually create the RVE itself. bool FE2FluidMaterialStatus :: createRVE(int n, GaussPoint *gp, const std::string &inputfile) { OOFEMTXTDataReader dr(inputfile.c_str()); EngngModel *em = InstanciateProblem(&dr, _processor, 0); // Everything but nrsolver is updated. dr.finish(); em->setProblemScale(microScale); em->checkProblemConsistency(); em->initMetaStepAttributes( em->giveMetaStep( 1 ) ); em->giveNextStep(); // Makes sure there is a timestep (which we will modify before solving a step) em->init(); this->rve = dynamic_cast<StokesFlow*> (em); if (!this->rve) { return false; } std::ostringstream name; name << this->rve->giveOutputBaseFileName() << "-gp" << n; #ifdef __PARALLEL_MODE if (this->domain->giveEngngModel()->isParallel() && this->domain->giveEngngModel()->giveNumberOfProcesses() > 1) { name << "." << this->domain->giveEngngModel()->giveRank(); } #endif this->rve->letOutputBaseFileNameBe(name.str()); this->bc = dynamic_cast< MixedGradientPressureBC* >(this->rve->giveDomain(1)->giveBc(1)); if (!this->bc) { OOFEM_ERROR("FE2FluidMaterialStatus :: createRVE - RVE doesn't have necessary boundary condition; should have MixedGradientPressure as first b.c. (in first domain)"); } return true; }
int main(int argc, char **argv) { ros::init(argc, argv, "deadreckoning"); ros::NodeHandle node("~"); ROS_INFO("Initialized ROS."); bool simulation = true; std::string mode; if (node.getParam("mode", mode)) simulation = mode != "realworld"; ROS_INFO("Mode: %s", simulation ? "Simulation" : "Real world"); srand(time(0)); double minX=-5, maxX=5, minY=-5, maxY=5; if (simulation) { minX = 0; maxX = 10; minY = 0; maxY = 10; } DeadReckoning dr(node, simulation, minX, maxX, minY, maxY); if (dr.ready()) dr.reckon(); ROS_INFO("Bye!"); return 0; };
std::set<DetectionReport> ReportManager::getDRs() { std::set<DetectionReport> result; for (std::size_t i = 0; i<packetSize_; ++i) { try { DB::DynDBDriver::DR_row row = drCursor_.fetchRow(); // TODO get features for DR DetectionReport dr(row); lastDR_ = dr; result.insert(dr); } catch (const DB::exceptions::NoResultAvailable& /*ex*/) { // if no more results available, prepare new Cursor and end loop Common::GlobalLogger ::getInstance().log("ReportManager","No result available from DB"); setupNextCursor(); break; } } return result; }
// Inherited via Task virtual void run() override { LOG_SCOPE_TIME(BitEngine::EngineLog, "Texture load"); ResourceLoader::DataRequest dr(nullptr); if (textureData) { dr = std::move(textureData->getData()); } else { dr = std::move(useData); } if (dr.isLoaded()) { texture->imgData.fileData.swap(dr.data); texture->imgData.pixelData = stbi_load_from_memory((unsigned char*)texture->imgData.fileData.data(), texture->imgData.fileData.size(), &texture->imgData.width, &texture->imgData.height, &texture->imgData.color, 0); if (texture->imgData.pixelData != nullptr) { LOG(BitEngine::EngineLog, BE_LOG_VERBOSE) << "stbi loaded texture: " << dr.meta->getNameId() << " w: " << texture->imgData.width << " h: " << texture->imgData.height; manager->uploadToGPU(texture); } else { LOG(BitEngine::EngineLog, BE_LOG_ERROR) << "stbi failed to load texture: " << dr.meta->getNameId() << " reason: " << stbi_failure_reason(); } } else { LOG(BitEngine::EngineLog, BE_LOG_ERROR) << "Resource meta " << dr.meta->getNameId() << " on state: " << dr.loadState; } }
int sc_main(int argc, char* argv[]) { sc_signal<char> i1, i2, i3; sc_signal<char>d1, o1, o2, o3, o4; sc_signal<bool>sr; sc_signal<bool>clk; change_case cc("cc"); filter ft("ft"); m_bus mb("mb"); driver dr("dr"); monitor mon("mon"); UART ur("ur"); arbiter ar("ar"); dr.d_char(d1); cc.char_in(d1); cc.char_out(o1); ft.char_in(d1); ft.char_out(o2); ar.selector(sr); ar.clk(clk); mb.char_in1(o1); mb.char_in2(o2); mb.char_out(o3); mb.selector(sr); ur.char_in(o3); ur.char_out(o4); mon.clk(clk); mon.m_char(o4); sc_start(); return 0; }
bool Query::Execute( RowReaderType rr ) { if( !stmt ) { printf( "Query::execute failed. _stmt = nullptr" ); return false; } if( vc != vi ) { printf( "Query::execute failed. parameter count is not valid. _vc = %d, _vi = %d", vc, vi ); return false; } vi = 0; int ok = sqlite3_step( stmt ); if( !( ok == SQLITE_OK || ok == SQLITE_DONE || ok == SQLITE_ROW ) ) { printf( "Query::execute sqlite3_step failed. code = %d, errmsg = %s", ok, sqlite3_errmsg( conn->db ) ); return false; } if( rr ) { DataReader dr( stmt ); while( ok == SQLITE_ROW ) { dr.Reset(); rr( dr ); ok = sqlite3_step( stmt ); } } ok = sqlite3_reset( stmt ); if( ok == SQLITE_OK || ok == SQLITE_DONE ) return true; printf( "Query::execute sqlite3_reset failed. code = %d", ok ); return false; }
bool StructuralFE2MaterialStatus :: createRVE(int n, GaussPoint *gp, const std :: string &inputfile) { OOFEMTXTDataReader dr( inputfile.c_str() ); EngngModel *em = InstanciateProblem(dr, _processor, 0); // Everything but nrsolver is updated. dr.finish(); em->setProblemScale(microScale); em->checkProblemConsistency(); em->initMetaStepAttributes( em->giveMetaStep(1) ); em->giveNextStep(); // Makes sure there is a timestep (which we will modify before solving a step) em->init(); this->rve.reset( em ); std :: ostringstream name; name << this->rve->giveOutputBaseFileName() << "-gp" << n; if ( this->domain->giveEngngModel()->isParallel() && this->domain->giveEngngModel()->giveNumberOfProcesses() > 1 ) { name << "." << this->domain->giveEngngModel()->giveRank(); } this->rve->letOutputBaseFileNameBe( name.str() ); this->bc = dynamic_cast< PrescribedGradientHomogenization * >( this->rve->giveDomain(1)->giveBc(1) ); if ( !this->bc ) { OOFEM_ERROR("RVE doesn't have necessary boundary condition; should have a type of PrescribedGradientHomogenization as first b.c."); } return true; }
bool AtlasTexture::get_rect_region(const Rect2& p_rect, const Rect2& p_src_rect,Rect2& r_rect,Rect2& r_src_rect) const { Rect2 rc=region; if (!atlas.is_valid()) return false; Rect2 src=p_src_rect; src.pos+=(rc.pos-margin.pos); Rect2 src_c = rc.clip(src); if (src_c.size==Size2()) return false; Vector2 ofs = (src_c.pos-src.pos); Vector2 scale = p_rect.size / p_src_rect.size; if(scale.x < 0) { float mx = (margin.size.width - margin.pos.x); mx -= margin.pos.x; ofs.x = -(ofs.x + mx); } if(scale.y < 0) { float my = margin.size.height - margin.pos.y; my -= margin.pos.y; ofs.y = -(ofs.y + my); } Rect2 dr( p_rect.pos+ofs*scale,src_c.size*scale ); r_rect=dr; r_src_rect=src_c; return true; }
void ContentContainer::DrawContentsInRegions(const Regions& rgns, const Point& offset) const { // layout shouldn't be empty unless there is no content anyway... if (layout.empty()) return; // should only have 1 region const Region& rgn = rgns.front(); // TODO: intersect with the screen clip so we can bail out even earlier const Point& drawOrigin = rgn.Origin(); Point drawPoint = drawOrigin; ContentLayout::const_iterator it = layout.begin(); #if (DEBUG_TEXT) Region dr(parentOffset + offset, contentBounds); core->GetVideoDriver()->DrawRect(dr, ColorRed, true); core->GetVideoDriver()->DrawRect(dr, ColorWhite, false); dr = Region(parentOffset + offset, ContentFrame()); core->GetVideoDriver()->DrawRect(dr, ColorGreen, true); core->GetVideoDriver()->DrawRect(dr, ColorWhite, false); #endif for (; it != layout.end(); ++it) { const Layout& l = *it; assert(drawPoint.x <= drawOrigin.x + frame.w); l.content->DrawContentsInRegions(l.regions, offset + parentOffset); } }
bool GSDevice10::CopyOffscreen(Texture& src, const GSVector4& sr, Texture& dst, int w, int h, int format) { dst = Texture(); if(format == 0) { format = DXGI_FORMAT_R8G8B8A8_UNORM; } if(format != DXGI_FORMAT_R8G8B8A8_UNORM && format != DXGI_FORMAT_R16_UINT) { ASSERT(0); return false; } Texture rt; if(CreateRenderTarget(rt, w, h, format)) { GSVector4 dr(0, 0, w, h); StretchRect(src, sr, rt, dr, m_convert.ps[format == DXGI_FORMAT_R16_UINT ? 1 : 0], NULL); if(CreateOffscreen(dst, w, h, format)) { m_dev->CopyResource(dst, rt); } } Recycle(rt); return !!dst; }
void AtlasTexture::draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate, bool p_transpose) const { //this might not necesarily work well if using a rect, needs to be fixed properly Rect2 rc=region; if (!atlas.is_valid()) return; Rect2 src=p_src_rect; src.pos+=(rc.pos-margin.pos); Rect2 src_c = rc.clip(src); if (src_c.size==Size2()) return; Vector2 ofs = (src_c.pos-src.pos); Vector2 scale = p_rect.size / p_src_rect.size; if(scale.x < 0) { float mx = (margin.size.width - margin.pos.x); mx -= margin.pos.x; ofs.x = -(ofs.x + mx); } if(scale.y < 0) { float my = margin.size.height - margin.pos.y; my -= margin.pos.y; ofs.y = -(ofs.y + my); } Rect2 dr( p_rect.pos+ofs*scale,src_c.size*scale ); VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item,dr,atlas->get_rid(),src_c,p_modulate,p_transpose); }
void EpisodeBox::openEpisode(QString dirPath) { d.clear(); dw.clear(); epPath = dirPath; QDir dr(dirPath); dr.setPath(dirPath); QStringList filters; //Files which are supports custom musics filters << "*.lvl"; filters << "*.lvlx"; filters << "*.wldx"; dr.setSorting( QDir::NoSort ); dr.setNameFilters( filters ); QDirIterator dirsList( dirPath, filters, QDir::Files|QDir::NoSymLinks|QDir::NoDotAndDotDot, QDirIterator::Subdirectories ); while( dirsList.hasNext() ) { dirsList.next(); QString file = dr.relativeFilePath( dirsList.filePath() ); if(file.endsWith(".lvl", Qt::CaseInsensitive) || file.endsWith(".lvlx", Qt::CaseInsensitive)) { EpisodeBox_level l; if( l.open( epPath + "/" + file ) ) //Push only valid files!!! d.push_back(l); } else { EpisodeBox_world l; if( l.open(epPath+"/"+file) ) //Push only valid files!!! dw.push_back(l); } } }
oidtype read_partial_tuple(bindtype env, oidtype tag, oidtype x, oidtype stream) { // Standard reader int size = 0, fills = 0, j = 0, k = 0; oidtype res, x0; struct ptcell *dres; //Pass 1: compute sizes x0 = x; while (x0 != nil) { if (hd(x) == nil) fills++; size++; x0 = tl(x0); } // Allocate PT res = alloc_partial_tuple(size - fills, fills); dres = dr(res, ptcell); //Pass 2: fill PT with values and blanks x0 = x; while (x0 != nil) { if (symbolp(hd(x0)) && strcmp(getpname(hd(x0)), "*") == 0) { dres->fill[j].pos = k; dres->fill[j].pendingOps = 0; a_setelem(dres->tuple, k, nil, FALSE); j++; } else a_setelem(dres->tuple, k, hd(x0), FALSE); k++; x0 = tl(x0); } return res; }
DrMain* KMLpdManager::loadPrinterDriver(KMPrinter *printer, bool config) { PrintcapEntry *entry = findPrintcapEntry(printer->name()); if (!entry) return NULL; // check for printtool driver (only for configuration) QString sd = entry->arg("sd"), dr(entry->comment(7)); if (QFile::exists(sd+"/postscript.cfg") && config && !dr.isEmpty()) { QMap<QString,QString> map = loadPrinttoolCfgFile(sd+"/postscript.cfg"); PrinttoolEntry *ptentry = findPrinttoolEntry(dr); if (!ptentry) return NULL; DrMain *dr = ptentry->createDriver(); dr->setOptions(map); map = loadPrinttoolCfgFile(sd+"/general.cfg"); dr->setOptions(map); map = loadPrinttoolCfgFile(sd+"/textonly.cfg"); dr->setOptions(map); return dr; } // default if (entry->m_comment.startsWith("##PRINTTOOL3##")) setErrorMsg(i18n("No driver found (raw printer)")); else setErrorMsg(i18n("Printer type not recognized.")); return NULL; }
void HistoryInteraction::build_coefficient_table() { Interpolation::UniformLagrangeSet lagrange(interp_order); for(int pair_idx = 0; pair_idx < num_interactions; ++pair_idx) { int src, obs; std::tie(src, obs) = idx2coord(pair_idx); Vec3d dr(separation((*dots)[src], (*dots)[obs])); std::pair<int, double> delay( split_double(dr.norm() / (config.c0 * config.dt))); floor_delays[pair_idx] = delay.first; lagrange.calculate_weights(delay.second, config.dt); std::vector<Eigen::Matrix3cd> interp_dyads( dyadic->coefficients(dr, lagrange)); for(int i = 0; i <= interp_order; ++i) { coefficients[pair_idx][i] = (*dots)[obs].dipole().dot(interp_dyads[i] * (*dots)[src].dipole()); } } }
void TestTranslation::apply( Alignable* it ) { std::cout << "------------------------" << std::endl << " BEFORE TRANSLATION " << std::endl; align::GlobalPoint pos_i = (it)->globalPosition() ; // RotationType dir_i = (it)->globalRotation(); std::cout << "x=" << pos_i.x() << ", y=" << pos_i.y() << ", z=" << pos_i.z() << std::endl; double dx = 1.0; double dy = 2.0; double dz = 3.0; align::GlobalVector dr( dx, dy, dz ); it->move( dr ); std::cout << "------------------------" << std::endl << " AFTER TRANSLATION " << std::endl; align::GlobalPoint pos_f = (it)->globalPosition() ; // RotationType dir_f = (it)->globalRotation(); std::cout << "x=" << pos_f.x() << ", y=" << pos_f.y() << ", z=" << pos_f.z() << std::endl ; std::cout << "------------------------" << std::endl; }
int InverseElementTransformation::FindClosestRefPoint( const Vector& pt, const IntegrationRule &ir) { MFEM_VERIFY(T != NULL, "invalid ElementTransformation"); MFEM_VERIFY(pt.Size() == T->GetSpaceDim(), "invalid point"); // Initialize distance and index of closest point int minIndex = -1; double minDist = std::numeric_limits<double>::max(); // Check all integration points in ir using the local metric at each point // induced by the transformation. Vector dp(T->GetSpaceDim()), dr(T->GetDimension()); const int npts = ir.GetNPoints(); for (int i = 0; i < npts; ++i) { const IntegrationPoint &ip = ir.IntPoint(i); T->Transform(ip, dp); dp -= pt; T->SetIntPoint(&ip); T->InverseJacobian().Mult(dp, dr); double dist = dr.Norml2(); // double dist = dr.Normlinf(); if (dist < minDist) { minDist = dist; minIndex = i; } } return minIndex; }
// {{{RME operation 'drive(int,int)' void roombaProgram_Actor::drive( int left, int right ) { // {{{USR clsDriveCommand dr(left,right); Roomba.drive(dr).send(); // }}}USR }
forceinline ConstSetView::ConstSetView(Space& home, const IntSet& dom) { size = dom.ranges(); domSize = 0; if (size > 0) { ranges = home.alloc<int>(2*size); IntSetRanges dr(dom); for (int i=0; dr(); ++dr, i+=2) { int min = dr.min(); int max = dr.max(); ranges[i] = min; ranges[i+1] = max; domSize += static_cast<unsigned int>(max-min+1); } } else { ranges = NULL; } }
GSVector2i GSRendererHW::GetInternalResolution() { GSVector2i dr(GetDisplayRect().width(), GetDisplayRect().height()); if (m_upscale_multiplier) return GSVector2i(dr.x * m_upscale_multiplier, dr.y * m_upscale_multiplier); else return GSVector2i(m_width, m_height); }
static void OpenOrCreate(HWND hwnd) { static bool openAlreadyOpened = false; if (openAlreadyOpened) return; class Unique { public: Unique() { openAlreadyOpened = true; } ~Unique() { openAlreadyOpened = false; } } unique; std::tstring dir = GetExistingDirectory(hwnd, _T("Select a folder which contains or will contain encrypted data."), _T("Select Crypt Folder")); if (dir.empty()) return; // if directory is already configured add and try to mount boost::shared_ptr<EncFSConfig> config(new EncFSConfig); if (readConfig(slashTerminate(wchar_to_utf8_cstr(dir.c_str())), config) != Config_None) { char drive = SelectFreeDrive(hwnd); if (drive) { Drives::drive_t dr(Drives::Add(dir, drive)); if (dr) dr->Mount(hwnd); } return; } // TODO check directory is empty, warning if continue // "You are initializing a crypted directory with a no-empty directory. Is this expected?" OptionsData data; data.rootDir = dir; if (DialogBoxParam(hInst, (LPCTSTR) IDD_OPTIONS, hwnd, (DLGPROC) OptionsDlgProc, (LPARAM) &data) != IDOK) return; // add configuration and add new drive createConfig(slashTerminate(wchar_to_utf8_cstr(dir.c_str())), data.paranoia, false, wchar_to_utf8_cstr(data.password).c_str(), true); Drives::drive_t dr(Drives::Add(dir, data.drive)); if (dr) dr->Mount(hwnd); }
void Registry::DestroyNominated() { // copy the elements in deathrow because when we delete // objects, they may release other objects. std::vector<Handle> dr(deathrow.begin(), deathrow.end()); deathrow.clear(); for (auto const &ob : dr) DestroyObject(ob); }
void UpdaterComponent::downloadUpdate(const QVariantMap& updateInfo) { if (isDownloading()) return; QLOG_INFO() << updateInfo; if (!updateInfo.contains("version") || !updateInfo.contains("manifestURL") || !updateInfo.contains("manifestHash") || !updateInfo.contains("fileURL") || !updateInfo.contains("fileHash") || !updateInfo.contains("fileName")) { QLOG_ERROR() << "updateInfo was missing fields required to carry out this action."; return; } m_version = updateInfo["version"].toString(); m_manifest = new Update(updateInfo["manifestURL"].toString(), UpdateManager::GetPath("manifest.xml.bz2", m_version, false), updateInfo["manifestHash"].toString(), this); // determine if we have a manifest (some distros don't like OE) m_hasManifest = ((!m_manifest->m_url.isEmpty()) && (!m_manifest->m_hash.isEmpty())); m_file = new Update(updateInfo["fileURL"].toString(), UpdateManager::GetPath(updateInfo["fileName"].toString(), m_version, true), updateInfo["fileHash"].toString(), this); if (m_hasManifest) connect(m_manifest, &Update::fileDone, this, &UpdaterComponent::fileComplete); connect(m_file, &Update::fileDone, this, &UpdaterComponent::fileComplete); // create directories we need QDir dr(QFileInfo(m_file->m_localPath).dir()); if (!dr.exists()) { if (!dr.mkpath(".")) { QLOG_ERROR() << "Failed to create update directory:" << dr.absolutePath(); emit downloadError("Failed to create download directory"); return; } } // this will first check if the files are done // and in that case emit the done signal. if (fileComplete(NULL)) return; if (!m_manifest->isReady() && m_hasManifest) downloadFile(m_manifest); if (!m_file->isReady()) downloadFile(m_file); }
/** * Runs the subscriber role of this example. * @return 0 if a sample was successfully read by the listener and the listener * received a notification of deadline expiration successfully, 1 otherwise. */ int subscriber(int argc, char *argv[]) { int result = 0; try { /** A domain participant, topic, and subscriber are created with matching QoS to the ::publisher */ dds::domain::DomainParticipant dp(org::opensplice::domain::default_id()); dds::topic::qos::TopicQos topicQos = dp.default_topic_qos() << dds::core::policy::Durability::Transient() << dds::core::policy::Reliability::Reliable() << dds::core::policy::Deadline(dds::core::Duration(1, 0)); dds::topic::Topic<ListenerData::Msg> topic(dp, "ListenerData_Msg", topicQos); dp.default_topic_qos(topicQos); std::string name = "Listener example"; dds::sub::qos::SubscriberQos subQos = dp.default_subscriber_qos() << dds::core::policy::Partition(name); dds::sub::Subscriber sub(dp, subQos); dds::sub::qos::DataReaderQos drqos = topic.qos(); /** An ExampleDataReaderListener and dds::core::status::StatusMask for the events * StatusMask::requested_deadline_missed() and StatusMask::data_available() are * both created and then specified when creating the dds::sub::DataReader */ ExampleDataReaderListener listener; dds::core::status::StatusMask mask; mask << dds::core::status::StatusMask::data_available() << dds::core::status::StatusMask::requested_deadline_missed(); std::cout << "=== [ListenerDataSubscriber] Set listener" << std::endl; dds::sub::DataReader<ListenerData::Msg> dr(sub, topic, drqos, &listener, mask); std::cout << "=== [ListenerDataSubscriber] Ready ..." << std::endl; /** The main thread then pauses until the listener thread has received a notification * that the deadline has expired (i.e. no more messages have been received for at least * 1 second) */ int count = 0; while(! listener.deadline_expired_ && count < 20) { exampleSleepMilliseconds(1000); count++; } result = ! (listener.deadline_expired_ && listener.data_received_); /** Remove the ExampleDataReaderListener from the DataReader */ dr.listener(0, dds::core::status::StatusMask::none()); std::cout << "=== [ListenerDataSubscriber] Closed" << std::endl; } catch (const dds::core::Exception& e) { std::cerr << "ERROR: Exception: " << e.what() << std::endl; result = 1; } return result; }