Esempio n. 1
0
void ConditionalDialog::slotOk()
{
    kDebug() << "slotOk";

    if (!checkInputData())
        return;

    kDebug() << "Input data is valid";

    QLinkedList<KCConditional> newList;

    KCConditional newCondition;

    if (getCondition(newCondition, m_dlg->m_condition_1, m_dlg->m_firstValue_1,
                     m_dlg->m_secondValue_1, m_dlg->m_style_1))
        newList.append(newCondition);

    if (getCondition(newCondition, m_dlg->m_condition_2, m_dlg->m_firstValue_2,
                     m_dlg->m_secondValue_2, m_dlg->m_style_2))
        newList.append(newCondition);

    if (getCondition(newCondition, m_dlg->m_condition_3, m_dlg->m_firstValue_3,
                     m_dlg->m_secondValue_3, m_dlg->m_style_3))
        newList.append(newCondition);

    kDebug() << "Setting conditional list";
    KCConditionCommand* manipulator = new KCConditionCommand();
    manipulator->setSheet(m_selection->activeSheet());
    manipulator->setConditionList(newList);
    manipulator->add(*m_selection);
    manipulator->execute(m_selection->canvas());

    accept();
}
Esempio n. 2
0
void MouseEventManager::loadCameraEventDefinitions ()
{
	xml::NodeList camviews = GlobalRegistry().findXPath("user/ui/input//cameraview");

	if (camviews.size() > 0) {

		// Find all the camera definitions
		xml::NodeList eventList = camviews[0].getNamedChildren("event");

		if (eventList.size() > 0) {
			globalOutputStream() << "MouseEventManager: Camera Definitions found: " << eventList.size() << "\n";
			for (unsigned int i = 0; i < eventList.size(); i++) {
				// Get the event name
				const std::string eventName = eventList[i].getAttributeValue("name");

				// Check if any recognised event names are found and construct the according condition.
				if (eventName == "EnableFreeLookMode") {
					_cameraConditions[ui::camEnableFreeLookMode] = getCondition(eventList[i]);
				} else if (eventName == "DisableFreeLookMode") {
					_cameraConditions[ui::camDisableFreeLookMode] = getCondition(eventList[i]);
				} else {
					globalOutputStream() << "MouseEventManager: Warning: Ignoring unknown event name: " << eventName
							<< "\n";
				}
			}
		} else {
			// No Camera definitions found!
			globalOutputStream() << "MouseEventManager: Critical: No camera event definitions found!\n";
		}
	} else {
		// No Camera definitions found!
		globalOutputStream() << "MouseEventManager: Critical: No camera event definitions found!\n";
	}
}
Esempio n. 3
0
 void computeInstructionBounds() override
 {
     Base::computeInstructionBounds();
     if (getCondition()->getBegin() == -1)
     {
         m_Begin = getBody()->getBegin() - 1;
         m_End = m_Begin;
     }
     else
     {
         m_Begin = getCondition()->getBegin();
         m_End = getCondition()->getEnd() + 1;
     }
 }
