当前位置: 首页>>代码示例>>C++>>正文


C++ Path类代码示例

本文整理汇总了C++中Path的典型用法代码示例。如果您正苦于以下问题:C++ Path类的具体用法?C++ Path怎么用?C++ Path使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Path类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fillPath

void LowLevelGraphicsSoftwareRenderer::drawLine (const Line <float>& line)
{
    Path p;
    p.addLineSegment (line, 1.0f);
    fillPath (p, AffineTransform::identity);
}
开发者ID:L-Naej,项目名称:VirtuOSE-Project,代码行数:6,代码来源:juce_LowLevelGraphicsSoftwareRenderer.cpp

示例2: getLocalBounds

void Oscilloscope::paint(juce::Graphics &g)
{
    g.fillAll (Colours::white);
    
    Path path;
    
    float xOffset = 21.f;
    float yOffset = 120.f;
    
    Rectangle<float> rect = logoPath.getBounds();
    Rectangle<int> rect2 = getLocalBounds();
    
    g.setColour (Colours::black);
    g.fillPath (logoPath, RectanglePlacement (RectanglePlacement::stretchToFit)
                .getTransformToFit (logoPath.getBounds(),
                                    getLocalBounds().toFloat()));
    

    // Horizontal zero line.
    path.addLineSegment(Line<float> (xOffset, yOffset, getLocalBounds().getWidth() - xOffset, yOffset), 1.);
    
    g.setColour (Colours::lightgrey);
    g.fillPath (path);
    
    float xIncrement = (getLocalBounds().getWidth() - 2 * xOffset) / (UIConstants::NUMBER_SCOPE_POINTS - 1);
    
    // Now iterate over points.
    int count = 0;
    float alpha = 0;
    for (auto& points : allPoints)
    {
        if ((currentPointsIndex - count + UIConstants::NUMBER_SCOPE_BUFFERS) % UIConstants::NUMBER_SCOPE_BUFFERS == 0)
        {
            // Current array is 'brightest'
            alpha = 1;
        } else
        {
            // Set older immediately to less than 0.5 alpha.
            alpha = 0.3 - ((currentPointsIndex - count + UIConstants::NUMBER_SCOPE_BUFFERS) % UIConstants::NUMBER_SCOPE_BUFFERS) * 0.03 ;
        }
        
//        g.setColour(Colour::fromFloatRGBA(0, 255 , 0, alpha)) ;
        g.setColour(scopeTraceColour.withAlpha(alpha));
        path.clear();

        float x = 0;
        path.startNewSubPath(xOffset, yOffset);
        for (auto& point : points)
        {
//            g.setPixel(x + xOffset, yOffset - 30 * point.x); // point.x in this case is the right value of the stereo pair.
            path.lineTo(x + xOffset, yOffset - 30 * point.x);
            x += xIncrement;
        }
//        path.closeSubPath();
        g.strokePath (path, PathStrokeType (1.0f));
        count++;
        
    }

    
}
开发者ID:nashpal,项目名称:mastering-expert,代码行数:61,代码来源:Oscilloscope.cpp

示例3: VirtualSize

