void generateRdfTypeInfo(const ontology::Ontology& ontology) { std::ofstream oifs; createFile(RdfsEntity::outdir + "/RdfTypeInfo.h", &oifs); startInternal(oifs); generateCodeProtectorBegin(oifs, "", "RdfTypeInfo"); oifs << "class RdfTypeInfo {" << std::endl; oifs << "public:" << std::endl; indent(oifs, 1) << "RdfTypeInfo();" << std::endl; oifs << std::endl; indent(oifs, 1) << "static const std::map<std::string, std::set<std::string> >& data() { return DATA; }" << std::endl; oifs << "private:" << std::endl; indent(oifs, 1) << "static std::map<std::string, std::set<std::string> > DATA;" << std::endl; oifs << "};" << std::endl; oifs << std::endl; generateCodeProtectorEnd(oifs, "", "RdfTypeInfo"); stopInternal(oifs); std::ofstream ofs; createFile(RdfsEntity::outdir + "/RdfTypeInfo.cpp", &ofs); startInternal(ofs); addBoilerPlate(ofs); ofs << std::endl; ofs << "#include <map>" << std::endl; ofs << "#include <set>" << std::endl; ofs << "#include <string>" << std::endl; ofs << std::endl; if ( RdfsEntity::outdir == ".") { ofs << "#include \"RdfTypeInfo.h\"" << std::endl; } else { ofs << "#include \"" << RdfsEntity::outdir << "/RdfTypeInfo.h\"" << std::endl; } ofs << std::endl; for ( auto const& klassMapItem: ontology.classUri2Ptr()) { const Klass cls(*klassMapItem.second); ofs << "#include \"" << cls.genCppNameSpaceInclusionPath() << "/" << klassMapItem.second->prettyIRIName() << ".h" << "\"" << std::endl; } ofs << std::endl; ofs << "std::map<std::string, std::set<std::string> > RdfTypeInfo::DATA;" << std::endl; ofs << std::endl; ofs << "RdfTypeInfo::RdfTypeInfo() {" << std::endl; indent(ofs, 1) << "if ( DATA.empty() ) {" << std::endl; for ( auto const& klassMapItem: ontology.classUri2Ptr()) { const Klass& cls = *klassMapItem.second; indent(ofs, 2) << "DATA[\"" << klassMapItem.first << "\"] = " << cls.genCppNameSpaceFullyQualified() << "::" << klassMapItem.second->prettyIRIName() << "::ancestorsRdfTypeIRI();" << std::endl; } indent(ofs, 1) << "};" << std::endl; ofs << std::endl; ofs << "}" << std::endl; ofs << std::endl; ofs << "namespace {" << std::endl; ofs << "RdfTypeInfo __loader;" << std::endl; ofs << "}" << std::endl; stopInternal(ofs); }
bool TCPConnection::write(uint8_t *buf, int len) { if (stopped) { return false; } assert(buf); assert(len > 0); boost::shared_array<uint8_t> bufCpy(new uint8_t[len]); memcpy(bufCpy.get(), buf, len); pendingWrites.increment(); beetle.writers.schedule(getId(), [this, bufCpy, len] { uint8_t bufLen = len; if (SSL_write_all(ssl, &bufLen, 1) != 1 || SSL_write_all(ssl, bufCpy.get(), len) != len) { if (debug_socket) { std::stringstream ss; ss << "socket write failed : " << strerror(errno); pdebug(ss.str()); } stopInternal(); } else { if (debug_socket) { pdebug("wrote " + std::to_string(len) + " bytes to " + getName()); phex(bufCpy.get(), len); } } pendingWrites.decrement(); }); return true; }
void RecognitionControl::uninitialize() { kDebug() << "Uninitializing recognition control"; shouldBeRunning = false; recog->uninitialize(); stopInternal(); m_initialized=false; }
/** * stop the play * */ void OpenSLIn::stop(){ J_ASSERT(mState != SLIN_STOP); tryCallBack(WHEN_STOP, 0); mState = SLIN_STOP; stopInternal(); return; }
void AbstractMaemoRunControl::stop() { m_stoppedByUser = true; if (isCleaning()) m_initialCleaner->stop(); else if (isDeploying()) m_sshDeployer->stop(); else stopInternal(); }
OpenSLIn::~OpenSLIn(){ mark(IN_DESTRUTCTOR); // NB! there are may be pure virtual function call // as in stop() function , we will call onCallBack() // so you should call stop before object delete IF_DO(mState != SLIN_STOP, JB_LOGE("openslout should call stop before delete," "leak some event")); IF_DO(mState != SLIN_STOP, stopInternal() ); }
void BbMediaPlayerControl::bpsEventHandler(bps_event_t *event) { if (m_videoControl) m_videoControl->bpsEventHandler(event); if (bps_event_get_domain(event) != mmrenderer_get_domain()) return; if (bps_event_get_code(event) == MMRENDERER_STATE_CHANGE) { const mmrenderer_state_t newState = mmrenderer_event_get_state(event); if (newState == MMR_STOPPED) { // Only react to stop events that happen when the end of the stream is reached and // playback is stopped because of this. // Ignore other stop event sources, souch as calling mmr_stop() ourselves and // mmr_input_attach(). if (m_stopEventsToIgnore > 0) { --m_stopEventsToIgnore; } else { setMediaStatus(QMediaPlayer::EndOfMedia); stopInternal(IgnoreMmRenderer); } return; } } if (bps_event_get_code(event) == MMRENDERER_STATUS_UPDATE) { // Prevent spurious position change events from overriding our own position, for example // when setting the position to 0 in stop(). if (m_state != QMediaPlayer::PlayingState || m_mediaStatus == QMediaPlayer::LoadingMedia || m_mediaStatus == QMediaPlayer::NoMedia || m_mediaStatus == QMediaPlayer::InvalidMedia) return; const qint64 newPosition = QString::fromAscii(mmrenderer_event_get_position(event)).toLongLong(); if (newPosition != 0 && newPosition != m_position) { m_position = newPosition; emit positionChanged(m_position); } const QString bufferStatus = QString::fromAscii(mmrenderer_event_get_bufferlevel(event)); const int slashPos = bufferStatus.indexOf('/'); if (slashPos != -1) { const int fill = bufferStatus.left(slashPos).toInt(); const int capacity = bufferStatus.mid(slashPos + 1).toInt(); if (capacity != 0) { m_bufferStatus = fill / static_cast<float>(capacity) * 100.0f; emit bufferStatusChanged(m_bufferStatus); } } } }
bool RecognitionControl::stop() { kDebug() << "Stopping recognition" << m_startRequests; if (--m_startRequests > 0) return true; if (m_startRequests < 0) m_startRequests = 0; kDebug() << "Stopping recognition: Continuing"; return stopInternal(); }
void StencilShader::stop() { Renderer* r = ARK2D::getRenderer(); if (r->isBatching()) { RendererBatchItem item; item.m_type = RendererBatchItem::TYPE_CUSTOM_OBJECT_FUNCTION; item.m_objectPointer = this; item.m_functionPointer = (void*) &stopStatic; Renderer::s_batch->items.push_back(item); return; } stopInternal(); }
void MmRendererMediaPlayerControl::handleMmStopped() { // Only react to stop events that happen when the end of the stream is reached and // playback is stopped because of this. // Ignore other stop event sources, souch as calling mmr_stop() ourselves and // mmr_input_attach(). if (m_stopEventsToIgnore > 0) { --m_stopEventsToIgnore; } else { setMediaStatus(QMediaPlayer::EndOfMedia); stopInternal(IgnoreMmRenderer); } }
void TCPConnection::startInternal() { beetle.readers.add(sockfd, [this] { if (stopped) { return; } uint8_t buf[256]; uint8_t len; // read length of ATT message int bytesRead = SSL_read(ssl, &len, sizeof(len)); if (bytesRead <= 0) { if (debug_socket) { std::stringstream ss; ss << "socket errno: " << strerror(errno); pdebug(ss.str()); } stopInternal(); } else { assert(bytesRead == 1); if (debug_socket) { pdebug("tcp expecting " + std::to_string(len) + " bytes"); } time_t startTime = time(NULL); struct timeval defaultTimeout; defaultTimeout.tv_sec = 0; defaultTimeout.tv_usec = 100000; fd_set fdSet; FD_ZERO(&fdSet); FD_SET(sockfd, &fdSet); // read payload ATT message bytesRead = 0; while (!stopped && bytesRead < len) { if (difftime(time(NULL), startTime) > TIMEOUT_PAYLOAD) { if (debug_socket) { pdebug("timed out reading payload"); } stopInternal(); break; } int result = SSL_pending(ssl); if (result <= 0) { struct timeval timeout = defaultTimeout; fd_set readFds = fdSet; fd_set exceptFds = fdSet; result = select(sockfd + 1, &readFds, NULL, &exceptFds, &timeout); if (result < 0) { if (debug_socket) { std::stringstream ss; ss << "select failed : " << strerror(errno); pdebug(ss.str()); } stopInternal(); break; } } if (result > 0) { int n = SSL_read(ssl, buf + bytesRead, len - bytesRead); if (n < 0) { if (debug_socket) { std::cerr << "socket errno: " << strerror(errno) << std::endl; } stopInternal(); break; } else { bytesRead += n; } } } if (bytesRead < len) { return; } if (debug_socket) { phex(buf, bytesRead); pdebug("read " + std::to_string(bytesRead) + " bytes from " + getName()); } readHandler(buf, bytesRead); } }); }
bool RecognitionControl::suspend() { bool res = stopInternal(); if (!res) return false; return true; }
void BbMediaPlayerControl::stop() { stopInternal(StopMmRenderer); }
void RemoteInspector::stop() { LockHolder lock(m_mutex); stopInternal(StopSource::API); }