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 01:04:51 +03:00
|
|
|
#include "interface/event.h"
|
2014-09-17 02:18:03 +03:00
|
|
|
#include "test1/include/api.h"
|
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-17 02:18:03 +03:00
|
|
|
namespace test1 {
|
|
|
|
|
2014-09-16 23:14:04 +03:00
|
|
|
struct Module: public interface::Module
|
2014-09-16 22:42:47 +03:00
|
|
|
{
|
2014-09-17 02:18:03 +03:00
|
|
|
interface::Server *m_server;
|
|
|
|
Event::Type m_EventType_test1_thing;
|
|
|
|
|
|
|
|
Module(interface::Server *server):
|
|
|
|
m_server(server),
|
2014-09-17 16:43:05 +03:00
|
|
|
m_EventType_test1_thing(Event::t("test1:thing"))
|
2014-09-16 23:14:04 +03:00
|
|
|
{
|
2014-09-16 23:57:31 +03:00
|
|
|
std::cout<<"test1 construct"<<std::endl;
|
2014-09-16 23:14:04 +03:00
|
|
|
}
|
2014-09-16 22:42:47 +03:00
|
|
|
|
2014-09-17 14:53:06 +03:00
|
|
|
void init()
|
|
|
|
{
|
|
|
|
std::cout<<"test1 init"<<std::endl;
|
|
|
|
m_server->sub_event(this, m_EventType_test1_thing);
|
|
|
|
}
|
|
|
|
|
2014-09-16 23:14:04 +03:00
|
|
|
~Module()
|
|
|
|
{
|
2014-09-16 23:57:31 +03:00
|
|
|
std::cout<<"test1 destruct"<<std::endl;
|
2014-09-16 23:14:04 +03:00
|
|
|
}
|
2014-09-16 22:42:47 +03:00
|
|
|
|
2014-09-17 16:43:05 +03:00
|
|
|
void event(const Event &event)
|
2014-09-16 23:21:41 +03:00
|
|
|
{
|
2014-09-17 02:18:03 +03:00
|
|
|
if(event.type == m_EventType_test1_thing){
|
2014-09-17 16:43:05 +03:00
|
|
|
on_thing(*static_cast<Thing*>(event.p.get()));
|
2014-09-17 01:04:51 +03:00
|
|
|
}
|
2014-09-16 23:21:41 +03:00
|
|
|
}
|
|
|
|
|
2014-09-17 16:43:05 +03:00
|
|
|
void on_thing(const Thing &thing)
|
2014-09-17 01:04:51 +03:00
|
|
|
{
|
2014-09-17 16:43:05 +03:00
|
|
|
std::cout<<"test1.thing: some_data="<<thing.some_data<<std::endl;
|
2014-09-17 01:04:51 +03:00
|
|
|
}
|
2014-09-16 23:14:04 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
extern "C" {
|
2014-09-17 02:18:03 +03:00
|
|
|
EXPORT void* createModule_test1(interface::Server *server){
|
|
|
|
return (void*)(new Module(server));
|
|
|
|
}
|
2014-09-16 23:14:04 +03:00
|
|
|
}
|
2014-09-16 22:42:47 +03:00
|
|
|
}
|