Original Post
I am starting to redesign a project that I did last year to make it more flexible - my question is partly tied to scripts, however it is more of a general problem so I thought it would be most at home here (however using a scripting engine as an example) The problem I have is thus: I want to be able to specify objects to 'add' in the script file, for example, I want to be able to do this:
add "BField" {
...
add "linearfield" {
...
}
}
add "particle" { ... The problem comes that I want the implementation to be vaguely flexible, that is, not hard-coded - to be able to pass the scripting code a list of "Class names" as strings (to match the parsed input) and some information that will let me create them dynamically - I assume all the objects would have to have to be inherited from the same base class, and that would be involved, but the only way I can think of is to pass a pointer to the objects constructor, but wouldn't that require it to be a static function? (And I'm sure that would cause other problems, if at all possible?) Any suggestions or insight would be greatly appreciated, I have tried searching but to be quite honest I'm not sure of the words I should be searching for, 'Dynamic class creation in c++ from scripts' and various permutations of that haven't yielded much information.