IContent* ContentManager::load(const String& name) { IContent* presult = NULL; String path = name + UTEXT(".c2d"); path.toLower(); File* pfile = FileSystem::getInstance().open(path, File::ERead | File::EBinary); if ( pfile != NULL ) { Uuid uuid; FileReaderStream stream(*pfile); uuid.read(stream); ContentModule* pmodule = findModule(uuid); if ( pmodule != NULL ) { ContentReader& reader = pmodule->getReader(); reader.setContentManager(*this); reader.setGraphicsDevice(mpDevice); reader.setPhysicsSimulator(mpSimulator); reader.setSoundManager(mpSoundManager); presult = reader.read(stream); if ( presult != NULL ) { presult->setFilename(name); } } } return presult; }
SI_SymbolPin::SI_SymbolPin(SI_Symbol& symbol, const Uuid& pinUuid) : SI_Base(), mCircuit(symbol.getSchematic().getProject().getCircuit()), mSymbol(symbol), mSymbolPin(nullptr), mComponentSignal(nullptr), mPinSignalMapItem(nullptr), mComponentSignalInstance(nullptr), mAddedToSchematic(false), mRegisteredNetPoint(nullptr), mGraphicsItem(nullptr) { // read attributes mSymbolPin = mSymbol.getLibSymbol().getPinByUuid(pinUuid); if (!mSymbolPin) { throw RuntimeError(__FILE__, __LINE__, pinUuid.toStr(), QString(tr("Invalid symbol pin UUID: \"%1\"")).arg(pinUuid.toStr())); } mPinSignalMapItem = mSymbol.getCompSymbVarItem().getPinSignalMapItemOfPin(pinUuid); if (!mPinSignalMapItem) { throw RuntimeError(__FILE__, __LINE__, QString(), QString(tr("Pin \"%1\" not found in pin-signal-map of symbol instance \"%2\".")) .arg(pinUuid.toStr(), symbol.getUuid().toStr())); } Uuid cmpSignalUuid = mPinSignalMapItem->getSignalUuid(); mComponentSignalInstance = mSymbol.getComponentInstance().getSignalInstance(cmpSignalUuid); mComponentSignal = mSymbol.getComponentInstance().getLibComponent().getSignalByUuid(cmpSignalUuid); mGraphicsItem = new SGI_SymbolPin(*this); updatePosition(); // create ERC messages mErcMsgUnconnectedRequiredPin.reset(new ErcMsg(mCircuit.getProject(), *this, QString("%1/%2").arg(mSymbol.getUuid().toStr()).arg(mSymbolPin->getUuid().toStr()), "UnconnectedRequiredPin", ErcMsg::ErcMsgType_t::SchematicError)); updateErcMessages(); }
static void test_uuid(Config & conf) { Uuid guid; guid.generate(); std::cout << guid.to_string() << std::endl; }
TEST(UuidTest, Clear) { Uuid uuid = Uuid::GenerateUuid(); EXPECT_FALSE(uuid.IsNull()); uuid.Clear(); EXPECT_TRUE(uuid.IsNull()); }
void CtrlrMIDILibrary::setCurrentProgram(const Uuid &uuid, const MidiProgramChangeControl midiProgramChangeControl, const bool changePanelState, const bool setAsCurrentProgram) { ValueTree program = getCurrentBank().getChildWithProperty(Ids::uuid, uuid.toString()); if (isProgram(program)) setCurrentProgram (program, midiProgramChangeControl, changePanelState, setAsCurrentProgram); else _WRN("CtrlrMIDILibrary::setCurrentProgram no program with UUID="+uuid.toString()); }
void CtrlrMIDILibrary::setCurrentSnapshot(const Uuid &uuid, const MidiProgramChangeControl midiProgramChangeControl) { ValueTree snap = getSnapshots().getChildWithProperty(Ids::uuid, uuid.toString()); if (isProgram(snap)) setCurrentSnapshot (snap,midiProgramChangeControl); else _WRN("CtrlrMIDILibrary::setCurrentSnapshot no snapshot with UUID="+uuid.toString()); }
void CtrlrMIDILibrary::setCurrentBank(const Uuid &uuid) { _DBG("CtrlrMIDILibrary::setCurrentBank uuid="+uuid.toString()); if (uuid == getUuid(getRoot())) { setCurrentBank (getRoot()); return; } setCurrentBank (getRoot().getChildWithProperty(Ids::uuid, uuid.toString())); }
string Store::to_str(const Uuid & uuid) { // 8-4-4-4-12 stringstream stream; convert_to_hex(stream, uuid.most_significant_bits()); convert_to_hex(stream, uuid.least_significant_bits()); string result( stream.str() ); for (int i=0; i<4; i++) { result.insert(8 + (i * 4) + i, 1, '-'); } return result; }
TEST(UuidTest, ToString) { Uuid uuid = Uuid::GenerateUuid(); EXPECT_FALSE(uuid.IsNull()); std::string uuidString = uuid.ToString(); EXPECT_FALSE(uuidString.empty()); std::string testUuid("5100b3be-d2d5-4ff3-b655-9e1bb9b7e3b0"); Uuid uuid2(testUuid); EXPECT_FALSE(uuid2.IsNull()); std::string uuid2String = uuid2.ToString(); EXPECT_EQ(uuid2String, testUuid); }
void checkNewVersion(const Uuid& uuid, const std::string& extraParams, CheckUpdateDelegate* delegate) { using namespace base; using namespace net; std::string url = UPDATE_URL; if (!uuid.empty()) { url += "&uuid="; url += uuid; } if (!extraParams.empty()) { url += "&"; url += extraParams; } HttpRequest request(url); HttpHeaders headers; headers.setHeader("User-Agent", getUserAgent()); request.setHeaders(headers); std::stringstream body; HttpResponse response(&body); request.send(response); CheckUpdateResponse data(body.str()); delegate->onResponse(data); }
bool checkNewVersion(const Uuid& uuid, const std::string& extraParams, CheckUpdateDelegate* delegate) { #ifndef UPDATE_URL #define UPDATE_URL "" #pragma message("warning: Define UPDATE_URL macro") #endif std::string url = UPDATE_URL; if (!uuid.empty()) { url += "&uuid="; url += uuid; } if (!extraParams.empty()) { url += "&"; url += extraParams; } m_request.reset(new net::HttpRequest(url)); net::HttpHeaders headers; headers.setHeader("User-Agent", getUserAgent()); m_request->setHeaders(headers); std::stringstream body; net::HttpResponse response(&body); if (m_request->send(response)) { TRACE("Checking updates: %s (User-Agent: %s)\n", url.c_str(), getUserAgent().c_str()); TRACE("Response:\n--\n%s--\n", body.str().c_str()); CheckUpdateResponse data(body.str()); delegate->onResponse(data); return true; } else return false; }
void LasHeader::put(OLeStream& out, Uuid uuid) { char buf[uuid.size]; uuid.pack(buf); out.put(buf, uuid.size); }
void checkNewVersion(const Uuid& uuid, const std::string& extraParams, CheckUpdateDelegate* delegate) { using namespace base; using namespace net; #ifndef UPDATE_URL #define UPDATE_URL "" #endif #pragma message("warning: Define UPDATE_URL macro") std::string url = UPDATE_URL; if (!uuid.empty()) { url += "&uuid="; url += uuid; } if (!extraParams.empty()) { url += "&"; url += extraParams; } HttpRequest request(url); HttpHeaders headers; headers.setHeader("User-Agent", getUserAgent()); request.setHeaders(headers); std::stringstream body; HttpResponse response(&body); request.send(response); TRACE("Checking updates: %s (User-Agent: %s)\n", url.c_str(), getUserAgent().c_str()); TRACE("Response:\n--\n%s--\n", body.str().c_str()); CheckUpdateResponse data(body.str()); delegate->onResponse(data); }
void LasHeader::get(ILeStream& in, Uuid& uuid) { char buf[uuid.size]; in.get(buf, uuid.size); uuid.unpack(buf); }
ComponentSignalInstance::ComponentSignalInstance(Circuit& circuit, ComponentInstance& cmpInstance, const XmlDomElement& domElement) throw (Exception) : QObject(nullptr), mCircuit(circuit), mComponentInstance(cmpInstance), mComponentSignal(nullptr), mNetSignal(nullptr), mAddedToCircuit(false) { // read attributes Uuid compSignalUuid = domElement.getAttribute<Uuid>("comp_signal", true); mComponentSignal = mComponentInstance.getLibComponent().getSignalByUuid(compSignalUuid); if(!mComponentSignal) { throw RuntimeError(__FILE__, __LINE__, compSignalUuid.toStr(), QString( tr("Invalid component signal UUID: \"%1\"")).arg(compSignalUuid.toStr())); } Uuid netsignalUuid = domElement.getAttribute<Uuid>("netsignal", false, Uuid()); if (!netsignalUuid.isNull()) { mNetSignal = mCircuit.getNetSignalByUuid(netsignalUuid); if(!mNetSignal) { throw RuntimeError(__FILE__, __LINE__, netsignalUuid.toStr(), QString(tr("Invalid netsignal UUID: \"%1\"")).arg(netsignalUuid.toStr())); } } init(); }
void Entry::setIcon(const Uuid& uuid) { Q_ASSERT(!uuid.isNull()); if (m_data.customIcon != uuid) { m_data.customIcon = uuid; m_data.iconNumber = 0; Q_EMIT modified(); emitDataChanged(); } }
void Metadata::addCustomIcon(const Uuid& uuid, const QImage& icon) { Q_ASSERT(!uuid.isNull()); Q_ASSERT(!m_customIcons.contains(uuid)); m_customIcons.insert(uuid, icon); // reset cache in case there is also an icon with that uuid m_customIconCacheKeys[uuid] = QPixmapCache::Key(); m_customIconScaledCacheKeys[uuid] = QPixmapCache::Key(); m_customIconsOrder.append(uuid); Q_ASSERT(m_customIcons.count() == m_customIconsOrder.count()); Q_EMIT modified(); }
void Group::setIcon(const Uuid& uuid) { Q_ASSERT(!uuid.isNull()); if (m_data.customIcon != uuid) { m_data.customIcon = uuid; m_data.iconNumber = 0; updateTimeinfo(); Q_EMIT modified(); Q_EMIT dataChanged(this); } }
bool VideoCaptureDeviceImpl::setCurrentVideoFormat( const RGBVideoFormat& videoFormat) { if (!isInitialized()) { return false; } if (!videoFormat) { return false; } if (!stopCapturing()) { return false; } const Uuid videoFormatUuid(videoFormat.uuid()); if (videoFormatUuid.is_nil()) { return false; } VideoFormatConstIterator iterator( m_videoFormatsByUuid.find(videoFormatUuid)); if (iterator == m_videoFormatsByUuid.end()) { return false; } const UuidVideoFormatPair uuidVideoFormatPair(*iterator); const VideoFormatSharedPtr pVideoFormat(uuidVideoFormatPair.second); if (!pVideoFormat) { return false; } m_currentVideoFormatUuid = uuidVideoFormatPair.first; if (!pVideoFormat->setMediaTypeOfStream(m_pStreamConfig)) { return false; } return true; }
void Metadata::removeCustomIcon(const Uuid& uuid) { Q_ASSERT(!uuid.isNull()); Q_ASSERT(m_customIcons.contains(uuid)); m_customIcons.remove(uuid); QPixmapCache::remove(m_customIconCacheKeys.value(uuid)); m_customIconCacheKeys.remove(uuid); QPixmapCache::remove(m_customIconScaledCacheKeys.value(uuid)); m_customIconScaledCacheKeys.remove(uuid); m_customIconsOrder.removeAll(uuid); Q_ASSERT(m_customIcons.count() == m_customIconsOrder.count()); Q_EMIT modified(); }
Uuid ConverterDb::getOrCreateUuid(const QString& cat, const QString& key1, const QString& key2) { QString allowedChars( "_-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); QString settingsKey = mLibFilePath.getFilename() % '_' % key1 % '_' % key2; settingsKey.replace("{", ""); settingsKey.replace("}", ""); settingsKey.replace(" ", "_"); for (int i = 0; i < settingsKey.length(); i++) { if (!allowedChars.contains(settingsKey[i])) settingsKey.replace( i, 1, QString("__U%1__").arg( QString::number(settingsKey[i].unicode(), 16).toUpper())); } settingsKey.prepend(cat % '/'); Uuid uuid = Uuid::createRandom(); QString value = mIniFile.value(settingsKey).toString(); if (!value.isEmpty()) uuid = Uuid::fromString(value); // can throw mIniFile.setValue(settingsKey, uuid.toStr()); return uuid; }
QSet<Uuid> Library::getDevicesOfComponent(const Uuid& component) const throw (Exception) { QSqlQuery query = prepareQuery( "SELECT uuid, filepath FROM devices WHERE component_uuid = :uuid"); query.bindValue(":uuid", component.toStr()); execQuery(query, false); QSet<Uuid> elements; while (query.next()) { QString uuidStr = query.value(0).toString(); Uuid uuid(uuidStr); if (!uuid.isNull()) elements.insert(uuid); else qWarning() << "Invalid element in library: devices::" << uuid; } return elements; }
void CDspIOCtClientHandler::handleToDispatcherPackage ( const IOSender::Handle& h, const SmartPtr<IOPackage>& p ) { if ( p->header.type == PET_IO_CLI_AUTHENTICATE_EXEC_SESSION ) { const PRL_IO_AUTH_EXEC_REQUEST *authRequest = reinterpret_cast<const PRL_IO_AUTH_EXEC_REQUEST*>( p->buffers[0].getImpl() ); if ( p->data[0].bufferSize < sizeof(*authRequest) ) { WRITE_TRACE(DBG_FATAL, "Wrong auth session package!"); CDspService::instance()->getIOServer().disconnectClient( h ); return; } Uuid sessionId = Uuid::toUuid( authRequest->sessionUuid ); if ( sessionId.isNull() ) { WRITE_TRACE(DBG_FATAL, "Wrong auth session package!"); CDspService::instance()->getIOServer().disconnectClient( h ); return; } // Try to find client by auth session SmartPtr<CDspClient> client = CDspService::instance()-> getClientManager().getUserSession( sessionId.toString() ); bool auth = client.isValid(); PRL_IO_AUTH_RESPONSE authResp = { auth }; SmartPtr<IOPackage> pkg = IOPackage::createInstance( PET_IO_AUTH_RESPONSE, IOPackage::RawEncoding, &authResp, sizeof(authResp) ); // Save result QMutexLocker locker( &m_mutex ); ClientInfo cliInfo; m_ioClients[h] = cliInfo; locker.unlock(); // Send package IOSendJob::Handle job = CDspService::instance()->getIOServer().sendPackage( h, pkg ); IOSendJob::Result res = CDspService::instance()->getIOServer().waitForSend( job ); // Close connection if fail if ( ! auth || res != IOSendJob::Success ) { WRITE_TRACE(DBG_FATAL, "Error: %s", (! auth ? "authentication failed!" : "send of authentication pkg failed!")); CDspService::instance()->getIOServer().disconnectClient( h ); } return; } else if (p->header.type == PET_IO_STDIN_PORTION || p->header.type == PET_IO_STDIN_WAS_CLOSED || p->header.type == PET_IO_CLIENT_PROCESSED_ALL_DESCS_DATA) { if (!getIOUserSession(h)) { WRITE_TRACE(DBG_FATAL, "Client '%s' is not authed! Close connection!", QSTR2UTF8(h)); CDspService::instance()->getIOServer().disconnectClient( h ); return; } SmartPtr<CDspCtResponseHandler> hResponse = getResponseHandler(h, Uuid::toString(p->header.parentUuid)); if (!hResponse) { WRITE_TRACE(DBG_FATAL, "Client %s guest session %s is not created pkt.type=%d", QSTR2UTF8(h), QSTR2UTF8((Uuid::toString(p->header.parentUuid))), p->header.type); CDspService::instance()->getIOServer().disconnectClient( h ); return; } hResponse->process(p); } }
inline bool operator>=(const Uuid &lhs, const Uuid &rhs) noexcept { return BComp(lhs.GetBytes(), rhs.GetBytes()) >= 0; }
inline void swap(Uuid &lhs, Uuid &rhs) noexcept { lhs.Swap(rhs); }
/// writes Uuid void WriteUuid(const Uuid& uuid) { WriteBlock(uuid.Raw(), 16); }
void XmlDomElement::setAttribute(const QString& name, const Uuid& value) noexcept { setAttribute<QString>(name, value.isNull() ? "" : value.toStr()); }
void XmlDomElement::setText<Uuid>(const Uuid& value) noexcept { setText(value.toStr()); }
ValueTree CtrlrMIDILibrary::getProgram(const Uuid &bankUuid, const Uuid &programUuid) { return (getBank(bankUuid).getChildWithProperty(Ids::uuid, programUuid.toString())); }
ValueTree CtrlrMIDILibrary::getSnapshot(const Uuid &snapshotUuid) { return (getSnapshots().getChildWithProperty(Ids::uuid, snapshotUuid.toString())); }