NWChemEx / NWChemEx/PluginPlay
Autoregister modules
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 13
- Forks
- 1
- Avg merge
- 43m
- Merged PRs (30d)
- 4
Description
Right now we have the load_mm() functions which look like:
mm.add_module(...);
mm.add_module(...);
This article gave me an idea for how to autoregister modules. Basically in SDE we declare some global map std::map<T, ModuleBase*()> factory (T likely typeid(DerivedClass), but maybe have the user set a string). We then define a macro:
#define REGISTER_MODULE(TypeOfModule, key)\
struct Register ## TypeOfModule {\
Register ## TypeOfModule(){ factory[key] = [](){ return new TypeOfModule();};}\
};\
Register ## TypeOfModule p
which a user puts in their source file like REGISTER_MODULE(MyModule, "DefaultKey");.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the existing load_mm() functions and their explicit mm.add_module(...) calls, then compare the proposed factory-map and REGISTER_MODULE approach with the current module-loading design. Done means modules can be declared for autoregistration so load_mm() no longer needs each module added explicitly; the key and factory mechanism still need to be settled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100