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); }
int main() { SP<A> spa = new A(10); spa->PrintNum(); copypointer(spa); spa->PrintNum(); return 0; }
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]); } } } }
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; }
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); }
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); }
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(); }
//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; } } } }
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); }
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; }
void get_setup_params() { int res; if(sp.state_connect != 0) { QString er_id, er_str; WareReferenceErrorText(55, er_str, er_id); InterfaceErrorWin(er_str, er_id); } else if((res = sp.Get_All_Param()) != 0) { ////printf("state in main = %d\n", res); QString er_id, er_str; WareReferenceErrorText(56, er_str, er_id); InterfaceErrorWin(er_str, er_id); } }
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(); } }
//======================================================================// void get_setup_params() { int res; if(sp.state_connect != 0) { QString er_id, er_str; RegistrationErrorText(78, er_str, er_id); InterfaceErrorWin(er_str, er_id); } else if((res = sp.Get_All_Param()) != 0) { //printf("state in main = %d\n", res); QString er_id, er_str; RegistrationErrorText(79, er_str, er_id); InterfaceErrorWin(er_str, er_id); } QTextCodec * DSPCodec = QTextCodec::codecForName(HWCODEC); UpStr = DBCodec->toUnicode(sp.cdsp_up_not_work); UpStr = DSPCodec->fromUnicode(UpStr); DownStr = DBCodec->toUnicode(sp.cdsp_down_not_work); DownStr = DSPCodec->fromUnicode(DownStr); }
void some_function(SP<T> ptr) { ptr->fn(); }
void CPDUUnbindImpl::ProcessPDUEventOut( SP<PDUEventHandler> EventHandler ){ EventHandler->OnPDUEventHandlerOut ( this ); }
SmartPointerCache( SP sp ) : CachedResource( sp.getObject() ), sp_( sp ) {}
void addResource( SP sp ) { if( resources_.find( sp.getObject() ) == resources_.end() ) new SmartPointerCache<SP>( sp ); }
bool operator()(SP<SquareObject> s) { return s->isPassable(); }
bool operator()(SP<SquareObject> s) { return s->blocksLight(); }
void release() { object = (T*) 0; if (object_lock) object_lock->unlock(); };
int main( int argc, char ** argv ) { QApplication a( argc, argv ); puts("`````````````````````````````````````````````````"); printf("RESHKA MAIN PROCESS ID - %d\n", getpid()); printf("VERSION: %s\n", PROGRAMM_VERSION); puts("`````````````````````````````````````````````````"); startHW(); get_setup_params(); hw->DSP_Up(UpStr); hw->DSP_Down(DownStr); init_keyboard_device(&a); bool flag = auth_request(false); if ( flag ) { cfw = new mainmenuForm; cfw->setWindowState(Qt::WindowNoState); cfw->setWindowState(Qt::WindowFullScreen); //printf("Authorization::GetInstance()->GetUserName() = %s \n", Authorization::GetInstance()->GetUserName()); cfw->textLabel2->setText(DBCodec->toUnicode((Authorization::GetInstance()->GetUserName()))); applyRights(); while ( true ) { puts("------Main Menu------"); cfw->setWindowState(Qt::WindowNoState); cfw->setWindowState(Qt::WindowFullScreen); cfw->exec(); //printf("Selected point = %d \n", cfw->focus_num); cfw->releaseKeyboard(); if ( cfw->exec_flag ) { switch(cfw->focus_num) { case 0 : printf("--------lincash-------\n"); delete (hw); ExecProgram(REG_PATH, REG_NAME, uid);//, REG_NAME); ///-------------------------23/10 16.41--------------- cfw->grabKeyboard(); //---(+)---Zuskin---27/02/2012--- sp.ReloadSections(); //------------------------------- startHW(); hw->DSP_Up(UpStr); hw->DSP_Down(DownStr); break; case 1 : printf("-------service-----\n"); //delete (hw); //QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) ); //ExecProgram(SERVICE_PATH, SERVICE_NAME, uid);//, SERVICE_NAME); StartService(); cfw->exec_flag = false; cfw->grabKeyboard(); //QApplication::restoreOverrideCursor(); //startHW(); hw->DSP_Up(UpStr); hw->DSP_Down(DownStr); break; case 2 : printf("-------accessrights-------\n"); delete (hw); //printf("RIGHTS_PATH = %s \n", RIGHTS_PATH); ExecProgram(RIGHTS_PATH);//, RIGHTS_NAME); Authorization::GetInstance()->GetRights(Authorization::GetInstance()->GetUid()); applyRights(); cfw->grabKeyboard(); startHW(); hw->DSP_Up(UpStr); hw->DSP_Down(DownStr); break; case 3 : printf("--------ware------\n"); delete (hw); ExecProgram(WARE_PATH);//, SETUP_NAME); cfw->grabKeyboard(); startHW(); hw->DSP_Up(UpStr); hw->DSP_Down(DownStr); break; case 4 : printf("-------programsetup-----\n"); StartSetup(); cfw->grabKeyboard(); get_setup_params(); cfw->exec_flag = false; hw->DSP_Up(UpStr); hw->DSP_Down(DownStr); break; case 5 : printf("--------devicesetup-------\n"); if ( kbcode_scaner != NULL ) { delete (kbcode_scaner); kbcode_scaner = NULL; } if ( kbcode_reader != NULL ) { delete (kbcode_reader); kbcode_reader = NULL; } delete (hw); ExecProgram(DCONF_PATH);//, DCONF_NAME); cfw->grabKeyboard(); startHW(); init_keyboard_device(&a); hw->DSP_Up(UpStr); hw->DSP_Down(DownStr); break; case 6 : printf("--------setuploadunload------\n"); delete (hw); ExecProgram(EXCH_PATH);//, EXCH_NAME); cfw->grabKeyboard(); startHW(); hw->DSP_Up(UpStr); hw->DSP_Down(DownStr); break; case 7 : printf("-------changeuser------\n"); bool auth = auth_request(true); while ( !auth ) auth = auth_request(true); cfw->grabKeyboard(); cfw->exec_flag = false; cfw->textLabel2->setText(DBCodec->toUnicode((Authorization::GetInstance()->GetUserName()))); applyRights(); break; } cfw->exec_flag = false; } else break; } delete(cfw); } if ( kbcode_scaner != NULL ) delete (kbcode_scaner); if ( kbcode_reader != NULL ) delete (kbcode_reader); if ( hw != NULL ) delete (hw); puts("END OF RESHKA"); return 0; }
void CPDUUnknownImpl::ProcessPDUEventIn( SP<PDUEventHandler> EventHandler ){ EventHandler->OnPDUEventHandlerIn ( this ); }