2020-12-01 12:56:04 +01:00
|
|
|
#ifndef OBJECT_H
|
|
|
|
#define OBJECT_H
|
|
|
|
|
2020-12-01 13:08:48 +01:00
|
|
|
#include <list>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2020-12-01 18:29:41 +01:00
|
|
|
class Database;
|
|
|
|
|
2020-12-01 13:08:48 +01:00
|
|
|
//taken from GodotEngine's object.h
|
|
|
|
#define RCPP_OBJECT(m_class, m_inherits) \
|
|
|
|
private: \
|
|
|
|
void operator=(const m_class &p_rval) {} \
|
|
|
|
\
|
|
|
|
public: \
|
|
|
|
virtual std::string get_class() const override { \
|
|
|
|
return std::string(#m_class); \
|
|
|
|
} \
|
2020-12-01 13:47:02 +01:00
|
|
|
static void *get_class_ptr_static() { \
|
2020-12-01 13:08:48 +01:00
|
|
|
static int ptr; \
|
|
|
|
return &ptr; \
|
|
|
|
} \
|
2020-12-01 13:47:02 +01:00
|
|
|
static std::string get_class_static() { \
|
2020-12-01 13:08:48 +01:00
|
|
|
return std::string(#m_class); \
|
|
|
|
} \
|
2020-12-01 13:47:02 +01:00
|
|
|
static std::string get_parent_class_static() { \
|
2020-12-01 13:08:48 +01:00
|
|
|
return m_inherits::get_class_static(); \
|
|
|
|
} \
|
|
|
|
static void get_inheritance_list_static(std::list<std::string> *p_inheritance_list) { \
|
|
|
|
m_inherits::get_inheritance_list_static(p_inheritance_list); \
|
|
|
|
p_inheritance_list->push_back(std::string(#m_class)); \
|
|
|
|
} \
|
|
|
|
static std::string inherits_static() { \
|
|
|
|
return std::string(#m_inherits); \
|
|
|
|
} \
|
|
|
|
virtual bool is_class(const std::string &p_class) const override { return (p_class == (#m_class)) ? true : m_inherits::is_class(p_class); } \
|
|
|
|
virtual bool is_class_ptr(void *p_ptr) const override { return (p_ptr == get_class_ptr_static()) ? true : m_inherits::is_class_ptr(p_ptr); } \
|
|
|
|
\
|
|
|
|
static void get_valid_parents_static(std::list<std::string> *p_parents) { \
|
|
|
|
if (m_class::_get_valid_parents_static != m_inherits::_get_valid_parents_static) { \
|
|
|
|
m_class::_get_valid_parents_static(p_parents); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
m_inherits::get_valid_parents_static(p_parents); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
private:
|
|
|
|
|
2020-12-01 12:56:04 +01:00
|
|
|
class Object {
|
|
|
|
public:
|
2020-12-01 18:29:41 +01:00
|
|
|
Database *db;
|
|
|
|
|
2020-12-01 13:47:02 +01:00
|
|
|
virtual std::string get_class() const { return "Object"; }
|
|
|
|
static void *get_class_ptr_static() {
|
|
|
|
static int ptr;
|
|
|
|
return &ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static std::string get_class_static() { return "Object"; }
|
|
|
|
static std::string get_parent_class_static() { return std::string(); }
|
|
|
|
|
|
|
|
static void get_inheritance_list_static(std::list<std::string> *p_inheritance_list) { p_inheritance_list->push_back("Object"); }
|
|
|
|
|
|
|
|
virtual bool is_class(const std::string &p_class) const { return (p_class == "Object"); }
|
|
|
|
virtual bool is_class_ptr(void *p_ptr) const { return get_class_ptr_static() == p_ptr; }
|
|
|
|
|
|
|
|
static void get_valid_parents_static(std::list<std::string> *p_parents) {}
|
|
|
|
static void _get_valid_parents_static(std::list<std::string> *p_parents) {}
|
|
|
|
|
|
|
|
//dbconnection
|
|
|
|
//setting object?
|
|
|
|
//FileCache? -> set it to the global singleton by default?
|
|
|
|
|
2020-12-01 13:08:48 +01:00
|
|
|
Object();
|
|
|
|
virtual ~Object();
|
2020-12-01 12:56:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|