Original Post
People arn''t being very helpfull with my other thread - possibly because it''s too specific or possibly because they don''t have enough information. So I''m going to try another approach - all the information:-)
My aim is to call a global function once for every class in existance that inherits from a base class - BSmart - this function takes two parameters - a text string representing that class, ie if you have GTurnip : public BSmart you would give it "GTurnip". The other parameter is a function pointer to a function that returns a BSmart * which has been declared new type() - new GTurnip() in the example case.
Thats all thats required - its for an object factory incase your wondering.
I can''t see any way of doing it completly automatically - so I''ve decided that an extra line of code per class is ok. Currently a macro that uses a templated singlton to do it is in use - this works except for templated classes. What happens is the singlton is declared by the macro in a different namespace - using the class token appended to a token as the identifier for the singlton - fine for normal classes but the angular braces in a templated name are not parts of a legal identifier name, so it dosn''t work for them. The annoying thing is I don''t even need an identifier for it as I never touch it and only want it for the code in the constructor:-(
A solution for this problem at any level would be greatly appreciated.
-Lethe
