2014-09-16 22:42:47 +03:00
|
|
|
#include "interface/module.h"
|
2014-09-16 23:14:04 +03:00
|
|
|
#include "interface/server.h"
|
2014-09-17 00:41:27 +03:00
|
|
|
#include "interface/fs.h"
|
2014-09-17 01:04:51 +03:00
|
|
|
#include "interface/event.h"
|
2014-09-17 01:25:55 +03:00
|
|
|
#include <cereal/archives/binary.hpp>
|
2014-09-16 23:57:31 +03:00
|
|
|
#include <iostream>
|
2014-09-16 22:42:47 +03:00
|
|
|
|
2014-09-17 01:04:51 +03:00
|
|
|
using interface::Event;
|
|
|
|
|
2014-09-16 23:14:04 +03:00
|
|
|
struct Module: public interface::Module
|
2014-09-16 22:42:47 +03:00
|
|
|
{
|
2014-09-16 23:21:41 +03:00
|
|
|
interface::Server *m_server;
|
|
|
|
|
|
|
|
Module(interface::Server *server):
|
|
|
|
m_server(server)
|
2014-09-16 23:14:04 +03:00
|
|
|
{
|
2014-09-16 23:57:31 +03:00
|
|
|
std::cout<<"__loader construct"<<std::endl;
|
2014-09-16 23:14:04 +03:00
|
|
|
}
|
2014-09-16 22:42:47 +03:00
|
|
|
|
2014-09-16 23:14:04 +03:00
|
|
|
~Module()
|
|
|
|
{
|
2014-09-16 23:57:31 +03:00
|
|
|
std::cout<<"__loader destruct"<<std::endl;
|
2014-09-16 23:14:04 +03:00
|
|
|
}
|
2014-09-16 22:42:47 +03:00
|
|
|
|
2014-09-17 01:04:51 +03:00
|
|
|
void event(const interface::Event &event)
|
|
|
|
{
|
|
|
|
switch(event.type){
|
|
|
|
case Event::Type::START:
|
|
|
|
start();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int test_add(int a, int b)
|
|
|
|
{
|
|
|
|
return a + b;
|
|
|
|
}
|
|
|
|
|
2014-09-16 23:21:41 +03:00
|
|
|
void start()
|
|
|
|
{
|
2014-09-17 00:41:27 +03:00
|
|
|
auto list = interface::getGlobalFilesystem()->list_directory(m_server->get_modules_path());
|
|
|
|
for(const interface::Filesystem::Node &n : list){
|
|
|
|
if(n.name == "__loader")
|
|
|
|
continue;
|
|
|
|
m_server->load_module(n.name, m_server->get_modules_path()+"/"+n.name);
|
|
|
|
}
|
2014-09-16 23:21:41 +03:00
|
|
|
}
|
2014-09-16 23:14:04 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
extern "C" {
|
2014-09-16 23:57:31 +03:00
|
|
|
EXPORT void* createModule___loader(interface::Server *server)
|
2014-09-16 22:42:47 +03:00
|
|
|
{
|
2014-09-16 23:21:41 +03:00
|
|
|
return (void*)(new Module(server));
|
2014-09-16 23:14:04 +03:00
|
|
|
}
|
2014-09-16 22:42:47 +03:00
|
|
|
}
|