Compare commits

..

3 Commits

Author SHA1 Message Date
79aab9999f some more code on this project ( i don't know what i do ) 2023-10-01 17:52:37 +02:00
dc5912187a finish timeout implementation 2023-10-01 17:52:02 +02:00
eeb8e22117 update gitignore 2023-10-01 17:51:43 +02:00
5 changed files with 168 additions and 12 deletions

56
.gitignore vendored
View File

@ -1 +1,55 @@
test-bench/test1/build-test1-idf-Desktop_Qt_6_3_0_MinGW_64_bit-Debug
# C++ objects and libs
*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.so.*
*.dll
*.dylib
# Qt-es
object_script.*.Release
object_script.*.Debug
*_plugin_import.cpp
/.qmake.cache
/.qmake.stash
*.pro.user
*.pro.user.*
*.qbs.user
*.qbs.user.*
*.moc
moc_*.cpp
moc_*.h
qrc_*.cpp
ui_*.h
*.qmlc
*.jsc
Makefile*
*build-*
*.qm
*.prl
# Qt unit tests
target_wrapper.*
# QtCreator
*.autosave
# QtCreator Qml
*.qmlproject.user
*.qmlproject.user.*
# QtCreator CMake
CMakeLists.txt.user*
# QtCreator 4.8< compilation database
compile_commands.json
# QtCreator local machine specific files for imported projects
*creator.user*
*_qmlcache.qrc
*.user

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

@ -1,9 +1,17 @@
#include "xf/timeout.h"
// TODO: Implement code for XFTimeout class
// TODO done: Implement code for XFTimeout class
XFTimeout::XFTimeout(int id, int interval, interface::XFBehavior *pBehavior):
XFEvent(XFEventType::Timeout, id), interval_(interval) {
}
bool XFTimeout::operator ==(const XFTimeout &timeout) const {
bool i = (id_ == timeout.id_);
bool b = (pBehavior_ == timeout.pBehavior_);
return (i && b);
}
bool XFTimeout::deleteAfterConsume() const {
return true;
}

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