bool SCXMLEstadoCompuesto::transicion(const char *desde,const char *hacia,SCXMLTransition *t,SCXMLData *eventdata) { if (!strcmp(desde,nombre)) { if (!strcmp(hacia,actual)) { termina(); t->ejecutar(eventdata); entrar(); return false; } else if (soyYo(hacia)) throw runtime_error("Máquina de estados mal construida.\n"); else { termina(); return true; } } SCXMLEstado *act=hijoC(hijos,actual); if (!act->soyYo(desde)) return false; //Esto nunca debe ocurrir, en realidad. if (act->transicion(desde,hacia,t,eventdata)) { //Queda trabajo por hacer if (soyYo(hacia)) { t->ejecutar(eventdata); SCXMLEstado *nuevo=NULL; for (SCXMLEstado **p=hijos;*p;p++) if ((*p)->soyYo(hacia)) { nuevo=*p; break; } if (!nuevo) throw runtime_error("Error desconocido gestionando los estados."); nuevo->entrar(hacia); actual=nuevo->getNombre(); return false; } else { actual=NULL; termina(); return true; } } else return false; }
void SCXMLEstadoCompuesto::haTerminado(const char *hijo) { //Sólo hay un estado hijo, de manera que si éste termina, el padre también. actual=NULL; termina(); internos->push_back(nombrevento); padre->haTerminado(nombre); }
void fun_random(int *id) { printf("Sou a thread: %d\n", *id); sleep(3); termina(); printf("Fim da thread: %d\n", *id); }
void ctrlHandler() { // Handler para o SIGINT para encerrar o programa (CTRL+C) #ifdef DEBUG printf("Bye bye!\n"); #endif termina(); }