Move Tournament and FetchCurrentTournament into its own file.
authorSteinar H. Gunderson <sesse@samfundet.no>
Sat, 19 Feb 2005 14:57:41 +0000 (14:57 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Sat, 19 Feb 2005 14:57:41 +0000 (14:57 +0000)
bigscreen/Makefile
bigscreen/ccbs_bigscreen.cpp
bigscreen/fetch_current_tournament.cpp [new file with mode: 0644]
bigscreen/fetch_current_tournament.h [new file with mode: 0644]

index ac92796..00a8e92 100644 (file)
@@ -4,7 +4,7 @@ CPPFLAGS=-I/usr/include/postgresql $(shell freetype-config --cflags) -Itinyptc/
 CXXFLAGS=-g -Wall
 LDFLAGS=-L/usr/X11R6/lib
 LIBS=$(shell freetype-config --libs) $(shell libpq3-config) -lpqxx tinyptc/libtinyptc.a -lX11
-CCBS_BIGSCREEN_OBJS=ccbs_bigscreen.o flagtrigger.o widestring.o
+CCBS_BIGSCREEN_OBJS=ccbs_bigscreen.o flagtrigger.o widestring.o fetch_current_tournament.o
 
 all: ccbs-bigscreen
 
index fb0d757..745faa5 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));
diff --git a/bigscreen/fetch_current_tournament.cpp b/bigscreen/fetch_current_tournament.cpp
new file mode 100644 (file)
index 0000000..364d8b3
--- /dev/null
@@ -0,0 +1,16 @@
+#include "fetch_current_tournament.h"
+
+FetchCurrentTournament::FetchCurrentTournament(Tournament *tourn) : tourn(tourn) {}
+void FetchCurrentTournament::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 = "";
+       }
+}
diff --git a/bigscreen/fetch_current_tournament.h b/bigscreen/fetch_current_tournament.h
new file mode 100644 (file)
index 0000000..4700871
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef _FETCH_CURRENT_TOURNAMENT_H
+#define _FETCH_CURRENT_TOURNAMENT_H 1
+
+#include <pqxx/transactor>
+#include "widestring.h"
+
+class Tournament {
+public:
+       int id;
+       widestring name;
+};
+
+/* A transactor that fetches the current tournament and some information about it. */
+class FetchCurrentTournament : public pqxx::transactor<> {
+private:
+       Tournament *tourn;
+
+public:
+       FetchCurrentTournament(Tournament *tourn);
+       void operator() (pqxx::transaction<> &t);
+};
+
+#endif /* !defined(_FETCH_CURRENT_TOURNAMENT_H) */