refs #246 refactored construction of all remaining contexts into factory methods

This commit is contained in:
Mathew Sutcliffe
2014-06-14 15:52:42 +01:00
parent 9e0909666e
commit 9b27b93de0
21 changed files with 157 additions and 66 deletions

View File

@@ -1,4 +1,6 @@
#include "blackcore/context_application.h"
#include "blackcore/context_application_impl.h"
#include "blackcore/context_application_proxy.h"
#include "blackcore/context_application_event.h"
#include "blackmisc/statusmessage.h"
#include <QCoreApplication>
@@ -12,6 +14,21 @@ namespace BlackCore
QList<IContextApplication *> IContextApplication::s_contexts;
QtMessageHandler IContextApplication::s_oldHandler = nullptr;
IContextApplication *IContextApplication::create(CRuntime *parent, CRuntimeConfig::ContextMode mode, CDBusServer *server, QDBusConnection &conn)
{
switch (mode)
{
case CRuntimeConfig::Local:
case CRuntimeConfig::LocalInDbusServer:
return (new CContextApplication(mode, parent))->registerWithDBus(server);
case CRuntimeConfig::Remote:
return new BlackCore::CContextApplicationProxy(BlackCore::CDBusServer::ServiceName, conn, mode, parent);
default:
qFatal("Always initialize an application context");
return nullptr;
}
}
/*
* Constructor
*/