bool RlvObject::removeCommand(const RlvCommand& rlvCmd) { RLV_ASSERT(RLV_TYPE_REMOVE == rlvCmd.getParamType()); for (rlv_command_list_t::iterator itCmd = m_Commands.begin(); itCmd != m_Commands.end(); ++itCmd) { //if (*itCmd == rlvCmd) <- commands will never be equal since one is an add and the other is a remove *rolls eyes* if ( (itCmd->getBehaviour() == rlvCmd.getBehaviour()) && (itCmd->getOption() == rlvCmd.getOption()) && (itCmd->isStrict() == rlvCmd.isStrict() ) ) { m_Commands.erase(itCmd); return true; } } return false; // Command was never added so nothing to remove now }
bool RlvObject::addCommand(const RlvCommand& rlvCmd) { RLV_ASSERT(RLV_TYPE_ADD == rlvCmd.getParamType()); // Don't add duplicate commands for this object (ie @detach=n followed by another @detach=n later on) for (rlv_command_list_t::iterator itCmd = m_Commands.begin(); itCmd != m_Commands.end(); ++itCmd) { if ( (itCmd->getBehaviour() == rlvCmd.getBehaviour()) && (itCmd->getOption() == rlvCmd.getOption()) && (itCmd->isStrict() == rlvCmd.isStrict() ) ) { return false; } } // Now that we know it's not a duplicate, add it to the end of the list m_Commands.push_back(rlvCmd); return true; }