#include <PluginManager.h>
Classes | |
struct | CommandDispatch |
class | PluginInfo |
Public Types | |
typedef SignalTraits< void(Entity &, const StringList &, bool &)> ::Signal | CommandSignal |
typedef CommandSignal::Slot | CommandSlot |
typedef std::unordered_map < std::string, Plugin * > | Registry |
typedef Registry::iterator | RegistryIter |
Public Member Functions | |
ADCHPP_DLL void | attention (const std::function< void()> &f) |
This is a thread-safe method to call when you need to perform some work in the main ADCH++ worker thread. | |
ADCHPP_DLL CommandSignal & | getCommandSignal (const std::string &commandName) |
Handle +-commands set by another script, and possibly prevent them from being dispatched. | |
Plugin * | getPlugin (const std::string &name) |
const StringList & | getPluginList () const |
Get a list of currently loaded plugins. | |
const std::string & | getPluginPath () const |
Get the plugin path as set in adchpp.xml. | |
const Registry & | getPlugins () const |
The full map of registered plugins. | |
void | load () |
ADCHPP_DLL ClientManager::SignalReceive::Connection | onCommand (const std::string &commandName, const CommandSlot &f) |
Utility function to handle +-commands from clients The parameters are the same as ClientManager::signalReceive, only that the parameters will have been parsed already, and the function will only be called if the command name matches. | |
bool | registerPlugin (const std::string &name, Plugin *ptr) |
Register a plugin interface under a name. | |
PluginDataHandle | registerPluginData (const PluginDataDeleter &deleter_) |
Register a plugin data type to be used with Client::setPSD and friends. | |
void | setPluginList (const StringList &pluginList) |
void | setPluginPath (const std::string &path) |
void | shutdown () |
bool | unregisterPlugin (const std::string &name) |
Static Public Member Functions | |
static void | deleteInstance () |
static PluginManager * | getInstance () |
static void | newInstance () |
Private Types | |
typedef std::unordered_map < std::string, CommandSignal > | CommandHandlers |
typedef PluginList::iterator | PluginIter |
typedef std::vector< PluginInfo > | PluginList |
Private Member Functions | |
bool | handleCommand (Entity &e, const StringList &l) |
bool | loadPlugin (const std::string &file) |
PluginManager () throw () | |
virtual | ~PluginManager () throw () |
Private Attributes | |
PluginList | active |
CommandHandlers | commandHandlers |
std::string | pluginPath |
StringList | plugins |
Registry | registry |
Static Private Attributes | |
static const std::string | className = "PluginManager" |
static ADCHPP_DLL PluginManager * | instance = 0 |
Friends | |
struct | CommandDispatch |
class | Singleton< PluginManager > |
Definition at line 122 of file PluginManager.h.
typedef std::unordered_map<std::string, CommandSignal> adchpp::PluginManager::CommandHandlers [private] |
Definition at line 250 of file PluginManager.h.
typedef SignalTraits<void (Entity&, const StringList&, bool&)>::Signal adchpp::PluginManager::CommandSignal |
Definition at line 189 of file PluginManager.h.
Definition at line 190 of file PluginManager.h.
typedef PluginList::iterator adchpp::PluginManager::PluginIter [private] |
Definition at line 236 of file PluginManager.h.
typedef std::vector<PluginInfo> adchpp::PluginManager::PluginList [private] |
Definition at line 235 of file PluginManager.h.
typedef std::unordered_map<std::string, Plugin*> adchpp::PluginManager::Registry |
Definition at line 125 of file PluginManager.h.
typedef Registry::iterator adchpp::PluginManager::RegistryIter |
Definition at line 126 of file PluginManager.h.
adchpp::PluginManager::~PluginManager | ( | ) | throw () [private, virtual] |
Definition at line 64 of file PluginManager.cpp.
adchpp::PluginManager::PluginManager | ( | ) | throw () [private] |
Definition at line 60 of file PluginManager.cpp.
ADCHPP_DLL void adchpp::PluginManager::attention | ( | const std::function< void()> & | f | ) |
This is a thread-safe method to call when you need to perform some work in the main ADCH++ worker thread.
Your job will be executed once, when time permits.
static void adchpp::Singleton< PluginManager >::deleteInstance | ( | ) | [inline, static, inherited] |
Definition at line 49 of file Singleton.h.
PluginManager::CommandSignal & adchpp::PluginManager::getCommandSignal | ( | const std::string & | commandName | ) |
Handle +-commands set by another script, and possibly prevent them from being dispatched.
Definition at line 197 of file PluginManager.cpp.
References commandHandlers.
static PluginManager * adchpp::Singleton< PluginManager >::getInstance | ( | ) | [inline, static, inherited] |
Definition at line 37 of file Singleton.h.
Referenced by onCommand(), and adchpp::PluginManager::CommandDispatch::operator()().
Plugin* adchpp::PluginManager::getPlugin | ( | const std::string & | name | ) | [inline] |
Definition at line 177 of file PluginManager.h.
References registry.
const StringList& adchpp::PluginManager::getPluginList | ( | ) | const [inline] |
Get a list of currently loaded plugins.
Definition at line 138 of file PluginManager.h.
References plugins.
const std::string& adchpp::PluginManager::getPluginPath | ( | ) | const [inline] |
Get the plugin path as set in adchpp.xml.
Definition at line 147 of file PluginManager.h.
References pluginPath.
const Registry& adchpp::PluginManager::getPlugins | ( | ) | const [inline] |
The full map of registered plugins.
Definition at line 185 of file PluginManager.h.
References registry.
bool adchpp::PluginManager::handleCommand | ( | Entity & | e, | |
const StringList & | l | |||
) | [private] |
Definition at line 205 of file PluginManager.cpp.
References commandHandlers.
Referenced by adchpp::PluginManager::CommandDispatch::operator()().
void adchpp::PluginManager::load | ( | ) |
Definition at line 72 of file PluginManager.cpp.
References loadPlugin(), PLUGIN_EXT, and plugins.
bool adchpp::PluginManager::loadPlugin | ( | const std::string & | file | ) | [private] |
Definition at line 78 of file PluginManager.cpp.
References active, className, adchpp::File::isAbsolutePath(), LOG, pluginPath, PLUGINVERSION, PM_GET_ADDRESS, PM_GET_ERROR_STRING, PM_LOAD_LIBRARY, PM_UNLOAD_LIBRARY, adchpp::Util::toString(), and adchpp::Text::utf8ToAcp().
Referenced by load().
static void adchpp::Singleton< PluginManager >::newInstance | ( | ) | [inline, static, inherited] |
Definition at line 42 of file Singleton.h.
ClientManager::SignalReceive::Connection adchpp::PluginManager::onCommand | ( | const std::string & | commandName, | |
const CommandSlot & | f | |||
) |
Utility function to handle +-commands from clients The parameters are the same as ClientManager::signalReceive, only that the parameters will have been parsed already, and the function will only be called if the command name matches.
Definition at line 193 of file PluginManager.cpp.
References CommandDispatch, and adchpp::Singleton< PluginManager >::getInstance().
bool adchpp::PluginManager::registerPlugin | ( | const std::string & | name, | |
Plugin * | ptr | |||
) | [inline] |
Register a plugin interface under a name.
Definition at line 165 of file PluginManager.h.
References registry.
PluginDataHandle adchpp::PluginManager::registerPluginData | ( | const PluginDataDeleter & | deleter_ | ) | [inline] |
Register a plugin data type to be used with Client::setPSD and friends.
When data is removed, the deleter function will automatically be called with the data as parameter, allowing automatic life cycle managment for plugin-specific data.
Definition at line 159 of file PluginManager.h.
void adchpp::PluginManager::setPluginList | ( | const StringList & | pluginList | ) | [inline] |
Definition at line 142 of file PluginManager.h.
References plugins.
void adchpp::PluginManager::setPluginPath | ( | const std::string & | path | ) | [inline] |
Definition at line 151 of file PluginManager.h.
References pluginPath.
void adchpp::PluginManager::shutdown | ( | ) |
Definition at line 147 of file PluginManager.cpp.
References active, PM_UNLOAD_LIBRARY, and registry.
bool adchpp::PluginManager::unregisterPlugin | ( | const std::string & | name | ) | [inline] |
Definition at line 170 of file PluginManager.h.
References registry.
friend struct CommandDispatch [friend] |
Definition at line 230 of file PluginManager.h.
Referenced by onCommand().
friend class Singleton< PluginManager > [friend] |
Definition at line 232 of file PluginManager.h.
PluginList adchpp::PluginManager::active [private] |
Definition at line 238 of file PluginManager.h.
Referenced by loadPlugin(), and shutdown().
const string adchpp::PluginManager::className = "PluginManager" [static, private] |
Definition at line 244 of file PluginManager.h.
Referenced by loadPlugin().
Definition at line 251 of file PluginManager.h.
Referenced by getCommandSignal(), and handleCommand().
PluginManager * adchpp::PluginManager::instance = 0 [static, private] |
Definition at line 233 of file PluginManager.h.
std::string adchpp::PluginManager::pluginPath [private] |
Definition at line 242 of file PluginManager.h.
Referenced by getPluginPath(), loadPlugin(), and setPluginPath().
StringList adchpp::PluginManager::plugins [private] |
Definition at line 241 of file PluginManager.h.
Referenced by getPluginList(), load(), and setPluginList().
Registry adchpp::PluginManager::registry [private] |
Definition at line 239 of file PluginManager.h.
Referenced by getPlugin(), getPlugins(), registerPlugin(), shutdown(), and unregisterPlugin().