]> git.sesse.net Git - ccbs/blobdiff - bigscreen/ccbs_bigscreen.cpp
Move Tournament and FetchCurrentTournament into its own file.
[ccbs] / bigscreen / ccbs_bigscreen.cpp
index fb0d75740c1c0875cb0e3f18e38256c929a9f02e..745faa5a8715e11b1a7154a9f4ff547a9d9e4b01 100644 (file)
@@ -8,40 +8,13 @@
 #include <tinyptc.h>
 #include "flagtrigger.h"
 #include "widestring.h"
+#include "fetch_current_tournament.h"
 
 int my_draw_text(const widestring &str, unsigned char *buf, int xpos, int ypos, bool real_render, int r, int g, int b, std::vector<FT_Face> &fontlist);
 
-class Tournament {
-public:
-       int id;
-       widestring name;
-};
-
 Tournament active_tournament;
 std::vector<FT_Face> fonts;
 
-/* A transactor that fetches the current tournament and some information about it. */
-class FetchCurrentTournament : public pqxx::transactor<> {
-private:
-       Tournament *tourn;
-
-public:
-       FetchCurrentTournament(Tournament *tourn) : tourn(tourn) {}
-       void operator() (pqxx::transaction<> &t)
-       {
-               pqxx::result res( t.exec("SELECT * FROM bigscreen.active_tournament NATURAL JOIN tournaments") );
-               try {
-                       pqxx::result::tuple tournament = res.at(0);
-
-                       tourn->id = tournament["tournament"].as(tourn->id);
-                       tourn->name = tournament["tournamentname"].as(tourn->name);
-               } catch (PGSTD::out_of_range &e) {
-                       tourn->id = -1;
-                       tourn->name = "";
-               }
-       }
-};
-
 void init(pqxx::connection &conn)
 {
        conn.perform(FetchCurrentTournament(&active_tournament));