void Sequence::add(const Pair& p) { if (_length == 0) _slot = p.slot(); this->push_back(p); _back_slot = p.slot(); p.source().add_to_sequence(this); p.target().add_to_sequence(this); ++_length; }
// ----------------------------------------------------------------- // Sets the state machine 'name' or zero to clear. Return true // if successful. If the 'code' is CHK_CUR_STATE or GET_NEXT_STATE // then we do NOT actually set the stMach, but we only check to // see if the stMach 'name' exists. // ----------------------------------------------------------------- bool StateMachine::setStMach(const char* const name, const StateTableCode code) { bool ok = false; if (code == CURR_STATE) { // Current state is now also the previous state StateMachine* oldStMach = stMach; // First, check to see if they're asking for the same state // as our current state. ok = (stMachName == nullptr && name == nullptr); if (!ok && stMachName != nullptr && name != nullptr) { ok = *stMachName == name; } // When they're not the same then we make a switch ... if (!ok) { if (name != nullptr) { Pair* p = findStMachByName(name); if (p != nullptr) { stMach = static_cast<StateMachine*>(p->object()); stMachName = p->slot(); ok = true; } } else { // 'name' is null, so set the new state to null. stMach = nullptr; stMachName = nullptr; ok = true; } if (ok) { pStMach = oldStMach; } } } else { // -- only need to look to see if this named state machine exists. ok = (findStMachByName(name) != nullptr); } return ok; }