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


C++ SP类代码示例

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


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

示例1: startAdding

void RectTool::startAdding()
{
	auto createNew = [this]()
	{
		SP<AbstractRectLayer> layer;
		
		if (d->addingType == RectTool::AddText)
		{
			auto textLayer = makeSP<TextLayer>();
			textLayer->setText(tr("Text"));
			textLayer->setName(tr("Text"));
			
			layer = textLayer;
			
			QFont font;
			font.setPointSize(36);
			
			layer->setFillBrush(Color::fromRgbValue(0, 0, 0));
			layer->setStrokeBrush(Color::fromRgbValue(0, 0, 0));
			layer->setStrokeEnabled(false);
			textLayer->setFont(font);
		}
		else
		{
			layer = makeSP<RectLayer>();
			
			if (d->addingType == RectTool::AddEllipse)
			{
				layer->setShapeType(AbstractRectLayer::ShapeTypeEllipse);
				layer->setName(tr("Ellipse"));
			}
			else
			{
				layer->setShapeType(AbstractRectLayer::ShapeTypeRect);
				layer->setName(tr("Rectangle"));
			}
			
			layer->setFillBrush(Color::fromRgbValue(0.5, 0.5, 0.5));
			layer->setStrokeBrush(Color::fromRgbValue(0, 0, 0));
		}
		
		return layer;
	};
	
	d->layerToAdd = createNew();
	
	auto current = layerScene()->current();
	if (current)
	{
		d->layerToAddParent = current->parent();
		d->layerToAddIndex = current->index();
	}
	else
	{
		d->layerToAddParent = layerScene()->rootLayer();
		d->layerToAddIndex = 0;
	}
	
	addLayerInsertion(d->layerToAddParent, d->layerToAddIndex, d->layerToAdd);
}
开发者ID:h2so5,项目名称:PaintField,代码行数:60,代码来源:recttool.cpp

示例2: main

int main()
{
    SP<A> spa = new A(10);
    spa->PrintNum();
    copypointer(spa);
    spa->PrintNum();

    return 0;
}
开发者ID:zhouyoulie,项目名称:SmartPointer,代码行数:9,代码来源:main.cpp

示例3: GPASSERT

GPStreamADF::GPStreamADF(const GPFunctionTree* tree)
{
    auto root = tree->root();
    auto rootfunc = root->data().pFunc;
    GPASSERT(NULL!=rootfunc);
    auto lists = root->display();
    std::map<const GPAbstractPoint*, GPPtr<Point>> maplists;
    /*Create All Function*/
    for (auto p : lists)
    {
        auto pp = (GPFunctionTreePoint*)p;
        if (GPFunctionTreePoint::INPUT == pp->type())
        {
            GPPtr<Point> cp = new SP(NULL);
            mSources.push_back(cp);
            mInputPos.push_back(pp->data().iInput);
            maplists.insert(std::make_pair(p, cp));
        }
        else
        {
            GPPtr<Point> cp = new CP(new GPComputePoint(pp->data().pFunc));
            mFunctions.push_back((CP*)(cp.get()));
            maplists.insert(std::make_pair(p, cp));
        }
    }
    /*Dest*/
    auto rootcp = maplists.find(root)->second;
    for (int i=0; i<rootfunc->outputType.size(); ++i)
    {
        GPPtr<Point> dst = (new DP(rootfunc->outputType[i]));
        dst->connectInput(rootcp.get(), 0);
        rootcp->connectOutput(dst, i);
        mDest.push_back(dst);
    }
    /*Connect*/
    for (auto p : lists)
    {
        auto PP = maplists.find(p)->second;
        auto func = ((GPFunctionTreePoint*)p)->data().pFunc;
        size_t n = p->getChildrenNumber();
        GPASSERT(!(NULL!=func && n==0));
        for (int i=0; i<n; ++i)
        {
            auto pc = p->getChild(i);
            auto PC = maplists.find(pc)->second;
            PP->connectInput(PC.get(), i);
            PC->connectOutput(PP, 0);
            if (pc->getChildrenNumber() == 0)
            {
                SP* s = (SP*)PC.get();
                s->setType(func->inputType[i]);
            }
        }
    }
}
开发者ID:geott6758,项目名称:Renascence,代码行数:55,代码来源:GPStreamADF.cpp

示例4: main

int main()
{

    SP<Person> p(new Person("Scott", 25));
    p->Display();
    {
        SP<Person> q = p;
        q->Display();
        // Destructor of Q will be called here..
    }
    p->Display(); //*** Now nO error

    return 0;
}
开发者ID:dipankar08,项目名称:craZyeXp,代码行数:14,代码来源:smartPointer3.cpp

示例5: save_and_load2

void save_and_load2(SP & first, SP & second)
{
    const char * testfile = boost::archive::tmpnam(NULL);
    BOOST_REQUIRE(NULL != testfile);

    save2(testfile, first, second);

    // Clear the pointers, thereby destroying the objects they contain
    first.reset();
    second.reset();

    load2(testfile, first, second);

    BOOST_CHECK(first == second);
    std::remove(testfile);
}
开发者ID:OggYiu,项目名称:rag-engine,代码行数:16,代码来源:test_shared_ptr.cpp

示例6: weak_shared

