My present concern is memory management. In my C styled programs I'm usually very strict about who has the power to create and delete memory in order to avoid leaks. However in a message passing system under C++ things get a little more complicated. I'd like to be able to pass pointers or references to data structures, such as strings or maybe even arrays, as arguments in my messages. But given the message could in theory last longer than the object that creates it, and it be passed to many different other objects, and I don't particularly want to have to make copies of everything if I don't need to, then deriving a memory leak proof system gets really complicated. Especially if I'm rusty on design and my C++ isn't that good.
Then there's the problem of how I can make a Message class general enough to take pointers to pretty much anything. I suppose I could derive a bazillion different message flavours from a base class, but then it gets trickier to use a memory pool of dead messages in order to save on memory reallocation. I'm sure there's a decent way I can have a general Message class that could take nearly anything (possibly using templates? I'm pretty naive on the proper uses of those), but I'm fighting against my C instincts of damning type safety to hell and bringing out the old "pointer to void" stand-by.
So far I've been reading up tips in Effective C++ and searching the internet on info on smart pointers, templates, garbage collection and various other techniques, but there's only so much I can take in before my brain has it's own memory leak and it all swims together. I'm now fighting the thought that maybe C++ isn't the best language for this kind of thing - maybe something with in-built garbage collection or possibly even functional would be better [smile]. Of course, improving my C++ is all part of the goals of this project.
Guess the therapeutic journal entry is now over; I've got more advanced C++ to learn.