--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/samples/main-event.cc Tue Aug 29 17:47:17 2006 +0200
@@ -0,0 +1,42 @@
+/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
+#include "yans/event.h"
+#include "yans/event.tcc"
+#include <iostream>
+
+using namespace yans;
+
+class MyModel {
+public:
+ void deal_with_event (double event_value);
+};
+
+void
+MyModel::deal_with_event (double value)
+{
+ std::cout << "Member method received event." << std::endl;
+}
+
+static void
+random_function (void)
+{
+ std::cout << "Function received event." << std::endl;
+}
+
+
+int main (int argc, char *argv[])
+{
+ Event ev;
+ // create event to forward to random_function
+ ev = make_event (&random_function);
+ // set cancel bit to on
+ ev.cancel ();
+ // try to invoke the random_function through the event.
+ // This does nothing since cancel bit is on.
+ ev ();
+ MyModel model;
+ // create event to forward to MyModel::deal_with_event
+ // on the class instance "model".
+ ev = make_event (&MyModel::deal_with_event, &model, 10.0);
+ // invoke member method through the event.
+ ev ();
+}