refs #246 refactored construction of the network context into a factory method

This commit is contained in:
Mathew Sutcliffe
2014-06-11 22:36:53 +01:00
parent 695eb5c41c
commit cdca7343e4
5 changed files with 33 additions and 13 deletions

View File

@@ -0,0 +1,27 @@
/* Copyright (C) 2013 VATSIM Community / contributors
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "context_network.h"
#include "context_network_impl.h"
#include "context_network_proxy.h"
namespace BlackCore
{
IContextNetwork *IContextNetwork::create(CRuntime *parent, CRuntimeConfig::ContextMode mode, CDBusServer *server, QDBusConnection &conn)
{
switch (mode)
{
case CRuntimeConfig::Local:
case CRuntimeConfig::LocalInDbusServer:
return (new CContextNetwork(mode, parent))->registerWithDBus(server);
case CRuntimeConfig::Remote:
return new BlackCore::CContextNetworkProxy(BlackCore::CDBusServer::ServiceName, conn, mode, parent);
default:
return nullptr; // network not mandatory
}
}
}