[reSIProcate] Contents static initializers
Hi all,
Happy New Year (western).
I took a look at the scary static initializers for derived Contents types. The
initializers map Mime type to the contents parser/packager through the
ContentsFactory template. This means that including a contents type ties it in
to the factory.
It turns out that they are implemented correctly as far as one can get C++
static initializers right.
In some cases, it may be necessary to call FooContents::init() explicity in main
to guarantee that the content type is added to the factory. I am not sure when
this will be required -- possibly in some obscure DLL cases, but it is always
safe. Perhaps someone with experience in dynamic linking can comment?
I fixed a few header files that had missing bits of the static initializer
magic. For the most part, you shouldn't have to worry about this issue -- just
make sure that all concrete contents derived types have:
1. a static init() method
2. a namespace level bool that is inited with the init() method
3. an implementation of init() (in .cxx) that creates the factory instance
as a scoped static variable.
See SdpContents for an example of correct usage.
thanks,
david