Commit ff4b003
abacus_fixer
refactor(esolver): extract init_esolver factory from base class file
The factory functions init_esolver() and determine_type() were previously
hosted in esolver.cpp, which is nominally the implementation file of the
abstract base class ESolver. To instantiate the concrete derived classes
(ESolver_KS_PW, ESolver_KS_LCAO, ESolver_OF, etc.), esolver.cpp had to
#include 13 derived-class headers, making the base-class file reverse-
depend on all its derivatives. This violates ABACUS coding rule 3
("Keep header dependencies minimal") and the dependency-inversion
principle.
Fix by moving the factory code into a dedicated esolver_factory module
so that esolver.h/cpp only carries the ESolver interface and knows
nothing about derived classes. The factory is the single place allowed
to see both the interface and all concrete implementations, which is
its essential responsibility.
Changes:
- Add source/source_esolver/esolver_factory.h with declarations of
determine_type() and init_esolver(); forward-declares Input_para
and ESolver to keep includes minimal.
- Add source/source_esolver/esolver_factory.cpp containing the full
bodies of determine_type() and init_esolver() moved verbatim from
esolver.cpp, plus the 13 derived-class includes that now live here.
- Remove source/source_esolver/esolver.cpp (its entire content was the
factory code; the ESolver base class has no out-of-line members).
- Trim source/source_esolver/esolver.h: drop determine_type() and
init_esolver() declarations and their doxygen blocks. The Input_para
forward declaration is retained because before_all_runners() takes it
as a parameter.
- Update source/source_esolver/CMakeLists.txt and source/Makefile.Objects
to compile esolver_factory.cpp instead of esolver.cpp.
- Add explicit #include "source_esolver/esolver_factory.h" in
source/source_main/driver_run.cpp, the sole caller of init_esolver();
previously the declaration was pulled in transitively via relax_driver.h.
No runtime behavior change. After this refactor, touching a derived
esolver header no longer forces recompilation of the base-class file.
Verified: incremental build of `esolver` and `abacus_std_para` targets
in build_std_para (ENABLE_LCAO=ON) passes.1 parent cead755 commit ff4b003
6 files changed
Lines changed: 43 additions & 22 deletions
File tree
- source
- source_esolver
- source_main
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
273 | | - | |
| 273 | + | |
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | 54 | | |
74 | 55 | | |
75 | 56 | | |
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
0 commit comments