Without going into too much detail...
I'm building a sockets class that:
A. Allows multiple sockets, reconnecting w/ varying connection timeouts, to connect to a single host -- using the first connected socket and closing all others.
B. Designed for Linux
C. Must be re-usable
D. Is named Sockets
Currently, I've decided that overloadable virtual functions (such as OnConnect(), OnTimeout(), OnDisconnect(), and OnDataReceived()) would be the best way to alert a derived class of socket-based events.
The inheritance goes like this:
Project name :YAWNB
YAWNB has a few functions that handle output and user input. YAWNB includes multiple instances of bot, which uses a single isntance of Sockets, which uses multiple sockets.
YAWNB uses Bot
Bot inherits BotInfo
BotInfo inherits Sockets
The problem I've run into is:
Sockets will be passing a pointer to itself to the overloaded functions. The fact that I want it to be reusable (without being dependent on other classes) makes it kind of ugly for my project to distinguish which "bot" is actually receiving those events. Then there's the issue of bot (which also needs to be reusable) not being able to output data to the screen without being dependent on YAWNB. I'm finding it very difficult to make all of these classes stand-alone and resuable. Anyone have any elegant solutions that don't involve raising and handling events?
P.S. I'm sorry if I'm being confusing. I'm having a very difficult time putting my questions into words. If some kind of pseudo-orotherwise-code will help, just let me know and I'll come up with something.
Thanks in advance. =]