void main() { clrscr(); char ans; do { char option; float b,h,a,area; cout<<"Of which geometrical figure do you want to find out the area? "; cout<<'\n'; cout<<"Rectangle, square, circle, triangle, parallelogram(r,s,c,t,p): "; cin>>option; switch(option) { case 'r': case 'R':cout<<"Enter the value of base and height: "; cin>>b>>h; area=rtp(b,h); cout<<"Area= "<<area<<" units"<<'\n'; break; case 's': case 'S':cout<<"Enter the side of the square: "; cin>>a; area=cirsqr(a); cout<<"Area= "<<area<<" units"<<'\n'; break; case 'C': case 'c':cout<<"Enter the radius of the circle: "; cin>>a; area=3.14*cirsqr(a); cout<<"Area= "<<area<<" units"<<'\n'; break; case 't': case 'T':cout<<"Enter the value of the base and the height of the triangle: "; cin>>b>>h; area=(0.5)*(rtp(b,h)); cout<<"Area= "<<area<<" units"<<'\n'; break; case 'p': case 'P':cout<<"Enter the value of the base and the height: "; cin>>b>>h; area=rtp(b,h); cout<<"Area= "<<area<<" unit"<<'\n'; break; } cout<<endl<<endl<<endl; cout<<"Do you want to continue once more? "; cin>>ans; } while(ans=='y'||ans=='Y'); }
sk_sp<GrRenderTargetContext> GrDrawingManager::makeRenderTargetContext( sk_sp<GrSurfaceProxy> sProxy, sk_sp<SkColorSpace> colorSpace, const SkSurfaceProps* surfaceProps, bool managedOpList) { if (this->wasAbandoned() || !sProxy->asRenderTargetProxy()) { return nullptr; } // SkSurface catches bad color space usage at creation. This check handles anything that slips // by, including internal usage. if (!SkSurface_Gpu::Valid(fContext, sProxy->config(), colorSpace.get())) { SkDEBUGFAIL("Invalid config and colorspace combination"); return nullptr; } sk_sp<GrRenderTargetProxy> rtp(sk_ref_sp(sProxy->asRenderTargetProxy())); return sk_sp<GrRenderTargetContext>(new GrRenderTargetContext( fContext, this, std::move(rtp), std::move(colorSpace), surfaceProps, fContext->contextPriv().getAuditTrail(), fSingleOwner, managedOpList)); }
RDOResType BlockForQueue::createType(const std::string& rtp_name, const parser::RDOParserSrcInfo& info) { // "длина_очереди" const std::string rtp_param_name = rdo::runtime::RDOPROCQueue::getQueueParamName(); // значение длины очереди по умолчанию parser::LPRDOValue pDefaultValue = rdo::Factory<parser::RDOValue>::create( rdo::explicit_value<std::size_t>(rdo::runtime::RDOPROCQueue::getDefaultValue()), info ); ASSERT(pDefaultValue); // Получили список всех типов ресурсов RDOResTypeList rtpList(parser::RDOParser::s_parser()); // Создадим тип ресурса RDOResType rtp(rtp_name); // Создадим параметр типа integer RDOResType::Param param(rtp_param_name, rdo::Factory<parser::RDOType__int>::create(), pDefaultValue); rtp.m_params.append(param); // Добавим тип ресурса if (!rtpList.append(rtp)) { parser::RDOParser::s_parser()->error().error(info, rdo::format("Ошибка создания типа ресурса: %s", rtp_name.c_str())); } else { parser::LPRDORTPResType pResType = parser::RDOParser::s_parser()->findRTPResType(rtp_name); ASSERT(pResType); pResType->setSubtype(parser::RDORTPResType::RT_PROCESS_RESOURCE); } return rtp; }
void RenderOperationDesc:: test() { // The RenderOperationDesc class should keep the filter operation used by a // render target and notify the render target about processing events. { RenderOperationDesc* rod; RenderOperationDescMockTarget* target; OperationDesc::ptr operation( new Test::TransparentOperationDesc() ); RenderTarget::ptr rtp(target = new RenderOperationDescMockTarget()); Signal::OperationDesc::ptr ro(rod = new RenderOperationDesc(operation, rtp)); Signal::Operation::ptr o = ro.write ()->createOperation(0); // Operations are processed through a Processing::Step Processing::Step step(ro); step.deprecateCache (Interval(4,9)); o->process (pBuffer()); EXCEPTION_ASSERT_EQUALS( Interval(4,9), target->I ); EXCEPTION_ASSERT_EQUALS( 1, target->processed_count ); EXCEPTION_ASSERT_EQUALS( (void*)0, rod->transform_desc ().get () ); } }
RDOResType BlockForSeize::createType(const std::string& rtp_name, const parser::RDOParserSrcInfo& info) { // "Состояние" const std::string rtp_param_name = rdo::runtime::RDOPROCBlockForSeize::getStateParamName(); // "Свободен" const std::string rtp_state_free = rdo::runtime::RDOPROCBlockForSeize::getStateEnumFree(); parser::LPRDOValue pDefaultValue = rdo::Factory<parser::RDOValue>::create( rdo::explicit_value<std::string>(rtp_state_free), info ); ASSERT(pDefaultValue); pDefaultValue->setSrcText(rtp_state_free); // "Занят" const std::string rtp_state_buzy = rdo::runtime::RDOPROCBlockForSeize::getStateEnumBuzy(); // Получили список всех типов ресурсов RDOResTypeList rtpList(parser::RDOParser::s_parser()); // Создадим тип ресурса RDOResType rtp(rtp_name); // Создадим параметр перечислимого типа - "Состояние" RDOResType::Param param( rtp_param_name, rdo::runtime::RDOEnumType::Enums(rtp_state_free)(rtp_state_buzy), pDefaultValue ); rtp.m_params.append(param); // Добавим тип ресурса if (!rtpList.append(rtp)) { parser::RDOParser::s_parser()->error().error(info, rdo::format("Ошибка создания типа ресурса: %s", rtp_name.c_str())); } else { parser::LPRDORTPResType pResType = parser::RDOParser::s_parser()->findRTPResType(rtp_name); ASSERT(pResType); pResType->setSubtype(parser::RDORTPResType::RT_PROCESS_RESOURCE); } return rtp; }
RTP::Session & Session::createSession(const Url &url, const Channel::Description & remote, const boost::optional< TSSrc > & ssrc ) throw( RTSP::Exception::ManagedError ) { try { Session::Lock lk( *this ); // setup channel boost::shared_ptr< Channel::Bi > rtpChan, rtcpChan; TPortPair local; // udp if ( remote.type == Channel::Owned ) { local = Port::Udp::getInstance()->getPair(); Log::debug("%s: creating udp socket locally bound to %d / %d", getLogName(), local.first, local.second ); auto_ptr< KGD::Socket::Udp > rtp( new KGD::Socket::Udp( local.first, url.host ) ), rtcp( new KGD::Socket::Udp( local.second, url.host ) ); Log::debug("%s: connecting udp socket to remote %d / %d", getLogName(), remote.ports.first, remote.ports.second); try { rtp->connectTo( remote.ports.first, url.remoteHost ); rtcp->connectTo( remote.ports.second, url.remoteHost ); } catch( const KGD::Socket::Exception & e ) { Log::debug( "%s: socket error: %s", getLogName(), e.what() ); throw RTSP::Exception::ManagedError( Error::UnsupportedTransport ); } rtp->setWriteTimeout( KGD::Socket::WRITE_TIMEOUT ); rtcp->setWriteTimeout( KGD::Socket::WRITE_TIMEOUT ); rtcp->setReadBlock( true ); rtcp->setReadTimeout( RTCP::Receiver::POLL_INTERVAL ); rtpChan = rtp; rtcpChan = rtcp; } // tcp interleaved else { Socket & rtsp = _conn.getSocket(); local = rtsp.addInterleavePair( remote.ports, _id ); rtpChan = rtsp.getInterleave( local.first ); rtcpChan = rtsp.getInterleave( local.second ); rtcpChan->setReadTimeout( RTCP::Receiver::POLL_INTERVAL ); } // get description int mediumIndex = fromString< int >( url.track ); SDP::Medium::Base & med = _conn.getDescription( url.file ).getMedium( mediumIndex ); // create session auto_ptr< RTP::Session > s( new RTP::Session( *this, url, med, rtpChan, rtcpChan, _conn.getUserAgent() ) ); if ( ssrc ) s->setSsrc( *ssrc ); // temp to return RTP::Session * sPtr = s.get(); // add to basket { string tmpTrack( url.track ); _sessions.insert( tmpTrack, s ); } Log::debug("%s: RTP session created / track: %s / ports: RTP %d %d - RTCP %d %d" , getLogName() , url.track.c_str() , local.first , remote.ports.first , local.second , remote.ports.second ); return *sPtr; } catch( const KGD::Socket::Exception & e ) { Log::debug( "%s: socket error: %s", getLogName(), e.what() ); throw RTSP::Exception::ManagedError( Error::InternalServerError ); } // no more ports catch( const KGD::Exception::NotFound & e ) { Log::debug( "%s: %s", getLogName(), e.what() ); throw RTSP::Exception::ManagedError( Error::NotEnoughBandwidth ); } }
void CetonStreamHandler::run(void) { RunProlog(); bool _error = false; QFile file(_device_path); CetonRTP rtp(_ip_address, _tuner); if (_using_rtp) { if (!(rtp.Init() && rtp.StartStreaming())) { LOG(VB_RECORD, LOG_ERR, LOC + "Starting recording (RTP initialization failed). Aborting."); _error = true; } } else { if (!file.open(QIODevice::ReadOnly)) { LOG(VB_RECORD, LOG_ERR, LOC + "Starting recording (file open failed). Aborting."); _error = true; } int flags = fcntl(file.handle(), F_GETFL, 0); if (flags == -1) flags = 0; fcntl(file.handle(), F_SETFL, flags | O_NONBLOCK); } if (_error) { RunEpilog(); return; } SetRunning(true, false, false); int buffer_size = (64 * 1024); // read about 64KB buffer_size /= TSPacket::kSize; buffer_size *= TSPacket::kSize; char *buffer = new char[buffer_size]; LOG(VB_RECORD, LOG_INFO, LOC + "RunTS(): begin"); _read_timer.start(); int remainder = 0; while (_running_desired && !_error) { int bytes_read; if (_using_rtp) bytes_read = rtp.Read(buffer, buffer_size); else bytes_read = file.read(buffer, buffer_size); if (bytes_read <= 0) { if (_read_timer.elapsed() >= 5000) { LOG(VB_RECORD, LOG_WARNING, LOC + "No data received for 5 seconds...checking tuning"); if (!VerifyTuning()) RepeatTuning(); _read_timer.start(); } usleep(5000); continue; } _read_timer.start(); _listener_lock.lock(); if (_stream_data_list.empty()) { _listener_lock.unlock(); continue; } StreamDataList::const_iterator sit = _stream_data_list.begin(); for (; sit != _stream_data_list.end(); ++sit) remainder = sit.key()->ProcessData( reinterpret_cast<unsigned char*>(buffer), bytes_read); _listener_lock.unlock(); if (remainder != 0) { LOG(VB_RECORD, LOG_INFO, LOC + QString("RunTS(): bytes_read = %1 remainder = %2") .arg(bytes_read).arg(remainder)); } } LOG(VB_RECORD, LOG_INFO, LOC + "RunTS(): " + "shutdown"); if (_using_rtp) rtp.StopStreaming(); else file.close(); delete[] buffer; LOG(VB_RECORD, LOG_INFO, LOC + "RunTS(): " + "end"); SetRunning(false, false, false); RunEpilog(); }
/* * CTxtEdit::InsertObject * * @mfunc inserts a new object */ STDMETHODIMP CTxtEdit::InsertObject( REOBJECT * preobj) //@parm object info { CTxtSelection *psel; CObjectMgr *pobjmgr; COleObject *pobj = NULL; DWORD cp; CCallMgr callmgr(this); CGenUndoBuilder undobldr(this, UB_AUTOCOMMIT); CRchTxtPtr rtp(this, 0); WCHAR ch = WCH_EMBEDDING; HRESULT hr; CNotifyMgr * pnm; // For notifying of changes LONG iFormat = -1; TRACEBEGIN(TRCSUBSYSOLE, TRCSCOPEEXTERN, "CTxtEdit::InsertObject"); // do some boundary case checking if( !preobj ) { return E_INVALIDARG; } psel = GetSel(); if( !psel ) { return E_OUTOFMEMORY; } // if the insertion of this character would cause // us to exceed the text limit, fail if( GetAdjustedTextLength() + 1 > TxGetMaxLength() ) { // if we're not replacing a selection (or the // selection is degenerate, then we will have exceeded // our limit if( preobj->cp != REO_CP_SELECTION || psel->GetCch() == 0) { GetCallMgr()->SetMaxText(); return E_OUTOFMEMORY; } } pobjmgr = GetObjectMgr(); if( pobjmgr ) { LONG selectRange = 0; undobldr.StopGroupTyping(); if( preobj->cp == REO_CP_SELECTION ) { LONG a, b; selectRange = psel->GetRange(a, b); cp = psel->GetCpMin(); iFormat = psel->Get_iCF(); HandleSelectionAEInfo(this, &undobldr, cp, psel->GetCch(), cp + 1, 0, SELAE_FORCEREPLACE); } else { cp = preobj->cp; } rtp.SetCp(cp); rtp.ReplaceRange(selectRange, 1, &ch, &undobldr, iFormat); //Don't want object selected. psel->SetSelection(cp+1, cp+1); hr = pobjmgr->InsertObject(cp, preobj, &undobldr); pobj = (COleObject *)(preobj->polesite); pobj->EnableGuardPosRect(); if (pnm = GetNotifyMgr()) // Get the notification mgr { pnm->NotifyPostReplaceRange(NULL, // Notify interested parties INFINITE, 0, 0, cp, cp + 1); // of the change. } pobj->DisableGuardPosRect(); ReleaseFormats(iFormat, -1); TxUpdateWindow(); return hr; } return E_OUTOFMEMORY; }
PetscVector<Number> assemble_coupled_rhs (EquationSystems& es,Tree& tree, Mesh& mesh) { std::cout<< "Assembling big rhs " <<std::endl; TransientLinearImplicitSystem & system = es.add_system<TransientLinearImplicitSystem> ("Newton-update"); NumericVector< Number > &solution_in= *(system.solution); NumericVector< Number > &rhs_in = *(system.rhs); Number size_mat = system.rhs->size(); Real size_t=tree.number_nodes+tree.number_edges; //Sort out rhs - put into big vector Vec x; VecCreate(PETSC_COMM_WORLD,&x); PetscObjectSetName((PetscObject) x, "Solution"); VecSetSizes(x,PETSC_DECIDE,size_mat); VecSetFromOptions(x); PetscVector<Number> xp(x) ; xp.add(1,solution_in); Vec r; VecCreate(PETSC_COMM_WORLD,&r); PetscObjectSetName((PetscObject) r, "rhs"); VecSetSizes(r,PETSC_DECIDE,size_mat); VecSetFromOptions(r); PetscVector<Number> rp(r) ; rp.add(1,rhs_in); Vec rt; rt=tree.make_tree_rhs( ); PetscVector<Number> rtp(rt) ; Vec big_r; VecCreate(PETSC_COMM_WORLD,&big_r); PetscObjectSetName((PetscObject) big_r, "big_rhs"); VecSetSizes(big_r,PETSC_DECIDE,size_mat+size_t); //VecSetSizes(big_r,PETSC_DECIDE,size_mat); VecSetFromOptions(big_r); // add system.rhs into big_rp for (int i=0; i<size_mat; i++) { //if(abs(rhs_in(i))>0){ VecSetValue(big_r,i,rp(i),INSERT_VALUES); //} } // add extra tree rhs entries should all be 0 if p0=0 for (int i=size_mat; i<size_mat+size_t; i++) { VecSetValue(big_r, i , rtp(i-size_mat) ,INSERT_VALUES); } PetscVector<Number> big_rp(big_r) ; return big_rp; }