]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/configuration/sgconfig-ng/stgconfig.cpp
Добавляю экспериментальный плагин конфигуратора. Проект полумертв, но
[stg.git] / projects / stargazer / plugins / configuration / sgconfig-ng / stgconfig.cpp
diff --git a/projects/stargazer/plugins/configuration/sgconfig-ng/stgconfig.cpp b/projects/stargazer/plugins/configuration/sgconfig-ng/stgconfig.cpp
new file mode 100644 (file)
index 0000000..1b51bbc
--- /dev/null
@@ -0,0 +1,58 @@
+#include <boost/thread.hpp>
+
+#include "base_store.h"
+#include "base_settings.h"
+#include "common.h"
+
+// TODO: Fix this shit!!!
+#include "../../../users.h"
+#include "../../../tariffs.h"
+#include "../../../admins.h"
+#include "../../../settings.h"
+
+#include "stgconfig.h"
+
+STGCONFIG2::STGCONFIG2()
+    : users(NULL),
+      tariffs(NULL),
+      admins(NULL),
+      store(NULL),
+      stgSettings(NULL),
+      ct(admins, tariffs, users, stgSettings)
+{
+    thread = new boost::thread;
+}
+
+STGCONFIG2::~STGCONFIG2()
+{
+    delete thread;
+}
+
+int STGCONFIG2::ParseSettings()
+{
+    return 0;
+}
+
+int STGCONFIG2::Start()
+{
+    ct.SetClasses(admins, tariffs, users, stgSettings);
+    *thread = boost::thread(boost::ref(ct));
+    return 0;
+}
+
+int STGCONFIG2::Stop()
+{
+    ct.Stop();
+    if (!thread->timed_join(boost::get_system_time() + boost::posix_time::milliseconds(5000))) {
+        thread->detach();
+        printfd(__FILE__, "STGCONFIG2::Stop() Thread not stopped.\n");
+        errorStr = "Failed to stop config thread.";
+        return -1;
+    }
+    return 0;
+}
+
+bool STGCONFIG2::IsRunning()
+{
+    return true;
+}