added: plugin mechanism
files: core/plugin.h core/plugin.cpp core/pluginmsg.h added: directory 'main' with main.cpp (moved from 'core' directory) changed: the way of building nearly everything is in cmslu.so only main() is in cmslu and is dynamically linked with cmslu.so git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@516 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
91
core/plugin.h
Executable file
91
core/plugin.h
Executable file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef headerfilecmsluplugin
|
||||
#define headerfilecmsluplugin
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "request.h"
|
||||
#include "data.h"
|
||||
#include "pluginmsg.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
|
||||
class Plugin;
|
||||
|
||||
|
||||
// plugin arguments
|
||||
struct Arg
|
||||
{
|
||||
void * app; // used for some purposes
|
||||
void * app2; // used for some purposes
|
||||
void * app3; // used for some purposes
|
||||
|
||||
int ret_true; // how many plugins returned true
|
||||
int ret_false; // how many plugins returned false
|
||||
|
||||
|
||||
void Clear()
|
||||
{
|
||||
app = 0;
|
||||
app2 = 0;
|
||||
app3 = 0;
|
||||
ret_true = 0;
|
||||
ret_false = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class Plugin
|
||||
{
|
||||
public:
|
||||
|
||||
typedef bool (*Fun)(Arg *);
|
||||
|
||||
|
||||
|
||||
Plugin();
|
||||
~Plugin();
|
||||
void LoadPlugin(const char * filename);
|
||||
void LoadPlugin(const std::string & filename);
|
||||
void LoadPlugins(const std::vector<std::string> & plugins);
|
||||
|
||||
void UnloadPlugins();
|
||||
|
||||
Arg * Call(int message, void * a=0, void * a2=0, void * a3=0);
|
||||
|
||||
|
||||
void Assign(int message, Fun);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
typedef std::vector<void*> Plugins;
|
||||
Plugins plugins;
|
||||
|
||||
typedef std::multimap<int, Fun> Slots;
|
||||
Slots slots;
|
||||
|
||||
|
||||
Arg arg;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
extern Plugin plugin;
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user