Multiple top-level systems that communicate with each other via messages(events/commands).
The Main class of the program wraps around all the systems and has a message dispacher component wich delivers messages from one system to another. Each system contains a lot of objects that need to communicate with each other, however these messages do not necessarily concern other systems.
My current implementation is as follows: each registered listener has an object(hashmap) "subscribedEvents" with callbacks for the concerned events(messages), but to avoid having the inner objects of a system send their messages through the main dispacher they would have a personal dispacher. The problem I have with this approach is how to identify each dispatcher, since inner objects still need to be able to listen for top level messages and the "subscribedEvents" object would have to become
What would be a proper way to add identifiers to the dispachers? A dispatcher is just a component of a class(system or inner object) and each dispatcher is not aware of the others. I can only think of a singleton eventDispatcher factory, but that doesn't look like a very elegant solution to me.
PS: I am open to a different whole new different approach for dealing with communication, this is just what I have come up with.