• ### Popular Now

• 14
• 12
• 9
• 10
• 9

This topic is 3920 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I know that some people like the idea of: SoundFx a=SoundManager.Load("badExampleOfOODesign.wav"); However, I have been trying to get away from the whole concept of a "manager" (which I despise intensely and will not argue over in this thread, so please do not try). Then in the midst of working on my code for loading graphics from file into a generic Bitmap object I stumbled into this syntax for loading.
bmp::Bitmap bitmap;
std::ifstream ifs("testin.png",std::ios::in|std::ios::binary);
ifs.close();


Object o;
Stream s(STREAM_PARAMETERS); // STREAM_PARAMETERS could be a file name
s.close(); // not necessary as this is automatic with RAII


Or if I have a LoaderObject that already knows the stream use (possibly a Monostate) it can be:
Object o;


And I may even add this syntax as well:
ContainerWithAnOutputIterator c;
c.reserve(NUMBER_OF_OBJECTS_TO_LOAD); // if this is a vector or a similar type
Container paramList; // list of STREAM_PARAMETERS which again could be file names


So now I am thinking that if I pair all (or at least most) of my objects that need IO with a Loader object, I can create objects now and still have great flexibility in what I do with IO later. I admit that I have heard of the idea IO visitor objects before, but I have never seen an example or an explanation for why one would use it. However, now I understand.