Id InterpreterEditorManager::element(Id const &id, qrRepo::RepoApi const * const repo, Id const &diagram) const { foreach (Id const &element, repo->children(diagram)) { if (id.element() == repo->name(element) && repo->isLogicalElement(element)) { return element; } } return Id(); }
/** * @brief Add a table to streamer. * * @param table Id of table. */ void Streamer::addTable( Id table ) { // If this table is not already in the vector, add it. for( size_t i = 0; i < tableIds_.size(); i++) if( table.path() == tableIds_[i].path() ) return; /* Already added. */ Table* t = reinterpret_cast<Table*>(table.eref().data()); tableIds_.push_back( table ); tables_.push_back( t ); tableTick_.push_back( table.element()->getTick() ); // NOTE: If user can make sure that names are unique in table, using name is // better than using the full path. if( t->getColumnName().size() > 0 ) columns_.push_back( t->getColumnName( ) ); else columns_.push_back( moose::moosePathToUserPath( table.path() ) ); }
vector< Id > HSolve::children( Id obj ) { //~ return Field< vector< Id > >::get( obj, "children" ); //~ return Field< vector< Id > >::fastGet( obj.eref(), "children" ); //~ return localGet< Neutral, vector< Id > >( obj.eref(), "children" ); vector< Id > c; Neutral::children( obj.eref(), c ); return c; }
RelayForwarder::RelayForwarder(const Id &local_id, const ConnectionTable &ct, const QSharedPointer<RpcHandler> &rpc) : _local_id(local_id), _base_been(local_id.ToString()), _ct(ct), _rpc(rpc), _cache(4096) { _rpc->Register("RF::Data", this, "IncomingData"); }
void HSolve::setSeed( Id seed ) { if ( !seed()->cinfo()->isA( "Compartment" ) ) { cerr << "Error: HSolve::setSeed(): Seed object '" << seed.path() << "' is not derived from type 'Compartment'." << endl; return; } seed_ = seed; }
virtual QStringList callMethod( EditorManagerInterface *editorManagerInterface , const Id &editorId , const Id &diagramId , const Id &elementId , const QString &propertyName ) const { Q_UNUSED(elementId); Q_UNUSED(propertyName); const QString &editorName = editorId.editor(); const QString &diagramName = diagramId.diagram(); mResult = callFunction([editorManagerInterface, editorName, diagramName]() { return editorManagerInterface->diagramNodeName(editorName, diagramName); }); return ConvertingMethods::convertStringIntoStringList( editorManagerInterface->diagramNodeName(editorName, diagramName)); }
void RelayForwarder::Send(const QSharedPointer<Connection> &con, const Id &to, const QByteArray &data, const QStringList &been, const QStringList &reverse) { QVariantHash msg; msg["to"] = to.ToString(); msg["data"] = data; msg["been"] = been + _base_been; if(!reverse.isEmpty()) { msg["reverse"] = reverse; } qDebug() << con->GetLocalId().ToString() << "Forwarding message from" << msg["been"].toStringList().value(0) << "to" << to.ToString() << "via" << con->GetRemoteId().ToString() << "Reverse path" << !reverse.isEmpty(); _rpc->SendNotification(con, "RF::Data", msg); }
void VisualDebuggerPlugin::activeTabChanged(Id const &rootElementId) { bool const enabled = rootElementId.diagram() == blockDiagram; foreach (ActionInfo const &actionInfo, mActionInfos) { if (actionInfo.isAction()) { actionInfo.action()->setEnabled(enabled); } else { actionInfo.menu()->setEnabled(enabled); } } }
void HHChannel2D::innerDestroyGate( const string& gateName, HHGate2D** gatePtr, Id chanId ) { if ( *gatePtr == 0 ) { cout << "Warning: HHChannel2D::destroyGate: '" << gateName << "' on Element '" << chanId.path() << "' not present\n"; return; } delete (*gatePtr); *gatePtr = 0; }
void HHChannel2D::innerCreateGate( const string& gateName, HHGate2D** gatePtr, Id chanId, Id gateId ) { //Shell* shell = reinterpret_cast< Shell* >( ObjId( Id(), 0 ).data() ); if ( *gatePtr ) { cout << "Warning: HHChannel2D::createGate: '" << gateName << "' on Element '" << chanId.path() << "' already present\n"; return; } *gatePtr = new HHGate2D( chanId, gateId ); }
void ShuffleRound::HandleShuffle(QDataStream &stream, const Id &id) { qDebug() << _group.GetIndex(_local_id) << _local_id.ToString() << ": received shuffle data from " << _group.GetIndex(id) << id.ToString(); if(_state != WaitingForShuffle) { qWarning() << "Received a shuffle message while in state " << StateToString(_state) << " from " << id.ToString(); return; } if(_group.Previous(_local_id) != id) { qWarning() << "Received shuffle out of order from " << id.ToString(); return; } stream >> _shuffle_data; Shuffle(); }
Element::Element( Id id, const Cinfo* c, const string& name ) : name_( name ), id_( id ), cinfo_( c ), msgBinding_( c->numBindIndex() ), msgDigest_( c->numBindIndex() ), isRewired_( false ), isDoomed_( false ) { id.bindIdToElement( this ); }
Id Subprograms::graphicalId(Id const &logicalId) const { IdList const graphicalIds = mRepo.graphicalElements(logicalId.type()); foreach (Id const &id, graphicalIds) { if (mRepo.logicalId(id) == logicalId) { return id; } } return Id(); }
void ActionManagerPrivate::saveSettings(QSettings *settings) { settings->beginWriteArray(QLatin1String(settingsGroup)); int count = 0; const IdCmdMap::const_iterator cmdcend = m_idCmdMap.constEnd(); for (IdCmdMap::const_iterator j = m_idCmdMap.constBegin(); j != cmdcend; ++j) { const Id id = j.key(); CommandPrivate *cmd = j.value(); QKeySequence key = cmd->keySequence(); if (key != cmd->defaultKeySequence()) { settings->setArrayIndex(count); settings->setValue(QLatin1String(idKey), id.toString()); settings->setValue(QLatin1String(sequenceKey), key.toString()); count++; } } settings->endArray(); }
void Ksolve::setDsolve( Id dsolve ) { if ( dsolve == Id () ) { dsolvePtr_ = 0; dsolve_ = Id(); } else if ( dsolve.element()->cinfo()->isA( "Dsolve" ) ) { dsolve_ = dsolve; dsolvePtr_ = reinterpret_cast< ZombiePoolInterface* >( dsolve.eref().data() ); } else { cout << "Warning: Ksolve::setDsolve: Object '" << dsolve.path() << "' should be class Dsolve, is: " << dsolve.element()->cinfo()->name() << endl; } }
HRESULT XMLHelper::GetAttributeId(MSXML2::IXMLDOMNode *node, const TCHAR *attr, Id &id) { BSTR bstr = 0; HRESULT hr = GetAttribute(node, attr, &bstr); if(hr == S_OK && bstr) { id.AssignHex(bstr); SysFreeString(bstr); } return hr; }
void Client::setProperty(const Id &id, const QString &name, const QVariant &value ) { if (mObjects.contains(id)) { Q_ASSERT(mObjects[id]->hasProperty(name) ? mObjects[id]->property(name).userType() == value.userType() : true); mObjects[id]->setProperty(name, value); } else { throw Exception("Client: Setting property of nonexistent object " + id.toString()); } }
// See what Element::getNeighbors does with 2 sub <----> prd. void testTwoReacGetNeighbors() { Shell* shell = reinterpret_cast< Shell* >( Id().eref().data() ); Id comptId = shell->doCreate( "CubeMesh", Id(), "cube", 1 ); Id meshId( comptId.value() + 1 ); Id subId = shell->doCreate( "Pool", comptId, "sub", 1 ); Id prdId = shell->doCreate( "Pool", comptId, "prd", 1 ); Id reacId = shell->doCreate( "Reac", comptId, "reac", 1 ); ObjId mid = shell->doAddMsg( "OneToOne", subId, "requestVolume", meshId, "get_volume" ); assert( mid != ObjId() ); mid = shell->doAddMsg( "OneToOne", prdId, "requestVolume", meshId, "get_volume" ); assert( mid != ObjId() ); ObjId ret = shell->doAddMsg( "Single", reacId, "sub", subId, "reac" ); assert( ret != ObjId() ); ret = shell->doAddMsg( "Single", reacId, "sub", subId, "reac" ); assert( ret != ObjId() ); ret = shell->doAddMsg( "Single", reacId, "prd", prdId, "reac" ); assert( ret != ObjId() ); vector< Id > pools; unsigned int num = reacId.element()->getNeighbors( pools, Reac::initCinfo()->findFinfo( "toSub" ) ); assert( num == 2 ); assert( pools[0] == subId ); assert( pools[1] == subId ); pools.clear(); num = reacId.element()->getNeighbors( pools, Reac::initCinfo()->findFinfo( "sub" ) ); assert( num == 2 ); assert( pools[0] == subId ); assert( pools[1] == subId ); shell->doDelete( comptId ); cout << "." << flush; }
Subprograms::GenerationResult Subprograms::generate(ControlFlowGeneratorBase *mainGenerator , const QString &indentString) { QMap<Id, QString> declarations; QMap<Id, QString> implementations; Id toGen = firstToGenerate(); while (toGen != Id()) { mDiscoveredSubprograms[toGen] = true; const Id graphicalDiagramId = graphicalId(toGen); if (graphicalDiagramId.isNull()) { mErrorReporter.addError(QObject::tr("Graphical diagram instance not found")); return GenerationResult::fatalError; } const QString rawIdentifier = mRepo.name(toGen); const QString identifier = mNameNormalizer->convert(rawIdentifier); if (!checkIdentifier(identifier, rawIdentifier)) { return GenerationResult::fatalError; } ControlFlowGeneratorBase *generator = mainGenerator->cloneFor(graphicalDiagramId, true); auto readableGenerator = dynamic_cast<ReadableControlFlowGenerator *>(generator); semantics::SemanticTree *controlFlow = generator->generate(Id(), "@@unknown@@"); if (!controlFlow || (readableGenerator && readableGenerator->cantBeGeneratedIntoStructuredCode())) { return GenerationResult::error; } implementations[toGen] = controlFlow->toString(1, indentString); const QString forwardDeclaration = readSubprogramTemplate(toGen, "subprograms/forwardDeclaration.t"); declarations[toGen] = forwardDeclaration; toGen = firstToGenerate(); } obtainCode(declarations, implementations); return GenerationResult::success; }
void SteadyState::setStoich( Id value ) { if ( !value.element()->cinfo()->isA( "Stoich" ) ) { cout << "Error: SteadyState::setStoich: Must be of Stoich class\n"; return; } stoich_ = value; Stoich* stoichPtr = reinterpret_cast< Stoich* >( value.eref().data()); numVarPools_ = Field< unsigned int >::get( stoich_, "numVarPools" ); nReacs_ = Field< unsigned int >::get( stoich_, "numRates" ); setupSSmatrix(); double vol = LookupField< unsigned int, double >::get( stoichPtr->getCompartment(), "oneVoxelVolume", 0 ); pool_.setVolume( vol ); pool_.setStoich( stoichPtr, 0 ); pool_.updateAllRateTerms( stoichPtr->getRateTerms(), stoichPtr->getNumCoreRates() ); isInitialized_ = 1; }
Id Id::loadFromString(QString const &string) { QStringList path = string.split('/'); Q_ASSERT(path.count() > 0 && path.count() <= 5); Q_ASSERT(path[0] == "qrm:"); Id result; switch (path.count()) { case 5: result.mId = path[4]; // Fall-thru case 4: result.mElement = path[3]; // Fall-thru case 3: result.mDiagram = path[2]; // Fall-thru case 2: result.mEditor = path[1]; // Fall-thru } Q_ASSERT(string == result.toString()); Q_ASSERT(string == result.toUrl().toString()); return result; }
void SigNeur::buildTree( Id soma, const vector< Id >& compts ) { const Finfo* axialFinfo; const Finfo* raxialFinfo; if ( soma.eref().e->cinfo() == initSymCompartmentCinfo() ) { axialFinfo = initSymCompartmentCinfo()->findFinfo( "raxial1" ); raxialFinfo = initSymCompartmentCinfo()->findFinfo( "raxial2" ); } else { axialFinfo = initCompartmentCinfo()->findFinfo( "axial" ); raxialFinfo = initCompartmentCinfo()->findFinfo( "raxial" ); } assert( axialFinfo != 0 ); assert( raxialFinfo != 0 ); // Soma may be in middle of messaging structure for cell, so we need // to traverse both ways. But nothing below soma should // change direction in the traversal. innerBuildTree( 0, soma.eref(), soma.eref(), axialFinfo->msg(), raxialFinfo->msg() ); // innerBuildTree( 0, soma.eref(), soma.eref(), raxialFinfo->msg() ); }
void Repository::setProperty(const Id &id, const QString &name, const QVariant &value ) const { if (mObjects.contains(id)) { // see Object::property() for details // Q_ASSERT(mObjects[id]->hasProperty(name) // ? mObjects[id]->property(name).userType() == value.userType() // : true); mObjects[id]->setProperty(name, value); } else { throw Exception("Repository: Setting property of nonexistent object " + id.toString()); } }
QString Serializer::pathToElement(const Id &id) const { QString dirName = mWorkingDir; QStringList partsList = id.toString().split('/'); Q_ASSERT(partsList.size() >=1 && partsList.size() <= 5); for (int i = 1; i < partsList.size() - 1; ++i) { dirName += "/" + partsList[i]; } return dirName + "/" + partsList[partsList.size() - 1]; }
void SlotModel::putToFront( const Id<Process::LayerModel>& id) { if(!id.val()) return; if(id != m_frontLayerModelId) { m_frontLayerModelId = id; emit layerModelPutToFront(layers.at(id)); } }
QList<int>* VisualDebugger::computeBreakpoints() { QList<int> *breakpoints = new QList<int>(); int line=1; Id curId = mIdByLineCorrelation[line]; while (mIdByLineCorrelation[line].element().compare("BlockFinalNode") != 0) { while (mIdByLineCorrelation.contains(line) && curId.toString().compare(mIdByLineCorrelation[line].toString()) == 0) { line++; } breakpoints->append(line-1); while (!mIdByLineCorrelation.contains(line)) { line++; } curId = mIdByLineCorrelation[line]; } breakpoints->append(line); return breakpoints; }
void SettingsDialog::showPage(Id categoryId, Id pageId) { // handle the case of "show last page" Id initialCategory = categoryId; Id initialPage = pageId; if (!initialCategory.isValid() && !initialPage.isValid()) { QSettings *settings = ICore::settings(); initialCategory = Id::fromSetting(settings->value(QLatin1String(categoryKeyC))); initialPage = Id::fromSetting(settings->value(QLatin1String(pageKeyC))); } if (!initialCategory.isValid()) // no category given and no old setting return; int initialCategoryIndex = -1; int initialPageIndex = -1; const QList<Category*> &categories = m_model->categories(); for (int i = 0; i < categories.size(); ++i) { Category *category = categories.at(i); if (category->id == initialCategory) { initialCategoryIndex = i; if (initialPage.isValid()) { ensureCategoryWidget(category); for (int j = 0; j < category->pages.size(); ++j) { IOptionsPage *page = category->pages.at(j); if (page->id() == initialPage) initialPageIndex = j; } } break; } } QTC_ASSERT(initialCategoryIndex != -1, qDebug("Unknown category: %s", initialCategory.name().constData()); return); QTC_ASSERT(!initialPage.isValid() || initialPageIndex != -1, qDebug("Unknown page: %s", initialPage.name().constData())); if (initialCategoryIndex != -1) { const QModelIndex modelIndex = m_proxyModel->mapFromSource(m_model->index(initialCategoryIndex)); m_categoryList->setCurrentIndex(modelIndex); if (initialPageIndex != -1) categories.at(initialCategoryIndex)->tabWidget->setCurrentIndex(initialPageIndex); } }
void EditorViewMViface::handleNodeElementsForRowsInserted( const QList<QPair<NodeElement *, QPersistentModelIndex> > &nodes , const QModelIndex &parent ) { for (const QPair<NodeElement *, QPersistentModelIndex> &p : nodes) { NodeElement *elem = p.first; QPersistentModelIndex current = p.second; Id currentId = current.data(roles::idRole).value<Id>(); bool needToProcessChildren = true; if (elem) { QPointF ePos = model()->data(current, roles::positionRole).toPointF(); // setting position before parent definition 'itemChange' to work correctly elem->setPos(ePos); elem->setGeometry(mGraphicalAssistApi->configuration(elem->id()).boundingRect().translated(ePos.toPoint())); handleAddingSequenceForRowsInserted(parent, elem, current); handleElemDataForRowsInserted(elem, current); if (currentId.element() == "Class" && mGraphicalAssistApi->children(currentId).empty()) { needToProcessChildren = false; for (int i = 0; i < 2; i++) { QString curChildElementType = (i == 0) ? "MethodsContainer" : "FieldsContainer"; Id newUuid = Id("Kernel_metamodel", "Kernel", curChildElementType, QUuid::createUuid().toString()); mGraphicalAssistApi->createElement(currentId, newUuid , false, "(anonymous something)", QPointF(0, 0)); } } } if (needToProcessChildren && model()->hasChildren(current)) { rowsInserted(current, 0, model()->rowCount(current) - 1); } if (elem) { elem->alignToGrid(); } } }
void ShuffleRound::ProcessData(const QByteArray &data, const Id &id) { QByteArray payload; if(!Verify(data, payload, id)) { return; } QDataStream stream(payload); int mtype; QByteArray session_id; stream >> mtype >> session_id; MessageType msg_type = (MessageType) mtype; Id sid(session_id); if(sid != GetId()) { qWarning() << "Invalid session, expected " << GetId().ToString() << ", found " << sid.ToString(); return; } _in_log.Append(data, id); switch(msg_type) { case PublicKeys: HandlePublicKeys(stream, id); break; case Data: HandleData(stream, id); break; case ShuffleData: HandleShuffle(stream, id); break; case EncryptedData: HandleDataBroadcast(stream, id); break; case GoMessage: HandleVerification(true, id); break; case NoGoMessage: HandleVerification(false, id); break; case PrivateKey: HandlePrivateKey(stream, id); break; default: qWarning() << "Unknown message type: " << MessageTypeToString(msg_type) << " from " << id.ToString(); return; } }
/** * Return the MeshEntry into which the enzyme should be placed. * This is simple: Just identify the compartment holding the enzyme * molecule. */ Id findMeshOfEnz( Id enz ) { static const Finfo* enzFinfo = EnzBase::initCinfo()->findFinfo( "enzOut" ); assert( enzFinfo ); vector< Id > enzVec; unsigned int numEnz = enz.element()->getNeighbors( enzVec, enzFinfo ); assert( numEnz == 1 ); vector< Id > meshEntries; return getCompt( enzVec[0] ); }