92 lines
1.3 KiB
C++
Executable File
92 lines
1.3 KiB
C++
Executable File
/*
|
|
* 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
|
|
|