Esempio n. 4
0
void MouseEventManager::loadObserverEventDefinitions ()
{
	xml::NodeList observers = GlobalRegistry().findXPath("user/ui/input//observer");

	if (observers.size() > 0) {

		// Find all the observer definitions
		xml::NodeList eventList = observers[0].getNamedChildren("event");

		if (eventList.size() > 0) {
			globalOutputStream() << "MouseEventManager: Observer Definitions found: " << eventList.size() << "\n";
			for (unsigned int i = 0; i < eventList.size(); i++) {
				// Get the event name
				const std::string eventName = eventList[i].getAttributeValue("name");

				// Check if any recognised event names are found and construct the according condition.
				if (eventName == "Manipulate") {
					_observerConditions[ui::obsManipulate] = getCondition(eventList[i]);
				} else if (eventName == "Select") {
					_observerConditions[ui::obsSelect] = getCondition(eventList[i]);
				} else if (eventName == "ToggleSelection") {
					_observerConditions[ui::obsToggle] = getCondition(eventList[i]);
				} else if (eventName == "ToggleFaceSelection") {
					_observerConditions[ui::obsToggleFace] = getCondition(eventList[i]);
				} else if (eventName == "CycleSelection") {
					_observerConditions[ui::obsReplace] = getCondition(eventList[i]);
				} else if (eventName == "CycleFaceSelection") {
					_observerConditions[ui::obsReplaceFace] = getCondition(eventList[i]);
				} else if (eventName == "CopyTexture") {
					_observerConditions[ui::obsCopyTexture] = getCondition(eventList[i]);
				} else if (eventName == "PasteTexture") {
					_observerConditions[ui::obsPasteTexture] = getCondition(eventList[i]);
				} else if (eventName == "PasteTextureToBrush") {
					_observerConditions[ui::obsPasteTextureToBrush] = getCondition(eventList[i]);
				} else if (eventName == "JumpToObject") {
					_observerConditions[ui::obsJumpToObject] = getCondition(eventList[i]);
				} else {
					globalOutputStream() << "MouseEventManager: Warning: Ignoring unknown event name: " << eventName
							<< "\n";
				}
			}
		} else {
			// No observer definitions found!
			globalOutputStream() << "MouseEventManager: Critical: No observer event definitions found!\n";
		}
	} else {
		// No observer definitions found!
		globalOutputStream() << "MouseEventManager: Critical: No observer event definitions found!\n";
	}
}
Esempio n. 5
0
bool Creature::setAttackedCreature(Creature* creature)
{
	if(creature)
	{
		const Position& creaturePos = creature->getPosition();
		if(creaturePos.z != getPosition().z || !canSee(creaturePos))
		{
			attackedCreature = NULL;
			return false;
		}
	}

	attackedCreature = creature;
	if(attackedCreature)
	{
		onTarget(attackedCreature);
		attackedCreature->onAttacked();
	}

	for(std::list<Creature*>::iterator cit = summons.begin(); cit != summons.end(); ++cit)
		(*cit)->setAttackedCreature(creature);

	Condition* condition = getCondition(CONDITION_LOGINPROTECTION, CONDITIONID_DEFAULT);
	if(condition)
		removeCondition(condition);

	return true;
}
Esempio n. 6
0
void Jump::print(std::ostream& stream) const {
    stream << "\t";
    switch (getCondition()) {
    case JumpCondition::IF_EQUAL:
        stream << "JE ";
        break;
    case JumpCondition::IF_NOT_EQUAL:
        stream << "JNE ";
        break;
    case JumpCondition::IF_ABOVE:
        stream << "JA ";
        break;
    case JumpCondition::IF_BELOW:
        stream << "JB ";
        break;
    case JumpCondition::IF_ABOVE_OR_EQUAL:
        stream << "JAE ";
        break;
    case JumpCondition::IF_BELOW_OR_EQUAL:
        stream << "JBE ";
        break;
    case JumpCondition::UNCONDITIONAL:
        default:
        stream << "GOTO ";
    }
    stream << getLabel() << "\n";
}
//--------------------------------------------------------------------------------
void QmvQueryWidget::advancedQuery()
{
    static QmvQueryWidget * aq;
    if ( !dialog_advqry )
    {
        aq = new QmvQueryWidget( this, this, "advanced query" );
        dialog_advqry = aq->getAdvancedDialog();
        dialog_advqry->move( mapToGlobal( QPoint( topLevelWidget()->width() - 400, 0) ) );
    }
        // update adv from simple
    aq->getCondition(0)->update();
        // activate all conditions
    for ( int row = 0; row < query_object->countConditions(); row++ )
        query_object->getCondition( row )->setActive(TRUE);

        // Run the advanced query
    dialog_advqry->exec();
    
        // update simple from adv
    getCondition(0)->update();
        // deactivate all other than first condition
    for ( int row = 1; row < query_object->countConditions(); row++ )
        query_object->getCondition( row )->setActive(FALSE);
    
}
Esempio n. 8
0
int MagicEffectItem::getDamage(Creature *target, const Creature *attacker /*= NULL*/) const
{

	if(target->access == 0) {

		bool refresh = true;
		for(ConditionVec::const_iterator condIt = condition.begin(); condIt != condition.end(); ++condIt) {
			if(condIt == condition.begin()) //skip first
				continue;

			if((condIt->getCondition()->attackType != ATTACK_NONE) &&
				(target->getImmunities() & condIt->getCondition()->attackType) != condIt->getCondition()->attackType) {
				target->addCondition(*condIt, refresh);
				refresh = false; //only set refresh flag on first "new event"
			}
		}

		const MagicEffectTargetCreatureCondition *magicTargetCondition = getCondition();
		
		if(magicTargetCondition)
			return magicTargetCondition->getDamage(target, attacker);
		else
			return 0;
	}

	return 0;
}
Esempio n. 9
0
/**
 *  allocPhiFunc
 *
 *  This function recursively check the node that require more than
 *  a phiFunction and place the required phiFunction for these subscript
 *
 *****************************************************/
