diff --git a/.gitignore b/.gitignore index e69de29..1d23d3a 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +link/ diff --git a/compile/act/controller.h b/compile/act/controller.h new file mode 100644 index 0000000..c3b47d0 --- /dev/null +++ b/compile/act/controller.h @@ -0,0 +1,15 @@ +#ifndef ACT_CONTROLLER +#define ACT_CONTROLLER +class controller_t { + public: + enum event_t { + start, + stop + }; + enum status_t { + ok, + error + }; + virtual status_t on_event(event_t event_p) = 0; +}; +#endif diff --git a/compile/act/root.cpp b/compile/act/root.cpp new file mode 100644 index 0000000..d7b5c76 --- /dev/null +++ b/compile/act/root.cpp @@ -0,0 +1,24 @@ +#include "controller/root.h" +#include "service/window.h" +root_controller_t::root_controller_t(root_controller_t::configuration_t configuration_p) { + configuration_m = configuration_p; +} +root_controller_t root_controller_factory_t::create(root_controller_t::configuration_t configuration_p) { + return new root_controller_t(configuration_p); +} +controller_t::status_t root_controller_t::on_event(controller_t::event_t event_p) { + if ( + window_service_t* window_service = new window_service_t(); + window_service_t::status_t window_status = window_service->create_window(); + controller_t::status_t controller_status; + switch (window_status) { + case window_service_t::status_t::ok: + controller_status = controller_t::status_t::ok; + break; + case window_service_t::status_t::error: + default: + controller_status = controller_t::status_t::error; + break; + } + return controller_status; +} diff --git a/compile/act/root.h b/compile/act/root.h new file mode 100644 index 0000000..4b921c0 --- /dev/null +++ b/compile/act/root.h @@ -0,0 +1,22 @@ +#ifndef ACT_ROOT +#define ACT_ROOT +#include "controller/controller.h" +#include "allocate/factory.h" +class root_controller_t : public controller_t { + public: + class configuration_t { + private: + mode_t mode_m; + public: + configuration_t(mode_t mode_p); + }; + controller_t::status_t on_event(event_t event_p) override; + private: + root_controller_t(configuration_t configuration_p); + friend class root_controller_factory_t; +}; +class root_controller_factory_t : public factory_t { + public: + root_controller_t create(root_controller_t::configuration_t configuration_p) override; +}; +#endif diff --git a/compile/allocate/factory.h b/compile/allocate/factory.h new file mode 100644 index 0000000..a908b79 --- /dev/null +++ b/compile/allocate/factory.h @@ -0,0 +1,6 @@ +#ifndef ALLOCATE_FACTORY +#define ALLOCATE_FACTORY +template class factory_t { + virtual O* create(I*) = 0; +}; +#endif diff --git a/compile/controller/event.h b/compile/controller/event.h deleted file mode 100644 index 7764354..0000000 --- a/compile/controller/event.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef CONTROLLER_EVENT -#define CONTROLLER_EVENT -enum controller_event_t { - start, - stop -}; -#endif diff --git a/compile/controller/root.h b/compile/controller/root.h deleted file mode 100644 index e5d8205..0000000 --- a/compile/controller/root.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef CONTROLLER_ROOT -#define CONTROLLER_ROOT -#include "controller/status.h" -#include "controller/event.h" - -class root_controller_t { - public: - - controller_status_t on_event(controller_event_t event); -}; -#endif diff --git a/compile/controller/status.h b/compile/controller/status.h deleted file mode 100644 index 7610fe7..0000000 --- a/compile/controller/status.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef CONTROLLER_STATUS -#define CONTROLLER_STATUS -enum controller_status_t { - ok, - error -}; -#endif diff --git a/compile/draw/window.h b/compile/draw/window.h new file mode 100644 index 0000000..c603d95 --- /dev/null +++ b/compile/draw/window.h @@ -0,0 +1,11 @@ +#ifndef SERVICE_WINDOW +#define SERVICE_WINDOW +class window_service_t { + public: + enum status_t { + ok, + error + }; + status_t create_window(); +}; +#endif diff --git a/compile/main.cpp b/compile/main.cpp index af1c4c2..9759f82 100644 --- a/compile/main.cpp +++ b/compile/main.cpp @@ -1,8 +1,8 @@ +#include "controller/controller.h" #include "controller/root.h" -#include "controller/status.h" - int main(int argc, char *argv[]) { - root_controller_t* controller = new root_controller_t(); - controller_status_t status = controller->on_event(controller_event_t::start); + controller_t* controller = new root_controller_t(); + controller_t::status_t status = controller->on_event(controller_t::event_t::start); + delete controller; return status; } diff --git a/compile/project_files.txt b/compile/project_files.txt index 24b0fd7..f625b3c 100644 --- a/compile/project_files.txt +++ b/compile/project_files.txt @@ -1,2 +1,3 @@ main.cpp controller/root.cpp +platform/linux/service/window.cpp diff --git a/compile/controller/root.cpp b/compile/target/linux/service/window.cpp similarity index 78% rename from compile/controller/root.cpp rename to compile/target/linux/service/window.cpp index cb9438c..34250d4 100644 --- a/compile/controller/root.cpp +++ b/compile/target/linux/service/window.cpp @@ -1,26 +1,22 @@ -#include "controller/root.h" +#include "service/window.h" #include #include #include #include - -controller_status_t root_controller_t::on_event(controller_event_t event) { +window_service_t::status_t window_service_t::create_window() { Display *d; Window w; XEvent e; const char *msg = "Hello, World!"; int s; - d = XOpenDisplay(NULL); if (d == NULL) { - return controller_status_t::error; + return window_service_t::status_t::error; } - s = DefaultScreen(d); w = XCreateSimpleWindow(d, RootWindow(d, s), 10, 10, 100, 100, 1, BlackPixel(d, s), WhitePixel(d, s)); XSelectInput(d, w, ExposureMask | KeyPressMask); XMapWindow(d, w); - while (true) { XNextEvent(d, &e); if (e.type == Expose) { @@ -30,7 +26,6 @@ controller_status_t root_controller_t::on_event(controller_event_t event) { if (e.type == KeyPress) break; } - XCloseDisplay(d); - return controller_status_t::ok; + return window_service_t::status_t::ok; } diff --git a/earn/executable b/earn/executable index b35282e..a700a52 100755 Binary files a/earn/executable and b/earn/executable differ diff --git a/link/controller/root.cpp.o b/link/controller/root.cpp.o deleted file mode 100644 index 7526cf1..0000000 Binary files a/link/controller/root.cpp.o and /dev/null differ diff --git a/link/library_options.txt b/link/library_options.txt deleted file mode 100644 index 9ab6786..0000000 --- a/link/library_options.txt +++ /dev/null @@ -1,2 +0,0 @@ - --lX11 diff --git a/link/main.cpp.o b/link/main.cpp.o deleted file mode 100644 index bf7546a..0000000 Binary files a/link/main.cpp.o and /dev/null differ diff --git a/link/project_files.txt b/link/project_files.txt deleted file mode 100644 index 53ecc27..0000000 --- a/link/project_files.txt +++ /dev/null @@ -1,3 +0,0 @@ - -/home/cogentleman/main/art/cpp_launchpad/command/linux/../.././link/main.cpp.o -/home/cogentleman/main/art/cpp_launchpad/command/linux/../.././link/controller/root.cpp.o