The BaseClient API is in it's first draft state now, viewable
here. Basically, the interface consists of three sections - virtual functions that derived classes can override to provide user interfaces various information (client software, nicknames and such); interface to get and set various state flags, such as requested files, connection state etc, which affect ClientManager lookups; and utility functions, which help reduce duplicate code over plugins (such as request generation). I'm also considering integrating A4AF handling into that class, but there are some cave-at's in that area that I'm not comfortable with (might be not portable across networks). The corresponding implementation can be seen
here.
The fun magic, however, starts at ClientManager. The public interface can be seen
here. Here you can see the "smart data structures and dumb code work lot better than vice versa" in action - 80-lines to define the data structure, and then one-liners to perform lookups there. That large multi_index_container allows me to get various views on the clients listing, queries such as:
- All clients for a specific module
- All clients offering a specific file
- All clients that have requested a specific file
- All connected clients for a specific module
- All uploading clients
- All uploading clients for a specific file
- All downloading clients
- All downloading clients for a specific file
- All queued clients
- All sources
- ...
Additional indices can be added easily when needed, altough I think the above covers all our needs (640kb ought to be enough for everyone, right?).
Madcat, ZzZz