make it build

This commit is contained in:
Morten Delenk 2017-04-24 10:09:09 +00:00
parent c6d3d9e1de
commit 2503a36016
3 changed files with 14 additions and 14 deletions

View file

@ -9,25 +9,25 @@ class Kref {
kobjectType type; kobjectType type;
void *ptr; void *ptr;
unsigned int refctr; unsigned int refctr;
bool set; bool mset;
Kobject(kobjectType type) { Kref(kobjectType type) {
this->type = type; this->type = type;
refctr = 1; refctr = 1;
set = false; mset = false;
} }
template<typename T> template<typename T>
auto set(T *data) -> Kobject & { auto set(T *data) -> Kref & {
if(set) if(mset)
return *this; return *this;
ptr = (void*)data; ptr = (void*)data;
set=true; mset=true;
return *this; return *this;
} }
template<typename T> template<typename T>
T *get() { T *get() {
return (T*)ptr; return (T*)ptr;
} }
auto operator++(int) -> Kobject & { auto operator++(int) -> Kref & {
unsigned int old = refctr; unsigned int old = refctr;
refctr++; refctr++;
if(old > refctr) { if(old > refctr) {
@ -37,11 +37,11 @@ class Kref {
} }
return *this; return *this;
} }
auto operator--(int) -> Kobject & { auto operator--(int) -> Kref & {
refctr--; refctr--;
if(!refctr) { if(!refctr) {
//delete ptr; //delete ptr;
set = false; mset = false;
ptr = nullptr; ptr = nullptr;
} }
return *this; return *this;
@ -49,9 +49,9 @@ class Kref {
}; };
class Kobject { class Kobject {
public: public:
KobjectType type; kobjectType type;
unsigned int refctr; unsigned int refctr;
Kobject(KobjectType type):type(type),refctr(1) {} Kobject(kobjectType type):type(type),refctr(1) {}
virtual ~Kobject() { virtual ~Kobject() {
refctr=0; refctr=0;
} }
@ -72,4 +72,4 @@ class Kobject {
} }
return *this; return *this;
} }
} };

View file

@ -1,5 +1,5 @@
#pragma once #pragma once
#include <kobject.h> #include <kobject.hpp>
enum Color { enum Color {
BLACK, BLACK,
BLUE, BLUE,

View file

@ -1,5 +1,5 @@
#include <tty.hpp> #include <tty.hpp>
TTY::TTY(int width, int height): x(0), y(0), width(width), height(height), curColor(WHITE), rgbColor(0xFFFFFF), useRGB(false), Kobject(KobjectType::TTY) {} TTY::TTY(int width, int height): x(0), y(0), width(width), height(height), curColor(WHITE), rgbColor(0xFFFFFF), useRGB(false), Kobject(kobjectType::TTY) {}
TTY::~TTY() {} TTY::~TTY() {}
auto TTY::plotChar(int x, int y, int c) -> void {} auto TTY::plotChar(int x, int y, int c) -> void {}
auto TTY::rgbSupport() -> bool {return true;} auto TTY::rgbSupport() -> bool {return true;}