- Binary Tree (Partial)
- Sequence (Partial)
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#define FENNEC_PLATFORM_INTERFACE_PLATFORM_H
|
||||
|
||||
#include <fennec/containers/list.h>
|
||||
#include <fennec/containers/sequence.h>
|
||||
#include <fennec/langproc/strings/cstring.h>
|
||||
#include <fennec/langproc/strings/string.h>
|
||||
#include <fennec/lang/typed.h>
|
||||
@@ -69,11 +70,48 @@ public:
|
||||
struct driver {
|
||||
int priority;
|
||||
ctor constructor;
|
||||
|
||||
driver()
|
||||
: priority(0)
|
||||
, constructor(nullptr) {
|
||||
}
|
||||
|
||||
driver(int priority, ctor constructor)
|
||||
: priority(priority)
|
||||
, constructor(constructor) {
|
||||
}
|
||||
|
||||
driver(const driver& d)
|
||||
: priority(d.priority)
|
||||
, constructor(d.constructor) {
|
||||
}
|
||||
|
||||
driver(driver&& d) noexcept
|
||||
: priority(d.priority)
|
||||
, constructor(d.constructor) {
|
||||
}
|
||||
|
||||
driver& operator=(const driver& d) {
|
||||
priority = d.priority;
|
||||
constructor = d.constructor;
|
||||
return *this;
|
||||
}
|
||||
|
||||
driver& operator=(driver&& d) noexcept {
|
||||
priority = fennec::move(d.priority);
|
||||
constructor = fennec::move(d.constructor);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator<(const driver& d) const {
|
||||
return priority > d.priority;
|
||||
}
|
||||
};
|
||||
|
||||
const string name;
|
||||
|
||||
virtual ~platform() = default;
|
||||
platform(const platform&) = delete;
|
||||
|
||||
// Dynamically linked objects
|
||||
virtual shared_object* load_object(const cstring& file) = 0;
|
||||
@@ -96,22 +134,27 @@ protected:
|
||||
explicit platform(const cstring& name, PlatformT* type)
|
||||
: typed(type)
|
||||
, name(name) {
|
||||
assertf(singleton == nullptr, "Conflicting platform implementations!");
|
||||
singleton = this;
|
||||
assertf(globals.singleton == nullptr, "Conflicting platform implementations!");
|
||||
globals.singleton = this;
|
||||
}
|
||||
|
||||
private:
|
||||
platform(const platform&) = delete;
|
||||
|
||||
// Static Stuff ========================================================================================================
|
||||
|
||||
public:
|
||||
static platform* instance() {
|
||||
return singleton;
|
||||
return globals.singleton;
|
||||
}
|
||||
|
||||
private:
|
||||
static platform* singleton;
|
||||
inline static struct global {
|
||||
platform* singleton;
|
||||
sequence<window_driver> windows;
|
||||
|
||||
global()
|
||||
: singleton(nullptr)
|
||||
, windows() {
|
||||
}
|
||||
} globals = global();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ namespace fennec
|
||||
class unix_platform : public platform {
|
||||
public:
|
||||
template<typename PlatformT>
|
||||
explicit unix_platform(const cstring& name, PlatformT*)
|
||||
: platform(name, (PlatformT*)(nullptr)) {
|
||||
explicit unix_platform(const cstring& name, PlatformT* type)
|
||||
: platform(name, type) {
|
||||
}
|
||||
|
||||
shared_object* load_object(const cstring& file) override;
|
||||
|
||||
Reference in New Issue
Block a user