NWChemEx / NWChemEx/PluginPlay

Autoregister modules

Open
#105 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.