void weak_shared(
    WP & first,
    SP & second
){
    const char * testfile = boost::archive::tmpnam(NULL);
    BOOST_REQUIRE(NULL != testfile);
    BOOST_CHECK(! first.expired());
    int firstm = first.lock()->m_x;
    int secondm = second->m_x;
    save2(testfile, first, second);

    // Clear the pointers, thereby destroying the objects they contain
    first.reset();
    second.reset();

    load2(testfile, first, second);
    BOOST_CHECK(! first.expired());

    // Check data member
    BOOST_CHECK(firstm == first.lock()->m_x);
    BOOST_CHECK(secondm == second->m_x);
    // Check pointer to vtable
    BOOST_CHECK(::dynamic_pointer_cast<Sub>(first.lock()));
    BOOST_CHECK(::dynamic_pointer_cast<Sub>(second));

    std::remove(testfile);
}
开发者ID:LancelotGHX,项目名称:Simula,代码行数:27,代码来源:test_shared_ptr_multi_base.cpp

示例7: main

void main()
{
	SP p(new StringBuffer("first pointer", 4));

	p->print_String();
	{
		SP q = p;
		q->print_String();

		p.append('a');

		cout << "new refount for p" << p->_refcount;
		SP r = p;
		p->print_String();
	}
	p->print_String();

	getchar();
}
开发者ID:mariahameed,项目名称:Maria-Hameed_05597_Assgn_1,代码行数:19,代码来源:Source.cpp

示例8: qDebug

//EVENT LISTENER
//do not invoke the parents method...
void ObjectWorld::eventRecieved(Event e){

    /*
    QString debug_output =  "Ow  ID: " + QString::number(this->EventTransmitter::id()) +
                            "   Event: " + QString::number(e.type);
    qDebug(debug_output.toUtf8());
    */

    if(e.type == Event::EventCompositeObjectModelLoaded){
        SP<CompositeObject> obj = e.compositeObject->getCompositeObject();
        //dispatch to correct tree
        if(obj->hasLight()){
            debugMessage("light...");
            //add it to the light dynamic tree...
            ot_dynamic_lights->addCompositeObject(obj);
            return;
        }
        else{
            //has no light... but should have a model
            if(obj->getObjectMovementType() == CompositeObject::MovementDynamic){
                debugMessage("dynamic...");
                ot_dynamic_model->addCompositeObject(obj);


                //count_models_out += 1;
                /*
                debugMessage("ObjectWorld : dyn_object in/out:  " +
                             QString::number(count_models_in) + " / " +
                             QString::number(count_models_out) + " ... " +
                             QString::number(obj->getAllListeners().size()));
                */
                return;
            }
            if(obj->getObjectMovementType() == CompositeObject::MovementStatic){
                debugMessage("static...");
                ot->addModel(obj);
                return;
            }
        }
    }
}
开发者ID:AJ92,项目名称:Engine,代码行数:43,代码来源:objectworld.cpp

示例9: save_and_load4

void save_and_load4(SP & spc)
{
    const char * testfile = boost::archive::tmpnam(NULL);
    BOOST_REQUIRE(NULL != testfile);
    save4(testfile, spc);
    SP spc1;
    load4(testfile, spc1);

    BOOST_CHECK(
        (spc.get() == NULL && spc1.get() == NULL)
        || * spc == * spc1
    );
    std::remove(testfile);
}
开发者ID:OggYiu,项目名称:rag-engine,代码行数:14,代码来源:test_shared_ptr.cpp

示例10: LoadFile

bool Wav::LoadFile(const SP &filename)
{
  SDL_RWops *f = SDL_RWFromFile(filename.c_str(), "rb");
  if (f == NULL) {
    SDL_ERROR("SDL_RWFromFile failed");
    return false;
  }

  bool ret = ParseData(f);

  SDL_RWclose(f);

  return ret;
}
开发者ID:iwadon,项目名称:junk,代码行数:14,代码来源:wav.cpp

示例11: setOriginalLayer

		void setOriginalLayer(const LayerConstRef &layer)
		{
			original = layer;
			
			auto originalRectLayer = dynamicSPCast<const AbstractRectLayer>(layer);
			if (originalRectLayer)
			{
				rectLayer = staticSPCast<AbstractRectLayer>(layer->clone());
				originalRectPos = rectLayer->rect().topLeft();
			}
			
			auto rasterLayer = dynamicSPCast<const RasterLayer>(layer);
			if (rasterLayer)
			{
				rasterBoundingRect = rasterLayer->surface().boundingRect();
				rasterOffset = QPoint();
			}
		}
开发者ID:h2so5,项目名称:PaintField,代码行数:18,代码来源:recttool.cpp

示例12: some_function

void some_function(SP<T> ptr) {
	ptr->fn();
}
开发者ID:prashkothawade,项目名称:CppIntQue,代码行数:3,代码来源:SmartPtr.cpp

示例13:

void
CPDUUnbindImpl::ProcessPDUEventOut( SP<PDUEventHandler> EventHandler ){
EventHandler->OnPDUEventHandlerOut ( this );
}
开发者ID:Hubbitus,项目名称:HuSMPP.exe,代码行数:4,代码来源:PDUUnbind.cpp

示例14: SmartPointerCache

	SmartPointerCache( SP sp ) : CachedResource( sp.getObject() ), sp_( sp )
	{}
开发者ID:siredblood,项目名称:tree-bumpkin-project,代码行数:2,代码来源:resource_cache.hpp

示例15: addResource

	void addResource( SP sp )
	{
		if( resources_.find( sp.getObject() ) == resources_.end() )
			new SmartPointerCache<SP>( sp );
	}
开发者ID:siredblood,项目名称:tree-bumpkin-project,代码行数:5,代码来源:resource_cache.hpp


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