diff --git a/src/simplified/xf/core/behavior.cpp b/src/simplified/xf/core/behavior.cpp index 76e5605..ab2c3bf 100644 --- a/src/simplified/xf/core/behavior.cpp +++ b/src/simplified/xf/core/behavior.cpp @@ -3,7 +3,7 @@ #include "xf/initialevent.h" #include "xf/behavior.h" -// TODO: Implement code for XFBehavior class +// TODO done: Implement code for XFBehavior class XFBehavior::XFBehavior() { @@ -14,11 +14,12 @@ XFBehavior::~XFBehavior() { } void XFBehavior::startBehavior() { - + GEN(XFInitialEvent()); } void XFBehavior::pushEvent(XFEvent *pEvent) { - + pEvent->setBehavior(this); + this->getDispatcher()->pushEvent(pEvent); } bool XFBehavior::deleteOnTerminate() const { @@ -34,11 +35,15 @@ const XFEvent *XFBehavior::getCurrentEvent() const { } interface::XFDispatcher *XFBehavior::getDispatcher() { - + return interface::XFDispatcher::getInstance(); } const XFTimeout *XFBehavior::getCurrentTimeout() { - + if(pCurrentEvent_->getEventType() == XFEvent::Timeout) { + return (XFTimeout*) pCurrentEvent_; + } else { + return nullptr; + } } void XFBehavior::setCurrentEvent(const XFEvent *pEvent) { @@ -47,6 +52,11 @@ void XFBehavior::setCurrentEvent(const XFEvent *pEvent) { XFBehavior::TerminateBehavior XFBehavior::process(const XFEvent *pEvent) { setCurrentEvent(pEvent); - processEvent(); - return deleteOnTerminate_; + XFEventStatus status = XFEventStatus::Unknown; + status = processEvent(); + if(status == XFEventStatus::Consumed) { + return deleteOnTerminate_; + } else { + return false; + } } diff --git a/src/simplified/xf/port/common/dispatcher.cpp b/src/simplified/xf/port/common/dispatcher.cpp index 5d9dfb7..48307ec 100644 --- a/src/simplified/xf/port/common/dispatcher.cpp +++ b/src/simplified/xf/port/common/dispatcher.cpp @@ -35,7 +35,10 @@ XFDispatcher::~XFDispatcher() { } void XFDispatcher::dispatchEvent(const XFEvent *pEvent) const { - pEvent->getBehavior()->startBehavior(); + if(pEvent->getBehavior()->process(pEvent)) { // TODO look weird + //events_.pop(); + delete pEvent; + } } void XFDispatcher::pushEvent(XFEvent *pEvent) { @@ -51,11 +54,16 @@ void XFDispatcher::unscheduleTimeout(int timeoutId, interface::XFBehavior *pBeha } void XFDispatcher::executeOnce() { + //XFEvent* event; + dispatchEvent(events_.front()); + events_.pop(); } int XFDispatcher::execute(const void *param) { - + while(true){ + executeOnce(); + } } diff --git a/src/simplified/xf/port/idf-stm32/mutex.cpp b/src/simplified/xf/port/idf-stm32/mutex.cpp index 2d15c6e..5b918d7 100644 --- a/src/simplified/xf/port/idf-stm32/mutex.cpp +++ b/src/simplified/xf/port/idf-stm32/mutex.cpp @@ -13,6 +13,12 @@ interface::XFMutex * interface::XFMutex::create() return new ::XFMutex; } +void XFMutex::lock() { +} + +void XFMutex::unlock() { +} + // TODO: Implement code for XFMutex class #endif // USE_XF_IDF_STM32_MUTEX_CLASS