some more code on this project ( i don't know what i do )

This commit is contained in:
Rémi Heredero 2023-10-01 17:52:37 +02:00
parent dc5912187a
commit 79aab9999f
3 changed files with 102 additions and 8 deletions

View File

@ -4,3 +4,47 @@
#include "xf/behavior.h"
// TODO: Implement code for XFBehavior class
XFBehavior::XFBehavior() {
}
XFBehavior::~XFBehavior() {
}
void XFBehavior::startBehavior() {
}
void XFBehavior::pushEvent(XFEvent *pEvent) {
}
bool XFBehavior::deleteOnTerminate() const {
return deleteOnTerminate_;
}
void XFBehavior::setDeleteOnTerminate(bool deleteBehaviour) {
deleteOnTerminate_ = deleteBehaviour;
}
const XFEvent *XFBehavior::getCurrentEvent() const {
return pCurrentEvent_;
}
interface::XFDispatcher *XFBehavior::getDispatcher() {
}
const XFTimeout *XFBehavior::getCurrentTimeout() {
}
void XFBehavior::setCurrentEvent(const XFEvent *pEvent) {
}
XFBehavior::TerminateBehavior XFBehavior::process(const XFEvent *pEvent) {
}

View File

@ -19,12 +19,46 @@ using Mutex = interface::XFMutex; // Rename XFMutex interface class to Mut
// Note: The implementation is done here because only in this file the real XFDispatcher
// class is known (port specific class). An instance of the XFDispatcher class is
// returned by the 'interface::XFDispatcher' class.
interface::XFDispatcher * interface::XFDispatcher::getInstance()
{
interface::XFDispatcher * interface::XFDispatcher::getInstance() {
static ::XFDispatcher dispatcher;
return &dispatcher;
}
// TODO: Implement code for XFDispatcher class
XFDispatcher::XFDispatcher() {
}
XFDispatcher::~XFDispatcher() {
}
void XFDispatcher::dispatchEvent(const XFEvent *pEvent) const {
}
void XFDispatcher::pushEvent(XFEvent *pEvent) {
events_.push(pEvent);
}
void XFDispatcher::scheduleTimeout(int timeoutId, int interval, interface::XFBehavior *pBehavior) {
XFTimeoutManager* timeoutManager = XFTimeoutManager::getInstance();
timeoutManager->scheduleTimeout(timeoutId, interval, pBehavior);
}
void XFDispatcher::unscheduleTimeout(int timeoutId, interface::XFBehavior *pBehavior) {
XFTimeoutManager* timeoutManager = XFTimeoutManager::getInstance();
timeoutManager->unscheduleTimeout(timeoutId, pBehavior);
}
void XFDispatcher::executeOnce() {
}
int XFDispatcher::execute(const void *param) {
}
#endif // USE_XF_COMMON_DISPATCHER_CLASS

View File

@ -23,7 +23,14 @@ interface::XFTimeoutManager * interface::XFTimeoutManager::getInstance() {
// TODO: Implement code for XFTimeoutManager class
XFTimeoutManager::XFTimeoutManager() {
}
void XFTimeoutManager::addTimeout(XFTimeout *pNewTimeout) {
timeouts_.push_front(pNewTimeout);
}
void XFTimeoutManager::returnTimeout(XFTimeout *pTimeout) {
timeouts_.remove(pTimeout);
}
XFTimeoutManager::~XFTimeoutManager() {
@ -36,14 +43,23 @@ void XFTimeoutManager::start(std::function<void (uint32_t)> startTimeoutManagerT
void XFTimeoutManager::scheduleTimeout(int32_t timeoutId, int32_t interval, interface::XFBehavior *pBehavior) {
::XFTimeout* timeout = new XFTimeout(timeoutId, interval, pBehavior);
timeouts_.push_front(timeout);
addTimeout(timeout);
}
int32_t timeoutIdComparison;
bool myPredicate(XFTimeout* timeout) {return (timeout->getId()==timeoutIdComparison);}
void XFTimeoutManager::unscheduleTimeout(int32_t timeoutId, interface::XFBehavior *pBehavior) {
timeoutIdComparison = timeoutId;
timeouts_.remove_if(myPredicate);
for(XFTimeout* timeout : timeouts_) {
bool id = ( timeout->getId() == timeoutId );
bool behavior = ( timeout->getBehavior() == pBehavior);
if( id && behavior ) {
timeouts_.remove(timeout);
}
}
}
void XFTimeoutManager::tick() {
for(XFTimeout* timeout : timeouts_) {
timeout->substractFromRelTicks(tickInterval_);
}
}
#endif // USE_XF_COMMON_TIMEOUTMANAGER_CLASS