diff --git a/.gitignore b/.gitignore index ef4cd25..a7d9d20 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *~ *.old *.tar.gz +session.vim /build /cache diff --git a/src/interface/event.h b/src/interface/event.h new file mode 100644 index 0000000..feabf47 --- /dev/null +++ b/src/interface/event.h @@ -0,0 +1,13 @@ +#pragma once +#include "core/types.h" + +namespace interface +{ + struct Event + { + enum class Type { + START, + } type; + }; +} + diff --git a/src/interface/module.h b/src/interface/module.h index f9dc0ce..608afc0 100644 --- a/src/interface/module.h +++ b/src/interface/module.h @@ -5,10 +5,13 @@ namespace interface { + struct Event; + struct Module { virtual ~Module(){}; - virtual void start() = 0; + virtual void event(const interface::Event &event) = 0; + virtual int test_add(int a, int b) = 0; }; } diff --git a/src/server/state.cpp b/src/server/state.cpp index 2d0a706..c38b849 100644 --- a/src/server/state.cpp +++ b/src/server/state.cpp @@ -3,6 +3,7 @@ #include "config.h" #include "interface/module.h" #include "interface/server.h" +#include "interface/event.h" #include extern server::Config g_server_config; @@ -34,7 +35,9 @@ struct CState: public State, public interface::Server m_compiler->construct(module_name.c_str(), this)); //int a = m->test_add(1, 2); //std::cout<<"a = "<start(); + interface::Event event; + event.type = interface::Event::Type::START; + m->event(event); } void load_modules(const ss_ &path) diff --git a/test/testmodules/__loader/server/init.cpp b/test/testmodules/__loader/server/init.cpp index 9f95190..011a557 100644 --- a/test/testmodules/__loader/server/init.cpp +++ b/test/testmodules/__loader/server/init.cpp @@ -1,8 +1,11 @@ #include "interface/module.h" #include "interface/server.h" #include "interface/fs.h" +#include "interface/event.h" #include +using interface::Event; + struct Module: public interface::Module { interface::Server *m_server; @@ -18,6 +21,20 @@ struct Module: public interface::Module std::cout<<"__loader destruct"<list_directory(m_server->get_modules_path()); @@ -27,11 +44,6 @@ struct Module: public interface::Module m_server->load_module(n.name, m_server->get_modules_path()+"/"+n.name); } } - - int test_add(int a, int b) - { - return a + b; - } }; extern "C" { diff --git a/test/testmodules/test1/server/init.cpp b/test/testmodules/test1/server/init.cpp index 766deaa..9cba62e 100644 --- a/test/testmodules/test1/server/init.cpp +++ b/test/testmodules/test1/server/init.cpp @@ -1,7 +1,10 @@ #include "interface/module.h" #include "interface/server.h" +#include "interface/event.h" #include +using interface::Event; + struct Module: public interface::Module { Module() @@ -14,14 +17,23 @@ struct Module: public interface::Module std::cout<<"test1 destruct"<