const std::string WObject::id() const { std::string result = objectName(); if (!result.empty()) return result + '_' + uniqueId(); else return uniqueId(); }
GameStorage::GameStorage(QObject *parent) : QObject(parent) { srand(time(0)); QSettings settings; this->m_uniqueId = settings.value("uniqueId", rand()).toInt(); settings.setValue("uniqueId", uniqueId()); setProfileName(settings.value("profileName", QString("Player %1").arg(uniqueId())).toString()); setAvatarId(settings.value("avatarId", QString("gomoku.jpg")).toString()); }
void QmlMetadata::setIsFavorite(bool isFavorite) { m_isFavorite = isFavorite; if (!uniqueId().isEmpty()) { if (isFavorite) { Settings.setFilterFavorite(uniqueId(), "yes"); } else { Settings.setFilterFavorite(uniqueId(), "no"); } } emit changed(); }
// PD_TRACE_DECLARE_FUNCTION ( SDB_RTNLOCALLOBSTREAM__LOCK, "_rtnLocalLobStream::_lock" ) INT32 _rtnLocalLobStream::_lock( _pmdEDUCB *cb, INT64 offset, INT64 length ) { INT32 rc = SDB_OK ; BOOLEAN locked = TRUE ; PD_TRACE_ENTRY( SDB_RTNLOCALLOBSTREAM__LOCK ) ; if ( -1 == uniqueId() ) { rc = SDB_SYS ; PD_LOG( PDERROR, "invalid unique id, rc=%d", rc ) ; goto error ; } if ( SDB_LOB_MODE_WRITE != _getMode() ) { rc = SDB_SYS ; PD_LOG( PDERROR, "LOB can only be locked in write mode, rc=%d", rc ) ; goto error ; } SDB_ASSERT( NULL != _accessInfo, "_accessInfo is null" ) ; _accessInfo->lock() ; locked = TRUE ; rc = _accessInfo->lockSection( _rtnLobSection( offset, length, uniqueId() ) ) ; if ( SDB_OK != rc ) { PD_LOG( PDERROR, "Failed to lock section[%lld, %lld, %lld], rc=%d", offset, length, uniqueId(), rc ) ; goto error ; } _accessInfo->unlock() ; locked = FALSE ; done: if ( locked ) { _accessInfo->unlock() ; locked = FALSE ; } PD_TRACE_EXITRC( SDB_RTNLOCALLOBSTREAM__LOCK, rc ) ; return rc ; error: goto done ; }
// PD_TRACE_DECLARE_FUNCTION ( SDB_RTNLOCALLOBSTREAM__GETACCESSPRIVILEGE, "_rtnLocalLobStream::_getAccessPrivilege" ) INT32 _rtnLocalLobStream::_getAccessPrivilege( const CHAR *fullName, const bson::OID &oid, INT32 mode ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY( SDB_RTNLOCALLOBSTREAM__GETACCESSPRIVILEGE ) ; for ( INT32 i = 0 ; i < RTN_LOB_ACCESS_PRIVILEGE_RETRY_TIMES ; i++ ) { rc = sdbGetRTNCB()->getLobAccessManager()->getAccessPrivilege( fullName, oid, mode, uniqueId(), SDB_LOB_MODE_WRITE == mode ? &_accessInfo : NULL ) ; if ( SDB_OK == rc ) { _hasLobPrivilege = TRUE ; break ; } else if ( SDB_LOB_IS_IN_USE == rc ) { ossSleepmillis( RTN_LOB_ACCESS_PRIVILEGE_RETRY_INTERVAL ) ; continue ; } else { PD_LOG( PDERROR, "Failed to get lob privilege:%d", rc ) ; goto error ; } } done: PD_TRACE_EXITRC( SDB_RTNLOCALLOBSTREAM__GETACCESSPRIVILEGE, rc ) ; return rc ; error: goto done ; }
void MerchantCamel::timeStep(const unsigned long time) { if( !_d->inCaravan ) { auto caravanHead = _city()->statistic().walkers .find<LandMerchant>( walker::merchant, _d->headId ); if( !caravanHead.isValid() ) { die(); Logger::warning( "!!! MerchantCamel havenot headID caravan {}", _d->headId ); } else { caravanHead->addCamel( this ); _d->inCaravan = true; } } if( _d->headLocation == TilePos::invalid() ) { return; } if( _d->headLocation.distanceFrom( pos() ) < 1 * (uniqueId() - _d->headId) ) { return; } Human::timeStep( time ); }
// We can use this function to set the Layer to point to surface texture. void VideoLayerAndroid::setSurfaceTexture(sp<SurfaceTexture> texture, int textureName, PlayerState playerState) { m_surfaceTexture = texture; m_playerState = playerState; TilesManager::instance()->videoLayerManager()->registerTexture(uniqueId(), textureName); }
QstProtocol::QstProtocol(QObject *parent) : QTcpSocket(parent) , tx_msg_id(1) , port(0) , onData_busy(false) , enable_reconnect(false) , reconnect_interval(10000) , last_data_received(false) , connection_valid(false) , debug_on(false) , m_auto_unpack(true) { static int id1 = qRegisterMetaType<QstMessage>(); Q_UNUSED(id1); static int id2 = qRegisterMetaType<QstMessage*>(); Q_UNUSED(id2); static int id3 = qRegisterMetaType<const QstMessage*>(); Q_UNUSED(id3); unique_id = QString::number(++g_unique_id); if (debug_on) { qDebug() << QString("%1 QstProtocol::QstProtocol()").arg(uniqueId()).toLatin1(); } cur_message = 0; rx_busy = false; QObject::connect( &connect_timer, SIGNAL(timeout()), this, SLOT(connectTimeout()), Qt::DirectConnection ); QObject::connect( this,SIGNAL(connected()),this,SLOT(onSocketConnected()), Qt::DirectConnection ); QObject::connect( this,SIGNAL(disconnected()),this,SLOT(onSocketClosed()), Qt::DirectConnection ); QObject::connect( this,SIGNAL(readyRead()),this,SLOT(onData()), Qt::DirectConnection ); // initialize. Any time is better than no time. rx_timer.start(); }
Thread::Thread(): _id(uniqueId()), _name(makeName()), _pTLS(0), _event(true) { }
void BlockBuilder::makeBlocks() { /** uses the base class GraphBuilder to work out which elements are connected (a subGraph) Each subGraph will be used to make a new PFBlock */ for (auto& elementIds : m_subGraphs) { if (elementIds.size() > 1) { sortIds(elementIds); // TODO allow sorting by energy using a helper class } auto block = PFBlock(elementIds, m_edges); // make the block PDebug::write("Made {}", block); // put the block in the unordered map of blocks using move IdType id = block.uniqueId(); m_blocks.emplace(id, std::move(block)); // update the history nodes (if they exist) if (m_historyNodes.size() > 0) { // make a new history node for the block and add into the history Nodes m_historyNodes.emplace(id, std::move(PFNode(id))); // move auto storedBlocknode = m_historyNodes[id]; // add in the links between the block elements and the block for (auto elemid : m_blocks[id].elementIds()) { m_historyNodes[elemid].addChild(storedBlocknode); } } } }
Thread::Thread(const std::string& name): _id(uniqueId()), _name(name), _pTLS(0), _event(true) { }
void Substrate::initializeCanvas() { m_image.fill(255, 255, 255); m_cracks.clear(); // make random crack seeds m_gridData.clear(); m_gridData.resize(m_image.width()*m_image.height(), GridData(UNCRACKED, UNCRACKED, NO_SHAPE)); for(uint k = 0; k < m_numInitialCracks; k++) { int c = m_image.width()/2; //randInt(0, m_image.width()); int r = m_image.height()/2; //randInt(0, m_image.height()); m_crackedPixels.push_back(r*m_image.width() + c); m_gridData[r*m_image.width() + c].angle = randInt(0, 360); m_gridData[r*m_image.width() + c].objectId = uniqueId(); } // make initial cracks m_curvedPercentage = 1.0f; for(uint k = 0; k < m_numInitialCracks; ++k) makeCrack(); // no more circles m_curvedPercentage = 0.0f; }
// We can use this function to set the Layer to point to surface texture. //AndroidJB4.3 Merge - START //void VideoLayerAndroid::setSurfaceTexture(sp<SurfaceTexture> texture, //Removed in 4.3 Merge void VideoLayerAndroid::setSurfaceTexture(sp<GLConsumer> texture, //AndroidJB4.3 Merge - END int textureName, PlayerState playerState) { m_surfaceTexture = texture; m_playerState = playerState; TilesManager::instance()->videoLayerManager()->registerTexture(uniqueId(), textureName); }
void Association::writeXml(QXmlStreamWriter& writer) const { writer.writeStartElement("Association"); writer.writeAttribute("id", uniqueId()); writer.writeAttribute("source", source()->uniqueId()); writer.writeAttribute("target", target()->uniqueId()); writer.writeAttribute("aggregation", toString(aggregation())); writer.writeEndElement(); }
void QmlMetadata::loadSettings() { //Override the default favorite setting if it has been set by the user. QString favorite = Settings.filterFavorite(uniqueId()); if (favorite == "yes") { m_isFavorite = true; } else if (favorite == "no") { m_isFavorite = false; } }
void LayerAndroid::mergeInvalsInto(LayerAndroid* replacementTree) { int count = this->countChildren(); for (int i = 0; i < count; i++) this->getChild(i)->mergeInvalsInto(replacementTree); LayerAndroid* replacementLayer = replacementTree->findById(uniqueId()); if (replacementLayer) replacementLayer->markAsDirty(m_dirtyRegion); }
void LayerAndroid::contentDraw(SkCanvas* canvas, PaintStyle style) { if (m_maskLayer && m_maskLayer->m_content) { // TODO: we should use a shader instead of doing // the masking in software if (m_originalLayer) m_originalLayer->m_content->draw(canvas); else if (m_content) m_content->draw(canvas); SkPaint maskPaint; maskPaint.setXfermodeMode(SkXfermode::kDstIn_Mode); int count = canvas->saveLayer(0, &maskPaint, SkCanvas::kHasAlphaLayer_SaveFlag); m_maskLayer->m_content->draw(canvas); canvas->restoreToCount(count); } else if (m_content) m_content->draw(canvas); if (TilesManager::instance()->getShowVisualIndicator()) { float w = getSize().width(); float h = getSize().height(); SkPaint paint; if (style == MergedLayers) paint.setARGB(255, 255, 255, 0); else if (style == UnmergedLayers) paint.setARGB(255, 255, 0, 0); else if (style == FlattenedLayers) paint.setARGB(255, 255, 0, 255); canvas->drawLine(0, 0, w, h, paint); canvas->drawLine(0, h, w, 0, paint); canvas->drawLine(0, 0, 0, h-1, paint); canvas->drawLine(0, h-1, w-1, h-1, paint); canvas->drawLine(w-1, h-1, w-1, 0, paint); canvas->drawLine(w-1, 0, 0, 0, paint); static SkTypeface* s_typeface = 0; if (!s_typeface) s_typeface = SkTypeface::CreateFromName("", SkTypeface::kBold); paint.setARGB(255, 0, 0, 255); paint.setTextSize(17); char str[256]; snprintf(str, 256, "%d", uniqueId()); paint.setTypeface(s_typeface); canvas->drawText(str, strlen(str), 2, h - 2, paint); } if (m_fixedPosition) return m_fixedPosition->contentDraw(canvas, style); }
void QstProtocol::testConnection() { if (debug_on) { qDebug() << QString("%1 QstProtocol::testConnection()").arg(uniqueId()).toLatin1(); } while (send_msg_replies.count() > 0) delete send_msg_replies.takeFirst(); postMessage( QstMessage(QLatin1String("QTEST_NEW_CONNECTION")) ); }
void QstProtocol::enableReconnect( bool enable, uint reconnectInterval ) { if (debug_on) { qDebug() << ( QString("%1 QstProtocol::enableReconnect( enable=%2, interval=%3)"). arg(uniqueId()). arg(enable). arg(reconnectInterval).toLatin1()); } enable_reconnect = enable; reconnect_interval = reconnectInterval; }
void QstProtocol::setSocket( int socket ) { if (debug_on) { qDebug() << ( QString("%1 QstProtocol::setSocket(socket=%2)"). arg(uniqueId()). arg(socket).toLatin1()); } setSocketDescriptor( socket ); rx_timer.start(); testConnection(); }
bool QstProtocol::waitForConnected( int timeout ) { QTime t; t.start(); bool ok = false; QTime t2; t2.start(); while (t.elapsed() < timeout && !ok) { ok = QTcpSocket::waitForConnected(timeout); if (!ok) { wait(100); if (t2.elapsed() > 1000) { t2.start(); reconnect(); } } } if (ok) { if (debug_on) { qDebug() << QString("%1 QstProtocol::waitForConnected(%2, %3) ...") .arg(uniqueId()).arg(timeout).arg(stateStr()).toLatin1(); } t2.start(); while (t.elapsed() < timeout && !isConnected()) { wait(10); if (!isConnected() && t2.elapsed() > 500) { postMessage( QstMessage(QLatin1String("QTEST_NEW_CONNECTION")) ); t2.start(); } } ok = isConnected(); } if (debug_on) { qDebug() << QString("%1 QstProtocol::waitForConnected() ... %2 (%3 ms)").arg(uniqueId()).arg(ok ? "OK" : "FAILED" ).arg(t.elapsed()).toLatin1(); if (!ok) qDebug() << errorStr(); } return ok; }
uint QstProtocol::postMessage(const QstMessage &message ) { if (debug_on && message.event() != QLatin1String("PING") && message.event() != QLatin1String("PONG")) { qDebug() << ( QString("%1 QstProtocol::postMessage(%2)"). arg(uniqueId()). arg(message.event()).toLatin1()); } if (state() != ConnectedState) return 0; QstMessage msg(message); msg.m_msg_id = tx_msg_id++; send( msg ); return msg.m_msg_id; }
PlaylistItem::PlaylistItem( const MetaBundle &bundle, QListViewItem *lvi, bool enabled ) : MetaBundle( bundle ), KListViewItem( lvi->listView(), lvi->itemAbove() ) , m_album( 0 ) , m_deleteAfterEdit( false ) , m_isBeingRenamed( false ) , m_isNew( true ) { setDragEnabled( true ); Playlist::instance()->m_urlIndex.add( this ); if( !uniqueId().isEmpty() ) Playlist::instance()->addToUniqueMap( uniqueId(), this ); refAlbum(); incrementCounts(); incrementLengths(); filter( listView()->m_filter ); listView()->countChanged(); setAllCriteriaEnabled( enabled ); }
void Brush::restore(const Brush& brushTemplate, bool checkId) { if (checkId) assert(uniqueId() == brushTemplate.uniqueId()); Utility::deleteAll(m_faces); const FaceList templateFaces = brushTemplate.faces(); for (size_t i = 0; i < templateFaces.size(); i++) { Face* face = new Face(m_worldBounds, m_forceIntegerFacePoints, *templateFaces[i]); face->setBrush(this); m_faces.push_back(face); } rebuildGeometry(); }
SkRect VideoLayerAndroid::calVideoRect(const SkRect& rect) { SkRect videoRect = rect; VideoLayerManager* manager = TilesManager::instance()->videoLayerManager(); float aspectRatio = manager->getAspectRatio(uniqueId()); float deltaY = rect.height() - rect.width() / aspectRatio; if (deltaY >= 0) videoRect.inset(0, deltaY / 2); else { float deltaX = rect.width() - rect.height() * aspectRatio; if (deltaX >= 0) videoRect.inset(deltaX / 2, 0); } return videoRect; }
/** * Loads the back links for this object from the passed data section. * * @param pSection The data section to load the backlinks from. */ void EditorChunkItemLinkable::loadBackLinks(DataSectionPtr pSection) { backLinks_.clear(); DataSectionPtr backLinksSection = pSection->openSection( "backLinks", true ); std::vector<DataSectionPtr> linkSects; backLinksSection->openSections( "link", linkSects ); for (uint i = 0; i < linkSects.size(); ++i) { DataSectionPtr ds = linkSects[i]; UniqueID uniqueId( ds->readString( "guid" ) ); std::string chunkId = ds->readString( "chunkId" ); backLinks_.insert(Link(uniqueId, chunkId)); } }
QstProtocol::~QstProtocol() { if (debug_on) { qDebug() << QString("%1 QstProtocol::~QstProtocol()").arg(uniqueId()).toLatin1(); } enableReconnect( false, 0 ); // anything that is still in the tx buffer gets lost abort(); close(); while (send_msg_replies.count() > 0) delete send_msg_replies.takeFirst(); while (unhandled_msg.count() > 0) delete unhandled_msg.takeFirst(); }
void QstProtocol::disconnect( bool disableReconnect ) { if (state() == ConnectedState) { if (debug_on) { qDebug() << ( QString("%1 QstProtocol::disconnect(disableReconnect=%2)"). arg(uniqueId()). arg(disableReconnect).toLatin1()); } // be polite and tell the other side we are closing postMessage( QstMessage("QTEST_CLOSING_CONNECTION") ); // we are closing ourselves, so we don't want to reconnect if (disableReconnect) enable_reconnect = false; onSocketClosed(); } }
CanvasLayer::CanvasLayer(RenderLayer* owner, HTMLCanvasElement* canvas) : LayerAndroid(owner) , m_canvas(canvas) , m_dirtyCanvas() , m_bitmap(0) { init(); m_canvas->addObserver(this); m_gpuCanvas = new CanvasLayerAndroid(); int canvasId = uniqueId(); m_gpuCanvas->setCanvasID(canvasId); m_canvas->setCanvasId(canvasId); // Make sure we initialize in case the canvas has already been laid out canvasResized(m_canvas); MutexLocker locker(s_mutex); CanvasLayer::setGpuCanvas(m_gpuCanvas, this); }
void MachineModel::addRegisterFile(const std::string& name, unsigned int registers) { auto file = _registerFiles.insert(std::make_pair(name, RegisterFile(this, name))).first; for(unsigned int i = 0; i < registers; ++i) { file->second.registers.push_back(PhysicalRegister(&file->second, i, _idToRegisters.size() + i, makeRegisterName(file->second, i))); } for(auto reg = file->second.registers.begin(); reg != file->second.registers.end(); ++reg) { _idToRegisters.insert(std::make_pair(reg->uniqueId(), &*reg)); } }