void allocPhiFunc(Node** thisNode){
  (*thisNode)->visitFlag |= 2;
  LinkedList* liveList    = getAllLiveList(thisNode, NULL);
  resetFlag(thisNode, 2);
  
  ListElement* livePtr    = liveList->head;
  LinkedList* listA, *listB;
  Node *nodeAPtr, *nodeBPtr, *rootPtr;
  Subscript* subsPtr, condtSubs;
  int i;
  if((*thisNode)->directDom->length == 2){
    nodeBPtr = (*thisNode)->directDom->head->node;
    nodeAPtr = (*thisNode)->directDom->head->next->node;
    listA = getListTillNode(nodeAPtr);
    listB = getListTillNode(nodeBPtr);
    Expression* phiFunction;
    while(livePtr != NULL){
      subsPtr     = getLargestIndex(listB, livePtr->node);
      phiFunction = getPhiFunction(listA, listB, subsPtr);
      condtSubs   = getCondition((*thisNode)->imdDom);
      phiFunction->condt = condtSubs;
      addListFirst((*thisNode)->block, phiFunction);
      
      livePtr = livePtr->next;
    }
  }
  
  for(i = 0; i < (*thisNode)->numOfChild; i++)
    if(((*thisNode)->children[i]->visitFlag & 2) == 0)
      allocPhiFunc(&(*thisNode)->children[i]);
}
Esempio n. 10
0
bool Creature::addCondition(Condition* condition, bool force/* = false*/)
{
	if (condition == NULL) {
		return false;
	}

	if (!force && condition->getType() == CONDITION_HASTE && hasCondition(CONDITION_PARALYZE)) {
		int64_t walkDelay = getWalkDelay();
		if (walkDelay > 0) {
			g_scheduler.addEvent(createSchedulerTask(walkDelay, boost::bind(&Game::forceAddCondition, &g_game, getID(), condition)));
			return false;
		}
	}

	Condition* prevCond = getCondition(condition->getType(), condition->getId(), condition->getSubId());
	if (prevCond) {
		prevCond->addCondition(this, condition);
		delete condition;
		return true;
	}

	if (condition->startCondition(this)) {
		conditions.push_back(condition);
		onAddCondition(condition->getType());
		return true;
	}

	delete condition;
	return false;
}
Esempio n. 11
0
void InstFcmp::dump(const Cfg *Func) const {
  Ostream &Str = Func->getContext()->getStrDump();
  dumpDest(Func);
  Str << " = fcmp " << InstFcmpAttributes[getCondition()].DisplayString << " "
      << getSrc(0)->getType() << " ";
  dumpSources(Func);
}
Esempio n. 12
0
	// 获取属性值
	Any TriggerObject::getProperty(uint id)const
	{
		if(id > ID_NullObject_Begin && id < ID_NullObject_End)
			return NullObject::getProperty(id);
		switch(id)
		{
		case ID_Trigger:							// 触发器设置
			{
				return Any();
			}
			break;
		case ID_TriggerCondition:							// 满足条件
			{
				return Any(getCondition());
			}
			break;
		case ID_TriggerOnEnterEvent:							// 进入事件
			{
				return Any(getOnEnterEvent());
			}
			break;
		case ID_TriggerOnLeaveEvent:							// 退出事件
			{
				return Any(getOnLeaveEvent());
			}
			break;
		default:
			return Any();
			break;
		}
	}
