/** * In case no mapped channel use the given @a label, an error is sent to the logger. Thus, the channel @a sig will be not assigned. */ void Hardware::setChannel(const std::string& label, TimeSequence* sig) { using vvt = std::pair<std::string, TimeSequence*>; auto optr = this->pimpl(); auto it = std::find_if(optr->MappedChannels.begin(), optr->MappedChannels.end(), [&](const vvt& v){return v.first == label;}); if (it != optr->MappedChannels.end()) { auto old = it->second; if (old == sig) return; auto parent = this->channels(); if (old != nullptr) { old->removeParent(parent); if (!old->hasParents()) delete old; } if (sig != nullptr) sig->addParent(parent); it->second = sig; // this->modified(); // removeParent and addParent calls modified } else error("No mapped channel with the label: %s", label.c_str()); };
static int shiftToSingleReduce( a_state *state, a_shift_action *saction ) { a_state *sub_state; a_sym *new_lhs; int made_change; /* requirements: (1) state (s1) must have a shift on token (t) into a state (s2) that only has one action and it must be a reduction by an unit production (after which state (s1) will shift into state (s3)) action: change shift action for token (t) to shift into state (s3) */ made_change = 0; for( sub_state = saction->state; (new_lhs = onlyOneReduction( sub_state )) != NULL; sub_state = saction->state ) { saction->state = findNewShiftState( state, new_lhs ); removeParent( sub_state, state ); made_change = 1; ++changeOccurred; } saction->units_checked = true; return( made_change ); }
/** * @brief Class::addParent * @param typeId * @param section * @return */ Parent Class::addParent(const QString &typeId, Section section) { auto parent = Parent(typeId, section); if (containsParent(typeId)) removeParent(typeId); m_Parents.append(parent); return parent; }
void Hardware::setChannel(unsigned idx, TimeSequence* sig) { auto optr = this->pimpl(); if (idx >= optr->MappedChannels.size()) { error("Index out of range. Impossible to assign the signal '%s' in the hardware '%s'.", (sig != nullptr ? sig->name().c_str() : "NULL"), this->name().c_str()); return; } auto old = optr->MappedChannels[idx].second; if (old == sig) return; auto parent = this->channels(); if (old != nullptr) { old->removeParent(parent); if (!old->hasParents()) delete old; } if (sig != nullptr) sig->addParent(parent); optr->MappedChannels[idx].second = sig; // this->modified(); // removeParent and addParent calls modified };