本文整理汇总了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);
}
示例2: main
int main()
{
SP<A> spa = new A(10);
spa->PrintNum();
copypointer(spa);
spa->PrintNum();
return 0;
}
示例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]);
}
}
}
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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;
}
}
}
}
示例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);
}
示例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;
}
示例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();
}
}
示例12: some_function
void some_function(SP<T> ptr) {
ptr->fn();
}
示例13:
void
CPDUUnbindImpl::ProcessPDUEventOut( SP<PDUEventHandler> EventHandler ){
EventHandler->OnPDUEventHandlerOut ( this );
}
示例14: SmartPointerCache
SmartPointerCache( SP sp ) : CachedResource( sp.getObject() ), sp_( sp )
{}
示例15: addResource
void addResource( SP sp )
{
if( resources_.find( sp.getObject() ) == resources_.end() )
new SmartPointerCache<SP>( sp );
}