Re: A design problem: how to represent resource id's
[Bob, I think the discussion you aim for is off-topic in clc++ since it
doesn't involve C++, so I'm setting follow-ups; please honor.]
* Bob Hairgrove:
Don't forget that resources in Windows can be created on the fly.
Depends what you mean: obviously they can be created, and hence, on the fly.
They
don't have to be embedded in the executable or a DLL, although that is
a popular alternative.
Classic API-level resources have to be embedded in files, mainly because
they're used without regard for deallocation.
Just an idea I have been playing with:
One could have a factory class for each kind of resource and let the
factory be a template taking a parameter of different kinds of
resource managers. In the debugging phase, for example, resource data
could be kept in a configuration file (e.g. XML, or even an INI file)
which would be read by the resource manager as text. The binary
resource would be created on the fly by the resource manager. Slow, of
course, but a whole lot easier to edit during development. No
recompiling, no linking, just edit the configuration and run.
XML resources like you describe are supported by many environments,
including Java and Windows .NET.
It's not a case of edit-and-go, however.
On the contrary, for all but the most trivial kinds of resources it
typically involves a lot of obscure under-documented or undocumented
tools and API's, e.g. conversion to and back from Base-64. It's IMHO an
over-generalization that only barely delivers the basic functionality,
and then in an inefficient and needlessly complex way. Unfortunately,
those who make the decisions about what we should use in the future, by
backing this or that approach so that support becomes available, have a
vested interest in selling tools, seminars and so on, and are perhaps
not so much engineers as buzz-word compliant managers with $$$ eyes.
Once everything is satisfactory, the configuration file could be
parsed and compiled as a RES file by an external tool and linked to
the executable. The template resource manager used for debugging would
be swapped for one that loads resources the "normal" way.
Uh. Microsoft is introducing something like that in Windows Vista.
It's ugly, and it's over-generalized. It tries to fix that which
doesn't need fixing, and solve that which is already solved, instead of
fixing the things that are broken (such as the documentation...).
I believe this is similar to how some GUI libraries manage resources
on Linux, isn't it?
Everywhere, unfortunately.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?