Actually add flagtrigger.{h,cpp}...
authorSteinar H. Gunderson <sesse@samfundet.no>
Sat, 19 Feb 2005 14:48:48 +0000 (14:48 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Sat, 19 Feb 2005 14:48:48 +0000 (14:48 +0000)
bigscreen/flagtrigger.cpp [new file with mode: 0644]
bigscreen/flagtrigger.h [new file with mode: 0644]

diff --git a/bigscreen/flagtrigger.cpp b/bigscreen/flagtrigger.cpp
new file mode 100644 (file)
index 0000000..258802a
--- /dev/null
@@ -0,0 +1,21 @@
+#include "flagtrigger.h"
+
+FlagTrigger::FlagTrigger(pqxx::connection_base &conn, const PGSTD::string &name)
+       : pqxx::trigger(conn, name), flag(false) {}
+FlagTrigger::~FlagTrigger() throw () {}
+       
+void FlagTrigger::operator() (int pid)
+{
+       flag = true;
+       std::fprintf(stderr, "Received a flag trigger from pid %u\n", pid);
+}
+
+bool FlagTrigger::get_flag() const
+{
+       return flag;
+}
+
+void FlagTrigger::reset_flag()
+{
+       flag = false;
+}
diff --git a/bigscreen/flagtrigger.h b/bigscreen/flagtrigger.h
new file mode 100644 (file)
index 0000000..3774ddd
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef _FLAGTRIGGER_H
+#define _FLAGTRIGGER_H 1
+
+#include <pqxx/trigger>
+
+/* A trigger that sets a flag whenever it's trigged. */
+class FlagTrigger : pqxx::trigger {
+private:
+       bool flag;
+       
+public:
+       FlagTrigger(pqxx::connection_base &conn, const PGSTD::string &name);
+       virtual ~FlagTrigger() throw ();
+       
+       virtual void operator() (int pid);
+       bool get_flag() const;
+       void reset_flag();
+};
+
+#endif /* !defined( _FLAGTRIGGER_H) */