diff options
author | fcolin | 2007-02-01 13:29:31 +0000 |
---|---|---|
committer | fcolin | 2007-02-01 13:29:31 +0000 |
commit | afe2e7dfc1388cad991e8d38dda7d648c137aa52 (patch) | |
tree | 92bf63d2b2b34a805927aa294c7c51912638f66a /IvyTest/ivytest.cpp | |
parent | 0be65f8a110ee9bf5da9c93e0bd5b5b62b3bad0c (diff) | |
parent | 04c263c314499e38d64af9d4a1aa5e2b8d9d5ead (diff) | |
download | ivy-cplusplus-afe2e7dfc1388cad991e8d38dda7d648c137aa52.zip ivy-cplusplus-afe2e7dfc1388cad991e8d38dda7d648c137aa52.tar.gz ivy-cplusplus-afe2e7dfc1388cad991e8d38dda7d648c137aa52.tar.bz2 ivy-cplusplus-afe2e7dfc1388cad991e8d38dda7d648c137aa52.tar.xz |
modif struct svnwindows@3001
Diffstat (limited to 'IvyTest/ivytest.cpp')
-rw-r--r-- | IvyTest/ivytest.cpp | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/IvyTest/ivytest.cpp b/IvyTest/ivytest.cpp new file mode 100644 index 0000000..370901e --- /dev/null +++ b/IvyTest/ivytest.cpp @@ -0,0 +1,84 @@ +// ivytest.cpp : Defines the entry point for the console application.
+//
+#include <iostream>
+
+#include <stdlib.h>
+using namespace std;
+
+#include "Ivy.h"
+#include "IvyApplication.h"
+
+static bool TheGrassIsGreenAndTheWindBlows = true;
+
+class cIvyTranslater : public IvyApplicationCallback
+{
+public:
+ cIvyTranslater(void);
+ ~cIvyTranslater();
+protected:
+ void OnApplicationConnected ( IvyApplication *app );
+ void OnApplicationDisconnected( IvyApplication *app );
+ void HelloCallback ( IvyApplication *app, int argc, const char **argv );
+ void ByeCallback ( IvyApplication *app, int argc, const char **argv );
+ Ivy *bus;
+};
+
+
+
+cIvyTranslater::cIvyTranslater(void)
+{
+ // initialization
+ bus = new Ivy( "cIvyTranslater","cIvyTranslater READY",this,FALSE);
+
+ int count;
+ count = bus->BindMsg( "^Hello(.*)", BUS_CALLBACK_OF(cIvyTranslater, HelloCallback ));
+ count = bus->BindMsg( "^Bye$", BUS_CALLBACK_OF(cIvyTranslater, ByeCallback ));
+
+ bus->start(NULL);
+}
+cIvyTranslater::~cIvyTranslater(void)
+{
+ bus->stop();
+ delete bus;
+}
+
+void cIvyTranslater::HelloCallback(IvyApplication *app, int argc, const char **argv)
+{
+ const char* arg = (argc < 1) ? "" : argv[0];
+ cout << "cIvyTranslater received msg: Hello'" << arg << "'" << endl;
+ bus->SendMsg( "Bonjour%s!", arg );
+}
+
+void cIvyTranslater::ByeCallback(IvyApplication *app, int argc, const char **argv)
+{
+ cout << "cIvyTranslater stops bus" << endl;
+ if (bus) {
+ TheGrassIsGreenAndTheWindBlows = false;
+ // This is causing the fatal bug
+// bus->stop();
+// delete bus; // This statement is never reached! Don't know why!
+ }
+
+}
+
+void cIvyTranslater::OnApplicationConnected(IvyApplication *app)
+{
+ cout << "cIvyTranslater is ready to accept messages from " << app->GetName() << endl;
+}
+
+void cIvyTranslater::OnApplicationDisconnected(IvyApplication *app)
+{
+ cout << "cIvyTranslater good buy '" << app->GetName() << "'" << endl;
+}
+
+
+void main(int argc, char* argv[])
+{
+ cIvyTranslater aIvyTL;
+
+ while (TheGrassIsGreenAndTheWindBlows) {
+ Sleep(2000);
+ cout << "new cycle..." << endl;
+ }
+ cout << "Good buy, world\n";
+}
\ No newline at end of file |