WIP Backend System Redesign Step 1
- Created 1 Context for Backend Management and Sharing - Made every class that used a static Backend require the Context or specific Backend - Bring Back 3ds support
This commit is contained in:
@@ -78,7 +78,7 @@ class PD_API Color {
|
||||
*/
|
||||
constexpr Color& Hex(const std::string_view& hex) {
|
||||
if (!(hex.length() == 7 || hex.length() == 9)) {
|
||||
throw "[PD] Color: hex string is not rgb or rgba!";
|
||||
PD::Throw("[PD] Color: hex string is not rgb or rgba!");
|
||||
}
|
||||
r = PD::Strings::HexChar2Int(hex[1]) * 16 +
|
||||
PD::Strings::HexChar2Int(hex[2]);
|
||||
|
||||
@@ -74,7 +74,12 @@ SOFTWARE.
|
||||
|
||||
namespace PD {
|
||||
[[noreturn]] inline void Throw(const std::string& str) {
|
||||
throw std::runtime_error("[PD] " + str);
|
||||
#ifdef _EXCEPTIONS
|
||||
throw std::runtime_error("PD Error " + str);
|
||||
#else
|
||||
std::cout << "PD Error " << str << std::endl;
|
||||
std::abort();
|
||||
#endif
|
||||
}
|
||||
/** Types */
|
||||
using u8 = unsigned char;
|
||||
|
||||
@@ -26,6 +26,7 @@ SOFTWARE.
|
||||
#include <pd/core/common.hpp>
|
||||
|
||||
namespace PD {
|
||||
class OsDriver;
|
||||
/**
|
||||
* Timer class
|
||||
*/
|
||||
@@ -35,7 +36,7 @@ class PD_API Timer {
|
||||
* Constructor
|
||||
* @param auto_start [default true] sets if timer should start after creation
|
||||
*/
|
||||
Timer(bool auto_start = true);
|
||||
Timer(OsDriver& os, bool auto_start = true);
|
||||
/**
|
||||
* Unused Deconstructor
|
||||
*/
|
||||
@@ -81,5 +82,7 @@ class PD_API Timer {
|
||||
u64 pNow;
|
||||
/** Is Running */
|
||||
bool pIsRunning = false;
|
||||
/** Os Driver reference */
|
||||
OsDriver& pOs;
|
||||
};
|
||||
} // namespace PD
|
||||
@@ -26,6 +26,7 @@ SOFTWARE.
|
||||
#include <pd/core/common.hpp>
|
||||
|
||||
namespace PD {
|
||||
class OsDriver;
|
||||
/**
|
||||
* Class to calculate Maximum/Minimum and Average Timings
|
||||
*/
|
||||
@@ -218,12 +219,12 @@ class Res {
|
||||
* Begin a Trace
|
||||
* @param id Name of the Trace
|
||||
*/
|
||||
PD_API void Beg(const std::string& id);
|
||||
PD_API void Beg(OsDriver& os, const std::string& id);
|
||||
/**
|
||||
* End a Trace
|
||||
* @param id Name of the Trace
|
||||
*/
|
||||
PD_API void End(const std::string& id);
|
||||
PD_API void End(OsDriver& os, const std::string& id);
|
||||
/**
|
||||
* Collect Start end end of the trace by tracking
|
||||
* when the Scope object goes out of scope
|
||||
@@ -245,18 +246,20 @@ class Scope {
|
||||
* Constructor requiring a Name for the Trace
|
||||
* @param id Name of the Trace
|
||||
*/
|
||||
Scope(const std::string& id) {
|
||||
Scope(OsDriver& os, const std::string& id) : pOs(os) {
|
||||
this->ID = id;
|
||||
Beg(id);
|
||||
Beg(pOs, id);
|
||||
}
|
||||
/**
|
||||
* Deconstructor getting the end time when going out of scope
|
||||
*/
|
||||
~Scope() { End(ID); }
|
||||
~Scope() { End(pOs, ID); }
|
||||
|
||||
private:
|
||||
/** Trace Name/ID */
|
||||
std::string ID;
|
||||
/** Os Driver Reference */
|
||||
OsDriver& pOs;
|
||||
};
|
||||
} // namespace TT
|
||||
} // namespace PD
|
||||
Reference in New Issue
Block a user