-
Notifications
You must be signed in to change notification settings - Fork 3
/
Source.cpp
54 lines (43 loc) · 1.44 KB
/
Source.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#define NOMINMAX
#include <curlpp/cURLpp.hpp>
#include "Factory.h"
#include <memory>
#include <map>
#include <string>
#include <functional>
#include <utility>
#include <pybind11/eval.h>
#include <Python.h>
#include <future>
#include <thread>
#include "Manager.h"
#include "Queen.h"
bool is_running = true;
namespace py = pybind11;
int main()
{
#ifdef _WIN32
std::unique_ptr<WindowsFactory> factory = std::make_unique<WindowsFactory>();
#elif defined __linux__
std::unique_ptr<LinuxFactory> factory = std::make_unique<LinuxFactory>();
#endif
std::ofstream out("err.txt"); // Error output
std::cerr.rdbuf(out.rdbuf()); // Redirecting it to err.txt
//Py_Initialize();
//py::object scope = py::module::import("__main__").attr("__dict__");
//py::eval_file("script.py", scope);
cURLpp::Cleanup cleanupmanager; // Automatically release network resources upon exit
Manager::instance().ReadConfig();
std::shared_ptr<Console> display(std::move(factory->create_context()));
Manager::instance().SetDisplay(display);
display->Display();
Manager::instance().RegisterCommand("help", [&](void*) { display->State = std::make_unique<HelpState>(); });
Manager::instance().RegisterCommand("connect", [=](void* in) { Queen q( *(static_cast<std::string*>(in)) ); });
Manager::instance().RegisterCommand("quit", [&](void*) {is_running = false;});
std::thread t1([]() {Manager::instance().CheckProgress(); });
while (is_running)
{
display->Input();
}
return 0;
}