From ee937667fd0ecd82faab4c88d756b906fb625f1a Mon Sep 17 00:00:00 2001 From: sc Date: Tue, 28 Nov 2000 17:07:47 +0000 Subject: Integration into IvyLeague Uvh -> Ivl Multiplexer.* is renamed into Scheduler.* A few name conflicts in the merger with ex-DNN have been solved Imakefile is replaced by Makefile Created InetAddress.* and UnixAddress.* from Address.* Created IrdaAddress.* OLD/TextStream has been updated --- comm/testbus.cc | 55 +++++++++++++++++++++++++------------------------------ 1 file changed, 25 insertions(+), 30 deletions(-) (limited to 'comm/testbus.cc') diff --git a/comm/testbus.cc b/comm/testbus.cc index ec06f18..6edeaec 100644 --- a/comm/testbus.cc +++ b/comm/testbus.cc @@ -1,21 +1,18 @@ - -#include "Multiplexer.h" +#include "Scheduler.h" #include "TimeOut.h" #include "BusAccess.h" -#include "dnn/Reaction.h" +#include "ivl/Reaction.h" #include #include #include -class DnnEvent; - +class IvlEvent; /* -Global variables. This is because we use DnnCallbacks and functions -instead of DnnReactions and objects. But this is only a test... +Global variables. This is because we use IvlCallbacks and functions +instead of IvlReactions and objects. But this is only a test... */ -UchBusAccess* A; -DnnCallback* C; - +IvlBusAccess* A; +IvlCallback* C; /* This is an example of how to emit messages on the bus. @@ -39,15 +36,15 @@ from the bus. Here, this function is associated to a callback, which in turn is associated to a regexp (see in main). */ void -print_event (DnnEvent& ev) +print_event (IvlEvent& ev) { - UchBusEvent* be = dynamic_cast (&ev); + IvlBusEvent* be = dynamic_cast (&ev); if (!be) return; cout << "Event matches '" << be->Regexp << "'\n"; cout << "\t(" << be->NbMatches << " matches: "; - CcuListIterOf li = be->MatchList; + IvlListIterOf li = be->MatchList; while (++li) cout << "'" << **li << "' "; cout << ")\n"; @@ -58,13 +55,13 @@ This is an example of how to handle a new agent connecting to the bus. Most applications are not interested in such events... */ void -agentready (DnnEvent& ev) +agentready (IvlEvent& ev) { - UchAgentEvent* ae = dynamic_cast (&ev); + IvlAgentEvent* ae = dynamic_cast (&ev); if (!ae) return; - UchBusAgent* a = ae->GetAgent (); + IvlBusAgent* a = ae->GetAgent (); cout << "Hello " << a->GetName () << "!\n"; C->SubscribeTo (a->Bye); @@ -75,45 +72,43 @@ This is an example of how to handle an agent leaving the bus. Most applications are not interested in such events... */ void -agentbye (DnnEvent& ev) +agentbye (IvlEvent& ev) { - UchAgentEvent* ae = dynamic_cast (&ev); + IvlAgentEvent* ae = dynamic_cast (&ev); if (!ae) return; - UchBusAgent* a = ae->GetAgent (); + IvlBusAgent* a = ae->GetAgent (); cout << "BYE " << a->GetName () << "!\n"; } - - main () { /* initialize communication library */ - UchOpen (); + IvlOpen (); /* create bus access */ - UchBusAccess a ("Uch test"); A = &a; + IvlBusAccess a ("Ivl test"); A = &a; /* periodically send messages on the bus (see foo for timeout handling) */ - UchTimeOut t (1000, foo); + IvlTimeOut t (1000, foo); /* subscribe to a few event types (see print_event for event handling) */ - /* Note that you can use every subclass of DnnBaseReaction instead - of DnnCallback */ - DnnCallback c1 (print_event); + /* Note that you can use every subclass of IvlBaseReaction instead + of IvlCallback */ + IvlCallback c1 (print_event); a.Subscribe (c1, "^(CLOCK) (.*)"); a.Subscribe (c1, "TRAFFIC Start"); a.Subscribe (c1, "(.*Tick.*)"); a.Subscribe (c1, "^AIRCRAFT:(.*) Moved (.*)"); /* react to new agents calling (see agentready for event handling) */ - DnnCallback c3 (agentready); + IvlCallback c3 (agentready); c3.SubscribeTo (a.NewAgents); /* reaction to agents leaving (see agentready for subscription, and agentbye for event handling) */ - DnnCallback c4 (agentbye); C = &c4; + IvlCallback c4 (agentbye); C = &c4; - UchLoop (); + IvlLoop (); } -- cgit v1.1