Component registration using a category name and the appropriate function returning a components instance object.
| 55 | // Component registration using a category name and the appropriate |
| 56 | // function returning a components instance object. |
| 57 | void Module::registerComponent (QString category, pInfoFunc info) { |
| 58 | Module * m = new Module (); |
| 59 | m->info = info; |
| 60 | m->category = category; |
| 61 | |
| 62 | // instantiation of the component once in order to obtain "Model" |
| 63 | // property of the component |
| 64 | QString Name, Model; |
| 65 | char * File; |
| 66 | Component * c = (Component *) info (Name, File, true); |
| 67 | Model = c->obsolete_model_hack(); |
| 68 | delete c; |
| 69 | |
| 70 | // put into category and the component hash |
| 71 | intoCategory (m); |
| 72 | if (!Modules.contains (Model)) |
| 73 | Modules.insert (Model, m); |
| 74 | } |
| 75 | |
| 76 | // Returns instantiated component based on the given "Model" name. If |
| 77 | // there is no such component registers the function returns NULL. |