From 5559b663b55bb4cc2a2553ae6518b1f446353685 Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 1 Dec 2020 13:47:02 +0100 Subject: [PATCH] Added a MessagePage class into a new module folder. Also set up module folder compilation, and fixed compile when objects are actually used. --- SConstruct | 46 +++++++++++++++++++++++++++ core/object.h | 28 +++++++++++++--- main.cpp | 7 ++++ modules/message_page/SCsub | 11 +++++++ modules/message_page/detect.py | 27 ++++++++++++++++ modules/message_page/message_page.cpp | 0 modules/message_page/message_page.h | 13 ++++++++ 7 files changed, 128 insertions(+), 4 deletions(-) create mode 100644 modules/message_page/SCsub create mode 100644 modules/message_page/detect.py create mode 100644 modules/message_page/message_page.cpp create mode 100644 modules/message_page/message_page.h diff --git a/SConstruct b/SConstruct index 957a6f1..85812ee 100644 --- a/SConstruct +++ b/SConstruct @@ -89,6 +89,25 @@ for x in sorted(glob.glob("database/*")): sys.path.remove(tmppath) sys.modules.pop("detect") +module_list = [] + +for x in sorted(glob.glob("modules/*")): + if not os.path.isdir(x) or not os.path.exists(x + "/detect.py"): + continue + + tmppath = "./" + x + + sys.path.insert(0, tmppath) + import detect + + if detect.is_active() and detect.can_build(): + x = x.replace("modules/", "") # rest of world + x = x.replace("modules\\", "") # win32 + module_list += [x] + + sys.path.remove(tmppath) + sys.modules.pop("detect") + # Build options @@ -142,6 +161,33 @@ for d in database_list: sys.path.remove(tmppath) sys.modules.pop("detect") +for m in module_list: + tmppath = "./modules/" + m + sys.path.insert(0, tmppath) + + import detect + + env_mod = env_base.Clone() + + # Compilation DB requires SCons 3.1.1+. + from SCons import __version__ as scons_raw_version + + scons_ver = env_mod._get_major_minor_revision(scons_raw_version) + + if scons_ver >= (4, 0, 0): + env_mod.Tool("compilation_db") + env_mod.Alias("compiledb", env.CompilationDatabase()) + + detect.configure(env_mod) + detect.configure(env) + + Export("env_mod") + + SConscript("modules/" + m + "/SCsub") + + sys.path.remove(tmppath) + sys.modules.pop("detect") + Export("env") SConscript("core/SCsub") diff --git a/core/object.h b/core/object.h index 7798472..6b36467 100644 --- a/core/object.h +++ b/core/object.h @@ -9,20 +9,19 @@ #define RCPP_OBJECT(m_class, m_inherits) \ private: \ void operator=(const m_class &p_rval) {} \ - mutable std::stringName _class_name; \ \ public: \ virtual std::string get_class() const override { \ return std::string(#m_class); \ } \ - static _FORCE_INLINE_ void *get_class_ptr_static() { \ + static void *get_class_ptr_static() { \ static int ptr; \ return &ptr; \ } \ - static _FORCE_INLINE_ std::string get_class_static() { \ + static std::string get_class_static() { \ return std::string(#m_class); \ } \ - static _FORCE_INLINE_ std::string get_parent_class_static() { \ + static std::string get_parent_class_static() { \ return m_inherits::get_class_static(); \ } \ static void get_inheritance_list_static(std::list *p_inheritance_list) { \ @@ -47,6 +46,27 @@ private: class Object { public: + 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 *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 *p_parents) {} + static void _get_valid_parents_static(std::list *p_parents) {} + + //dbconnection + //setting object? + //FileCache? -> set it to the global singleton by default? + Object(); virtual ~Object(); }; diff --git a/main.cpp b/main.cpp index d1f4f22..0f96360 100644 --- a/main.cpp +++ b/main.cpp @@ -7,6 +7,8 @@ #include "rdn_application.h" +#include "modules/message_page/message_page.h" + #define MAIN_CLASS RDNApplication int main(int argc, char **argv) { @@ -34,6 +36,10 @@ int main(int argc, char **argv) { HTTPServer *server = new HTTPServer(); + MessagePage *mp = new MessagePage(); + + printf("%s\n", mp->get_class().c_str()); + server->port = 8080; server->initialize(); server->main_loop(); @@ -41,6 +47,7 @@ int main(int argc, char **argv) { delete server; delete app; delete file_cache; + delete mp; return 0; } \ No newline at end of file diff --git a/modules/message_page/SCsub b/modules/message_page/SCsub new file mode 100644 index 0000000..eedee71 --- /dev/null +++ b/modules/message_page/SCsub @@ -0,0 +1,11 @@ +#!/usr/bin/env python + +Import("env_mod") + +env_mod.core_sources = [] + +env_mod.add_source_files(env_mod.core_sources, "*.cpp") + +# Build it all as a library +lib = env_mod.add_library("message_page", env_mod.core_sources) +env_mod.Prepend(LIBS=[lib]) diff --git a/modules/message_page/detect.py b/modules/message_page/detect.py new file mode 100644 index 0000000..37b584b --- /dev/null +++ b/modules/message_page/detect.py @@ -0,0 +1,27 @@ +import os +import platform +import sys + + +def is_active(): + return True + + +def get_name(): + return "message_page" + + +def can_build(): + return True + + +def get_opts(): + return [] + +def get_flags(): + + return [] + + +def configure(env): + pass diff --git a/modules/message_page/message_page.cpp b/modules/message_page/message_page.cpp new file mode 100644 index 0000000..e69de29 diff --git a/modules/message_page/message_page.h b/modules/message_page/message_page.h new file mode 100644 index 0000000..e096fe8 --- /dev/null +++ b/modules/message_page/message_page.h @@ -0,0 +1,13 @@ +#ifndef MESSAGE_PAGE_H +#define MESSAGE_PAGE_H + +#include "core/object.h" + +class MessagePage : public Object { + RCPP_OBJECT(MessagePage, Object); + +public: + +}; + +#endif \ No newline at end of file