Okay, I know I’ve said it before that I was getting tons done. Well, I’m about to have graphical proof!
I just got event passing working on my code project. It’s awesome. Now I’ll just be making resource concepts using templates and boost concept check, and things will be groovalicious!
*moments later*
Ah. So this is what bites for now. I’ve got a lot of resource concepts in the code (besides additional libraries I’ll allow the user to plop down inside the program dir). XMPP hosts, directly connected users, disk IO, graphical contexts, and also memory storage (primarily for events and mostly discrete data). The thing is, they all dole out various resource share types in order for me to get everything to connect smoothly. Really, I do that because it makes threading much easier by designing read-only and easily parallel code to just work at the highest speed, while allowing other types that need write permission (and thus mutex/blocking) to also still work. Some resources are also plain ol’ monitors, with their own worker threads (you pretty much have to do that for net IO), and so they need to create shares that are really just fancy looking thread-safe buffers.
What am I getting at? Well, the worst thing I could do is design OO to just wrap around everything. That would turn it into class/object pea-soup. Design patterns are always stumbling blocks when every problem you are solving is really separate and unifying any two resources under a pattern will typically lead to a golden hammer scenario (suddenly, you gotta make everything a nail or else it won’t work). Rather than tie myself down with all that junk, I decided to just design concepts using boost’s concept check. All’s well, but still… frustratingly enough, I have to create about 4 classes per handler to make everything work out, because my pointer storage will allow virtual function tables and all, but you still have to make first a base class (to build the VTable on) and then you have to make a template that inherits, which will also let you store share pointers in it. But don’t forget that the handler needs to design a template for the holder, which will concept check the incoming share. Now to make things even sillier, this all won’t work unless you then create a share class that caters to that concept. Still… if you put in all the infrastructure… suddenly… it just works. And the design is rather static… you literally only need to make an empty call to a function or member in the concept to add to it. And you only need to add virtual functions if it’s completely necessary… and usually they just call new concept functions. So, once in place, it’s not going to be hard to expand. Still, it gets a little tedious to update three classes to add a feature (the concept, template, and base).
Whatever, though. I’d hate to try just doing reinterpret casts and all the other madness that you have to go to just to get the same functionality without type-safety. And the concepts generate nice error checking… and the VTable sure is dandy. It lets me partially specify special cases of the template class to revert to the base class functionality or just completely add new and bizarre changes if I so desire (at the cost of adding… you guessed it… another object/class).
Still, I’m hopeful that the thing won’t be too huge a pain in the end. And the idea is to reduce feature changes… and mostly just make it easy to add as many resource share types as I want without the fear that something will break, leak, or take a hundred additional changes just to support it.
The bottom line: OO will always be evil. And I really just gear my UI to be as ignorant of it as possible (UI + OO + adding features = painful death). The downside of it is that my executable code is getting REALLY big… even with -O3 and lots of added stripping to the release binaries. And geez… I still gotta add the individual resource shares once I make them transport data trivially (hopefully tbb will make tuning the CPU usage of each worker thread painless).
We’ll see. For now… I’m optimistic. I SHOULD have a real alpha before classes start. Why? Because I’m confident that if events are working (the part I thought would take forever), data generation to follow the events is merely brainless function calls and byte pushing. I hope. I hope I hope.
OH! and using OpenGL plus nvidia’s lil’ IMGUI toolkit has made the UI side of data representation and threading almost TOO easy to pull off. I love that so much more than any other type of GUI. I can’t tell you how much I hate retained GUI’s, because of all the work to keep track of EVERYTHING on the screen.