I have this typedef to define a function pointer.
typedef Script*(*CreateObjectFn)(TiXmlElement* node);
I've created a generic container for my purpose that acts like a map. It's called Dictionary, so I've created a Dictionary of CreateObjectFn inside a class like this:
class ScriptBank
{
public:
~ScriptBank();
static Dictionary<CreateObjectFn>& getInstance()
{
static Dictionary<CreateObjectFn>& registry = m_registry;
return registry;
}
private:
static Dictionary<CreateObjectFn> m_registry;
ScriptBank();
};
I have various type of Script so in this Dictionary I want to put inside a certain function of the derived Script.
Now from the template class:
template <class T>
class Register
{
public:
Register()
{
ScriptBank::getInstance().insert("Some string", T::create);
}
~Register()
{
}
};
Inside the derived Script i have something like:
static Script* create(TiXmlElement* node);
static Register<DoorChStateScript> m_Registry;
My purpose is to insert the function pointer at compilation time, but compiler seems to not recognize the right type.
In the Register class I got this error: cannot convert parameter 2 from 'Script *(TiXmlElement *)' to 'CreateObjectFn *'
Any ideas?