void RenderDemoDlg::RenderControl(ReDrawInfoType* ExtraInfo)
{
	// Go get a render region
	DocRect VirtualSize(-ExtraInfo->dx/2, -ExtraInfo->dy/2, ExtraInfo->dx/2, ExtraInfo->dy/2);
	RenderRegion* pRender = CreateGRenderRegion(&VirtualSize, ExtraInfo);
	if (pRender!=NULL)
	{
		DialogColourInfo RedrawColours;		// Get a supplier for default dlg colours

		// Render stuff in here
		// Build a Linear fill attribute
		LinearFillAttribute MyGradFill;
		MyGradFill.Colour = DocColour(255, 255, 0);
		MyGradFill.EndColour = DocColour(0, 255, 255);
		MyGradFill.StartPoint = DocCoord(0, ExtraInfo->dy);
		MyGradFill.EndPoint = DocCoord(ExtraInfo->dx, 0);

		// Build a path
		Path InkPath;
		InkPath.Initialise(12,12);
		InkPath.FindStartOfPath();

		// Get the coords used to build a shape
		INT32 dx = ExtraInfo->dx / 2;
		INT32 dy = ExtraInfo->dy / 2;
		INT32 Midx = ExtraInfo->dx / 4;
		INT32 Midy = ExtraInfo->dy / 4;

		// build a circle in the middle of the control
		InkPath.InsertMoveTo(DocCoord(Midx, dy));
		InkPath.InsertCurveTo(DocCoord(Midx+Midx/2, dy), DocCoord(dx, Midy+Midy/2), DocCoord(dx, Midy));
		InkPath.InsertCurveTo(DocCoord(dx, Midy-Midy/2), DocCoord(Midx+Midx/2, 0), DocCoord(Midx, 0));
		InkPath.InsertCurveTo(DocCoord(Midx-Midx/2, 0), DocCoord(0, Midy-Midy/2), DocCoord(0, Midy));
		InkPath.InsertCurveTo(DocCoord(0, Midy+Midy/2), DocCoord(Midx-Midx/2, dy), DocCoord(Midx, dy));
		InkPath.IsFilled = TRUE;
		
		// A Grey colour [...hmmm, it's not a very grey grey any more... oragnge more like]
		DocColour Grey(255,200,0);

		// Render the attributes and the a rectangle
		pRender->SaveContext();
		pRender->SetLineColour(Grey);

		// Draw a rectangle to fill in the background - Fill with Dialogue Background colour
		DocRect DrawMe(0, 0, ExtraInfo->dx, ExtraInfo->dy);
		pRender->SetFillColour(RedrawColours.DialogBack());
		pRender->DrawRect(&VirtualSize);

		// Draw some shapes and stuff
		pRender->SetFillGeometry(&MyGradFill, FALSE);
		pRender->DrawPath(&InkPath);

		// Build a path
		Path TriPath;
		TriPath.Initialise(12,12);
		TriPath.FindStartOfPath();

		// build a circle in the middle of the control
		TriPath.InsertMoveTo(VirtualSize.lo);
		TriPath.InsertLineTo(DocCoord(VirtualSize.hi.x, VirtualSize.lo.y));
		TriPath.InsertLineTo(DocCoord(0, VirtualSize.hi.y));
		TriPath.InsertLineTo(VirtualSize.lo);
		TriPath.IsFilled = TRUE;

		LinearFillAttribute MyTriFill;
		MyTriFill.Colour = ShowFirst ? First : Second;
		MyTriFill.EndColour = DocColour(0,0,0);
		MyTriFill.StartPoint = DocCoord(ExtraInfo->dx, 0);
		MyTriFill.EndPoint = DocCoord(0, ExtraInfo->dy);

		pRender->SetFillGeometry(&MyTriFill, FALSE);
		pRender->DrawPath(&TriPath);

		pRender->RestoreContext();

		// Get rid of the render region
		DestroyGRenderRegion(pRender);
	}

	// and animate it!
	if (ShowFirst)
	{
		INT32 Red, Green, Blue;
		First.GetRGBValue(&Red, &Green, &Blue);

		if (Blue>0)
		{
			// Set the colour back again
			Blue -= 10;
			First.SetRGBValue(Red, Green, Blue);

			// redraw it
			InvalidateGadget(_R(IDC_REDRAW_ME));
		}
	}
	else
	{
		// Set the colour back to how it was
		First.SetRGBValue(255, 0, 250);
	}
//.........这里部分代码省略.........
开发者ID:vata,项目名称:xarino,代码行数:101,代码来源:renddlg.cpp

示例4: evaluate

	// Evaluate the contributions of the given eye and light paths
	void evaluate(GBDPTWorkResult *wr,
		Path &emitterSubpath, std::vector<Path> &sensorSubpath, std::vector<ShiftPathData> &pathData, int vert_b,
		std::vector<Spectrum> &value,  std::vector<Float> &miWeight, std::vector<Float> &valuePdf,
		std::vector<double> &jacobianLP, std::vector<double> &genGeomTermLP, bool *pathSuccess) {

		/* we use fixed neighborhood kernel! Future work will be to extend this to structurally-adaptive neighbours!!! */
		Vector2 shifts[4] = { Vector2(0, -1), Vector2(-1, 0), Vector2(1, 0), Vector2(0, 1) };
		int neighbourCount = 4;

		Point2 initialSamplePos = sensorSubpath[0].vertex(1)->getSamplePosition();
		int pixelIndex = (int)initialSamplePos[0] + (int)initialSamplePos[1] * m_sensor->getFilm()->getSize().x;

		const Scene *scene = m_scene;
		PathEdge  connectionEdge;

		/* combined weights along the two subpaths */
		Spectrum *importanceWeights = (Spectrum *)alloca(emitterSubpath.vertexCount() * sizeof(Spectrum));
		Spectrum **radianceWeights = (Spectrum **)alloca((neighbourCount + 1) * sizeof(Spectrum*));

		/* combined Pdfs along the two subpaths */
		Float *importancePdf = (Float*)alloca(emitterSubpath.vertexCount() * sizeof(Float));
		Float **radiancePdf = (Float **)alloca((neighbourCount + 1) * sizeof(Float*));

		for (int k = 0; k <= neighbourCount; k++){
			radianceWeights[k] = (Spectrum *)alloca(sensorSubpath[0].vertexCount()  * sizeof(Spectrum));
			radiancePdf[k] = (Float *)alloca(sensorSubpath[0].vertexCount() * sizeof(Float));
		}

		/* Compute the importance and radiance data */
		combineImportanceData(emitterSubpath, importanceWeights, importancePdf);
		combineRadianceData(sensorSubpath, pathData, neighbourCount, radianceWeights, radiancePdf);

		/* Allocate space for gradients */
		Spectrum primal = Spectrum(0.f);

		Spectrum *gradient = (Spectrum *)alloca(neighbourCount * sizeof(Spectrum));
		for (int k = 0; k<neighbourCount; k++){
			gradient[k] = Spectrum(0.f);
		}

		Path offsetEmitterSubpath, connectedBasePath;
		Spectrum geomTermBase, connectionPartsBase, offsetImportanceWeight;
		PathEdge connectionEdgeBase;
		bool successConnectBase, successOffsetGen, lightpathSuccess, samplePosValid;
		Float offsetImportancePdf, offsetImportanceGeom;
		Point2 samplePos;

		
		Spectrum visibility = Spectrum(0.f);
		Spectrum light = Spectrum(0.f);


		for (int s = (int)emitterSubpath.vertexCount() - 1; s >= 0; --s) {

			/* Determine the range of sensor vertices to be traversed, while respecting the specified maximum path length */
			int minT = std::max(2 - s, m_config.lightImage ? 1 : 2), // disable t=0 paths
				maxT = (int)sensorSubpath[0].vertexCount() - 1;
			if (m_config.maxDepth != -1)
				maxT = std::min(maxT, m_config.maxDepth + 1 - s);

			for (int t = maxT; t >= minT; --t) {

				samplePosValid = true;

				/* neighbour count and sample position for non-light paths */
				samplePos = initialSamplePos;

				/* if light path can be computed: recalculate pixel position and neighbours*/
				if (t == 1){
					if (sensorSubpath[0].vertex(t)->isSensorSample()&& !sensorSubpath[0].vertex(t)->getSamplePosition(emitterSubpath.vertex(s), samplePos)
						|| !Path::isConnectable_GBDPT(emitterSubpath.vertex(s), m_config.m_shiftThreshold))
						continue;
				}

				int memPointer;

				for (int k = 0; k <= neighbourCount; k++){

					miWeight[k] = 1.f / (s + t + 1);
					pathSuccess[k] = pathData[k].success;
					value[k] = Spectrum(0.f);
					valuePdf[k] = 0.f;

					/* for radiance make sure that offset light paths have the correct value */
					const Spectrum *importanceWeightTmp = &importanceWeights[s],
						           *radianceWeightTmp = &radianceWeights[t == 1 ? 0 : k][t];
					 
					const Float	 *importancePdfTmp = &importancePdf[s],
								 *radiancePdfTmp = &radiancePdf[t == 1 ? 0 : k][t];

					const Path	 *sensorSubpathTmp = &sensorSubpath[k],
								 *emitterSubpathTmp = &emitterSubpath;

					MutationRecord muRec;
					

					/* create the base path on which the shift is applied. changes for every light tracing path */
					if (t == 1 && k == 0){
						pathSuccess[0] = createShiftablePath(connectedBasePath, emitterSubpath, sensorSubpath[0], s, 1,  memPointer);
//.........这里部分代码省略.........
开发者ID:ArtisticCoding,项目名称:gradientdomain-mitsuba,代码行数:101,代码来源:gbdpt_proc.cpp

示例5: addPath

void GraphicsContext::addPath(const Path& path)
{
    m_data->currentPath = *(path.platformPath());
}
开发者ID:acss,项目名称:owb-mirror,代码行数:4,代码来源:GraphicsContextQt.cpp

示例6: main

int main(int argc, char** argv)
{
	if (argc != 4)
	{	
		Log.info() << "Need 3 arguments: <INIFile> <input.pdb> <output.hin>" << endl;
		Log.info() << "Note: exemplary rules can be found in BALL/data/solvation/PARSE.rul." << endl;
		return(1);
	}

	Path path;
	String filename = path.find(argv[1]);
	if (filename == "")
	{
		cerr << "Could not find rule file " << argv[1] << std::endl;
		return(1);
	}

	INIFile charge_rules(filename);
	charge_rules.read();
	RadiusRuleProcessor proc(charge_rules, "RadiusRules");

	PDBFile infile(argv[2]);
	if (!infile)
	{
		// if file does not exist: complain and abort
		Log.error() << "error opening " << argv[2] << " for input." << endl;
		return 2;
	}

	System system;
	infile >> system;
	infile.close();

	Log << "Initializing FragmentDB..." << endl;
	FragmentDB db("");
	Log << "  done." << endl;
	
	Log << "Normalizing names..." << endl;
	system.apply(db.normalize_names);
	Log << "  done." << endl;
	
	Log << "Building Bonds..." << endl;
	system.apply(db.build_bonds);
	Log << "  done." << endl;

	Log << "Applying RadiusRuleProcessor..." << endl;
	system.apply(proc);
	Log << "  done." << endl;

	Log << "Checking results..." << endl;
	// PARANOIA
	ResidueConstIterator res_it = system.beginResidue();

	for (; +res_it; ++res_it)
	{
		AtomConstIterator it = res_it->beginAtom();
		for (; +it; ++it)
		{
			float c = it->getCharge();
			if (fabs(c) > 4.0f)
			{
				Log.warn() << "WARNING: atom " << it->getFullName() << ":"
					<< res_it->getID() << " has suspect charge " << c << endl;
			}
		}
	}
	Log << "  done." << endl;

	HINFile outfile(argv[3], std::ios::out);
	outfile << system;
	outfile.close();	
	Log << "Outputfile " << argv[3] << " written." << endl;

}
开发者ID:HeyJJ,项目名称:ball,代码行数:74,代码来源:assign_radii_from_rules.C

示例7: startJobs

void JobScheduler::startJobs()
{
    static Path rp;
    if (rp.isEmpty()) {
        rp = Rct::executablePath().parentDir() + "rp";
        if (!rp.isFile()) {
            rp = Rct::executablePath();
            rp.resolve();
            rp = rp.parentDir() + "rp";
            if (!rp.isFile()) // should be in $PATH
                rp = "rp";
        }
    }

    const auto &options = Server::instance()->options();
    std::shared_ptr<Node> node = mPendingJobs.first();
    auto cont = [&node, this]() {
        auto tmp = node->next;
        mPendingJobs.remove(node);
        node = tmp;
    };

    while (mActiveByProcess.size() < options.jobCount && node) {
        assert(node);
        assert(node->job);
        assert(!(node->job->flags & (IndexerJob::Running|IndexerJob::Complete|IndexerJob::Crashed|IndexerJob::Aborted)));
        std::shared_ptr<Project> project = Server::instance()->project(node->job->project);
        if (!project) {
            cont();
            debug() << node->job->sourceFile << "doesn't have a project, discarding";
            continue;
        }

        uint32_t headerError = 0;
        if (!mHeaderErrors.isEmpty()) {
            headerError = hasHeaderError(node->job->source.fileId, project);
            if (headerError) {
                // error() << "We got a headerError" << Location::path(headerError) << "for" << node->job->source.sourceFile()
                //         << mHeaderErrorMaxJobs << mHeaderErrorJobIds;
                if (options.headerErrorJobCount <= mHeaderErrorJobIds.size()) {
                    warning() << "Holding off on" << node->job->sourceFile << "it's got a header error from" << Location::path(headerError);
                    node = node->next;
                    continue;
                }
            }
        }

        const uint64_t jobId = node->job->id;
        Process *process = new Process;
        debug() << "Starting process for" << jobId << node->job->source.key() << node->job.get();
        List<String> arguments;
        for (int i=logLevel().toInt(); i>0; --i)
            arguments << "-v";

        process->readyReadStdOut().connect([this](Process *proc) {
                std::shared_ptr<Node> node = mActiveByProcess[proc];
                assert(node);
                node->stdOut.append(proc->readAllStdOut());

                std::regex rx("@[email protected]([^@]*)@[email protected]");
                std::smatch match;
                while (std::regex_search(node->stdOut.ref(), match, rx)) {
                    error() << match[1].str();
                    node->stdOut.remove(match.position(), match.length());
                }
            });

        if (!process->start(rp, arguments)) {
            error() << "Couldn't start rp" << rp << process->errorString();
            delete process;
            node->job->flags |= IndexerJob::Crashed;
            debug() << "job crashed (didn't start)" << jobId << node->job->source.key() << node->job.get();
            std::shared_ptr<IndexDataMessage> msg(new IndexDataMessage(node->job));
            msg->setFlag(IndexDataMessage::ParseFailure);
            jobFinished(node->job, msg);
            rp.clear(); // in case rp was missing for a moment and we fell back to searching $PATH
            cont();
            continue;
        }
        if (headerError) {
            node->job->priority = IndexerJob::HeaderError;
            warning() << "Letting" << node->job->sourceFile << "go even with a headerheader error from" << Location::path(headerError);
            mHeaderErrorJobIds.insert(jobId);
        }
        process->finished().connect([this, jobId](Process *proc) {
                EventLoop::deleteLater(proc);
                auto node = mActiveByProcess.take(proc);
                assert(!node || node->process == proc);
                const String stdErr = proc->readAllStdErr();
                if ((node && !node->stdOut.isEmpty()) || !stdErr.isEmpty()) {
                    error() << (node ? ("Output from " + node->job->sourceFile + ":") : String("Orphaned process:"))
                            << '\n' << stdErr << (node ? node->stdOut : String());
                }

                if (node) {
                    assert(node->process == proc);
                    node->process = 0;
                    assert(!(node->job->flags & IndexerJob::Aborted));
                    if (!(node->job->flags & IndexerJob::Complete) && proc->returnCode() != 0) {
                        auto nodeById = mActiveById.take(jobId);
//.........这里部分代码省略.........
开发者ID:emdeesee,项目名称:rtags,代码行数:101,代码来源:JobScheduler.cpp

示例8: apply

 virtual bool apply( const Path &p ) {
     if ( !boost::filesystem::exists( p ) )
         return false;
     boostRenameWrapper( p, newPath_ / p.leaf() );
     return true;
 }
开发者ID:Benguang,项目名称:mongo,代码行数:6,代码来源:repair_database.cpp

示例9: clip

void PlatformGraphicsContextSkia::clip(const Path& path)
{
    mCanvas->clipPath(*path.platformPath(), SkRegion::kIntersect_Op, true);
}
开发者ID:OmarBizreh,项目名称:Sliding_XZ,代码行数:4,代码来源:PlatformGraphicsContextSkia.cpp

示例10: clipOut

void PlatformGraphicsContextSkia::clipOut(const Path& path)
{
    mCanvas->clipPath(*path.platformPath(), SkRegion::kDifference_Op);
}
开发者ID:OmarBizreh,项目名称:Sliding_XZ,代码行数:4,代码来源:PlatformGraphicsContextSkia.cpp

示例11: file

QVector<Path> Switchers::viewsToSwitch()
{
    QVector<Path> urls;

    auto doc = ICore::self()->documentController()->activeDocument();
    if (!doc) {
        return urls;
    }

    const QUrl &url = doc->url();
    QFileInfo file(url.toLocalFile());
    if (!file.exists()) {
        return urls;
    }

    const QString &ext = file.completeSuffix();
    QString name = file.baseName();
    QString switchTo = "";

    if (isViewExtension(ext)) {
        switchTo = file.dir().dirName();
    } else if (ext == "rb") {
        switchTo = name.remove(QRegExp("_controller$"));
        switchTo = switchTo.remove(QRegExp("_controller_test$"));
        switchTo = switchTo.remove(QRegExp("_test$"));
    }

    if (switchTo.isEmpty()) {
        return urls;
    }
    if (switchTo.endsWith("s")) {
        switchTo = switchTo.mid(0, switchTo.length() - 1);
    }

    Path root = Helpers::findRailsRoot(url);
    if (!root.isValid()) {
        return urls;
    }

    Path viewsUrl(root, QStringLiteral("app/views"));
    Path viewsUrlS(viewsUrl, switchTo);
    Path viewsUrlP(viewsUrl, switchTo + "s");

    if (QFile::exists(viewsUrlS.toLocalFile())) {
        viewsUrl = viewsUrlS;
    } else if (QFile::exists(viewsUrlP.toLocalFile())) {
        viewsUrl = viewsUrlP;
    } else {
        return urls;
    }

    QDir viewsDir(viewsUrl.toLocalFile());
    const QStringList &views = viewsDir.entryList();
    const Path base(viewsDir.absolutePath());

    foreach (const QString &name, views) {
        if (!(name.endsWith("~") || name == "." || name == "..")) {
            urls << KDevelop::Path(base, name);
        }
    }
    return urls;
}
开发者ID:KDE,项目名称:kdev-ruby,代码行数:62,代码来源:switchers.cpp

示例12: ASSERT

int BuddhabrotSketch::GetGroup(double th, Complex *pts, GLcolor *cols, int n)
{
	ColorSet colorset;
	colorset.fromHues(BASIC_HUE_SET, 10, 0.9, 1.0);
	colorset.offsetHues(270);	// ?

	// shorthand path
	Path *pPath = ((Path*)(m_pPath.get()));

	ASSERT(n>=GetGroupSize());
	int count = 0;
	Complex c, z;
	for(int j=0; j<pPath->getGroupSize(); ++j)
	{
		c = pPath->get(th, j);
		z = c;

		int i;
		for(i=0; i<m_nMaxIter; ++i)
		{
			z = (z*z + c);
			if(normal(z) > 4.0)
				break;
		}

		// slight alteration here:
		// we're not going to plot short orbits, only
		// interesting ones whose length is at least MinIter.
		if(i < m_nMaxIter && i >= m_nMinIter)
		{
			// plot this point's orbit, until it hits the bailout value

			int nStopIter = i;

			z = c;
			for(i=0; i<=nStopIter; ++i)		// was i<=m_nMaxIter
			{
				z = (z*z) + c;
				pts[count] = z;
				// color according to...
				switch(m_nColorScheme)
				{
				case 0:
					// abs(c)?
					cols[count].SetHSV(360*log(abs(c)), 0.9, 0.9, m_fBrightness);
					break;
				case 1:
					// iter? (busy)
//					cols[count].SetHSV((i-m_nMinIter)*360.0/(m_nMaxIter-m_nMinIter+1), 0.9, 0.9, m_fBrightness);
					cols[count].SetHSV((i*360.0/m_nMaxIter), 0.9, 0.9, m_fBrightness);
					break;
				case 2:
					// c.arg?
					cols[count].SetHSV(arg(c)*360.0/6.283, 0.9, 0.9, m_fBrightness);
					break;
				case 3:
					// ring index? (this makes bright figures with little or no blur)
					cols[count].SetHSV(j*360.0/pPath->getGroupSize(), 0.9, 0.9, m_fBrightness);
					break;
				case 4:
					// stopiter?
					cols[count].SetHSV((nStopIter-m_nMinIter)*360.0/(m_nMaxIter-m_nMinIter+1), 0.9, 0.9, m_fBrightness);
				}

				++count;
			}
		}
	}

	ASSERT(count <= n);
	return count;
}
开发者ID:jlidbeck,项目名称:NewtonBasinVS,代码行数:72,代码来源:Formulas.cpp

示例13: get_mime

std::string View_types::get_mime(const Path& p) const
{
	std::lock_guard<std::mutex> lk {m_mtx};
	const char* m = magic_file(m_magic_guard->magic_cookie, p.c_str());
	return m ? m : std::string {};
}
开发者ID:gman0,项目名称:libhawk,代码行数:6,代码来源:View_types.cpp

示例14: invariant

    Status MMAPV1Engine::repairDatabase( OperationContext* txn,
                                         const std::string& dbName,
                                         bool preserveClonedFilesOnFailure,
                                         bool backupOriginalFiles ) {
        // We must hold some form of lock here
        invariant(txn->lockState()->threadState());
        invariant( dbName.find( '.' ) == string::npos );

        scoped_ptr<RepairFileDeleter> repairFileDeleter;
        doingRepair dr;

        log() << "repairDatabase " << dbName << endl;

        BackgroundOperation::assertNoBgOpInProgForDb(dbName);

        txn->recoveryUnit()->syncDataAndTruncateJournal(); // Must be done before and after repair

        intmax_t totalSize = dbSize( dbName );
        intmax_t freeSize = File::freeSpace(storageGlobalParams.repairpath);

        if ( freeSize > -1 && freeSize < totalSize ) {
            return Status( ErrorCodes::OutOfDiskSpace,
                           str::stream() << "Cannot repair database " << dbName
                           << " having size: " << totalSize
                           << " (bytes) because free disk space is: " << freeSize << " (bytes)" );
        }

        txn->checkForInterrupt();

        Path reservedPath =
            uniqueReservedPath( ( preserveClonedFilesOnFailure || backupOriginalFiles ) ?
                                "backup" : "_tmp" );
        MONGO_ASSERT_ON_EXCEPTION( boost::filesystem::create_directory( reservedPath ) );
        string reservedPathString = reservedPath.string();

        if ( !preserveClonedFilesOnFailure )
            repairFileDeleter.reset( new RepairFileDeleter( txn,
                                                            dbName,
                                                            reservedPathString,
                                                            reservedPath ) );

        {
            Database* originalDatabase =
                            dbHolder().get(txn, dbName);
            if (originalDatabase == NULL) {
                return Status(ErrorCodes::NamespaceNotFound, "database does not exist to repair");
            }

            scoped_ptr<MMAPV1DatabaseCatalogEntry> dbEntry;
            scoped_ptr<Database> tempDatabase;
            {
                dbEntry.reset( new MMAPV1DatabaseCatalogEntry( txn,
                                                               dbName,
                                                               reservedPathString,
                                                               storageGlobalParams.directoryperdb,
                                                               true ) );
                invariant( !dbEntry->exists() );
                tempDatabase.reset( new Database( txn,
                                                  dbName,
                                                  dbEntry.get() ) );

            }

            map<string,CollectionOptions> namespacesToCopy;
            {
                string ns = dbName + ".system.namespaces";
                Client::Context ctx(txn,  ns );
                Collection* coll = originalDatabase->getCollection( txn, ns );
                if ( coll ) {
                    scoped_ptr<RecordIterator> it( coll->getIterator( txn,
                                                                      DiskLoc(),
                                                                      false,
                                                                      CollectionScanParams::FORWARD ) );
                    while ( !it->isEOF() ) {
                        DiskLoc loc = it->getNext();
                        BSONObj obj = coll->docFor( loc );

                        string ns = obj["name"].String();

                        NamespaceString nss( ns );
                        if ( nss.isSystem() ) {
                            if ( nss.isSystemDotIndexes() )
                                continue;
                            if ( nss.coll() == "system.namespaces" )
                                continue;
                        }

                        if ( !nss.isNormal() )
                            continue;

                        CollectionOptions options;
                        if ( obj["options"].isABSONObj() ) {
                            Status status = options.parse( obj["options"].Obj() );
                            if ( !status.isOK() )
                                return status;
                        }
                        namespacesToCopy[ns] = options;
                    }
                }
            }
//.........这里部分代码省略.........
开发者ID:Benguang,项目名称:mongo,代码行数:101,代码来源:repair_database.cpp

示例15: PushPath

 void PushPath(vector<Point> & OutPath){
     if (LastPath != NULL)
         LastPath->PushPath(OutPath);
     OutPath.push_back(P);
 }
开发者ID:weepingwillowben,项目名称:qtwargame,代码行数:5,代码来源:player.cpp


注:本文中的Path类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。