Esempio n. 13
0
//=============================================================================
// METHOD    : SPELLcontroller::setStatus
//=============================================================================
void SPELLcontroller::setStatus( const SPELLexecutorStatus& st )
{
	DEBUG("[C] Attempt to set status " + SPELLexecutorUtils::statusToString(st));
    bool newStatus = (st != m_status);

	if (newStatus) notifyBeforeStatusChange(m_status);

    m_status = st;
    // We don't want to notify status redundantly
    if (newStatus || st == STATUS_WAITING || st == STATUS_PROMPT)
    {
        LOG_INFO("Procedure status: " + SPELLexecutorUtils::statusToString(st));
        SPELLstatusInfo info(st);
        info.condition = getCondition();
        info.actionLabel = SPELLexecutor::instance().getUserAction().getLabel();
        info.actionEnabled = SPELLexecutor::instance().getUserAction().isEnabled();

		SPELLexecutor::instance().getCIF().notifyStatus( info );
    }

    if (newStatus) notifyAfterStatusChange(m_status);

    if (newStatus && st == STATUS_ABORTED)
    {
    	std::string event = "Procedure aborted: " + m_procId;
    	raiseEvent( event );
    }
}
Esempio n. 14
0
bool _FDMonitor_impl::registerFD(int fd, short mask, FDMonitorCallback* cb) {
	m_lock.lock();
	if (monitored_fds[fd] != NULL) {
		m_lock.unlock();
		return false;
	}
	monitored_fds[fd] = new FDMonitorEntry(fd, mask, cb);
	m_lock.unlock();
	getCondition()->wakeAll();
	return true;
}
Esempio n. 15
0
void InstBr::dump(const Cfg *Func) const {
  Ostream &Str = Func->getContext()->getStrDump();
  dumpDest(Func);
  Str << "br ";
  if (!isUnconditional()) {
    Str << "i1 ";
    getCondition()->dump(Func);
    Str << ", label %" << getTargetTrue()->getName() << ", ";
  }
  Str << "label %" << getTargetFalse()->getName();
}
Esempio n. 16
0
QString QrDeleteSql::getSqlStatement()
{
    Q_ASSERT(!getTable()->tableName().isEmpty());

    QString condition = getCondition();
    if (condition.isEmpty ()) {
        Q_ASSERT("condition is empty, would be erase all data in table!!");
        return "";  //  stop erase all, if want, append 1=1 or others
    }

    return  "DELETE FROM " + getTable()->tableName() + condition;
}
Esempio n. 17
0
/**
 * Loads the StatString from a YAML file.
 * @param node YAML node.
 */
