some work on dependency injection
git-svn-id: svn://ttmath.org/publicrep/winix/branches/0.7.x@1147 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -40,13 +40,36 @@
|
||||
#include "sessionmanager.h"
|
||||
#include "functions/functions.h"
|
||||
#include "templates/templates.h"
|
||||
#include "winixsystem.h"
|
||||
#include "winixrequest.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* PluginInfo
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
void PluginInfo::set_dependency_for(WinixBase * winix_base)
|
||||
{
|
||||
plugin->SetDependencyFor(winix_base);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Plugin
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
void Plugin::UnloadPlugins()
|
||||
{
|
||||
@@ -71,7 +94,7 @@ Plugin::Plugin()
|
||||
functions = nullptr;
|
||||
templates = nullptr;
|
||||
session_manager = nullptr;
|
||||
winix_system = nullptr;
|
||||
winix_request = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -128,9 +151,9 @@ void Plugin::SetSessionManager(SessionManager * psession_manager)
|
||||
}
|
||||
|
||||
|
||||
void Plugin::SetWinixSystem(WinixSystem * winix_system)
|
||||
void Plugin::SetWinixRequest(WinixRequest * winix_request)
|
||||
{
|
||||
this->winix_system = winix_system;
|
||||
this->winix_request = winix_request;
|
||||
}
|
||||
|
||||
|
||||
@@ -154,7 +177,7 @@ void Plugin::Unlock()
|
||||
bool Plugin::SetDependency(PluginInfo & info)
|
||||
{
|
||||
// for safety we call a plugin function only when all our pointers are not null
|
||||
bool res = (db && config && cur && system && functions && templates && synchro && session_manager && winix_system);
|
||||
bool res = (db && config && cur && system && functions && templates && synchro && session_manager && winix_request);
|
||||
|
||||
if( !res )
|
||||
{
|
||||
@@ -171,13 +194,19 @@ bool Plugin::SetDependency(PluginInfo & info)
|
||||
info.templates = templates;
|
||||
info.synchro = synchro;
|
||||
info.session_manager = session_manager;
|
||||
info.winix_system = winix_system;
|
||||
info.plugin = this;
|
||||
|
||||
info.log.SetDependency(&log);
|
||||
log.Init(config->log_level, config->log_save_each_line, config->log_request);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void Plugin::SetDependencyFor(WinixBase * winix_base)
|
||||
{
|
||||
winix_base->set_dependency(winix_request);
|
||||
}
|
||||
|
||||
|
||||
void Plugin::LoadPlugins(const std::wstring & plugins_dir, const std::vector<std::wstring> & plugins)
|
||||
{
|
||||
@@ -536,5 +565,13 @@ const Plugin::Plugins * Plugin::GetPlugins()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
Reference in New Issue
Block a user