mirror of
https://git.tesses.org/tesses50/tessesframework.git
synced 2026-06-01 18:15:31 +00:00
Overhaul cmake configuration, add console api, fix http code that caused issues with cgi-bin
This commit is contained in:
@@ -1,98 +1,119 @@
|
||||
/*
|
||||
TessesFramework a library to make C++ easier for me, used in CrossLang:
|
||||
https://git.tesses.org/tesses50/crosslang Copyright (C) 2026 Mike Nolan
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Threading/Mutex.hpp"
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <cstring>
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <ratio>
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include "Threading/Mutex.hpp"
|
||||
#include <optional>
|
||||
#include <atomic>
|
||||
|
||||
namespace Tesses::Framework
|
||||
{
|
||||
|
||||
|
||||
std::optional<std::string> TF_GetCommandName();
|
||||
class TF_Timer_Handle;
|
||||
//Used for internal purposes, don't use unless you want to run timer events on another thread
|
||||
|
||||
class TF_Timer_Handler {
|
||||
private:
|
||||
std::vector<std::weak_ptr<TF_Timer_Handle>> handles;
|
||||
public:
|
||||
void Update();
|
||||
|
||||
|
||||
static std::shared_ptr<TF_Timer_Handle> Make(std::shared_ptr<TF_Timer_Handler> handler);
|
||||
friend class TF_Timer_Handle;
|
||||
};
|
||||
namespace Tesses::Framework {
|
||||
|
||||
class TF_Timer_Handle {
|
||||
|
||||
private:
|
||||
std::shared_ptr<TF_Timer_Handler> timerHandler;
|
||||
std::function<void()> cb;
|
||||
std::chrono::milliseconds interval;
|
||||
std::chrono::time_point<std::chrono::steady_clock, std::chrono::milliseconds> last;
|
||||
bool enabled;
|
||||
TF_Timer_Handle() = delete;
|
||||
class TF_Timer_Handle;
|
||||
// Used for internal purposes, don't use unless you want to run timer events on
|
||||
// another thread
|
||||
|
||||
TF_Timer_Handle(std::shared_ptr<TF_Timer_Handler> timerHandler);
|
||||
class TF_Timer_Handler {
|
||||
private:
|
||||
std::vector<std::weak_ptr<TF_Timer_Handle>> handles;
|
||||
|
||||
public:
|
||||
|
||||
void SetCallback(std::function<void()> cb);
|
||||
public:
|
||||
void Update();
|
||||
|
||||
int64_t GetIntervalMilliseconds();
|
||||
std::chrono::duration<int64_t,std::milli> GetIntervalDuration();
|
||||
static std::shared_ptr<TF_Timer_Handle>
|
||||
Make(std::shared_ptr<TF_Timer_Handler> handler);
|
||||
friend class TF_Timer_Handle;
|
||||
};
|
||||
|
||||
void SetIntervalFromMilliseconds(int64_t ms);
|
||||
|
||||
void SetIntervalFromDuration(std::chrono::milliseconds dur);
|
||||
|
||||
class TF_Timer_Handle {
|
||||
|
||||
void SetEnabled(bool enabled);
|
||||
bool GetEnabled();
|
||||
friend class TF_Timer_Handler;
|
||||
};
|
||||
private:
|
||||
std::shared_ptr<TF_Timer_Handler> timerHandler;
|
||||
std::function<void()> cb;
|
||||
std::chrono::milliseconds interval;
|
||||
std::chrono::time_point<std::chrono::steady_clock,
|
||||
std::chrono::milliseconds>
|
||||
last;
|
||||
bool enabled;
|
||||
TF_Timer_Handle() = delete;
|
||||
|
||||
TF_Timer_Handle(std::shared_ptr<TF_Timer_Handler> timerHandler);
|
||||
|
||||
std::shared_ptr<TF_Timer_Handle> TF_Timer();
|
||||
std::shared_ptr<TF_Timer_Handle> TF_Timer(std::function<void()> cb, int64_t interval=1000, bool enabled=true);
|
||||
std::shared_ptr<TF_Timer_Handle> TF_Timer(std::function<void()> cb, std::chrono::milliseconds interval, bool enabled=true);
|
||||
|
||||
void TF_Init();
|
||||
void TF_InitWithConsole();
|
||||
void TF_AllowPortable(std::string argv0);
|
||||
void TF_ConnectToSelf(uint16_t port);
|
||||
void TF_InitEventLoop();
|
||||
void TF_RunEventLoop();
|
||||
void TF_RunEventLoopItteration();
|
||||
bool TF_IsRunning();
|
||||
void TF_Sleep(uint32_t sleepMS);
|
||||
void TF_SetIsRunning(bool _isRunning);
|
||||
void TF_Quit();
|
||||
bool TF_GetConsoleEventsEnabled();
|
||||
void TF_SetConsoleEventsEnabled(bool flag);
|
||||
void TF_InitConsole();
|
||||
void TF_Invoke(std::function<void()> cb);
|
||||
std::string TF_FileSize(uint64_t bytes, bool usesBin=true);
|
||||
|
||||
#if defined(TESSESFRAMEWORK_LOGTOFILE)
|
||||
void TF_Log(std::string dataToLog);
|
||||
#endif
|
||||
public:
|
||||
void SetCallback(std::function<void()> cb);
|
||||
|
||||
int64_t GetIntervalMilliseconds();
|
||||
std::chrono::duration<int64_t, std::milli> GetIntervalDuration();
|
||||
|
||||
#if defined(TESSESFRAMEWORK_LOGTOFILE)
|
||||
#define TF_LOG(log) Tesses::Framework::TF_Log(log)
|
||||
#else
|
||||
#define TF_LOG(log)
|
||||
#endif
|
||||
}
|
||||
void SetIntervalFromMilliseconds(int64_t ms);
|
||||
|
||||
void SetIntervalFromDuration(std::chrono::milliseconds dur);
|
||||
|
||||
void SetEnabled(bool enabled);
|
||||
bool GetEnabled();
|
||||
friend class TF_Timer_Handler;
|
||||
};
|
||||
|
||||
std::shared_ptr<TF_Timer_Handle> TF_Timer();
|
||||
std::shared_ptr<TF_Timer_Handle> TF_Timer(std::function<void()> cb,
|
||||
int64_t interval = 1000,
|
||||
bool enabled = true);
|
||||
std::shared_ptr<TF_Timer_Handle> TF_Timer(std::function<void()> cb,
|
||||
std::chrono::milliseconds interval,
|
||||
bool enabled = true);
|
||||
|
||||
void TF_Init();
|
||||
void TF_InitWithConsole();
|
||||
std::string TF_GetExecutableName();
|
||||
void TF_AllowPortable();
|
||||
void TF_AllowPortable(std::string argv0);
|
||||
void TF_ConnectToSelf(uint16_t port);
|
||||
void TF_InitEventLoop();
|
||||
void TF_RunEventLoop();
|
||||
void TF_RunEventLoopItteration();
|
||||
bool TF_IsRunning();
|
||||
void TF_Sleep(uint32_t sleepMS);
|
||||
void TF_SetIsRunning(bool _isRunning);
|
||||
void TF_Quit();
|
||||
bool TF_GetConsoleEventsEnabled();
|
||||
void TF_SetConsoleEventsEnabled(bool flag);
|
||||
void TF_InitConsole();
|
||||
void TF_Invoke(std::function<void()> cb);
|
||||
std::string TF_FileSize(uint64_t bytes, bool usesBin = true);
|
||||
|
||||
#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
|
||||
} // namespace Tesses::Framework
|
||||
Reference in New Issue
Block a user