Commit b1d67cd
committed
refactor: code quality overhaul, new APIs, tests, and docs
Code quality (entitygen.hpp):
- Replace component_entry std::pair with named struct (.key, .comp)
- Replace entity::to_string() loop with std::ranges::fold_left_first
- Add default_to_string support for long type
- Validate choice_component/weighted_choice_component constructors
(throw std::invalid_argument on empty or all-zero weights)
New APIs:
- entity::size(), entity::empty()
- eg::clear(), eg::size(), eg::component_keys()
- operator<<(wostream, stats_observer)
Rename eg::count() → eg::size() for STL consistency with
entity::size(); count() in C++ idiom means "occurrences of X",
size() means "total number of elements".
Tests (254 cases, 746 assertions):
- ~35 new test cases: input validation, boundary conditions,
error messages, edge cases, move semantics, observer ordering,
async failure, stream operator, empty entity serialization
- Fix shallow stats assertions with deterministic retry counts
- Simplify clear_generator fixture to use eg::clear()
Docs:
- Document default_to_string supported types
- Document entity::get_any(), keys(), size(), empty()
- Document eg::clear(), size(), component_keys()
- Add behavior notes for add/remove/remove_group
- Add observer thread safety warning
- Fix stale roadmap references in README
Example:
- Add demos for validate(), entity inspection, multiple observers,
weight overrides, independent instances, error handling, clear()1 parent c5a1374 commit b1d67cd
6 files changed
Lines changed: 657 additions & 53 deletions
File tree
- dasmig
- ext
- doc
- examples
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| |||
103 | 105 | | |
104 | 106 | | |
105 | 107 | | |
106 | | - | |
| 108 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
125 | 126 | | |
126 | 127 | | |
127 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
128 | 133 | | |
129 | 134 | | |
130 | 135 | | |
| |||
181 | 186 | | |
182 | 187 | | |
183 | 188 | | |
184 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
185 | 194 | | |
186 | 195 | | |
187 | 196 | | |
| |||
296 | 305 | | |
297 | 306 | | |
298 | 307 | | |
299 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
300 | 317 | | |
301 | 318 | | |
302 | 319 | | |
| |||
395 | 412 | | |
396 | 413 | | |
397 | 414 | | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
398 | 421 | | |
399 | 422 | | |
400 | 423 | | |
401 | 424 | | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
413 | 429 | | |
414 | | - | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
415 | 434 | | |
416 | 435 | | |
417 | 436 | | |
| |||
537 | 556 | | |
538 | 557 | | |
539 | 558 | | |
540 | | - | |
| 559 | + | |
541 | 560 | | |
542 | 561 | | |
543 | 562 | | |
544 | | - | |
| 563 | + | |
545 | 564 | | |
546 | 565 | | |
547 | 566 | | |
548 | | - | |
| 567 | + | |
549 | 568 | | |
550 | 569 | | |
551 | 570 | | |
| |||
580 | 599 | | |
581 | 600 | | |
582 | 601 | | |
583 | | - | |
584 | | - | |
| 602 | + | |
| 603 | + | |
585 | 604 | | |
586 | 605 | | |
587 | 606 | | |
| |||
592 | 611 | | |
593 | 612 | | |
594 | 613 | | |
595 | | - | |
596 | | - | |
| 614 | + | |
| 615 | + | |
597 | 616 | | |
598 | 617 | | |
599 | 618 | | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
600 | 641 | | |
601 | 642 | | |
602 | 643 | | |
| |||
906 | 947 | | |
907 | 948 | | |
908 | 949 | | |
909 | | - | |
910 | | - | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
911 | 955 | | |
912 | 956 | | |
913 | 957 | | |
| |||
928 | 972 | | |
929 | 973 | | |
930 | 974 | | |
931 | | - | |
| 975 | + | |
932 | 976 | | |
933 | 977 | | |
934 | 978 | | |
| |||
1067 | 1111 | | |
1068 | 1112 | | |
1069 | 1113 | | |
1070 | | - | |
1071 | | - | |
| 1114 | + | |
| 1115 | + | |
1072 | 1116 | | |
1073 | 1117 | | |
1074 | 1118 | | |
| |||
1082 | 1126 | | |
1083 | 1127 | | |
1084 | 1128 | | |
1085 | | - | |
| 1129 | + | |
1086 | 1130 | | |
1087 | 1131 | | |
1088 | | - | |
1089 | | - | |
| 1132 | + | |
| 1133 | + | |
1090 | 1134 | | |
1091 | 1135 | | |
1092 | 1136 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
429 | 429 | | |
430 | 430 | | |
431 | 431 | | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
432 | 439 | | |
433 | 440 | | |
434 | 441 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
| 69 | + | |
| 70 | + | |
67 | 71 | | |
68 | 72 | | |
69 | 73 | | |
| |||
93 | 97 | | |
94 | 98 | | |
95 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
96 | 105 | | |
97 | 106 | | |
98 | 107 | | |
| |||
102 | 111 | | |
103 | 112 | | |
104 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
105 | 117 | | |
106 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
107 | 122 | | |
108 | 123 | | |
109 | 124 | | |
| |||
469 | 484 | | |
470 | 485 | | |
471 | 486 | | |
| 487 | + | |
| 488 | + | |
472 | 489 | | |
473 | 490 | | |
474 | 491 | | |
| |||
586 | 603 | | |
587 | 604 | | |
588 | 605 | | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
589 | 648 | | |
590 | 649 | | |
591 | 650 | | |
| |||
0 commit comments