should be finish but for sure won't work
This commit is contained in:
parent
820aff5af4
commit
b3cec6c926
@ -3,7 +3,7 @@
|
|||||||
#include "xf/initialevent.h"
|
#include "xf/initialevent.h"
|
||||||
#include "xf/behavior.h"
|
#include "xf/behavior.h"
|
||||||
|
|
||||||
// TODO: Implement code for XFBehavior class
|
// TODO done: Implement code for XFBehavior class
|
||||||
|
|
||||||
XFBehavior::XFBehavior() {
|
XFBehavior::XFBehavior() {
|
||||||
|
|
||||||
@ -14,11 +14,12 @@ XFBehavior::~XFBehavior() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void XFBehavior::startBehavior() {
|
void XFBehavior::startBehavior() {
|
||||||
|
GEN(XFInitialEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
void XFBehavior::pushEvent(XFEvent *pEvent) {
|
void XFBehavior::pushEvent(XFEvent *pEvent) {
|
||||||
|
pEvent->setBehavior(this);
|
||||||
|
this->getDispatcher()->pushEvent(pEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XFBehavior::deleteOnTerminate() const {
|
bool XFBehavior::deleteOnTerminate() const {
|
||||||
@ -34,11 +35,15 @@ const XFEvent *XFBehavior::getCurrentEvent() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface::XFDispatcher *XFBehavior::getDispatcher() {
|
interface::XFDispatcher *XFBehavior::getDispatcher() {
|
||||||
|
return interface::XFDispatcher::getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
const XFTimeout *XFBehavior::getCurrentTimeout() {
|
const XFTimeout *XFBehavior::getCurrentTimeout() {
|
||||||
|
if(pCurrentEvent_->getEventType() == XFEvent::Timeout) {
|
||||||
|
return (XFTimeout*) pCurrentEvent_;
|
||||||
|
} else {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XFBehavior::setCurrentEvent(const XFEvent *pEvent) {
|
void XFBehavior::setCurrentEvent(const XFEvent *pEvent) {
|
||||||
@ -47,6 +52,11 @@ void XFBehavior::setCurrentEvent(const XFEvent *pEvent) {
|
|||||||
|
|
||||||
XFBehavior::TerminateBehavior XFBehavior::process(const XFEvent *pEvent) {
|
XFBehavior::TerminateBehavior XFBehavior::process(const XFEvent *pEvent) {
|
||||||
setCurrentEvent(pEvent);
|
setCurrentEvent(pEvent);
|
||||||
processEvent();
|
XFEventStatus status = XFEventStatus::Unknown;
|
||||||
return deleteOnTerminate_;
|
status = processEvent();
|
||||||
|
if(status == XFEventStatus::Consumed) {
|
||||||
|
return deleteOnTerminate_;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,10 @@ XFDispatcher::~XFDispatcher() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void XFDispatcher::dispatchEvent(const XFEvent *pEvent) const {
|
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) {
|
void XFDispatcher::pushEvent(XFEvent *pEvent) {
|
||||||
@ -51,11 +54,16 @@ void XFDispatcher::unscheduleTimeout(int timeoutId, interface::XFBehavior *pBeha
|
|||||||
}
|
}
|
||||||
|
|
||||||
void XFDispatcher::executeOnce() {
|
void XFDispatcher::executeOnce() {
|
||||||
|
//XFEvent* event;
|
||||||
|
dispatchEvent(events_.front());
|
||||||
|
events_.pop();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int XFDispatcher::execute(const void *param) {
|
int XFDispatcher::execute(const void *param) {
|
||||||
|
while(true){
|
||||||
|
executeOnce();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,6 +13,12 @@ interface::XFMutex * interface::XFMutex::create()
|
|||||||
return new ::XFMutex;
|
return new ::XFMutex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void XFMutex::lock() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void XFMutex::unlock() {
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Implement code for XFMutex class
|
// TODO: Implement code for XFMutex class
|
||||||
|
|
||||||
#endif // USE_XF_IDF_STM32_MUTEX_CLASS
|
#endif // USE_XF_IDF_STM32_MUTEX_CLASS
|
||||||
|
Reference in New Issue
Block a user