mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-04 16:22:52 +08:00
Updating IContext to our current style and making it less reliant on macros.
Updating code that uses IContext to a more conformant pattern of usage.
This commit is contained in:
@@ -8,8 +8,8 @@
|
||||
#include <iostream>
|
||||
#include <QStringList>
|
||||
|
||||
Client::Client()
|
||||
: m_net(BlackMisc::IContext::getInstance().singleton<BlackCore::INetwork>())
|
||||
Client::Client(BlackMisc::IContext &ctx)
|
||||
: m_net(&ctx.getObject<BlackCore::INetwork>())
|
||||
{
|
||||
using namespace BlackCore;
|
||||
connect(m_net, &INetwork::atcPositionUpdate, this, &Client::atcPositionUpdate);
|
||||
|
||||
@@ -6,18 +6,19 @@
|
||||
#ifndef __BLACKSAMPLE_CLI_CLIENT_H__
|
||||
#define __BLACKSAMPLE_CLI_CLIENT_H__
|
||||
|
||||
#include "blackcore/network.h"
|
||||
#include "blackmisc/context.h"
|
||||
#include <QObject>
|
||||
#include <QTextStream>
|
||||
#include <QMap>
|
||||
#include <functional>
|
||||
#include "blackcore/network.h"
|
||||
|
||||
class Client : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Client();
|
||||
Client(BlackMisc::IContext &);
|
||||
|
||||
signals:
|
||||
void quit();
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "blackcore/network_vatlib.h"
|
||||
#include "blackmisc/context.h"
|
||||
#include "client.h"
|
||||
#include "reader.h"
|
||||
#include <QCoreApplication>
|
||||
@@ -12,11 +13,15 @@
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication app (argc, argv);
|
||||
BlackMisc::CApplicationContext myApplicationContext;
|
||||
BlackMisc::IContext::getInstance().setSingleton(new BlackMisc::CDebug());
|
||||
BlackMisc::IContext::getInstance().setSingleton<BlackCore::INetwork>(new BlackCore::NetworkVatlib());
|
||||
|
||||
Client client;
|
||||
BlackMisc::CApplicationContext ctx;
|
||||
BlackMisc::IContext::setInstance(ctx);
|
||||
BlackMisc::CDebug debug;
|
||||
ctx.setObject(debug);
|
||||
BlackCore::NetworkVatlib net;
|
||||
ctx.setObject<BlackCore::INetwork>(net);
|
||||
|
||||
Client client(ctx);
|
||||
LineReader reader;
|
||||
QObject::connect(&reader, SIGNAL(command(const QString&)), &client, SLOT(command(const QString&)));
|
||||
QObject::connect(&client, SIGNAL(quit()), &reader, SLOT(terminate()));
|
||||
|
||||
Reference in New Issue
Block a user