Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!well!tmh From: tmh@well.UUCP (Todd M. Hoff) Newsgroups: comp.lang.c++ Subject: Combining event driven and object orient programming Message-ID: <13928@well.UUCP> Date: 4 Oct 89 03:37:57 GMT Reply-To: tmh@well.UUCP (Todd M. Hoff) Distribution: all Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 45 With the question of C++ having boolean types out of our blood, let's move on to something really challenging. QUESTION: In an event driven environment, how are events associated with the correct method within the correct object instance? How is argument parsing handled? SITUATION: For our project each process is completely event driven. A set of libraries implements event handling through a set of callback routines and work/response queues. There are a number of clients and servers using and providing various services. Applications process events from multiple sources including a user interface manager, several database managers, processes on remote machines asnchronously emitting events, and a few others. In each application are multiple objects handling these events and controlling remote objects. The problem is how to associate an event with a particular method within a particular object instance. Events arrive and they must be processed. Use which object? Which method? How is the message translated into method arguments? The situation is complicated even more by the heterogenaity of the event message formats. Some messages are basically just serialized C structures and others are CMIP messages encoded in ASN.1, needing A LOT of decoding. So there is no standard message format or standard set of arguments to pass. SOLUTION: The problem seems to stem around the inability to send a message to an object, something like: objID selector data. There's function overloading, but function overloading assumes you're in a context such that you know what method to call. In an event driven environment the former is rarely the case. I have a couple of possible solutions, but I am hoping someone has faced this problem before and has an elegant painfully-obvious-on- further-reflection solution. I don't consider endless switch statements a real solution. Thanks in advance tmh@well