本文整理汇总了C++中IdList::at方法的典型用法代码示例。如果您正苦于以下问题:C++ IdList::at方法的具体用法?C++ IdList::at怎么用?C++ IdList::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IdList
的用法示例。
在下文中一共展示了IdList::at方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UncertMLNode
UncertMLNode *
UncertMLNode::createStatisticsNode(std::string arguments,
std::string argumentIds)
{
UncertMLNode *node = new UncertMLNode();
node->setElementName("StatisticsCollection");
XMLAttributes attr = XMLAttributes();
/* really the url should be specific to the distribtuion
* but whilst the attribue is required in uncertML it does not require
* it to be an exact match
*/
attr.add("definition", "http://www.uncertml.org/statistics");
node->setAttributes(attr);
/* create an idlist from the arguments
* and check we have the same number of args and ids
*/
IdList args = IdList(arguments);
IdList argIds = IdList(argumentIds);
unsigned int numArgs = args.size();
unsigned int numIds = argIds.size();
if (numArgs != numIds)
{
return NULL;
}
for (unsigned int i = 0; i < numArgs; i++)
{
UncertMLNode * varChild = new UncertMLNode();
varChild->setElementName("var");
XMLAttributes attributes = XMLAttributes();
attributes.add("varId", argIds.at(i));
varChild->setAttributes(attributes);
UncertMLNode * valueChild = new UncertMLNode();
valueChild->setElementName("value");
valueChild->addChild(varChild);
UncertMLNode * child = new UncertMLNode();
child->setElementName(args.at(i));
XMLAttributes attr1 = XMLAttributes();
attr1.add("definition", "http://www.uncertml.org/statistics");
child->setAttributes(attr1);
child->addChild(valueChild);
node->addChild(child);
}
return node;
}
示例2: nextElementsGeneration
bool LoopElementGenerator::nextElementsGeneration()
{
IdList const outgoingLinks = mNxtGen->api()->outgoingLinks(mElementId);
Q_ASSERT(outgoingLinks.size() == 2);
int elementConnectedByIterationEdgeNumber = -1;
int afterLoopElementNumber = -1;
if (mNxtGen->api()->stringProperty(mNxtGen->api()->logicalId(outgoingLinks.at(0)), "Guard").toUtf8() == "итерация") {
elementConnectedByIterationEdgeNumber = 0;
afterLoopElementNumber = 1;
} else {
elementConnectedByIterationEdgeNumber = 1;
afterLoopElementNumber = 0;
}
//generate loop
Id const loopNextElement = mNxtGen->api()->to(outgoingLinks.at(elementConnectedByIterationEdgeNumber));
if (loopNextElement == Id::rootId()) {
mNxtGen->errorReporter().addError("Loop block " + mElementId.toString() + " has no correct loop branch!"\
" May be you need to connect it to some diagram element.", mElementId);
return false;
}
AbstractElementGenerator* const loopGen = ElementGeneratorFactory::generator(mNxtGen
, loopNextElement, *mNxtGen->api());
mNxtGen->previousElement() = mElementId;
mNxtGen->previousLoopElements().push(mElementId);
if (!loopGen->generate()) {
return false;
}
delete loopGen;
//generate next blocks
Id const nextBlockElement = mNxtGen->api()->to(outgoingLinks.at(afterLoopElementNumber));
if (nextBlockElement == Id::rootId()) {
mNxtGen->errorReporter().addError("Loop block " + mElementId.toString() + " has no correct next block branch!"\
" May be you need to connect it to some diagram element.", mElementId);
return false;
}
AbstractElementGenerator* nextBlocksGen = ElementGeneratorFactory::generator(mNxtGen
, nextBlockElement, *mNxtGen->api());
mNxtGen->previousElement() = mElementId;
mNxtGen->previousLoopElements().push(mElementId);
if (!nextBlocksGen->generate()) {
return false;
}
delete nextBlocksGen;
return true;
}
示例3: preGenerationCheck
bool LoopElementGenerator::preGenerationCheck()
{
IdList const outgoingLinks = mNxtGen->api()->outgoingLinks(mElementId);
if ((outgoingLinks.size() != 2) ||
((mNxtGen->api()->property(mNxtGen->api()->logicalId(outgoingLinks.at(0)), "Guard").toString() == "итерация")
&& (mNxtGen->api()->property(mNxtGen->api()->logicalId(outgoingLinks.at(1)), "Guard").toString() == "итерация") )
) {
return false;
}
return true;
}
示例4: createIdByLineCorrelation
void VisualDebugger::createIdByLineCorrelation(UML::Element *elem, int& line)
{
UML::Element *curElem = dynamic_cast<UML::NodeElement *>(elem);
if (curElem && elem->id().element().compare("InitialNode") != 0) {
if (elem->id().element().compare("Action") == 0) {
mIdByLineCorrelation[line] = elem->id();
line++;
if (mLogicalModelApi.logicalRepoApi().outgoingLinks(curElem->id()).count() != 0) {
Id nextEdge = mLogicalModelApi.logicalRepoApi().outgoingLinks(curElem->id()).at(0);
createIdByLineCorrelation(mEditor->mvIface()->scene()->getElem(nextEdge), line);
} else {
error(missingEndNode);
mHasNotEndWithFinalNode = true;
}
} else {
if (elem->id().element().compare("ConditionNode") == 0) {
mIdByLineCorrelation[line] = elem->id();
line++;
IdList outLinks = mLogicalModelApi.logicalRepoApi().outgoingLinks(curElem->id());
Id falseEdge = falseEdge.rootId();
Id trueEdge = trueEdge.rootId();
for (int i=0; i<outLinks.count(); i++) {
bool type = getProperty(outLinks.at(i), "type").toBool();
if (type) {
trueEdge = outLinks.at(i);
} else {
falseEdge = outLinks.at(i);
}
}
createIdByLineCorrelation(mEditor->mvIface()->scene()->getElem(trueEdge), line);
line++;
if (falseEdge != falseEdge.rootId()) {
line++;
createIdByLineCorrelation(mEditor->mvIface()->scene()->getElem(falseEdge), line);
line++;
}
} else {
mIdByLineCorrelation[line] = elem->id();
}
}
} else {
if (elem->id().element().compare("InitialNode") != 0) {
Id nextNode = mLogicalModelApi.logicalRepoApi().to(elem->id());
createIdByLineCorrelation(mEditor->mvIface()->scene()->getElem(nextNode), line);
} else {
Id nextEdge = mLogicalModelApi.logicalRepoApi().outgoingLinks(curElem->id()).at(0);
createIdByLineCorrelation(mEditor->mvIface()->scene()->getElem(nextEdge), line);
}
}
}
示例5: setItemsToDelete
void MultipleRemoveCommand::setItemsToDelete(IdList &itemsToDelete)
{
IdList itemsToUpdate;
addEdgesToBeDeleted(itemsToDelete);
// QGraphicsScene::selectedItems() returns items in no particular order,
// so we should handle parent-child relationships manually
while (!itemsToDelete.isEmpty()) {
const Id currentItem = itemsToDelete.at(0);
const IdList children = mGraphicalApi.children(currentItem);
foreach (const Id &child, children) {
itemsToDelete.removeAll(child);
// Child remove commands will be added in currentItem delete command
}
const bool isEdge = !mLogicalApi.editorManagerInterface().isGraphicalElementNode(currentItem);
if (isEdge) {
const Id src = mGraphicalApi.from(currentItem);
if (src != Id() && !itemsToUpdate.contains(src)) {
itemsToUpdate.append(src);
}
const Id dst = mGraphicalApi.to(currentItem);
if (dst != Id() && !itemsToUpdate.contains(dst)) {
itemsToUpdate.append(dst);
}
insertPreAction(graphicalDeleteCommand(currentItem), 0);
} else {
addPreAction(graphicalDeleteCommand(currentItem));
}
itemsToDelete.removeAll(currentItem);
}
示例6: findValidLink
Id VisualDebugger::findValidLink()
{
IdList outLinks = mModelApi.graphicalRepoApi().outgoingLinks(mCurrentId);
QString conditionStr = mModelApi.graphicalRepoApi().property(mCurrentId, "condition").toString();
int pos=0;
bool condition = mBlockParser->parseCondition(conditionStr, pos, mCurrentId);
for (int i=0; i<outLinks.count(); i++) {
bool type = mModelApi.graphicalRepoApi().property(outLinks.at(i), "type").toBool();
if (type == condition) {
return outLinks.at(i);
}
}
if (!mBlockParser->hasErrors()) {
error(VisualDebugger::missingValidLink);
}
return ROOT_ID;
}
示例7: insertWidget
void QWizardContainer::insertWidget(int index, QWidget *widget)
{
enum { delta = 5 };
QWizardPage *newPage = qobject_cast<QWizardPage *>(widget);
if (!newPage) {
qWarning("%s", msgWrongType);
return;
}
const IdList idList = m_wizard->pageIds();
const int pageCount = idList.size();
if (index >= pageCount) {
addWidget(widget);
return;
}
// Insert before, reshuffle ids if required
const int idBefore = idList.at(index);
const int newId = idBefore - 1;
const bool needsShuffle =
(index == 0 && newId < 0) // At start: QWizard refuses to insert id -1
|| (index > 0 && idList.at(index - 1) == newId); // In-between
if (needsShuffle) {
// Create a gap by shuffling pages
WizardPageList pageList;
pageList.push_back(newPage);
for (int i = index; i < pageCount; i++) {
pageList.push_back(m_wizard->page(idList.at(i)));
m_wizard->removePage(idList.at(i));
}
int newId = idBefore + delta;
const WizardPageList::const_iterator wcend = pageList.constEnd();
for (WizardPageList::const_iterator it = pageList.constBegin(); it != wcend; ++it) {
m_wizard->setPage(newId, *it);
newId += delta;
}
} else {
// Gap found, just insert
m_wizard->setPage(newId, newPage);
}
// Might be at -1 after adding the first page
setCurrentIndex(index);
}
示例8:
QWidget *QWizardContainer::widget(int index) const
{
QWidget *rc = 0;
if (index >= 0) {
const IdList idList = m_wizard->pageIds();
if (index < idList.size())
rc = m_wizard->page(idList.at(index));
}
return rc;
}
示例9: generateInitialNodeCode
DispatcherGenerator::CodeBranchGenerationResult DispatcherGenerator::generateInitialNodeCode(
qReal::Id const ¤tNode) const
{
IdList const links = mApi.outgoingLinks(currentNode);
if (links.size() != 1) {
mErrorReporter.addError(QObject::tr("Initial node should have exactly 1 outgoing link"), currentNode);
return CodeBranchGenerationResult("", currentNode);
}
Id const nextNode = mApi.otherEntityFromLink(links.at(0), currentNode);
return generateOperatorCode(nextNode);
}
示例10: generateCaseBody
QString DispatcherGenerator::generateCaseBody(qReal::Id const &handlerStart) const
{
IdList const links = mApi.outgoingLinks(handlerStart);
if (links.size() > 1) {
mErrorReporter.addError(QObject::tr("Start node should have exactly 1 outgoing link"), handlerStart);
return "";
}
if (links.size() == 0) {
return "";
}
Id const nextNode = mApi.otherEntityFromLink(links.at(0), handlerStart);
return generateOperatorCode(nextNode).text;
}
示例11: logCycle
void
FunctionDefinitionRecursion::determineCycles(const Model& m)
{
IdIter it;
IdRange range;
IdList variables;
IdMap logged;
std::string id;
variables.clear();
/* create a list of variables that are cycles ie (x, x) */
for (it = mIdMap.begin(); it != mIdMap.end(); it++)
{
if ((*it).first == (*it).second)
{
id = (*it).first;
if (!variables.contains(id))
{
variables.append(id);
}
}
}
/* loop thru other dependencies for each; if the dependent is also
* in the list then this is the cycle
* keep a record of logged dependencies to avoid logging twice
*/
for (unsigned int n = 0; n < variables.size(); n++)
{
id = variables.at((int)n);
range = mIdMap.equal_range(id);
for (it = range.first; it != range.second; it++)
{
if (((*it).second != id)
&& (variables.contains((*it).second))
&& !alreadyExistsInMap(logged,
pair<const std::string, std::string>(id, (*it).second))
&& !alreadyExistsInMap(logged,
pair<const std::string, std::string>((*it).second, id)))
{
logCycle(m.getFunctionDefinition(id), m.getFunctionDefinition((*it).second));
logged.insert(pair<const std::string, std::string>(id, (*it).second));
}
}
}
}
示例12: remove
void QWizardContainer::remove(int index)
{
if (index < 0)
return;
const IdList idList = m_wizard->pageIds();
if (index >= idList.size())
return;
m_wizard->removePage(idList.at(index));
// goto next page, preferably
const int newSize = idList.size() - 1;
if (index < newSize) {
setCurrentIndex(index);
} else {
if (newSize > 0)
setCurrentIndex(newSize - 1);
}
}
示例13: generateActionCode
DispatcherGenerator::CodeBranchGenerationResult DispatcherGenerator::generateActionCode(
qReal::Id const ¤tNode) const
{
QString operatorCode = mApi.name(currentNode);
IdList const links = mApi.outgoingLinks(currentNode);
if (links.size() == 0) {
return CodeBranchGenerationResult(operatorCode, currentNode);
} else if (links.size() > 1) {
mErrorReporter.addError(QObject::tr("Action node should have exactly 1 outgoing link"), currentNode);
return CodeBranchGenerationResult("", currentNode);
}
Id const nextNode = mApi.otherEntityFromLink(links.at(0), currentNode);
CodeBranchGenerationResult result = generateOperatorCode(nextNode);
result.text = operatorCode + "\n" + result.text;
return result;
}
示例14: generateMethodBody
void SimpleElementGenerator::generateMethodBody()
{
generateBodyWithoutNextElementCall();
IdList const outgoingConnectedElements = mNxtGen->mApi->outgoingConnectedElements(mElementId);
if (outgoingConnectedElements.size() > 1) {
mNxtGen->mErrorReporter.addError(QObject::tr("Too many outgoing connections!"), mElementId);
return;
}
//if (outgoingConnectedElements.size() == 0) - case of last loop element, for example
if (outgoingConnectedElements.size() == 1) {
Id nextElement = outgoingConnectedElements.at(0);
if (!mNxtGen->mApi->isLogicalElement(nextElement)) {
nextElement = mNxtGen->mApi->logicalId(nextElement);
}
QString const methodName = mNxtGen->mIdToMethodNameMap[nextElement.toString()];
mNxtGen->mGeneratedStrings.append(SmartLine(methodName + "();", mElementId));
}
}
示例15: generateCode
void VisualDebugger::generateCode(UML::Element *elem, QFile &codeFile)
{
UML::Element *curElem = dynamic_cast<UML::NodeElement *>(elem);
if (curElem && elem->id().element().compare("InitialNode") != 0) {
if (elem->id().element().compare("Action") == 0) {
QString code = getProperty(curElem->id(), "process").toString();
if (code.mid(0,4).compare("var ") == 0) {
codeFile.write(code.mid(4).toAscii());
} else {
codeFile.write(code.toAscii());
}
codeFile.write("\n");
if (mLogicalModelApi.logicalRepoApi().outgoingLinks(curElem->id()).count() != 0) {
Id nextEdge = mLogicalModelApi.logicalRepoApi().outgoingLinks(curElem->id()).at(0);
generateCode(mEditor->mvIface()->scene()->getElem(nextEdge), codeFile);
} else {
error(VisualDebugger::missingEndNode);
error(codeGenerationError);
return;
}
} else {
if (elem->id().element().compare("ConditionNode") == 0) {
codeFile.write("if (");
codeFile.write(getProperty(curElem->id(), "condition").toByteArray());
codeFile.write(") {\n");
IdList outLinks = mLogicalModelApi.logicalRepoApi().outgoingLinks(curElem->id());
Id falseEdge = falseEdge.rootId();
Id trueEdge = trueEdge.rootId();
for (int i=0; i<outLinks.count(); i++) {
bool type = getProperty(outLinks.at(i), "type").toBool();
if (type) {
trueEdge = outLinks.at(i);
} else {
falseEdge = outLinks.at(i);
}
}
if (trueEdge == trueEdge.rootId()) {
error(VisualDebugger::missingValidLink);
error(codeGenerationError);
return;
}
generateCode(mEditor->mvIface()->scene()->getElem(trueEdge), codeFile);
codeFile.write("}\n");
if (falseEdge != falseEdge.rootId()) {
codeFile.write("else {\n");
generateCode(mEditor->mvIface()->scene()->getElem(falseEdge), codeFile);
codeFile.write("}\n");
}
}
}
} else {
if (elem->id().element().compare("InitialNode") != 0) {
Id nextNode = mLogicalModelApi.logicalRepoApi().to(elem->id());
generateCode(mEditor->mvIface()->scene()->getElem(nextNode), codeFile);
} else {
Id nextEdge = mLogicalModelApi.logicalRepoApi().outgoingLinks(curElem->id()).at(0);
generateCode(mEditor->mvIface()->scene()->getElem(nextEdge), codeFile);
}
}
return;
}