2017-02-01 18:01:02 +01:00
|
|
|
|
#include "MasterController.h"
|
2016-12-26 16:06:55 +01:00
|
|
|
|
#include <QApplication>
|
2017-08-23 13:27:23 +02:00
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
|
# include <winsock2.h>
|
|
|
|
|
|
#endif
|
2017-02-01 18:01:02 +01:00
|
|
|
|
#include <memory>
|
2017-08-24 19:45:00 +02:00
|
|
|
|
#include "GlobalIoService.h"
|
2016-12-27 10:27:44 +01:00
|
|
|
|
|
2016-12-26 16:06:55 +01:00
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
|
|
{
|
2016-12-27 10:27:44 +01:00
|
|
|
|
|
|
|
|
|
|
/* Use the MAKEWORD(lowbyte, highbyte) macro declared in Windef.h */
|
2017-08-24 19:45:00 +02:00
|
|
|
|
#ifdef WIN32
|
2016-12-27 10:27:44 +01:00
|
|
|
|
WORD wVersionRequested = MAKEWORD(2, 2);
|
|
|
|
|
|
WSADATA wsaData;
|
|
|
|
|
|
int err = WSAStartup(wVersionRequested, &wsaData);
|
|
|
|
|
|
if (err != 0) {
|
|
|
|
|
|
/* Tell the user that we could not find a usable */
|
|
|
|
|
|
/* Winsock DLL. */
|
|
|
|
|
|
printf("WSAStartup failed with error: %d\n", err);
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
2017-08-23 13:27:23 +02:00
|
|
|
|
#endif
|
2017-08-24 19:45:00 +02:00
|
|
|
|
|
2016-12-26 16:06:55 +01:00
|
|
|
|
QApplication a(argc, argv);
|
2017-01-14 20:07:12 +01:00
|
|
|
|
|
2017-01-15 12:27:36 +01:00
|
|
|
|
QCoreApplication::setOrganizationName("pglab");
|
2017-01-14 20:07:12 +01:00
|
|
|
|
QCoreApplication::setOrganizationDomain("eelkeklein.nl");
|
2017-01-15 12:27:36 +01:00
|
|
|
|
QCoreApplication::setApplicationName("pglab");
|
2017-01-14 20:07:12 +01:00
|
|
|
|
|
2017-08-24 19:45:00 +02:00
|
|
|
|
std::thread asio_service_thread;
|
|
|
|
|
|
int result = -1;
|
|
|
|
|
|
{
|
|
|
|
|
|
auto ios = getGlobalAsioIoService();
|
|
|
|
|
|
boost::asio::io_service::work work(*ios); // Prevent service from running out of work so run doesn't return
|
|
|
|
|
|
asio_service_thread = std::thread([ios](){ ios->run(); });
|
|
|
|
|
|
|
|
|
|
|
|
// make sure the io_service is stopped before we wait on the future
|
|
|
|
|
|
auto master_controller = std::make_unique<MasterController>();
|
|
|
|
|
|
master_controller->init();
|
|
|
|
|
|
result = a.exec();
|
|
|
|
|
|
}
|
|
|
|
|
|
asio_service_thread.join();
|
|
|
|
|
|
#ifdef WIN32
|
2016-12-27 10:27:44 +01:00
|
|
|
|
WSACleanup();
|
2017-08-23 13:27:23 +02:00
|
|
|
|
#endif
|
2016-12-27 10:27:44 +01:00
|
|
|
|
return result;
|
2016-12-26 16:06:55 +01:00
|
|
|
|
}
|
2017-01-17 19:04:47 +01:00
|
|
|
|
|