#pragma once #include #include #include #include #include #include #include #include class TextException : public std::exception { std::string error_message; public: TextException(std::string ex) { error_message = "TextException: "; error_message.append(ex); } const char * what() const noexcept override { return error_message.c_str(); } }; namespace Tesses::Framework { template class Event { public: virtual void Invoke(TArgs... args)=0; virtual ~Event() {} }; template class FunctionalEvent : public Event { std::function cb; public: FunctionalEvent(std::function cb) { this->cb = cb; } void Invoke(TArgs... args) { this->cb(args...); } }; template class EventList : public Event { std::vector>> items; public: void operator+=(std::shared_ptr> event) { for(std::shared_ptr>& item : this->items) { if(item.get() == event.get()) return; } this->items.push_back(event); } void operator-=(std::shared_ptr> event) { for(auto i = this->items.begin(); i != this->items.end(); i++) { if(i->get() == event.get()) { this->items.erase(i); return; } } } void Invoke(TArgs... args) { for(auto& item : this->items) { item->Invoke(args...); } } }; extern EventList OnItteraton; void TF_Init(); void TF_InitWithConsole(); void TF_ConnectToSelf(uint16_t port); void TF_RunEventLoop(); void TF_RunEventLoopItteration(); bool TF_IsRunning(); void TF_Quit(); bool TF_GetConsoleEventsEnabled(); void TF_SetConsoleEventsEnabled(bool flag); void TF_InitConsole(); #if defined(TESSESFRAMEWORK_LOGTOFILE) void TF_Log(std::string dataToLog); #endif #if defined(TESSESFRAMEWORK_LOGTOFILE) #define TF_LOG(log) Tesses::Framework::TF_Log(log) #else #define TF_LOG(log) #endif }