summaryrefslogtreecommitdiff
path: root/src/event_utils.hh
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@yahoo.com>2015-06-25 02:13:15 +0200
committerJoel Klinghed <the_jk@yahoo.com>2015-06-25 02:13:15 +0200
commit0c55606145b6c5d9a303b19b3dba4996ec3ed3a9 (patch)
treeff7804d99c83a0c22e4074cd11624c93365057ff /src/event_utils.hh
parent021dbcb976f9534750e9dc42812f1a66f47a6392 (diff)
Split out common event code for future use
Diffstat (limited to 'src/event_utils.hh')
-rw-r--r--src/event_utils.hh58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/event_utils.hh b/src/event_utils.hh
new file mode 100644
index 0000000..8151d64
--- /dev/null
+++ b/src/event_utils.hh
@@ -0,0 +1,58 @@
+#ifndef EVENT_UTILS_HH
+#define EVENT_UTILS_HH
+
+#include <functional>
+#include <memory>
+#include <string>
+
+namespace stuff {
+
+class Config;
+class Event;
+class SenderClient;
+
+class EventUtils {
+public:
+ virtual ~EventUtils();
+
+ virtual std::unique_ptr<Event> create(
+ const std::string& name, time_t start) = 0;
+ virtual void created(Event* event) = 0;
+
+ virtual std::vector<std::unique_ptr<Event>> all() = 0;
+ virtual std::unique_ptr<Event> next() = 0;
+
+ virtual bool good() const = 0;
+
+ virtual void cancel(Event* event, size_t index) = 0;
+
+ virtual void updated(Event* event, int64_t was_first) = 0;
+
+ virtual void going(Event* event, bool going, const std::string& user,
+ const std::string& owner) = 0;
+
+ virtual const std::string& channel() const = 0;
+
+ static std::unique_ptr<EventUtils> create(
+ const std::string& channel,
+ std::function<void(const std::string&)> error_cb,
+ Config* config,
+ SenderClient* sender);
+
+ static const double ONE_DAY_IN_SEC;
+ static const double ONE_WEEK_IN_SEC;
+ static const double ONE_YEAR_IN_SEC;
+
+ static std::string format_date(time_t date);
+
+protected:
+ EventUtils();
+
+private:
+ EventUtils(const EventUtils&) = delete;
+ EventUtils& operator=(const EventUtils&) = delete;
+};
+
+} // namespace stuff
+
+#endif /* EVENT_UTILS_HH */