On Thursday 05 October 2006 17:39, Richard Hosking wrote:
> The problem of communication between objects never seemed to be
> satisfactorily solved in C++ - Qt used the signals/slots mechanism,
> wxWidgets appears to use validators. The details of how these worked
> appeared to me to be quite arcane and impenetrable.
"Validators" have nothing to do with messaging in wxWidgets, they are just
callback methods that are called automatically whenever widget content is
modified
The principle of messaging is nearly always the same regardless of toolkit and
language:
1.) the frame work keeps a hash table of message identifiers mapped to
associated methods
2.) objects register interest in certain messages = they add an entry to the
hash table, e.g. "if a message <msg identifier> is received <from all>|<from
stated object(s)> then call <this method>""
3.) parameters passed with method call depend on conventions = read the API
manuals
Example of the simplest messaging system:
a) convention:
- message identifiers are strings
- message parameter is a single string
b) hash table: private member of a singleton class, exposed through public
methods with the scope of the whole application
c) any object can call singleton.register("message1", mymethod)
d) any object can call singleton.send("message1")
e) when the singleton receives "message1" (= singleton method "send" has been
called with parameter "message1") it looks up the hash table, finds that
there is a method "mymethod" associated with that message, and executes it
If you keep this simple principle in mind, there won't be any problem
understanding how to use the various semantics. The main difference in
frameworks is the handling of parameter passing, sender and context
identifiers
Horst
_______________________________________________
Gpcg_talk mailing list
[email protected]
http://ozdocit.org/cgi-bin/mailman/listinfo/gpcg_talk