0.7.0 rewrite dev
- remove everyting - keep core -rename bit_utils to bits - add formatter for color - add float getters to color - start with new drivers api
This commit is contained in:
@@ -1,53 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/core/common.hpp>
|
||||
#include <pd/core/timetrace.hpp>
|
||||
#include <pd/drivers/types.hpp>
|
||||
#include <pd/pd_p_api.hpp>
|
||||
#include <pd/drivers/interface.hpp>
|
||||
|
||||
namespace PD {
|
||||
using TraceMap = std::map<std::string, TT::Res::Ref>;
|
||||
|
||||
class PD_API OsDriver {
|
||||
class PD_API OsDriver : public DriverInterface {
|
||||
public:
|
||||
OsDriver(const std::string& name = "StdPd") : pName(name) {}
|
||||
OsDriver(PDDriverData data) : pName("StdPd") {}
|
||||
virtual ~OsDriver() = default;
|
||||
PD_SHARED(OsDriver);
|
||||
OsDriver(std::string_view name = "Default") : DriverInterface(name) {}
|
||||
virtual ~OsDriver() {}
|
||||
|
||||
virtual u64 GetTime();
|
||||
virtual u64 GetNanoTime();
|
||||
TraceMap& GetTraceMap();
|
||||
TT::Res::Ref& GetTraceRef(const std::string& id);
|
||||
bool TraceExist(const std::string& id);
|
||||
const std::string& GetName() const { return pName; }
|
||||
virtual u64 GetTime() const;
|
||||
virtual u64 GetTimeNano() const;
|
||||
};
|
||||
|
||||
TraceMap pTraces;
|
||||
class PD_API Os {
|
||||
public:
|
||||
Os() = default;
|
||||
~Os() = default;
|
||||
|
||||
template <typename T, typename... Args>
|
||||
static void UseDriver(Args&&... args) {
|
||||
// assert(driver == nullptr && "OS Driver already set");
|
||||
driver = std::make_unique<T>(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
static u64 GetTime() { return driver->GetTime(); }
|
||||
static u64 GetTimeNano() { return driver->GetTimeNano(); }
|
||||
|
||||
private:
|
||||
const std::string pName = "StdPd";
|
||||
static std::unique_ptr<OsDriver> driver;
|
||||
};
|
||||
} // namespace PD
|
||||
Reference in New Issue
Block a user