void UmlTransition::init(UmlClass *, Q3CString, Q3CString, UmlState * state) { if (triggerName() == "_completion") state->setHasCompletion(); }
void UmlTransition::generate(UmlClass * machine, UmlClass * anystate, UmlState * state) { if (_already_managed) return; Q3CString s = triggerName(); // group transitions having the same trigger const Q3PtrVector<UmlItem> ch = parent()->children(); unsigned index = ch.findRef(this); Q3PtrList<UmlTransition> trs; UmlTransition * tr_no_guard = 0; if (cppGuard().isEmpty()) tr_no_guard = this; else trs.append(this); while (++index != ch.count()) { if ((ch[index]->kind() == aTransition) && (((UmlTransition *) ch[index])->triggerName() == s)) { if (!((UmlTransition *) ch[index])->cppGuard().isEmpty()) trs.append((UmlTransition *) ch[index]); else if (tr_no_guard != 0) { UmlCom::trace("Error : several transitions from '" + parent()->name() + "' don't have guard"); throw 0; } else tr_no_guard = (UmlTransition *) ch[index]; ((UmlTransition *) ch[index])->_already_managed = TRUE; } } if (tr_no_guard != 0) // place it at end trs.append(tr_no_guard); // made the trigger UmlOperation * trg = state->assocClass()->trigger(s, machine, anystate); Q3CString body; if (s == "create") { // manage entry if (!state->cppEntryBehavior().isEmpty()) body = " _doentry(stm);\n"; } if (!state->cppDoActivity().isEmpty()) // state do activity before each event except create body += " _do(stm);\n"; bool completion = (s == "_completion"); if (!completion && state->isLeaf() && state->hasCompletion()) // manage completion body += " if (_completion(stm)) return;\n"; UmlTransition::generate(trs, machine, anystate, state, body, " ", completion); trg->set_CppBody(body); }
//creates a trigger of type aType(EntryTrigger/ExitTrigger), with the coordinates and radius as //supplied in the argument bool QMLBackendMonitorCreateTriggerAO::InitializeTrigger(QGeoAreaMonitorS60* aParent , enTriggerType aType, TCoordinate& aCoordinate, qreal& aRadius) { TInt ret = KErrGeneral; TLbtTriggerId triggerID = NULL; //try retrieving the trigger information from the linked list corresponding to the aParent and aType CMonitorTriggerInfo* triggerInfo = iTriggerMonitorInfo->getMonitorTriggerInfo(aParent, aType); //if no triggerinfo available in the linked list if (triggerInfo == NULL) { //Define the triggering area CLbtGeoCircle* trigArea = NULL; TRAP(ret, trigArea = CLbtGeoCircle::NewL( aCoordinate ,//center coordinate aRadius //radius in meters. If //NaN is used, Location //Triggering Server will //use minimal size of trigger //area as the radius of the //trigger )); if ((ret != KErrNone) || !trigArea) return FALSE; CleanupStack::PushL(trigArea); CLbtTriggerConditionArea* cond = NULL; if (aType == EntryTrigger) { //2: Construct a entry type of trigger condition TRAP(ret, cond = CLbtTriggerConditionArea::NewL( trigArea, CLbtTriggerConditionArea::EFireOnEnter )); } else if (aType == ExitTrigger) { TRAP(ret, cond = CLbtTriggerConditionArea::NewL( trigArea, CLbtTriggerConditionArea::EFireOnExit )); } if ((ret != KErrNone) || !cond) { CleanupStack::PopAndDestroy(trigArea); return FALSE; } CleanupStack::Pop(trigArea); //ownership of trigArea is transferred. CleanupStack::PushL(cond); RRequestorStack reqStack; CleanupClosePushL(reqStack); //trigger name. _LIT(KMyTriggerName, "EntryTrigger"); TDesC triggerName(KMyTriggerName); if (aType == ExitTrigger) { _LIT(KMyTriggerName, "ExitTrigger"); triggerName = KMyTriggerName; } //Construct requestor _LIT(KMyRequestorName, "QTLBTBackend"); //Application name used as requestor identifier CRequestor *req = NULL; TRAP(ret, req = CRequestor::NewL( CRequestorBase::ERequestorService, CRequestorBase::EFormatApplication, KMyRequestorName )); if ((ret != KErrNone) || !req) { CleanupStack::PopAndDestroy(&reqStack); CleanupStack::PopAndDestroy(cond); return FALSE; } CleanupStack::PushL(req); TRAP(ret, reqStack.AppendL(req)); CleanupStack::Pop(req); if (ret != KErrNone) { CleanupStack::PopAndDestroy(&reqStack); CleanupStack::PopAndDestroy(cond); return FALSE; } TUid managerUid = TUid::Uid(0); CLbtSessionTrigger* trig = NULL; TRAP(ret, trig = CLbtSessionTrigger::NewL( triggerName, CLbtTriggerEntry::EStateDisabled, reqStack, managerUid, cond )); CleanupStack::PopAndDestroy(&reqStack); CleanupStack::Pop(cond); trig->SetTimeToRearm(0); if ((ret != KErrNone) || (!trig)) { CleanupStack::PopAndDestroy(cond); return FALSE; } CleanupStack::PushL(trig); //iLbt.CreateTrigger(*trig, triggerID, ETrue, iStatus); //CleanupStack::PopAndDestroy(trig ); TRAP(ret, iActiveSchedulerwait = new(ELeave) CActiveSchedulerWait); if ((ret != KErrNone) || !iActiveSchedulerwait) { CleanupStack::PopAndDestroy(trig); return FALSE; } iTriggerCreation = FALSE; //create a trigger asynchronously iLbt.CreateTrigger(*trig, triggerID, ETrue, iStatus); SetActive(); //wait till the iActiveSchedularwait->AsyncStop() is called in RunL iActiveSchedulerwait->Start(); delete iActiveSchedulerwait; CleanupStack::PopAndDestroy(trig); //if the trigger creation is successful, add the triggerinfo to the linked list if (iTriggerCreation == TRUE) iTriggerMonitorInfo->addMonitorTriggerInfo(aParent, triggerID, aType); delete req; return iTriggerCreation; } else { //triggerinfo available in the linked list CLbtSessionTrigger* trig = NULL; //Define the triggering area CLbtGeoCircle* trigArea = NULL; TRAP(ret, trigArea = CLbtGeoCircle::NewL( aCoordinate , //center coordinate aRadius //radius in meters. If //NaN is used, Location //Triggering Server will //use minimal size of trigger //area as the radius of the //trigger )); if ((ret != KErrNone) || (!trigArea)) { return FALSE; } CleanupStack::PushL(trigArea); //2: Construct a entry type of trigger condition CLbtTriggerConditionArea* cond = NULL; if (aType == EntryTrigger) { //2: Construct a entry type of trigger condition TRAP(ret, cond = CLbtTriggerConditionArea::NewL( trigArea, CLbtTriggerConditionArea::EFireOnEnter )); } else if (aType == ExitTrigger) { TRAP(ret, cond = CLbtTriggerConditionArea::NewL( trigArea, CLbtTriggerConditionArea::EFireOnExit )); } if ((ret != KErrNone) || !cond) { CleanupStack::PopAndDestroy(trigArea); return FALSE; } CleanupStack::Pop(trigArea); //ownership of trigArea is transferred. CleanupStack::PushL(cond); //create a session trigger TRAP(ret, trig = CLbtSessionTrigger::NewL()); if ((ret != KErrNone) || (!trig)) { CleanupStack::PopAndDestroy(cond); return FALSE; } //set the condition for the trigger trig->SetCondition(cond); CleanupStack::Pop(cond); CleanupStack::PushL(trig); //set the trigger ID trig->SetId(triggerInfo->iTriggerID); iLbt.SetTriggerStateL(triggerInfo->iTriggerID, CLbtTriggerEntry::EStateDisabled, ELbtTrue); //update the trigger with the new condition in LBT server TRAP(ret, iLbt.UpdateTriggerL(*trig, CLbtTriggerEntry::EAttributeCondition, ELbtTrue)); CleanupStack::PopAndDestroy(trig); if (ret != KErrNone) { return FALSE;; } return TRUE; } }