void StatString::load(const YAML::Node &node)
{
    std::string conditionNames[] = {"psiStrength", "psiSkill", "bravery", "strength", "firing", "reactions", "stamina", "tu", "health", "throwing"};
	_stringToBeAddedIfAllConditionsAreMet = node["string"].as<std::string>(_stringToBeAddedIfAllConditionsAreMet);
    for (size_t i = 0; i < sizeof(conditionNames)/sizeof(conditionNames[0]); i++)
	{
        if (node[conditionNames[i]])
		{
            _conditions.push_back(getCondition(conditionNames[i], node));
        }
    }
}
Esempio n. 18
0
void InstSelect::dump(const Cfg *Func) const {
  Ostream &Str = Func->getContext()->getStrDump();
  dumpDest(Func);
  Operand *Condition = getCondition();
  Operand *TrueOp = getTrueOperand();
  Operand *FalseOp = getFalseOperand();
  Str << " = select " << Condition->getType() << " ";
  Condition->dump(Func);
  Str << ", " << TrueOp->getType() << " ";
  TrueOp->dump(Func);
  Str << ", " << FalseOp->getType() << " ";
  FalseOp->dump(Func);
}
bool CondManager::addCondition(string condName, string& errorMsg, Prefix* prefix) {
    Condition* cond = getCondition(condName);
    if (cond) {
        errorMsg = "redefinition of condition " + condName;
        return false;
    } else {
        cond = new Condition(nextConditionId++, condName, CondScheduler::FIFS, prefix);
        //Condition* cond = new Condition(condName, Condition::RANDOM);
        pair<string, Condition*> item(condName, cond);
        condPool.insert(item);
        return true;
    }
}
Esempio n. 20
0
omni::core::statement_emit_result omni::core::model::do_while_statement::llvmEmit (llvm::BasicBlock * llvmBasicBlock)
{
    llvm::BasicBlock * whileBlock = getBody ()->llvmEmit (llvmBasicBlock).getContinueBlock ();
    llvm::BasicBlock * continueBlock = llvm::BasicBlock::Create (llvmBasicBlock->getContext (), "", llvmBasicBlock->getParent ());

    llvm::IRBuilder <true, llvm::NoFolder> builder (llvmBasicBlock);
    builder.CreateBr (whileBlock);

    llvm::IRBuilder <true, llvm::NoFolder> whileBuilder (whileBlock);
    whileBuilder.CreateCondBr (getCondition ()->llvmEmit (whileBlock).getValue (), whileBlock, continueBlock);

    return statement_emit_result (continueBlock, nullptr);
}
Esempio n. 21
0
void _FDMonitor_impl::run() {
	while(this->isRunning()) {
		if (!this->doIteration()) {
			if (!monitored_fds.size()) {
				err() << "Nothing to listen against, so waiting for something to show up..." << endl;
				getCondition()->waitFor();
			}
			err() << "Polling "<< monitored_fds.size() << " returnerte false... venter i 0.5sec og prøver igjen" << endl;
			/**
			* Dersom den returnere false, så 
			* venter vi litt, for å unngå en grum-loop
			*/ 
			usleep(500000);
		}
	}
}
Esempio n. 22
0
void NotificationItem::saveState(QSettings* settings) const
{
    settings->setValue("SoundCollectionPath", Utils::PathUtils().RemoveDataPath(getSoundCollectionPath()));
    settings->setValue(QLatin1String("CurrentLanguage"), getCurrentLanguage());
    settings->setValue(QLatin1String("ObjectField"), getObjectField());
    settings->setValue(QLatin1String("DataObject"), getDataObject());
    settings->setValue(QLatin1String("RangeLimit"), getCondition());
    settings->setValue(QLatin1String("Value1"), singleValue());
    settings->setValue(QLatin1String("Value2"), valueRange2());
    settings->setValue(QLatin1String("Sound1"), getSound1());
    settings->setValue(QLatin1String("Sound2"), getSound2());
    settings->setValue(QLatin1String("Sound3"), getSound3());
    settings->setValue(QLatin1String("SayOrder"), getSayOrder());
    settings->setValue(QLatin1String("Repeat"), retryValue());
    settings->setValue(QLatin1String("ExpireTimeout"), lifetime());
    settings->setValue(QLatin1String("Mute"), mute());
}
Esempio n. 23
0
void MouseEventManager::loadXYViewEventDefinitions() {

	xml::NodeList xyviews = GlobalRegistry().findXPath("user/ui/input//xyview");

	if (!xyviews.empty())
	{
		// Find all the xy view definitions
		xml::NodeList eventList = xyviews[0].getNamedChildren("event");

		if (!eventList.empty())
		{
			rMessage() << "MouseEventManager: XYView Definitions found: "
								 << eventList.size() << std::endl;

			for (std::size_t i = 0; i < eventList.size(); i++)
			{
				// Get the event name
				const std::string eventName = eventList[i].getAttributeValue("name");

				// Check if any recognised event names are found and construct the according condition.
				if (eventName == "MoveView") {
					_xyConditions[ui::xyMoveView] = getCondition(eventList[i]);
				}
				else if (eventName == "Select") {
					_xyConditions[ui::xySelect] = getCondition(eventList[i]);
				}
				else if (eventName == "Zoom") {
					_xyConditions[ui::xyZoom] = getCondition(eventList[i]);
				}
				else if (eventName == "CameraMove") {
					_xyConditions[ui::xyCameraMove] = getCondition(eventList[i]);
				}
				else if (eventName == "CameraAngle") {
					_xyConditions[ui::xyCameraAngle] = getCondition(eventList[i]);
				}
				else if (eventName == "NewBrushDrag") {
					_xyConditions[ui::xyNewBrushDrag] = getCondition(eventList[i]);
				}
				else {
					rMessage() << "MouseEventManager: Warning: Ignoring unkown event name: " << eventName << std::endl;
				}
			}
		}
		else {
			// No event definitions found!
			rMessage() << "MouseEventManager: Critical: No XYView event definitions found!\n";
		}
	}
	else {
		// No event definitions found!
		rMessage() << "MouseEventManager: Critical: No XYView event definitions found!\n";
	}
}
bool CondManager::signal(string condName, unsigned& releasedThreadId, string& errorMsg) {
    Condition* cond = getCondition(condName);
    if (cond == NULL) {
        errorMsg = "condition " + condName + " undefined";
        return false;
    } else {
        WaitParam* wp = cond->signal();
        if (wp != NULL) {
            releasedThreadId = wp->threadId;
            //change state
            mutexManager->addBlockedThread(wp->threadId, wp->mutexName);
            delete wp;
        } else {
            releasedThreadId = 0;
        }
        return true;
    }
}
bool CondManager::broadcast(string condName, vector<unsigned>& threads, string& errorMsg) {
    Condition* cond = getCondition(condName);
    if (cond == NULL) {
        errorMsg = "condition " + condName + " undefined";
        return false;
    } else {
        vector<WaitParam*> itemList;
        cond->broadcast(itemList);
        threads.resize(itemList.size());
        vector<unsigned>::iterator ti = threads.begin();
        for (vector<WaitParam*>::iterator wi = itemList.begin(), we = itemList.end(); wi != we; wi++, ti++) {
            WaitParam* wp = *wi;
            *ti = wp->threadId;
            mutexManager->addBlockedThread(wp->threadId, wp->mutexName);
            delete wp;
        }
        return true;
    }
}
void Fence9::getFenceiv(GLenum pname, GLint *params)
{
    if (mQuery == NULL)
    {
        return gl::error(GL_INVALID_OPERATION);
    }

    switch (pname)
    {
        case GL_FENCE_STATUS_NV:
        {
            // GL_NV_fence spec:
            // Once the status of a fence has been finished (via FinishFenceNV) or tested and the returned status is TRUE (via either TestFenceNV
            // or GetFenceivNV querying the FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence.
            if (getStatus())
            {
                params[0] = GL_TRUE;
                return;
            }
            
            HRESULT result = mQuery->GetData(NULL, 0, 0);

            if (d3d9::isDeviceLostError(result))
            {
                params[0] = GL_TRUE;
                mRenderer->notifyDeviceLost();
                return gl::error(GL_OUT_OF_MEMORY);
            }

            ASSERT(result == S_OK || result == S_FALSE);
            setStatus(result == S_OK);
            params[0] = getStatus();

            break;
        }
        case GL_FENCE_CONDITION_NV:
            params[0] = getCondition();
            break;
        default:
            return gl::error(GL_INVALID_ENUM);
            break;
    }
}
bool CondManager::wait(string condName, string mutexName, unsigned threadId, string& errorMsg) {
    Mutex* mutex = mutexManager->getMutex(mutexName);
    if (mutex == NULL) {
        errorMsg = "mutex " + mutexName + " undefined";
        return false;
    }
    Condition* cond = getCondition(condName);
    if (cond == NULL) {
        errorMsg = "condition " + condName + " undefined";
        return false;
    }
    if (!mutex->isThreadOwnMutex(threadId)) {
        errorMsg = Transfer::uint64toString(threadId) + " does not own mutex " + mutexName;
        return false;
    } else {
        WaitParam* wp = new WaitParam(mutexName, threadId);
        cond->wait(wp);
        return mutexManager->unlock(mutexName, errorMsg);
    }
}
Esempio n. 28
0
bool Creature::addCondition(Condition* condition)
{
	if(!condition)
		return false;

	bool hadCondition = hasCondition(condition->getType(), -1, false);
	if(Condition* previous = getCondition(condition->getType(), condition->getId(), condition->getSubId()))
	{
		previous->addCondition(this, condition);
		delete condition;
		return true;
	}

	if(condition->startCondition(this))
	{
		conditions.push_back(condition);
		onAddCondition(condition->getType(), hadCondition);
		return true;
	}

	delete condition;
	return false;
}
Esempio n. 29
0
bool SVConditionParam::SaveCondition(MAPNODE &alertnode)
{
    bool bNoError = true;
    list<string> lstCondition;
    list<string> lstParam;
    list<string> lstOperate;

    string szValue = m_pConditionArea->text();

    if(!szValue.empty())
    {
        unsigned int nResult = getCondition(lstCondition, szValue);
        nResult = getParam(lstParam, szValue);

        if(lstCondition.size() != lstParam.size() - 1)
        {
            bNoError = false;
            showErrorMsg(sv_condition_relation_error);
            return bNoError;
        }

        char szCount[4] = {0}, szKey [32] = {0};
        int nCount = static_cast<int>(lstCondition.size());
        int nIndex = 1;
        string szExpression ("");
        if(nCount >= 1)
        {
            while(lstCondition.size())
            {
                string szConValue = *(lstCondition.begin());
                lstCondition.pop_front();

                string szParamCondition = *(lstParam.begin());
                lstParam.pop_front();
                string szCondition (""), szReturn (""), szParamValue ("");
                int nPos = getOperatePostion(szParamCondition, m_lsCondition, szCondition);

                if(nPos > 0)
                {
                    szReturn = szParamCondition.substr(0, nPos - 1);
                    szParamValue = szParamCondition.substr(nPos + szCondition.length() + 1, szParamCondition.length() - 
                        (nPos + szCondition.length() + 1));
                }

                if(! checkParamValue(szReturn, szParamValue))
                {
                    bNoError = false;
                    break;
                }
                sprintf(szKey, "%d", nIndex);
                szExpression = szExpression + szKey + "#" + szConValue + "#";
                sprintf(szKey, "sv_relation%d", nIndex);
                if((bNoError = AddNodeAttrib(alertnode, szKey, szConValue)))
                {
                    sprintf(szKey, "sv_paramname%d", nIndex);
                    if((bNoError = AddNodeAttrib(alertnode, szKey, szReturn)))
                    {
                        sprintf(szKey, "sv_operate%d", nIndex);
                        if((bNoError = AddNodeAttrib(alertnode, szKey, szCondition)))
                        {
                            sprintf(szKey, "sv_paramvalue%d", nIndex);
                            bNoError = AddNodeAttrib(alertnode, szKey, szParamValue);
                        }
                    }
                }
                if(!bNoError)
                    break;
                nIndex ++;
            }
        }
        if(bNoError)
        {
            string szParamCondition = *(lstParam.begin());
            lstParam.pop_front();
            string szCondition (""), szReturn (""), szParamValue ("");
            int nPos = getOperatePostion(szParamCondition, m_lsCondition, szCondition);

            if(nPos > 0)
            {
                szReturn = szParamCondition.substr(0, nPos - 1);
                szParamValue = szParamCondition.substr(nPos + szCondition.length() + 1, szParamCondition.length() - 
                    (nPos + szCondition.length() + 1));
            }

            if(!checkParamValue(szReturn, szParamValue))
            {
                bNoError = false;
            }
            if(bNoError)
            {
                sprintf(szKey, "%d", nIndex);
                szExpression = szExpression + szKey;
                sprintf(szKey, "sv_paramname%d", nIndex);
                if((bNoError = AddNodeAttrib(alertnode, szKey, szReturn)))
                {
                    sprintf(szKey, "sv_operate%d", nIndex);
                    if((bNoError = AddNodeAttrib(alertnode, szKey, szCondition)))
                    {
                        sprintf(szKey, "sv_paramvalue%d", nIndex);
                        if(bNoError = AddNodeAttrib(alertnode, szKey, szParamValue))
                        {
                            if(bNoError = AddNodeAttrib(alertnode, "sv_expression", szExpression))
                            {
                                sprintf(szCount, "%d", nCount + 1);
                                bNoError = AddNodeAttrib(alertnode, "sv_conditioncount", szCount);
                            }
                        }
                    }
                }
            }     
        }
    }
    else
    {
        showErrorMsg(sv_condition_is_null);
        bNoError = false;
    }
    return bNoError ;
}
Esempio n. 30
0
bool SVConditionParam::checkCondition(MAPNODE &alertnode)
{
    bool bNoError = true;
    list<string> lstCondition;
    list<string> lstParam;
    list<string> lstOperate;

    string szValue = m_pConditionArea->text();

    if(!szValue.empty())
    {
        unsigned int nResult = getCondition(lstCondition, szValue);
        nResult = getParam(lstParam, szValue);

        if(lstCondition.size() != lstParam.size() - 1)
        {
            bNoError = false;
            showErrorMsg(sv_condition_relation_error);
            return bNoError;
        }

        char szCount[4] = {0}, szKey [32] = {0};
        int nCount = static_cast<int>(lstCondition.size());
        int nIndex = 1;
        string szExpression ("");
        if(nCount >= 1)
        {
            while(lstCondition.size())
            {
                string szConValue = *(lstCondition.begin());
                lstCondition.pop_front();

                string szParamCondition = *(lstParam.begin());
                lstParam.pop_front();
                string szCondition (""), szReturn (""), szParamValue ("");
                int nPos = getOperatePostion(szParamCondition, m_lsCondition, szCondition);

                if(nPos > 0 && !szCondition.empty())
                {
                    szReturn = szParamCondition.substr(0, nPos - 1);
                    szParamValue = szParamCondition.substr(nPos + szCondition.length() + 1, szParamCondition.length() - 
                        (nPos + szCondition.length() + 1));
                    if(! checkParamValue(szReturn, szParamValue))
                    {
                        bNoError = false;
                        break;
                    }
                }
                else
                {
                    showErrorMsg(sv_condition_relation_error);
                    bNoError = false;
                }
                nIndex ++;
            }
        }
        if(bNoError)
        {
            string szParamCondition = *(lstParam.begin());
            lstParam.pop_front();
            string szCondition (""), szReturn (""), szParamValue ("");
            int nPos = getOperatePostion(szParamCondition, m_lsCondition, szCondition);

            if(nPos > 0 && !szCondition.empty())
            {
                szReturn = szParamCondition.substr(0, nPos - 1);
                szParamValue = szParamCondition.substr(nPos + szCondition.length() + 1, szParamCondition.length() - 
                    (nPos + szCondition.length() + 1));
                bNoError = checkParamValue(szReturn, szParamValue);
            }
            else
            {
                showErrorMsg(sv_condition_relation_error);
                bNoError = false;
            } 
        }
    }
    else
    {
        showErrorMsg(sv_condition_is_null);
        bNoError = false;
    }
    if(bNoError)
    {
        showHelp(m_bShowHelp);
    }
    return bNoError ;
}