Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Merge rosea development back on the trunk. Release of rosea version 1.9.1. |
---|---|
Timelines: | family | ancestors | descendants | both | trunk | rosea_1.9.1 |
Files: | files | file ages | folders |
SHA1: |
0ce4956a68eb109ec7cc3736e736c6a7 |
User & Date: | andrewm 2020-05-06 10:37:46 |
Context
2020-05-07
| ||
14:25 | Merging bug fix from the rosea-develop branch. Release of rosea 1.9.2. check-in: 11a86db0eb user: andrewm tags: trunk, rosea_1.9.2 | |
2020-05-06
| ||
10:37 | Merge rosea development back on the trunk. Release of rosea version 1.9.1. check-in: 0ce4956a68 user: andrewm tags: trunk, rosea_1.9.1 | |
10:33 | Corrected a problem with generation of seqdiag output for polymorphic events. Minor changes in the formatting of event traces. Changed the tracing of a cascade of repeated polymorphic events so that the target of the previous event polymorphic event becomes the source for the next one. Previously, all polymorphic events appear to have originated from the source instance of the first one. check-in: 9b50ed6133 user: andrewm tags: rosea-develop | |
2020-05-05
| ||
15:56 | Merge of rosea-develop onto the trunk. Release of rosea version 1.9. check-in: c909a33e32 user: andrewm tags: trunk, rosea_1.9 | |
Changes
Added modules/rosea-1.9.1.tm.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 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 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 |
# DO NOT EDIT THIS FILE! # THIS FILE IS AUTOMATICALLY GENERATED FROM A LITERATE PROGRAM SOURCE FILE. # # This software is copyrighted 2014-2015 by G. Andrew Mangogna. # The following terms apply to all files associated with the software unless # explicitly disclaimed in individual files. # # The authors hereby grant permission to use, copy, modify, distribute, # and license this software and its documentation for any purpose, provided # that existing copyright notices are retained in all copies and that this # notice is included verbatim in any distributions. No written agreement, # license, or royalty fee is required for any of the authorized uses. # Modifications to this software may be copyrighted by their authors and # need not follow the licensing terms described here, provided that the # new terms are clearly indicated on the first page of each file where # they apply. # # IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING # OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES # THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE # IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE # NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, # OR MODIFICATIONS. # # GOVERNMENT USE: If you are acquiring this software on behalf of the # U.S. government, the Government shall have only "Restricted Rights" # in the software and related documentation as defined in the Federal # Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you # are acquiring the software on behalf of the Department of Defense, # the software shall be classified as "Commercial Computer Software" # and the Government shall have only "Restricted Rights" as defined in # Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, # the authors grant the U.S. Government and others acting in its behalf # permission to use and distribute the software in accordance with the # terms specified in this license. package require Tcl 8.6 package require logger package require ral package require ralutil package require struct::set package require lambda proc ::K {x y} {set x} namespace eval ::rosea { namespace export configure namespace export configureFromChan namespace export configureFromFile namespace export generate namespace export populate namespace export populateFromChan namespace export populateFromFile namespace export save namespace export restore namespace export info namespace export tunnel namespace export trace namespace ensemble create variable version 1.9.1 logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar pipe { relation semijoin $class $Attribute -using {Domain Domain Name Class} | relation project ~ Name Type | relation dict ~ Name Type } headingQuery pipe { relation semijoin $class $Identifier -using {Domain Domain Name Class}\ $IdentifyingAttribute | relation group ~ Attributes Attribute } idQuery pipe { relation semijoin $class $Attribute -using {Domain Domain Name Class} | relation join ~ $UserSuppliedValue -using {Domain Domain Class Class Name Attribute} } defaultValuesQuery pipe { relation semijoin $class $Attribute -using {Domain Domain Name Class} | relation join ~ $SystemSuppliedValue -using {Domain Domain Class Class Name Attribute} } suppliedValuesQuery pipe { relation semijoin $class $Attribute -using {Domain Domain Name Class} | relation join ~ $GeneratedValue -using {Domain Domain Class Class Name Attribute} } generatedValuesQuery pipe { relation semijoin $class $Attribute -using {Domain Domain Name Class} | relation join ~ $ValueCheck -using {Domain Domain Class Class Name Attribute} } checkValuesQuery pipe { relation semijoin $class $StateModel -using {Domain Domain Name Model} | relation isnotempty } hasSMQuery pipe { relation semijoin $class $State -using {Domain Domain Name Model} | relation project ~ Name Parameters Action } statesQuery pipe { relation join $AttributeReference $refing\ -using {Domain Domain ReferringClass Class\ Relationship Relationship ReferringRole Role} | relation rename ~ Conditionality ReferringCond\ Multiplicity ReferringMult | relation join ~ $refed -using {Domain Domain\ ReferencedClass Class Relationship\ Relationship ReferencedRole Role} | relation project ~ Domain Relationship\ ReferringClass ReferringAttribute\ ReferencedClass ReferencedAttribute\ ReferringCond ReferringMult Conditionality | relation group ~ ReferringAttrs\ ReferringAttribute ReferencedAttribute | relation extend ~ rfa\ TagReferringAttrs {Relation {RefOrder int ReferringAttribute string\ ReferencedAttribute string}} { [relation tag [tuple extract $rfa ReferringAttrs] RefOrder] } | relation extend ~ wfa\ SrcAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferringAttribute -ascending RefOrder] }\ DstAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferencedAttribute -ascending RefOrder] } | relation extend ~ ram\ ForwAttrs list { [Interleave [tuple extract $ram SrcAttrs]\ [tuple extract $ram DstAttrs]] }\ RevAttrs list { [Interleave [tuple extract $ram DstAttrs]\ [tuple extract $ram SrcAttrs]] } | relation eliminate ~ TagReferringAttrs } referencesQuery pipe { relation semijoin $cassocs $AssociatorClass\ -using {Domain Domain Name Relationship}\ $ReferringClass $AttributeReference\ -using {Domain Domain Class ReferringClass\ Relationship Relationship Role ReferringRole} | relation project ~ Domain Relationship ReferringClass ReferringAttribute\ ReferencedClass ReferencedAttribute ReferencedRole | relation join ~ $bothclass -using {Domain Domain Relationship Relationship\ ReferencedClass Class ReferencedRole Role} | relation group ~ ReferringAttrs ReferringAttribute ReferencedAttribute | relation extend ~ rfa\ TagReferringAttrs {Relation {RefOrder int ReferringAttribute string\ ReferencedAttribute string}} { [relation tag [tuple extract $rfa ReferringAttrs] RefOrder] } | relation extend ~ wfa\ SrcAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferringAttribute -ascending RefOrder] }\ DstAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferencedAttribute -ascending RefOrder] } | relation extend ~ ram\ ForwAttrs list { [Interleave [tuple extract $ram SrcAttrs]\ [tuple extract $ram DstAttrs]] }\ RevAttrs list { [Interleave [tuple extract $ram DstAttrs]\ [tuple extract $ram SrcAttrs]] } | relation eliminate ~ TagReferringAttrs } assocrefsQuery pipe { relation semijoin $rships $Generalization\ $Subclass -using {Domain Domain Name Relationship}\ $ReferringClass $AttributeReference\ -using {Domain Domain Class ReferringClass\ Relationship Relationship Role ReferringRole} | relation project ~ Domain Relationship ReferringClass ReferringAttribute\ ReferencedClass ReferencedAttribute | relation group ~ ReferringAttrs\ ReferringAttribute ReferencedAttribute | relation extend ~ rfa\ TagReferringAttrs {Relation {RefOrder int ReferringAttribute string\ ReferencedAttribute string}} { [relation tag [tuple extract $rfa ReferringAttrs] RefOrder] } | relation extend ~ wfa\ SrcAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferringAttribute -ascending RefOrder] }\ DstAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferencedAttribute -ascending RefOrder] } | relation extend ~ ram\ ForwAttrs list { [Interleave [tuple extract $ram SrcAttrs]\ [tuple extract $ram DstAttrs]] }\ RevAttrs list { [Interleave [tuple extract $ram DstAttrs]\ [tuple extract $ram SrcAttrs]] } | relation eliminate ~ TagReferringAttrs } subrefsQuery proc configure {script} { namespace upvar Config errcount errcount configlineno configlineno set errcount 0 set configlineno 1 ConfigEvaluate ::rosea::Config $script if {$errcount > 0} { tailcall DeclError CONFIG_ERRORS $errcount } return $errcount } proc configureFromChan {chan} { tailcall configure [::chan read -nonewline $chan] } proc configureFromFile {filename} { set f [::open $filename r] try { configureFromChan $f } finally { ::chan close $f } } proc generate {{pattern *} {prefix {}}} { if {$prefix ne {}} { if {[string range $prefix 0 1] ne "::"} { set prefix [uplevel 1 {namespace current}]::$prefix } set prefix [string trimright $prefix :] } elseif {$prefix eq "::"} { set prefix {} ; # <1> } namespace upvar Config\ Domain Domain\ DomainElement DomainElement\ Class Class\ Attribute Attribute\ DefaultValue DefaultValue\ UserSuppliedValue UserSuppliedValue\ SystemSuppliedValue SystemSuppliedValue\ GeneratedValue GeneratedValue\ ValueCheck ValueCheck\ Identifier Identifier\ IdentifyingAttribute IdentifyingAttribute\ Relationship Relationship\ Association Association\ SimpleAssociation SimpleAssociation\ SimpleReferringClass SimpleReferringClass\ SimpleReferencedClass SimpleReferencedClass\ ClassBasedAssociation ClassBasedAssociation\ AssociatorClass AssociatorClass\ SourceClass SourceClass\ TargetClass TargetClass\ Generalization Generalization\ Superclass Superclass\ Subclass Subclass\ AttributeReference AttributeReference\ ReferencedIdAttribute ReferencedIdAttribute\ ReferringClass ReferringClass\ ReferencedClass ReferencedClass\ DomainOperation DomainOperation\ SuppliedOperation SuppliedOperation\ UserClassOperation UserClassOperation\ SystemClassOperation SystemClassOperation\ UserInstanceOperation UserInstanceOperation\ SystemInstanceOperation SystemInstanceOperation\ InstanceStateModel InstanceStateModel\ StateModel StateModel\ StatePlace StatePlace\ State State\ EffectiveEvent EffectiveEvent\ DeferredEvent DeferredEvent\ TransitionPlace TransitionPlace\ StateTransition StateTransition\ NonStateTransition NonStateTransition\ AssignerStateModel AssignerStateModel\ SingleAssigner SingleAssigner\ MultipleAssigner MultipleAssigner\ PolymorphicEvent PolymorphicEvent set genDomain [relation restrict $Domain dom { [string match $pattern [tuple extract $dom Name]] }] relation foreach domain $genDomain { set domainName [relation extract $domain Name] relvar updateone Config::Domain dtup [list Name $domainName] { tuple update $dtup Location $prefix } set domns ${prefix}::$domainName namespace eval $domns { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe ral relvar create __Arch_RefLink { Relationship string ReferringClass string ReferencedClass string ReferringAttrs {Relation {ReferringAttribute string ReferencedAttribute string}} } Relationship ral relvar create __Arch_AssocRef { Relationship string AssocClass string References {Relation\ {Participant string Role string ReferringAttrs {Relation\ {ReferringAttribute string ReferencedAttribute string}}}} } Relationship ral relvar create __Arch_SuperLink { Relationship string SuperClass string } Relationship ral relvar create __Arch_SubLink { Relationship string SubClass string ReferringAttrs {Relation\ {ReferringAttribute string ReferencedAttribute string}} } {Relationship SubClass} ral relvar association __Arch_R5\ __Arch_SubLink Relationship +\ __Arch_SuperLink Relationship 1 ral relvar create __Arch_Link { Name string SrcClass string } {Name SrcClass} ral relvar create __Arch_AssociationLink { Name string SrcClass string DstClass string Attrs list PrevSrcClass string } {Name SrcClass} ral relvar association __Arch_R4\ __Arch_AssociationLink {Name PrevSrcClass} ?\ __Arch_AssociationLink {Name SrcClass} ? ral relvar create __Arch_PartitionLink { Name string SrcClass string } {Name SrcClass} ral relvar partition __Arch_R3 __Arch_Link {Name SrcClass}\ __Arch_AssociationLink {Name SrcClass}\ __Arch_PartitionLink {Name SrcClass} ral relvar create __Arch_PartitionDst { Name string SrcClass string DstClass string Attrs list } {Name SrcClass DstClass} ral relvar association __Arch_R2\ __Arch_PartitionDst {Name SrcClass} +\ __Arch_PartitionLink {Name SrcClass} 1 ral relvar create __Arch_State { Class string State string } {Class State} ral relvar create __Arch_Event { Class string Event string } {Class Event} ral relvar create __Arch_Transition { Class string State string Event string NewState string } {Class State Event} ral relvar correlation __Arch_R1 __Arch_Transition\ {Class State} + __Arch_State {Class State}\ {Class Event} + __Arch_Event {Class Event} ral relvar create __Arch_InitialState { Class string State string } Class ral relvar association __Arch_R6\ __Arch_InitialState {Class State} ?\ __Arch_State {Class State} 1 ral relvar create __Arch_TerminalState { Class string State string } {Class State} ral relvar association __Arch_R7\ __Arch_TerminalState {Class State} *\ __Arch_State {Class State} 1 ral relvar create __Arch_PolymorphicEvent { Class string Event string } {Class Event} } namespace eval $domns namespace path ::rosea::InstCmds set domops [relation semijoin $domain $DomainOperation -using {Name Domain}] relation foreach domop $domops { relation assign $domop\ {Name name} {Parameters parameters} {Body body} proc ${domns}::$name $parameters [list ::ral relvar eval $body] ; # <1> } namespace eval $domns [list\ namespace export {*}[relation list $domops Name]\ ] namespace eval $domns namespace ensemble create set statemodels [relation semijoin $domain $StateModel\ -using {Name Domain}] relvar eval { relvar set ${domns}::__Arch_InitialState [pipe { relation project $statemodels Model InitialState | relation rename ~ Model Class InitialState State }] set states [relation semijoin $domain $StatePlace -using {Name Domain}] relvar set ${domns}::__Arch_State [pipe { relation project $states Model Name | relation rename ~ Model Class Name State }] relvar set ${domns}::__Arch_TerminalState [pipe { relation semijoin $domain $State -using {Name Domain} | relation restrict ~ termtuple {[tuple extract $termtuple IsFinal]} | relation project ~ Model Name | relation rename ~ Model Class Name State }] set events [relation semijoin $domain $EffectiveEvent\ -using {Name Domain}] relvar set ${domns}::__Arch_Event [pipe { relation project $events Model Event | relation rename ~ Model Class }] set alltrans [pipe { relation join $states $events | relation rename ~ Name State }] ; # <1> set statetrans [relation semijoin $domain $StateTransition\ -using {Name Domain}] set nontrans [pipe { relation semijoin $domain $NonStateTransition -using {Name Domain} | relation rename ~ TransRule NewState }] set deftrans [pipe { relation minus $alltrans $TransitionPlace | relation join ~ $StateModel | relation eliminate ~ InitialState | relation rename ~ DefaultTrans NewState | relation update ~ dttup {[tuple extract $dttup State] eq "@"} { tuple update $dttup NewState CH} }] relvar set ${domns}::__Arch_Transition [pipe { relation union $statetrans $nontrans $deftrans | relation eliminate ~ Domain | relation rename ~ Model Class }] relvar set ${domns}::__Arch_PolymorphicEvent [pipe { relation semijoin $domain $DeferredEvent\ -using {Name Domain} | relation project ~ Model Event | relation rename ~ Model Class }] } variable headingQuery variable idQuery variable defaultValuesQuery variable suppliedValuesQuery variable generatedValuesQuery variable checkValuesQuery variable hasSMQuery variable statesQuery set classes [relation semijoin $domain $DomainElement -using {Name Domain}\ $Class -using {Domain Domain Element Name}] relation foreach class $classes { set className ${domns}::[relation extract $class Name] namespace eval $className { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe } namespace eval $className [list namespace path\ [list ::rosea::InstCmds $domns]] set heading [eval $headingQuery] set idset [list] relation foreach id [eval $idQuery] -ascending Number { lappend idset [relation list\ [relation extract $id Attributes] Attribute] } relvar create $className $heading {*}$idset # <1> set checkvalues [eval $checkValuesQuery] if {[relation isnotempty $checkvalues]} { relvar trace add variable $className {insert update set} [list\ ::rosea::Helpers::CheckValueTrace\ [relation dict $checkvalues Name Expression]\ ] } set defaultvalues [eval $defaultValuesQuery] if {[relation isnotempty $defaultvalues]} { relvar trace add variable $className insert [list\ ::rosea::Helpers::UserDefaultTrace\ [relation dict $defaultvalues Name Type]\ [relation dict $defaultvalues Name Value]\ ] } set supplied [eval $suppliedValuesQuery] if {[relation isnotempty $supplied]} { pipe { relation extend $supplied stup ClassName string { [string cat [tuple extract $stup Class] , [tuple extract $stup Name]] } | relation array ~ ${domns}::__Arch_SuppliedDefault ClassName StartValue } ; # <1> relvar trace add variable $className insert [list\ ::rosea::Helpers::SupplyDefaultTrace\ [relation dict $supplied Name Type]\ ] } set generatecmds [eval $generatedValuesQuery] if {[relation isnotempty $generatecmds]} { relvar trace add variable $className insert [list\ ::rosea::Helpers::GenerateDefaultTrace\ [relation dict $generatecmds Name Type]\ [relation dict $generatecmds Name Cmd]\ ] } set hasStateModel [eval $hasSMQuery] if {$hasStateModel} { set instid [lindex $idset 0] set instheading [list] foreach attr $instid { lappend instheading $attr [dict get $heading $attr] ; # <1> } lappend instheading __State string relvar create ${domns}::[relation extract $class Name]__STATEINST\ $instheading $instid set actns ${className}::__Activity namespace eval $actns { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe } namespace eval $actns [list\ namespace path [list\ ::rosea::InstCmds\ $className\ $domns\ ]\ ] relation foreach state [eval $statesQuery] { relation assign $state\ {Name stateName}\ {Parameters params}\ {Action stateAction} proc ${actns}::$stateName [linsert $params 0 self] $stateAction } } set opmap [dict create] set classops [relation semijoin $class $UserClassOperation\ -using {Domain Domain Name Class}] relation foreach classop $classops { relation assign $classop\ {Name opname}\ {Parameters params}\ {Body opbody} proc ${className}::$opname $params $opbody dict set opmap $opname ${className}::$opname } set sysmap [QuerySystemClassOperations $className false] if {$hasStateModel} { set sysmap [dict merge $sysmap [QuerySystemClassOperations $className true]] } namespace ensemble create\ -command $className\ -map [dict merge $opmap $sysmap] set opmap [dict create] set instops [relation semijoin $class $UserInstanceOperation\ -using {Domain Domain Name Class}] relation foreach instop $instops { relation assign $instop\ {Name opname}\ {Parameters params}\ {Body opbody} proc ${className}::$opname [linsert $params 0 self] $opbody dict set opmap $opname ${className}::$opname } set sysmap [QuerySystemInstanceOperations false] set hasPolyEvents [relation isnotempty\ [relation semijoin $class $PolymorphicEvent\ -using {Domain Domain Name Model}]\ ] if {$hasStateModel || $hasPolyEvents} { set sysmap [dict merge $sysmap [QuerySystemInstanceOperations true]] } namespace ensemble create\ -command ${className}::Instance\ -parameters instref\ -map [dict merge $opmap $sysmap] } set rships [relation semijoin $domain $DomainElement -using {Name Domain}\ $Relationship -using {Domain Domain Element Name}] set sassocs [relation semijoin $rships $Association\ $SimpleAssociation] set refing [relation semijoin $sassocs $SimpleReferringClass\ -using {Domain Domain Name Relationship}] set refed [relation semijoin $sassocs $SimpleReferencedClass\ -using {Domain Domain Name Relationship}] variable referencesQuery set references [eval $referencesQuery] relvar eval { set flink [pipe { relation project $references Relationship ReferringClass | relation rename ~ Relationship Name ReferringClass SrcClass }] set blink [pipe { relation project $references Relationship ReferencedClass | relation rename % Relationship Name ReferencedClass SrcClass | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] ; # <1> relvar union ${domns}::__Arch_Link $flink $blink set flink [pipe { relation project $references Relationship ReferringClass\ ReferencedClass ForwAttrs | relation rename ~ Relationship Name ReferringClass SrcClass\ ReferencedClass DstClass ForwAttrs Attrs | relation extend ~ al PrevSrcClass string {{}} }] ; # <1> set blink [pipe { relation project $references Relationship ReferringClass\ ReferencedClass RevAttrs | relation rename % Relationship Name ReferencedClass SrcClass\ ReferringClass DstClass RevAttrs Attrs | relation extend % al PrevSrcClass string {{}} | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] relvar union ${domns}::__Arch_AssociationLink $flink $blink relvar union ${domns}::__Arch_RefLink [relation project $references\ Relationship ReferringClass ReferencedClass ReferringAttrs] } relation foreach reference $references { relation assign $reference\ {Relationship relationship}\ {ReferringClass referringClass}\ {ReferencedClass referencedClass}\ {ReferringCond referringCond}\ {ReferringMult referringMult}\ {Conditionality referencedCond}\ {SrcAttrs srcAttrs}\ {DstAttrs dstAttrs} # Create the relvar constraint. relvar association ${domns}::$relationship\ ${domns}::$referringClass $srcAttrs\ [MapCondMultToConstraint $referringCond $referringMult]\ ${domns}::$referencedClass $dstAttrs\ [MapCondMultToConstraint $referencedCond false] # All simple associations get a link and unlink command in their ensemble. set ensemblemap [dict create\ link [list ::rosea::RelCmds::linkSimple $relationship]\ unlink [list ::rosea::RelCmds::unlinkSimple $relationship]\ ] # Determine if we have any assigners assocated with the relationship. # Single assigners get different commands from multiple assigners. set rpath ${domns}::$relationship set assigner [relation semijoin $reference $SingleAssigner\ -using {Domain Domain Relationship Relationship}] if {[relation isnotempty $assigner]} { dict set ensemblemap signal\ [list ::rosea::RelCmds::signalAssigner $rpath] } else { set assigner [relation semijoin $reference $MultipleAssigner\ -using {Domain Domain Relationship Relationship}] if {[relation isnotempty $assigner]} { dict set ensemblemap signal [list\ ::rosea::RelCmds::signalMultiAssigner $rpath] dict set ensemblemap create [list\ ::rosea::RelCmds::createMultiAssigner $rpath] } } # Create the relationship ensemble command. namespace ensemble create -command $rpath -map $ensemblemap } set cassocs [relation semijoin $rships $Association\ $ClassBasedAssociation] set sourceclass [relation semijoin $cassocs $SourceClass\ -using {Domain Domain Name Relationship}] set targetclass [relation semijoin $cassocs $TargetClass\ -using {Domain Domain Name Relationship}] set bothclass [relation union $sourceclass $targetclass] ; # <1> variable assocrefsQuery set assocrefs [eval $assocrefsQuery] relvar eval { set aforw [pipe { relation project $assocrefs Relationship ReferringClass | relation rename ~ Relationship Name ReferringClass SrcClass }] set arev [relation update $aforw lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]}] set sources [pipe { relation restrict $assocrefs aref { [tuple extract $aref ReferencedRole] eq "source"} | relation eliminate ~ ReferencedRole }] set sforw [pipe { relation project $sources Relationship ReferencedClass | relation rename ~ Relationship Name ReferencedClass SrcClass }] set targets [pipe { relation restrict $assocrefs aref { [tuple extract $aref ReferencedRole] eq "target"} | relation eliminate ~ ReferencedRole }] set trev [pipe { relation project $targets Relationship ReferencedClass | relation rename % Relationship Name ReferencedClass SrcClass | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] relvar union ${domns}::__Arch_Link $aforw $arev $sforw $trev set sforw [pipe { relation project $sources Relationship ReferringClass ReferencedClass\ RevAttrs | relation rename ~ Relationship Name ReferringClass DstClass\ ReferencedClass SrcClass RevAttrs Attrs | relation extend ~ al PrevSrcClass string {{}} }] set trev [pipe { relation project $targets Relationship ReferringClass ReferencedClass\ RevAttrs | relation rename % Relationship Name ReferringClass DstClass\ ReferencedClass SrcClass RevAttrs Attrs | relation extend % al PrevSrcClass string {{}} | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] set onerefs [relation rename $sources ReferencedClass OneClass\ Conditionality OneCond Multiplicity OneMult\ ReferringAttrs OneReferringAttrs SrcAttrs OneSrcAttrs\ DstAttrs OneDstAttrs ForwAttrs OneForwAttrs RevAttrs OneRevAttrs] set otherrefs [relation rename $targets ReferencedClass OtherClass\ Conditionality OtherCond Multiplicity OtherMult ReferringAttrs\ OtherReferringAttrs SrcAttrs OtherSrcAttrs DstAttrs OtherDstAttrs\ ForwAttrs OtherForwAttrs RevAttrs OtherRevAttrs] set bothrefs [relation join $onerefs $otherrefs\ -using {Domain Domain ReferringClass ReferringClass\ Relationship Relationship}] set aforw [pipe { relation project $bothrefs Relationship ReferringClass OtherClass\ OtherForwAttrs OneClass | relation rename ~ Relationship Name ReferringClass SrcClass\ OtherClass DstClass OtherForwAttrs Attrs OneClass PrevSrcClass }] set arev [pipe { relation project $bothrefs Relationship ReferringClass OneClass\ OneForwAttrs OtherClass | relation rename % Relationship Name ReferringClass SrcClass\ OneClass DstClass OneForwAttrs Attrs OtherClass PrevSrcClass | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] relvar union ${domns}::__Arch_AssociationLink $sforw $trev $aforw $arev relvar union ${domns}::__Arch_AssocRef [pipe { relation project $assocrefs Relationship ReferringClass\ ReferencedClass ReferencedRole ReferringAttrs | relation rename ~ ReferringClass AssocClass ReferencedClass Participant\ ReferencedRole Role | relation group ~ References Participant Role ReferringAttrs }] } relation foreach bothref $bothrefs { relation assign $bothref\ {Relationship relationship}\ {ReferringClass associator}\ {OneClass sourceClass}\ {OneCond sourceCond}\ {OneMult sourceMult}\ {OneSrcAttrs sourceAssocAttrs}\ {OneDstAttrs sourceDstAttrs}\ {OtherClass targetClass}\ {OtherCond targetCond}\ {OtherMult targetMult}\ {OtherSrcAttrs targetAssocAttrs}\ {OtherDstAttrs targetDstAttrs} # Create the correlation constraint relvar correlation ${domns}::$relationship ${domns}::$associator\ $sourceAssocAttrs [MapCondMultToConstraint $targetCond $targetMult]\ ${domns}::$sourceClass $sourceDstAttrs\ $targetAssocAttrs [MapCondMultToConstraint $sourceCond $sourceMult]\ ${domns}::$targetClass $targetDstAttrs ; # <1> set ensemblemap [dict create\ link [list ::rosea::RelCmds::linkAssoc $relationship]\ reference [list ::rosea::RelCmds::referenceAssoc $relationship]\ unlink [list ::rosea::RelCmds::unlinkAssoc $relationship]\ ] # Determine if we have any assigners set rpath ${domns}::$relationship set assigner [relation semijoin $bothref $SingleAssigner\ -using {Domain Domain Relationship Relationship}] if {[relation isnotempty $assigner]} { dict set ensemblemap signal\ [list ::rosea::RelCmds::signalAssigner $rpath] } else { set assigner [relation semijoin $bothref $MultipleAssigner\ -using {Domain Domain Relationship Relationship}] if {[relation isnotempty $assigner]} { dict set ensemblemap signal [list\ ::rosea::RelCmds::signalMultiAssigner $rpath] dict set ensemblemap create [list\ ::rosea::RelCmds::createMultiAssigner $rpath] } } namespace ensemble create -command $rpath -map $ensemblemap } variable subrefsQuery set subrefs [eval $subrefsQuery] relvar eval { set sublinks [pipe { relation project $subrefs Relationship ReferringClass | relation rename ~ Relationship Name ReferringClass SrcClass }] set superlinks [pipe { relation project $subrefs Relationship ReferencedClass | relation rename % Relationship Name ReferencedClass SrcClass | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] relvar union ${domns}::__Arch_Link $sublinks $superlinks relvar union ${domns}::__Arch_AssociationLink [pipe { relation project $subrefs Relationship ReferringClass ReferencedClass\ ForwAttrs | relation rename ~ Relationship Name ReferringClass SrcClass\ ReferencedClass DstClass ForwAttrs Attrs | relation extend ~ al PrevSrcClass string {{}} }] relvar union ${domns}::__Arch_PartitionLink $superlinks relvar union ${domns}::__Arch_PartitionDst [pipe { relation project $subrefs Relationship ReferencedClass\ ReferringClass RevAttrs | relation rename % Relationship Name ReferencedClass SrcClass\ ReferringClass DstClass RevAttrs Attrs | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] relvar union ${domns}::__Arch_SuperLink [pipe { relation project $subrefs Relationship ReferencedClass | relation rename ~ ReferencedClass SuperClass }] relvar union ${domns}::__Arch_SubLink [pipe { relation project $subrefs Relationship ReferringClass ReferringAttrs | relation rename ~ ReferringClass SubClass }] } set partrefs [pipe { relation project $subrefs Relationship ReferencedClass DstAttrs\ ReferringClass SrcAttrs | relation extend ~ prs SubAttrMap list {[list\ ${domns}::[tuple extract $prs ReferringClass]\ [tuple extract $prs SrcAttrs]]} | relation eliminate ~ ReferringClass SrcAttrs | relation group ~ SubClassRefs SubAttrMap | relation extend ~ spt SubParts list { [concat {*}[relation list [tuple extract $spt SubClassRefs]]]} | relation eliminate ~ SubClassRefs }] relation foreach partref $partrefs { relation assign $partref\ {Relationship relationship}\ {ReferencedClass superclass}\ {DstAttrs superattrs}\ {SubParts subparts} relvar partition ${domns}::$relationship ${domns}::$superclass\ $superattrs {*}$subparts namespace ensemble create\ -command ${domns}::$relationship\ -map [dict create migrate [list ::rosea::RelCmds::migrate\ $relationship]] } set assigners [relation semijoin $domain $AssignerStateModel\ -using {Name Domain}] relation foreach assigner $assigners { set asgnns\ ${domns}::[relation extract $assigner Relationship]::__Activity namespace eval $asgnns { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe } namespace eval $asgnns [list\ namespace path [list\ ::rosea::InstCmds\ $domns\ ]\ ] set states [pipe { relation semijoin $assigner $State\ -using {Domain Domain Relationship Model} | relation project ~ Name Parameters Action }] relation foreach state $states { relation assign $state\ {Name stateName}\ {Parameters params}\ {Action stateAction} set params [linsert $params 0 self] proc ${asgnns}::$stateName $params $stateAction } } relation foreach sassigner\ [relation semijoin $domain $SingleAssigner\ -using {Name Domain}] { relation assign $sassigner {Relationship relationship} relvar create ${domns}::${relationship}__STATEINST { Id int __State string } Id CreateInInitialState $domns $relationship {Id 0} ; # <1> } relation foreach massigner\ [relation semijoin $domain $MultipleAssigner\ -using {Name Domain}] { relation assign $massigner {Relationship relationship} set assignvar ${domns}::${relationship}__STATEINST set idattrs [pipe { relation semijoin $massigner $Identifier\ $IdentifyingAttribute\ $Attribute -using {Domain Domain Class Class\ Attribute Name} | relation dict ~ Name Type }] relvar create $assignvar\ [concat $idattrs [list __State string]]\ [dict keys $idattrs] } } } proc populate {script} { namespace upvar Config errcount errcount configlineno configlineno set errcount 0 set configlineno 1 ConfigEvaluate ::rosea::Populate $script ; # <1> if {$errcount > 0} { tailcall DeclError CONFIG_ERRORS $errcount } return $errcount } proc populateFromChan {chan} { tailcall populate [::chan read -nonewline $chan] } proc populateFromFile {filename} { set f [::open $filename r] try { populateFromChan $f } finally { ::chan close $f } } proc save {args} { set savecmd ::ral::serializeToFile set asynccmd {} set options $args while {1} { if {[string index [lindex $options 0] 0] eq "-"} { set options [lassign $options option] switch -exact -- $option { -sqlite { set savecmd ::ral::storeToSQLite } -tclral { set savecmd ::ral::serializeToFile } -async { set options [lassign $options asynccmd] } default { tailcall DeclError UNKNOWN_OPTION save $option } } } else { break } } if {[llength $options] == 2} { lassign $options domain file if {[string range $domain 0 1] ne "::"} { # <1> set domrel [relvar restrictone ::rosea::Config::Domain Name $domain] if {[relation isempty $domrel]} { tailcall DeclError UNKNOWN_DOMAIN $domain } set domain [string cat [relation extract $domrel Location]\ :: $domain] } } else { tailcall DeclError SAVE_ARG_ERROR $args } set script "try \{$savecmd $file ${domain}::\\\[A-Za-z0-9\\\]*\}" ; # <2> if {$asynccmd ne {}} { append script " finally \{$asynccmd $domain $file\}" } after idle [list ::apply [list {} $script]] ; # <3> } proc restore {args} { set restorecmd ::ral::mergeFromFile set options $args while {1} { if {[string index [lindex $options 0] 0] eq "-"} { set options [lassign $options option] switch -exact -- $option { -sqlite { set restorecmd ::ral::mergeFromSQLite } -tclral { set restorecmd ::ral::mergeFromFile } default { tailcall DeclError UNKNOWN_OPTION restore $option } } } else { break } } if {[llength $options] == 2} { lassign $options domain file if {[string range $domain 0 1] ne "::"} { set domrel [relvar restrictone ::rosea::Config::Domain Name $domain] if {[relation isempty $domrel]} { tailcall DeclError UNKNOWN_DOMAIN $domain } set domain [string cat [relation extract $domrel Location]\ :: $domain] } } else { tailcall DeclError RESTORE_ARG_ERROR $args } eval [list $restorecmd $file $domain] # Determine the values for the system supplied defaults. We examine all # the classes that have such attributes and find the maximum value of the # attribute. This can then be placed in the array that is used when new # default values are generated. set domainname [namespace tail $domain] set supplied [pipe { relvar set ::rosea::Config::SystemSuppliedValue | relation restrictwith ~ {$Domain eq $domainname} }] relation foreach sup $supplied { relation assign $sup set classtups [relvar set ${domain}::$Class] if {[relation isempty $classtups]} { set maxvalue $StartValue } else { set maxvalue [pipe { relation summarizeby $classtups {} cv\ MaxValue int {rmax($cv, $Attribute)} | relation extract ~ MaxValue }] } set ${domain}::__Arch_SuppliedDefault($Class,$Attribute)\ [expr {$maxvalue + 1}] } return } proc info {args} { set args [lassign $args subcmd] switch -exact -- $subcmd { domain { Info::domain $args } class { Info::class $args } statemodel { Info::statemodel $args } default { tailcall DeclError UNKNOWN_INFO_CMD $subcmd } } } proc tunnel {instref op args} { relvar eval { set result [[lindex $instref 0]::Instance $instref $op {*}$args] } return $result } proc trace {subcmd args} { switch -exact -- $subcmd { control { tailcall traceControl {*}$args } decode { switch -exact -- [lindex $args 0] { all { tailcall Trace::DecodeAllTraces } class { tailcall Trace::DecodeClassTraces {*}[lrange $args 1 end] } target { tailcall Trace::DecodeTargetTraces {*}[lrange $args 1 end] } default { tailcall DeclError UNKNOWN_TRACE_CMD [lindex $args 0] } } } format { tailcall formatTraces {*}$args } diagram { switch -exact -- [lindex $args 0] { all { tailcall Trace::DiagAllTraces {*}[lrange $args 1 end] } class { tailcall Trace::DiagClassTraces {*}[lrange $args 1 end] } target { tailcall Trace::DiagTargetTraces {*}[lrange $args 1 end] } default { tailcall DeclError UNKNOWN_TRACE_CMD [lindex $args 0] } } } default { tailcall DeclError UNKNOWN_TRACE_CMD $subcmd } } } proc traceControl {op args} { switch -exact -- $op { on { namespace upvar Trace traceState traceState set traceState on } off { namespace upvar Trace traceState traceState set traceState off } status { namespace upvar Trace traceState traceState return $traceState } clear { relvar eval { foreach rvar {Trace Creation Polymorphic Transition} { relvar set Trace::$rvar\ [relation emptyof [relvar set Trace::$rvar]] } } namespace upvar Trace traceNumber traceNumber set traceNumber 0 } logon { namespace upvar Trace traceLogState traceLogState set traceLogState on } logoff { namespace upvar Trace traceLogState traceLogState set traceLogState off } loglevel { namespace upvar Trace traceLogLevel traceLogLevel if {[llength $args] != 0} { set traceLogLevel [lindex $args 0] } return $traceLogLevel } save { if {[llength $args] == 0} { DeclError NO_SAVEFILE } ral storeToSQLite [lindex $args 0] ::rosea::Trace::* } default { DeclError BAD_TRACEOP $op } } } proc formatTraces {tracerecs} { if {[llength $tracerecs] == 0} { return {} } set prevtime [dict get [lindex $tracerecs 0] time] foreach rec $tracerecs { dict with rec { append result "[Trace::FormatTimestamp $time]: " append result "[Trace::FormatTimeAsSec\ [expr {$time - $prevtime}]]: " set prevtime $time append result [Trace::FormatTraceRec $rec] \n } } return [string trimright $result] } namespace eval Helpers { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar variable errFormats set errFormats [dict create {*}{ SAME_CLASS {operation is only allowed for references to the same class,\ got "%s" and "%s"} UNKNOWN_STATE {unknown state, "%s", for class, "%s"} UNKNOWN_EVENT {unknown event, "%s", for class, "%s"} NO_CREATION_EVENTS {class, "%s", has no defined creation events} NO_CROSS_DOMAIN {cannot link instances across domains,\ got "%s" and "%s"} UNKNOWN_RELATIONSHIP {unknown relationship, "%s"} NON_PARTICIPANTS {"%s" and "%s" don't participate in %s,\ expected "%s" and "%s"} MUST_BE_SINGULAR {number of referred to instances for "%s" must be one,\ got %d} NOT_IN_ASSOCIATION {"%s" $relvar1 not a participant in "%s"} DIRECTION_REQUIRED {direction argument is required: got "%s"} AMBIGUOUS_UNLINK {"%s" is reflexive and linking via "%s" is ambiguous} NO_SUBCLASS {relationship "%s" does not have a "%s"} NO_ASSIGNER {relationship, "%s", does not have an assigner} NO_IDENTIFIER {bad identifying attributes, expected "%s", got "%s"} UNKNOWN_ASSIGNER {unknown assigner instance, "%s", for relationship, "%s"} UNKNOWN_LINKAGE {unknown relationship, "%s", for class, "%s"} PATH_ERROR {relationship, "%s", from "%s" to "%s", does not end at "%s"} GEN_PATH_ERROR {navigating from superclass, "%s", along generalization "%s",\ does not have "%s" as a subclass} ARG_ERROR {attribute updates must be name / value pairs, got "%s"} ID_UPDATE {cannot update identifying attributes, "%s"} UNKNOWN_ATTRIBUTE {unknown attribute, "%s"} WITH_ATTR_USAGE {wrong arguments, should be,\ "withAttribute attrvarpair1 ?attrvarpair2 ...? body"} ATTR_VAR_SPEC {attribute / variable argument must be a one or two element\ list, got "%s"} INVALID_TIME {invalid time value, "%s"} SINGLE_OR_EMPTY_REF_REQUIRED {single valued or nil reference required, %d found} SINGLE_REF_REQUIRED {single valued reference required, %d found} ASYNC_CREATION_FAILED {asynchronous creation of an instance of class, "%s",\ with attributes, "%s", failed: %s} EVENT_IN_FLIGHT {event, "%s", sent to "%s", which does not exist} CANT_HAPPEN_EVENT {can't happen transition, %s - %s -> %s ==> %s -> CH} CONFIG_ERRORS {encountered %d configuration script errors} EMPTY_NAME {the empty string is not a valid name for a %s} BAD_CLASS_NAME {class names must be begin with an alphanumeric\ character, got: "%s"} DUP_ELEMENT_NAME {a class, relationship or domain operation named, "%s",\ already exists} RESERVED_NAME {names beginning with two underscore characters are reserved,\ "%s" cannot be used as a name in this context} INT_TYPE_REQUIRED {attribute must be of "int" type, got "%s"} INT_VALUE_REQUIRED {an integer value is required, got "%s"} ARG_FORMAT {options and values must come in pairs, got "%s"} UNKNOWN_OPTION {unknown %s command option, "%s"} DUP_OP_NAME {operation call, "%s", already exists} NS_QUALIFIERS {name, "%s", contains namespace qualifiers} TILDE_NAME {names beginning with the tilde character are not allowed\ in this context, "%s"} BAD_RELATIONSHIP_SPEC {bad relationship specifier, "%s"} NEED_ASSOCIATOR {relationship of type, "%s", requires associative class} NEED_REFLEXIVE_PATH {traversal path must be specified for reflexive\ association, %s, %s %s %s} REFLEXIVE_NOT_ALLOWED {associations of type, "%s", cannot be reflexive} TOO_FEW_SUBCLASSES {at least 2 subclasses must be specified, got %d} BAD_CREATION_TARGET {the target of a creation event must be a state,\ got "%s"} PSEUDO_STATE {the transition action, "%s", is not valid as %s} EXPECTED_PSEUDO_STATE {expected CH or IG, got "%s"} RELVAR_TRACE_OP {unexpected relvar trace operation, "%s"} ATTR_CHECK_FAILED {check for attribute, "%s", failed:\ instance value was, "%s": "%s" evaluated to "%s"} UNKNOWN_DOMAIN {unknown domain, "%s"} ARG_MISMATCH {number of population values must be a multiple of %d, got %d} SAVE_ARG_ERROR {wrong number of arguments: expected:\ "save ?-sqlite | -tclral? ?-async <cmdprefix>?\ <domain> <filename>", got: "%s"} RESTORE_ARG_ERROR {wrong number of arguments: expected:\ "restore ?-sqlite | -tclral? <domain> <filename>", got: "%s"} UNKNOWN_INFO_CMD {unknown info request, "%s"} UNKNOWN_CLASS {unknown class, "%s", in domain, "%s"} UNKNOWN_TRACE_CMD {unknown trace subcomand, "%s"} BAD_TRACEOP {unknown trace operation, "%s"} NO_SAVEFILE {no save file name provided} BAD_TRACETYPE {unknown trace type, "%s"} }] proc ToRef {relvar relvalue} { tailcall list $relvar [relation project $relvalue\ {*}[lindex [relvar identifiers $relvar] 0]] ; # <1> } proc nilInstRef {} { return {{} {{} {}}} } proc CreateStateInstance {domns class state idattrs} { tailcall relvar insert ${domns}::${class}__STATEINST\ [concat $idattrs [list __State $state]] } proc CreateInInitialState {domns class idattrs} { set initstate [relvar restrictone ${domns}::__Arch_InitialState\ Class $class] if {[relation isnotempty $initstate]} { CreateStateInstance $domns $class [relation extract $initstate State]\ $idattrs } return } proc CreateStateInstanceFromRef {domns class state ref} { relation foreach inst [lindex $ref 1] { # <1> CreateStateInstance $domns $class $state\ [tuple get [relation tuple $inst]] } return } proc CreateInInitialStateFromRef {domns class ref} { set initstate [relvar restrictone ${domns}::__Arch_InitialState\ Class $class] if {[relation isnotempty $initstate]} { CreateStateInstanceFromRef $domns $class\ [relation extract $initstate State] $ref } return } proc SelfInstRef {{level 2}} { set foundRef false set ref [nilInstRef] for {set ns [uplevel $level namespace current]} {$ns ne "::"}\ {set ns [uplevel [incr level] namespace current]} { if {!$foundRef} { upvar $level self srcself if {[info exists srcself]} { set ref $srcself set foundRef true } } if {[string match {*__Activity*} $ns]} { return $ref ; # <1> } } return [nilInstRef] } namespace export DeclError proc DeclError {errcode args} { variable errFormats set errmsg [format [dict get $errFormats $errcode] {*}$args] tailcall throw [list ROSEA $errcode {*}$args $errmsg] $errmsg } proc SplitRelvarName {relvar {dvarname domain} {cvarname class}} { upvar 1 $dvarname domain $cvarname class set domain [namespace qualifiers $relvar] set class [namespace tail $relvar] } proc PropagatePolyEvents {super} { namespace upvar ::rosea::Config\ DeferredEvent DeferredEvent\ LocalEvent LocalEvent\ Superclass Superclass\ Subclass Subclass\ DeferralPath DeferralPath\ Generalization Generalization ; # <1> set supername [relation extract $super Class] set subs [pipe { relation semijoin $super\ $Generalization -using {Domain Domain Relationship Name}\ $Subclass -using {Domain Domain Name Relationship} }] relation foreach sub $subs { set defrdevents [pipe { relation semijoin $super $DeferralPath\ -using {Domain Domain Class Model Relationship Relationship}\ $DeferredEvent | relation update ~ deftup {1} { tuple update $deftup Model [relation extract $sub Class] } }] set multigens [relation semijoin $sub $Superclass\ -using {Domain Domain Class Class}] if {[relation isempty $multigens]} { relvar minus ::rosea::Config::LocalEvent $defrdevents relvar union ::rosea::Config::Event $defrdevents relvar union ::rosea::Config::EffectiveEvent $defrdevents relvar union ::rosea::Config::MappedEvent [relation extend\ $defrdevents metuple ParentModel string {$supername}] } else { set consumed [relation semijoin $defrdevents $LocalEvent] if {[relation isnotempty $consumed]} { relvar minus ::rosea::Config::LocalEvent $consumed ; # <1> relvar union ::rosea::Config::MappedEvent [relation extend\ $consumed ctup ParentModel string {$supername}] relvar union ::rosea::Config::NonLocalEvent [relation extend\ $consumed nletuple\ Relationship string {[relation extract $sub Relationship]}\ Role string {[relation extract $sub Role]}] set defrdevents [relation minus $defrdevents $consumed] ; # <2> set usedinsubs [pipe { FindSubclassesOf $multigens| relation tclose ~ | relation semijoin $consumed ~ -using {Model Super} | relation semijoin ~ $LocalEvent -using {Sub Model} | relation semijoin $consumed ~ -using {Domain Domain Event Event} }] relvar minus ::rosea::Config::LocalEvent $usedinsubs ; # <3> relvar minus ::rosea::Config::EffectiveEvent $usedinsubs relvar minus ::rosea::Config::Event $usedinsubs } relvar union ::rosea::Config::Event $defrdevents relvar union ::rosea::Config::DeferredEvent $defrdevents relvar union ::rosea::Config::InheritedEvent $defrdevents relvar union ::rosea::Config::DeferralPath [relation join\ $defrdevents $Superclass -using {Domain Domain Model Class}] } relvar union ::rosea::Config::NonLocalEvent [relation extend\ $defrdevents nletuple\ Relationship string {[relation extract $sub Relationship]}\ Role string {[relation extract $sub Role]}] relation foreach multigen $multigens { PropagatePolyEvents $multigen } } } proc FindSubclassesOf {supers} { namespace upvar ::rosea::Config\ Generalization Generalization\ Superclass Superclass\ Subclass Subclass if {[relation isempty $supers]} {# <1> return [relation create {Super string Sub string}] } set supnames [pipe { relation project $supers Class | relation rename ~ Class Super }] ; # <2> set subclasses [relation semijoin $supers\ $Generalization -using {Domain Domain Relationship Name}\ $Subclass -using {Domain Domain Name Relationship}] set subnames [pipe { relation project $subclasses Class | relation rename ~ Class Sub }] ; # <3> set uses [relation times $supnames $subnames] ; # <4> set nextsupers [relation semijoin $subclasses $Superclass\ -using {Domain Domain Class Class}] ; # <5> return [relation union $uses [FindSubclassesOf $nextsupers]] ; # <6> } proc UserDefaultTrace {defheading defvalues op relvar tuple} { tuple create\ [dict merge $defheading [tuple heading $tuple]]\ [dict merge $defvalues [tuple get $tuple]] } proc SupplyDefaultTrace {defheading op relvar tuple} { set attrs [tuple attributes $tuple] ; # <1> SplitRelvarName $relvar domain class ; # <2> foreach {attrname attrtype} $defheading { if {$attrname ni $attrs} { set value [set ${domain}::__Arch_SuppliedDefault($class,$attrname)] ; # <3> incr ${domain}::__Arch_SuppliedDefault($class,$attrname) set tuple [tuple extend $tuple $attrname $attrtype $value] ; # <4> } } return $tuple } proc GenerateDefaultTrace {defheading defcmds op relvar tuple} { set attrs [tuple attributes $tuple] foreach {attrname attrtype} $defheading { if {$attrname ni $attrs} { set value [eval [dict get $defcmds $attrname]] set tuple [tuple extend $tuple $attrname $attrtype $value] } } return $tuple } proc CheckValueTrace {attrchecks op relvar args} { if {$op eq "insert"} { set tuple [lindex $args 0] EvalAttrCheck $attrchecks $tuple return $tuple } elseif {$op eq "update"} { set tuple [lindex $args 1] EvalAttrCheck $attrchecks $tuple return $tuple } elseif {$op eq "set"} { set relvalue [lindex $args 0] relation foreach inst $relvalue { set tuple [relation tuple $inst] EvalAttrCheck $attrchecks $tuple } return $relvalue } else { tailcall DeclError RELVAR_TRACE_OP $op } } proc EvalAttrCheck {attrchecks tuple} { dict for {attrname checkexpr} $attrchecks { tuple assign $tuple set result [expr $checkexpr] if {!$result} { tailcall DeclError ATTR_CHECK_FAILED $attrname [tuple get $tuple]\ $checkexpr $result } } } proc QuerySystemOperations {which requiresSM} { return [pipe { relvar set ::rosea::Config::SuppliedOperation | relation restrictwith ~ {$RequiresStateModel == $requiresSM} | relation join [relvar set ::rosea::Config::$which] ~ }] } proc QuerySystemClassOperations {className requiresSM} { return [pipe { QuerySystemOperations SystemClassOperation $requiresSM | relation update ~ sco 1 { tuple update $sco Command\ [concat [tuple extract $sco Command]\ [list $className]] } | relation dict ~ Name Command }] } proc QuerySystemInstanceOperations {requiresSM} { return [pipe { QuerySystemOperations SystemInstanceOperation $requiresSM | relation dict ~ Name Command }] } proc Interleave {l1 l2} { set result [list] foreach a $l1 b $l2 { lappend result $a $b } return $result } proc MapCondMultToConstraint {cond mult} { if {$cond} { return [expr {$mult ? "*" : "?"}] } else { return [expr {$mult ? "+" : "1"}] } } } namespace eval ClassCmds { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path [namespace parent]::Helpers ; # <1> proc findAll {relvar} { tailcall ToRef $relvar [relvar set $relvar] } proc findById {relvar args} { tailcall ToRef $relvar [relvar restrictone $relvar {*}$args] } proc findWhere {relvar expr} { tailcall ToRef $relvar [uplevel 1 [list ::ral relation restrictwith\ [relvar set $relvar] $expr]] } proc create {relvar args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } set ref [ToRef $relvar [relvar insert $relvar $args]] ; # <1> SplitRelvarName $relvar domain class CreateInInitialStateFromRef $domain $class $ref return $ref } proc createin {relvar state args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } SplitRelvarName $relvar domain class set initstate [relvar restrictone ${domain}::__Arch_State\ Class $class State $state] if {[relation isempty $initstate]} { # <1> tailcall DeclError UNKNOWN_STATE $state $relvar } set ref [ToRef $relvar [relvar insert $relvar $args]] CreateStateInstanceFromRef $domain $class $state $ref return $ref } proc createasync {relvar event eventparams args} { SplitRelvarName $relvar domain class if {[relation isempty [relvar restrictone ${domain}::__Arch_Event\ Class $class Event $event]]} { tailcall DeclError UNKNOWN_EVENT $event $class } if {[relation isempty [relvar restrictone ${domain}::__Arch_State\ Class $class State @]]} { tailcall DeclError NO_CREATION_EVENTS $class } set srcref [SelfInstRef] set eventInfo [dict create\ type creation\ src $srcref\ dstClass $relvar\ dstAttrs $args\ event $event\ params $eventparams\ ] if {[::rosea::InstCmds::isRefEqual $srcref [nilInstRef]]} { lappend ::rosea::Dispatch::toc_queue $eventInfo } else { lappend ::rosea::Dispatch::event_queue $eventInfo } ::after 0 ::rosea::Dispatch::DispatchEvent return } proc update {relvar relvalue} { tailcall ToRef $relvar [relvar updateper $relvar $relvalue] } } namespace eval InstCmds { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace path [namespace parent]::Helpers pipe { relvar set ${domain}::$DstClass | relation $op $related ~ -using $Attrs } relatedQuery proc deRef {instref args} { lassign $instref relvar ref set inst [relation semijoin $ref [relvar set $relvar]] ; # <1> if {[llength $args] != 0} { set inst [relation project $inst\ {*}[relation attributes $ref] {*}$args] ; # <2> } return $inst } proc isEmptyRef {instref} { tailcall relation isempty [lindex $instref 1] } proc isNotEmptyRef {instref} { tailcall relation isnotempty [lindex $instref 1] } proc refMultiplicity {instref} { tailcall relation cardinality [lindex $instref 1] } proc isRefSingular {instref} { expr {[refMultiplicity $instref] == 1} } proc limitRef {instref {count 1}} { lassign $instref relvar insts return [pipe { relation tag $insts __Tag | relation restrictwith ~ {$__Tag >= 0 && $__Tag < $count} | ToRef $relvar ~ }] } proc isRefEqual {instref1 instref2} { lassign $instref1 relvar1 inst1 lassign $instref2 relvar2 inst2 return [expr {$relvar1 eq $relvar2 && [relation is $inst1 equal $inst2]}] } proc RefSetCommand {op instref1 instref2} { lassign $instref1 relvar1 inst1 lassign $instref2 relvar2 inst2 if {$relvar1 ne $relvar2} { tailcall DeclError SAME_CLASS $relvar1 $relvar2 } return [list $relvar1 [relation $op $inst1 $inst2]] } proc refUnion {instref1 instref2} { tailcall RefSetCommand union $instref1 $instref2 } proc refIntersect {instref1 instref2} { tailcall RefSetCommand intersect $instref1 $instref2 } proc refMinus {instref1 instref2} { tailcall RefSetCommand minus $instref1 $instref2 } proc forAllRefs {varname instref body} { lassign $instref relvar refs upvar 1 $varname inst relation foreach ref $refs { set inst [list $relvar $ref] uplevel 1 $body } ; # <1> return } proc FindRelatedInsts {instref op args} { set srcrelvar [lindex $instref 0] SplitRelvarName $srcrelvar domain class # This procedure queries the architectural data about relationship linkage, # so we bring the relvar variables into scope. namespace upvar ${domain}\ __Arch_Link Link\ __Arch_AssociationLink AssociationLink\ __Arch_PartitionLink PartitionLink\ __Arch_PartitionDst PartitionDst variable relatedQuery ; # <1> # We start by dereferencing the instance reference. set related [deRef $instref] foreach linkage $args { lassign $linkage lname dst ; # split out the linkage spec set link [relvar restrictone ${domain}::__Arch_Link\ Name $lname SrcClass $class] if {[ral relation isempty $link]} { tailcall DeclError UNKNOWN_LINKAGE $lname $class } # First we determine if we are dealing with an associative link or a # partition link. set assoc [relation join $link $AssociationLink] if {[relation isnotempty $assoc]} { relation assign $assoc DstClass Attrs # Check if additional path information was provided. if {$dst eq {}} { # Find the set of instances related to the current set. set related [eval $relatedQuery] # We must see if this is a class-based association. If so, then the first # traversal was to the associator and we must traverse again to the other # class. set assoc [relation semijoin $assoc $AssociationLink\ -using {Name Name SrcClass PrevSrcClass}] if {[relation isnotempty $assoc]} { relation assign $assoc DstClass Attrs set related [pipe {# <1> relvar set ${domain}::$DstClass | relation semijoin $related ~ -using $Attrs }] } } else { # If a destination was specified in the linkage, then we need to verify # that it is actually part of the relationship. if {$dst ne $DstClass} { tailcall DeclError PATH_ERROR $lname $class $DstClass\ $dst } set related [eval $relatedQuery] } } else { set partdst [relvar restrictone ${domain}::__Arch_PartitionDst\ Name $lname SrcClass $class DstClass $dst] if {[relation isempty $partdst]} { tailcall DeclError GEN_PATH_ERROR $class $lname $dst } relation assign $partdst DstClass Attrs set related [eval $relatedQuery] } # Continue the iteration by setting the next source to the current # destination class. set class $DstClass set srcrelvar ${domain}::$class } # N.B. that we are not returning an instance reference but rather the # complete relation value of the related instances. This allows us # to further filter the result in the "findRelatedWhere" command. return [list $srcrelvar $related] } proc findRelated {instref args} { tailcall ToRef {*}[FindRelatedInsts $instref semijoin {*}$args] ; # <1> } proc findUnrelated {instref args} { tailcall ToRef {*}[FindRelatedInsts $instref semiminus {*}$args] ; # <1> } proc findRelatedWhere {instref rchain expr} { lassign [FindRelatedInsts $instref semijoin {*}$rchain] relvar insts tailcall ToRef $relvar [uplevel 1\ [list ::ral relation restrictwith $insts $expr]] ; # <1> } proc findUnrelatedWhere {instref rchain expr} { lassign [FindRelatedInsts $instref semiminus {*}$rchain] relvar insts tailcall ToRef $relvar [uplevel 1\ [list ::ral relation restrictwith $insts $expr]] } proc idInstance {instref} { lassign $instref relvar insts SplitRelvarName $relvar domain relationship set assignrelvar ${domain}::${relationship}__STATEINST if {![relvar exists $assignrelvar]} { tailcall DeclError NO_ASSIGNER $rname } set idclass [pipe { relvar restrictone [namespace parent]::Config::MultipleAssigner\ Domain [string trim $domain :] Relationship $relationship | relation extract ~ Class }] return [pipe { relvar set ${domain}::$idclass | relation semijoin $insts ~ | ToRef ${domain}::$idclass ~ }] } proc updateAttribute {instref args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_ERROR $args } lassign $instref relvar insts if {[relation cardinality $insts] != 1} { tailcall MUST_BE_SINGULAR $relvar [relation cardinality $insts] } set idattrs [list] foreach identifier [relvar identifiers $relvar] { ::struct::set add idattrs $identifier } set idupdates [::struct::set intersect $idattrs $args] if {![::struct::set empty $idupdates]} { tailcall DeclError ID_UPDATE [join $idupdates {, }] } set extcmd [list relation extend $insts exttuple] set heading [relation heading [relvar set $relvar]] foreach {attr value} $args { if {![dict exists $heading $attr]} { tailcall DeclError UNKNOWN_ATTRIBUTE $attr } lappend extcmd $attr [dict get $heading $attr] \{$value\} } relvar updateper $relvar [eval $extcmd] return } proc withAttribute {instref args} { if {[llength $args] < 2} { tailcall DeclError WITH_ATTR_USAGE } lassign $instref relvar insts if {[relation cardinality $insts] != 1} { tailcall MUST_BE_SINGULAR $relvar [relation cardinality $insts] } set body [lindex $args end] set attrspecs [lrange $args 0 end-1] set attrnames [list] set varnames [list] foreach attrspec $attrspecs { set speclen [llength $attrspec] if {$speclen == 1} { lappend attrnames [lindex $attrspec 0] lappend varnames [lindex $attrspec 0] } elseif {$speclen == 2} { lappend attrnames [lindex $attrspec 0] lappend varnames [lindex $attrspec 1] } else { tailcall DeclError ATTR_VAR_SPEC $attrspec } } set idattrs [list] foreach identifier [relvar identifiers $relvar] { ::struct::set add idattrs $identifier } set idupdates [::struct::set intersect $idattrs $attrnames] if {![::struct::set empty $idupdates]} { tailcall DeclError ID_UPDATE [join $idupdates {, }] } uplevel 1 [list ral relation assign [deRef $instref] {*}$attrspecs] uplevel 1 $body set extcmd [list relation extend $insts exttuple] set heading [relation heading [relvar set $relvar]] foreach attr $attrnames var $varnames { if {[uplevel 1 [list info exists $var]]} { upvar 1 $var varvalue lappend extcmd $attr [dict get $heading $attr] \{$varvalue\} } } relvar updateper $relvar [eval $extcmd] return } proc readAttribute {ref args} { # We insist upon a singular reference for reading attributes. Multiple # references can be handled by dereferences and using TclRAL "relation" # commands. if {![isRefSingular $ref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $ref] } return [expr {[llength $args] == 0 ? {} :\ [relation extract [deRef $ref {*}$args] {*}$args]}] ; # <1> } proc assignAttribute {ref args} { # We must insist upon a singular references, since assigning to scalar # variables from a relation value doesn't make a lot of sense. if {![isRefSingular $ref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $ref] } uplevel 1 [list ral relation assign [deRef $ref] {*}$args] ; # <1> return } proc delete {args} { foreach instref $args { lassign $instref relvar insts relvar minus $relvar [deRef $instref] SplitRelvarName $relvar domain class set instrelvar ${domain}::${class}__STATEINST if {[relvar exists $instrelvar]} { relvar minus $instrelvar [relation semijoin $insts\ [relvar set $instrelvar]] } } return } proc signal {dstset event args} { set srcref [SelfInstRef] if {![::rosea::Dispatch::MapPolymorphicEvent ::rosea::Dispatch::SignalEvent\ $srcref $dstset $event $args]} { ::rosea::Dispatch::SignalEvent $srcref $dstset $event $args } return } proc delaysignal {time dstset event args} { if {!([string is integer -strict $time] && $time >= 0)} { tailcall DeclError INVALID_TIME $time } set srcref [SelfInstRef] if {![::rosea::Dispatch::MapPolymorphicEvent\ [list ::rosea::Dispatch::SignalDelayedEvent $time]\ $srcref $dstset $event $args]} { ::rosea::Dispatch::SignalDelayedEvent $time $srcref $dstset $event $args } return } proc canceldelayed {srcref dstset event} { set srcmult [refMultiplicity $srcref] if {$srcmult > 1} { tailcall DeclError SINGLE_OR_EMPTY_REF_REQUIRED $srcmult } forAllRefs dstref $dstset { ::rosea::Dispatch::CancelDelayedSignal $srcref $event $dstref } return } proc delayremaining {srcref dstref event} { set srcmult [refMultiplicity $srcref] if {$srcmult > 1} { tailcall DeclError SINGLE_OR_EMPTY_REF_REQUIRED $srcmult } if {![isRefSingular $dstref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $dstref] } tailcall ::rosea::Dispatch::SignalTimeRemaining $srcref $event $dstref } proc instop {instref op args} { tailcall [lindex $instref 0]::Instance $instref $op {*}$args } } namespace eval RelCmds { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path [list\ [namespace parent]::Helpers\ [namespace parent]::InstCmds\ ] proc linkSimple {rname instref1 instref2} { lassign $instref1 relvar1 inst1 SplitRelvarName $relvar1 domain1 class1 lassign $instref2 relvar2 inst2 SplitRelvarName $relvar2 domain2 class2 if {$domain1 ne $domain2} { tailcall DeclError NO_CROSS_DOMAIN $domain1 $domain2 } set reflink [relvar restrictone ${domain1}::__Arch_RefLink Relationship $rname] if {[relation isempty $reflink]} { tailcall DeclError UNKNOWN_RELATIONSHIP $rname } relation assign $reflink\ {ReferringClass referringClass}\ {ReferencedClass referencedClass}\ {ReferringAttrs referringAttrs} ; # <1> if {$class1 eq $referringClass && $class2 eq $referencedClass} { set fromrelvar $relvar1 set frominsts $inst1 set torelvar $relvar2 set toinst $inst2 } elseif {$class2 eq $referringClass && $class1 eq $referencedClass} { set fromrelvar $relvar2 set frominsts $inst2 set torelvar $relvar1 set toinst $inst1 } else { tailcall DeclError NON_PARTICIPANTS $relvar1 $relvar2 $rname\ $referringClass $referencedClass } if {[relation cardinality $toinst] != 1} { tailcall MUST_BE_SINGULAR $torelvar [relation cardinality $toinst] } set refedvalue [relation semijoin $toinst [relvar set $torelvar]] set tovalues [pipe { relation extend $referringAttrs rfa RefValue string { [relation extract $refedvalue\ [tuple extract $rfa ReferencedAttribute]]} | relation dict ~ ReferringAttribute RefValue }] relation foreach frominst $frominsts { relvar updateone $fromrelvar fromtup\ [tuple get [relation tuple $frominst]] { # <1> tuple update $fromtup {*}$tovalues ; # <2> } } return } proc linkAssoc {rname instref1 instref2 args} { lassign $instref1 relvar1 inst1 SplitRelvarName $relvar1 domain1 class1 lassign $instref2 relvar2 inst2 SplitRelvarName $relvar2 domain2 class2 if {$domain1 ne $domain2} { tailcall DeclError NO_CROSS_DOMAIN $domain1 $domain2 } set assocref [relvar restrictone ${domain1}::__Arch_AssocRef\ Relationship $rname] if {[relation isempty $assocref]} { tailcall DeclError UNKNOWN_RELATIONSHIP $rname } relation assign $assocref\ {AssocClass assocClass}\ {References references} set ref1 [relation restrictwith $references {$Participant eq $class1}] if {[relation isempty $ref1]} { tailcall DeclError NOT_IN_ASSOCIATION $class1 $rname } if {[relation cardinality $ref1] > 1} { set ref2 [relation restrictwith $ref1 {$Role eq "target"}] set ref1 [relation minus $ref1 $ref2] ; # <1> } else { set ref2 [relation restrictwith $references {$Participant eq $class2}] if {[relation isempty $ref2]} { tailcall DeclError NOT_IN_ASSOCIATION $class2 $rname } } set rattr1 [relation extract $ref1 ReferringAttrs] set rattr2 [relation extract $ref2 ReferringAttrs] set values1 [relation semijoin $inst1 [relvar set $relvar1]] set values2 [relation semijoin $inst2 [relvar set $relvar2]] set assoctuples [list] relation foreach v1 $values1 { # <1> set refto1 [pipe { relation extend $rattr1 rfa RefValue string { [relation extract $v1 [tuple extract $rfa ReferencedAttribute]] } | relation dict ~ ReferringAttribute RefValue }] relation foreach v2 $values2 { set refto2 [pipe { relation extend $rattr2 rfa RefValue string { [relation extract $v2\ [tuple extract $rfa ReferencedAttribute]] } | relation dict ~ ReferringAttribute RefValue }] lappend assoctuples [dict merge $args $refto1 $refto2] ; # <2> } } set ref [ToRef ${domain1}::$assocClass\ [relvar insert ${domain1}::$assocClass {*}$assoctuples]] CreateInInitialStateFromRef $domain1 $assocClass $ref ; # <1> return $ref } proc referenceAssoc {rname assocref instref {dir {}}} { if {![isRefSingular $assocref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $assocref] } lassign $assocref assocrelvar associnst SplitRelvarName $assocrelvar assocdomain assocclass if {![isRefSingular $instref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $instref] } lassign $instref instrelvar inst SplitRelvarName $instrelvar instdomain instclass if {$assocdomain ne $instdomain} { tailcall DeclError NO_CROSS_DOMAIN $domain1 $domain2 } set assocref [relvar restrictone ${instdomain}::__Arch_AssocRef\ Relationship $rname] if {[relation isempty $assocref]} { tailcall DeclError UNKNOWN_RELATIONSHIP $rname } relation assign $assocref\ {AssocClass assocClass}\ {References references} if {$assocClass ne $assocclass} { tailcall DeclError NOT_IN_ASSOCIATION $assocclass $rname } set ref [relation restrictwith $references {$Participant eq $instclass}] set refcard [relation cardinality $ref] if {$refcard == 2} { switch -exact -- $dir { forward { set role target } backward { set role source } default { tailcall DeclError DIRECTION_REQUIRED $dir } } set ref [relation restrictwith $ref {$Role eq $role}] } elseif {$refcard == 0} { tailcall DeclError NOT_IN_ASSOCIATION $instclass $rname } set referringAttrs [relation extract $ref ReferringAttrs] set refedvalue [relation semijoin $inst [relvar set $instrelvar]] set tovalues [pipe { relation extend $referringAttrs rfa RefValue string { [relation extract $refedvalue\ [tuple extract $rfa ReferencedAttribute]]} | relation dict ~ ReferringAttribute RefValue }] relvar updateone $assocrelvar assoctup [tuple get [relation tuple $associnst]] { tuple update $assoctup {*}$tovalues } } proc unlinkSimple {rname instref} { lassign $instref relvar inst SplitRelvarName $relvar domain class set reflink [relvar restrictone ${domain}::__Arch_RefLink\ Relationship $rname] if {[relation isempty $reflink]} { tailcall DeclError UNKNOWN_RELATIONSHIP $rname } relation assign $reflink\ {ReferringClass referringClass}\ {ReferencedClass referencedClass}\ {ReferringAttrs referringAttrs} if {$class eq $referringClass} { set fromrelvar $relvar set frominsts $inst } elseif {$class eq $referencedClass} { lassign [::rosea::InstCmds::findRelated $instref ~$rname]\ fromrelvar frominsts } else { tailcall DeclError NOT_IN_ASSOCIATION $relvar $rname } set tovalues [pipe { relation extend $referringAttrs rfa RefValue string {{}} | relation dict ~ ReferringAttribute RefValue }] relation foreach frominst $frominsts { relvar updateone $fromrelvar fromtup\ [tuple get [relation tuple $frominst]] { tuple update $fromtup {*}$tovalues } } return } proc unlinkAssoc {rname instref} { lassign $instref relvar insts SplitRelvarName $relvar domain class set assocref [relvar restrictone ${domain}::__Arch_AssocRef\ Relationship $rname] if {[relation isempty $assocref]} { tailcall DeclError UNKNOWN_RELATIONSHIP $rname } relation assign $assocref\ {Relationship relationship}\ {AssocClass associator}\ {References references} # If we are given instances to the associator class, then there is no # more work to do. if {$class ne $associator} { # Otherwise, we have to find the associator class instances ourselves. set part [relation restrictwith $references {$Participant eq $class}] set partcard [relation cardinality $part] if {$partcard == 0} { tailcall DeclError NOT_IN_ASSOCIATION $class $rname } elseif {$partcard > 1} { tailcall DeclError AMBIGUOUS_UNLINK $rname $relvar ; # <1> } else { # Find associative class instances. We have to determine the # direction of the relationship traversal. set navdir [expr {[relation extract $part Role] eq "source" ?\ "$relationship" : "~$relationship"}] set instref [::rosea::InstCmds::findRelated $instref\ [list $navdir [namespace tail $associator]]] lassign $instref relvar insts SplitRelvarName $relvar domain class } } # We are going to delete tuples from the relvar that holds the class # instances. set delrelvars [list ${domain}::$class] # If the associative class also has a state model, then we need to also # delete the state instance tuples. if {[relvar exists ${domain}::${class}__STATEINST]} { lappend delrelvars ${domain}::${class}__STATEINST } # Now, we iterate across the associative class instances and delete all the # tuples in class relvar and, if necessary, the state instances. relation foreach inst $insts { set idattrs [tuple get [relation tuple $inst]] foreach rv $delrelvars { relvar deleteone $rv {*}$idattrs } } return $instref } proc migrate {rname instref subclass args} { if {![isRefSingular $instref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $instref] } lassign $instref relvar inst SplitRelvarName $relvar domns class set link [relvar restrictone ${domns}::__Arch_AssociationLink Name $rname\ SrcClass $class] if {[relation isempty $link]} { tailcall DeclError NO_SUBCLASS $rname $relvar } # Traverse the relationship to the superclass. We need to get the values of # the referenced attributes to use in creating the new subclass instance. set superinst [pipe { relvar set ${domns}::[relation extract $link DstClass] | relation semijoin $inst ~ -using [relation extract $link Attrs] }] set sublink [relvar restrictone ${domns}::__Arch_SubLink\ Relationship $rname SubClass $subclass] if {[relation isempty $sublink]} { tailcall DeclError NO_SUBCLASS $rname $subclass } # Using the same relation extend strategy, we compute a dictionary of the # attribute names / values as they must appear in the subclass we are about # to create. set refedvalues [pipe { relation extract $sublink ReferringAttrs | relation extend ~ rval Value string { [relation extract $superinst\ [tuple extract $rval ReferencedAttribute]] } | relation dict ~ ReferringAttribute Value }] # We use the class commands to delete the old subclass instance and create # the new one. This will make sure that if the subclass has a state model # that the initial state is set correctly. # N.B. this is _not_ done in a relvar transaction. The transaction # boundaries should be set by the current thread of control or domain # operation. ::rosea::InstCmds::delete $instref return [::rosea::ClassCmds::create ${domns}::$subclass\ {*}[dict merge $args $refedvalues]] } proc signalAssigner {rname event args} { SplitRelvarName $rname domain relationship set assignrelvar ${domain}::${relationship}__STATEINST if {![relvar exists $assignrelvar]} { tailcall DeclError NO_ASSIGNER $rname } set dstref [pipe { relvar set $assignrelvar | relation project ~ {*}[lindex [relvar identifiers $assignrelvar] 0] | list $rname ~ }] ::rosea::Dispatch::SignalEvent [SelfInstRef] $dstref $event $args return } proc signalMultiAssigner {rname idvalues event args} { SplitRelvarName $rname domain relationship set assignrelvar ${domain}::${relationship}__STATEINST if {![relvar exists $assignrelvar]} { tailcall DeclError NO_ASSIGNER $rname } set idattrs [lindex [relvar identifiers $assignrelvar] 0] # We will insist that the idvalues contain the necessary identifying # attributes. if {![struct::set equal [dict keys $idvalues] $idattrs]} { tailcall DeclError NO_IDENTIFIER [dict keys $idvalues] $idattrs } set assigninsts [relvar set $assignrelvar] set assignrefs [relation project $assigninsts {*}$idattrs] # We need to find the tuple in "assignrefs" that matches the attributes and # values in "idvalues". We will do this by creating a relation value from # the idvalues list and semijoining that to "assignrefs". If we come up # non-empty, then we have found our multi-assigner instance. set heading [relation heading $assignrefs] set dstinst [pipe { tuple create $heading $idvalues | tuple relation ~ | relation semijoin ~ $assignrefs }] if {[relation isempty $dstinst]} { tailcall DeclError UNKNOWN_ASSIGNER $idvalues $rname } set dstref [list $rname $dstinst] ::rosea::Dispatch::SignalEvent [SelfInstRef] $dstref $event $args ; # <1> return } proc createMultiAssigner {rname args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } SplitRelvarName $rname domain relationship set assignrelvar ${domain}::${relationship}__STATEINST if {![relvar exists $assignrelvar]} { tailcall DeclError NO_ASSIGNER $rname } set idattrs [lindex [relvar identifiers $assignrelvar] 0] if {![struct::set equal [dict keys $args] $idattrs]} { tailcall DeclError NO_IDENTIFIER [dict keys $args] $idattrs } CreateInInitialState $domain $relationship $args } } namespace eval Dispatch { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path [list\ [namespace parent]::Helpers\ [namespace parent]::InstCmds\ ] variable toc_queue [list] variable event_queue [list] pipe { relvar restrictone ${domain}::__Arch_Transition\ Class $class State $currstate Event $event | relation extract ~ NewState } transitionQuery relvar create DelayedSignal { RefId int SrcInstRef list Event string DstInstRef list TimerId string Expire bignum } RefId {SrcInstRef Event DstInstRef} TimerId variable DelayedSignalId 0 pipe { relvar set ${domain}::__Arch_PartitionDst | relation restrictwith ~ {$SrcClass eq $dstclass} | relation group ~ DstLinks DstClass Attrs } polymapQuery proc SignalEvent {srcref dstset event arglist} { lassign $dstset relvar insts SplitRelvarName $relvar domain class if {[relation isempty [relvar restrictone ${domain}::__Arch_Event\ Class $class Event $event]]} { tailcall DeclError UNKNOWN_EVENT $event $class } set callback [namespace code DispatchEvent] set eventInfo [dict create\ type ordinary\ src $srcref\ event $event\ params $arglist\ ] if {[isRefEqual $srcref [nilInstRef]]} { variable toc_queue forAllRefs dstref $dstset { # Queue the thread of control events. dict set eventInfo dst $dstref lappend toc_queue $eventInfo ::after 0 $callback } } else { variable event_queue forAllRefs dstref $dstset { dict set eventInfo dst $dstref if {[isRefEqual $srcref $dstref]} { # <1> for {set eqindex 0} {$eqindex < [llength $event_queue]} {incr eqindex} { set cmpevent [lindex $event_queue $eqindex] if {![isRefEqual [dict get $cmpevent src] [dict get $cmpevent dst]]} { break } } set event_queue [linsert [K $event_queue [set event_queue {}]]\ $eqindex $eventInfo] ; # <1> } else { # Non-self directed events are always simply appended to the # event queue. lappend event_queue $eventInfo } ::after 0 $callback } } } proc DispatchEvent {} { variable event_queue variable toc_queue if {[llength $event_queue] != 0} { set eventInfo [lindex $event_queue 0] set event_queue [lrange [K $event_queue [set event_queue {}]] 1 end] ; # <1> } elseif {[llength $toc_queue] != 0} { set eventInfo [lindex $toc_queue 0] set toc_queue [lrange [K $toc_queue [set toc_queue {}]] 1 end] relvar transaction begin ; # <2> } else { return } if {[dict get $eventInfo type] eq "creation"} { try { set dstref [::rosea::ClassCmds::createin\ [dict get $eventInfo dstClass] @\ {*}[dict get $eventInfo dstAttrs]] ; # <1> } on error {result} { catch { if {[llength $event_queue] == 0} { relvar transaction end } } tailcall DeclError ASYNC_CREATION_FAILED [dict get $eventInfo dstClass]\ [dict get $eventInfo dstAttrs] $result } dict set eventInfo dst $dstref ; # <2> ::rosea::Trace::TraceCreation [dict get $eventInfo src]\ [dict get $eventInfo event] $dstref [dict get $eventInfo params] } set dstref [dict get $eventInfo dst] lassign $dstref relvar ref SplitRelvarName $relvar domain class set instrelvar ${domain}::${class}__STATEINST set state [relation semijoin $ref [relvar set $instrelvar]] if {[relation isempty $state]} { tailcall DeclError EVENT_IN_FLIGHT [dict get $eventInfo event] $ref } set currstate [relation extract $state __State] set event [dict get $eventInfo event] variable transitionQuery set newState [eval $transitionQuery] ::rosea::Trace::TraceTransition [dict get $eventInfo src]\ $event $dstref $currstate $newState [dict get $eventInfo params] ; # <1> try { if {$newState eq "CH"} { TransitionError [dict get $eventInfo src] $event $dstref $currstate } elseif {$newState ne "IG"} { set idattrs [tuple get [relation tuple $ref]] relvar updateone $instrelvar is $idattrs { tuple update $is __State $newState } try { ${relvar}::__Activity::$newState $dstref\ {*}[dict get $eventInfo params] ; # <1> } on error {result opts} { return -options $opts $result } finally { set term [relvar restrictone ${domain}::__Arch_TerminalState\ Class $class State $newState] if {[relation isnotempty $term]} { relvar deleteone $relvar {*}$idattrs relvar deleteone $instrelvar {*}$idattrs } } } } on error {result opts} { catch { if {[llength $event_queue] == 0} { relvar transaction end } } ; # <1> return -options $opts $result } if {[llength $event_queue] == 0} { relvar transaction end } return } proc TransitionError {src event dst currstate} { tailcall DeclError CANT_HAPPEN_EVENT $src $event $dst $currstate } proc FindDelayedSignal {srcref event dstref} { variable DelayedSignal return [relation restrictwith $DelayedSignal { [isRefEqual $SrcInstRef $srcref] && $Event eq $event &&\ [isRefEqual $DstInstRef $dstref]}] } proc DeleteDelayedSignal {srcref event dstref} { relvar delete DelayedSignal dsig { [isRefEqual [tuple extract $dsig SrcInstRef] $srcref] &&\ [tuple extract $dsig Event] eq $event &&\ [isRefEqual [tuple extract $dsig DstInstRef] $dstref] } } proc SignalDelayedEvent {time srcref dstset event arglist} { lassign $dstset relvar insts SplitRelvarName $relvar domain class if {[relation isempty [relvar restrictone ${domain}::__Arch_Event\ Class $class Event $event]]} { tailcall DeclError UNKNOWN_EVENT $event $class } variable DelayedSignalId set eventInfo [dict create\ id [incr DelayedSignalId]\ type ordinary\ src $srcref\ event $event\ params $arglist\ ] forAllRefs dstref $dstset { dict set eventInfo dst $dstref DeleteDelayedSignal $srcref $event $dstref ; # <1> relvar insert DelayedSignal [list\ RefId $DelayedSignalId\ SrcInstRef $srcref\ Event $event\ DstInstRef $dstref\ TimerId [::after $time [list\ ::rosea::Dispatch::DispatchDelayedEvent $eventInfo]]\ Expire [expr {entier([clock milliseconds]) + entier($time)}]\ ] } return } proc DispatchDelayedEvent {eventInfo} { relvar deleteone DelayedSignal RefId [dict get $eventInfo id] variable toc_queue lappend toc_queue $eventInfo tailcall DispatchEvent } proc CancelDelayedSignal {srcref event dstref} { variable DelayedSignal set sig [FindDelayedSignal $srcref $event $dstref] if {[relation isnotempty $sig]} { ::after cancel [relation extract $sig TimerId] DeleteDelayedSignal $srcref $event $dstref } else { # Search the toc_queue to see if the signal delay has already expired # and the event is awaiting dispatch. variable toc_queue for {set i 0} {$i < [llength $toc_queue]} {incr i} { set eventInfo [lindex $toc_queue $i] dict update eventInfo src evtsrc dst evtdst event evtevent { if {[isRefEqual $evtsrc $srcref] &&\ [isRefEqual $evtdst $dstref] &&\ $evtevent eq $event} { set toc_queue [lreplace\ [K $toc_queue [set toc_queue {}]] $i $i] break } } } } } proc SignalTimeRemaining {srcref event dstref} { set sig [FindDelayedSignal $srcref $event $dstref] return [expr {[relation isempty $sig] ? 0 :\ max([relation extract $sig Expire] - [clock milliseconds], 0)}] ; # <1> } proc MapPolymorphicEvent {frwdcmd srcref dstrefs event arglist} { lassign $dstrefs dstrelvar dstinsts SplitRelvarName $dstrelvar domain dstclass set polyevent [relvar restrictone ${domain}::__Arch_PolymorphicEvent\ Class $dstclass Event $event] if {[relation isempty $polyevent]} { return false } variable polymapQuery set partitions [eval $polymapQuery] relation foreach inst $dstinsts { relation foreach partition $partitions { relation assign $partition relation foreach dstlink $DstLinks { relation assign $dstlink set related [relation semijoin $inst\ [relvar set ${domain}::$DstClass] -using $Attrs] if {[relation isnotempty $related]} { set dstreference [ToRef ${domain}::${DstClass} $related] set target [ToRef $dstrelvar $inst] ::rosea::Trace::TracePolymorphic $srcref $event $target $dstreference $Name\ $arglist if {![MapPolymorphicEvent $frwdcmd $target $dstreference $event $arglist]} { {*}$frwdcmd $target $dstreference $event $arglist ; # <1> } break } } } } return true } } namespace eval Config { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path [namespace parent]::Helpers variable evalLambda {{body} { upvar #0 ::rosea::Config::errcount errcount ; # <1> upvar #0 ::rosea::Config::configlineno configlineno set lineno $configlineno set command {} foreach line [split $body \n] { # <2> append command $line \n incr lineno ; # <3> if {[info complete $command]} { try { eval $command } on error {result} { log::error "line $configlineno: \"$result\"" incr errcount } set command {} ; # <4> set configlineno $lineno } } return $errcount }} relvar create Domain { Name string Location string } Name relvar create DomainElement { Domain string Element string } {Domain Element} relvar association R1\ DomainElement Domain *\ Domain Name 1 relvar create Class { Domain string Name string } {Domain Name} relvar create Relationship { Domain string Name string } {Domain Name} relvar create DomainOperation { Domain string Name string Parameters list Body string } {Domain Name} relvar partition R2 DomainElement {Domain Element}\ Class {Domain Name}\ Relationship {Domain Name}\ DomainOperation {Domain Name} relvar create Attribute { Domain string Class string Name string Type string } {Domain Class Name} relvar association R3\ Attribute {Domain Class} +\ Class {Domain Name} 1 relvar create Identifier { Domain string Class string Number int } {Domain Class Number} relvar association R4\ Identifier {Domain Class} +\ Class {Domain Name} 1 relvar create IdentifyingAttribute { Domain string Class string Attribute string Number int } {Domain Class Attribute Number} relvar correlation R5 IdentifyingAttribute\ {Domain Class Number} + Identifier {Domain Class Number}\ {Domain Class Attribute} * Attribute {Domain Class Name} relvar create DefaultValue { Domain string Class string Attribute string } {Domain Class Attribute} relvar association R6\ DefaultValue {Domain Class Attribute} ?\ Attribute {Domain Class Name} 1 relvar create UserSuppliedValue { Domain string Class string Attribute string Value string } {Domain Class Attribute} relvar create SystemSuppliedValue { Domain string Class string Attribute string StartValue int } {Domain Class Attribute} relvar create GeneratedValue { Domain string Class string Attribute string Cmd string } {Domain Class Attribute} relvar partition R18 DefaultValue {Domain Class Attribute}\ UserSuppliedValue {Domain Class Attribute}\ SystemSuppliedValue {Domain Class Attribute}\ GeneratedValue {Domain Class Attribute} relvar create ValueCheck { Domain string Class string Attribute string Expression string } {Domain Class Attribute} relvar association R17\ ValueCheck {Domain Class Attribute} ?\ Attribute {Domain Class Name} 1 relvar create AttributeReference { Domain string ReferringClass string ReferringAttribute string ReferringRole string ReferencedClass string ReferencedAttribute string ReferencedRole string ReferencedIdNumber int Relationship string } {Domain ReferringClass ReferringAttribute ReferringRole\ ReferencedClass ReferencedAttribute ReferencedRole ReferencedIdNumber\ Relationship} relvar association R13\ AttributeReference {Domain ReferringClass ReferringAttribute} *\ Attribute {Domain Class Name} 1 relvar create ReferencedIdAttribute { Domain string Class string Relationship string Role string Attribute string Number int } {Domain Class Relationship Role Attribute Number} relvar create Operation { Domain string Class string Name string } {Domain Class Name} relvar association R8\ Operation {Domain Class} * Class {Domain Name} 1 relvar create InstanceOperation { Domain string Class string Name string } {Domain Class Name} relvar create ClassOperation { Domain string Class string Name string } {Domain Class Name} relvar partition R7 Operation {Domain Class Name}\ InstanceOperation {Domain Class Name}\ ClassOperation {Domain Class Name} relvar create UserInstanceOperation { Domain string Class string Name string Parameters string Body string } {Domain Class Name} relvar create SystemInstanceOperation { Domain string Class string Name string } {Domain Class Name} relvar partition R9 InstanceOperation {Domain Class Name}\ UserInstanceOperation {Domain Class Name}\ SystemInstanceOperation {Domain Class Name} relvar create UserClassOperation { Domain string Class string Name string Parameters string Body string } {Domain Class Name} relvar create SystemClassOperation { Domain string Class string Name string } {Domain Class Name} relvar partition R10 ClassOperation {Domain Class Name}\ UserClassOperation {Domain Class Name}\ SystemClassOperation {Domain Class Name} relvar create SuppliedOperation { Name string Command string RequiresStateModel boolean } Name relvar create SuppliedClassOperation { Name string } Name relvar create SuppliedInstanceOperation { Name string } Name relvar partition R14 SuppliedOperation Name\ SuppliedClassOperation Name\ SuppliedInstanceOperation Name relvar association R15\ SystemClassOperation Name *\ SuppliedClassOperation Name 1 relvar association R16\ SystemInstanceOperation Name *\ SuppliedInstanceOperation Name 1 relvar eval { relvar insert SuppliedOperation { Name findAll Command ::rosea::ClassCmds::findAll RequiresStateModel false } { Name findById Command ::rosea::ClassCmds::findById RequiresStateModel false } { Name findWhere Command ::rosea::ClassCmds::findWhere RequiresStateModel false } { Name create Command ::rosea::ClassCmds::create RequiresStateModel false } { Name createin Command ::rosea::ClassCmds::createin RequiresStateModel true } { Name createasync Command ::rosea::ClassCmds::createasync RequiresStateModel true } { Name update Command ::rosea::ClassCmds::update RequiresStateModel false } relvar insert SuppliedClassOperation { Name findAll } { Name findById } { Name findWhere } { Name create } { Name createin } { Name createasync } { Name update } } relvar eval { relvar insert SuppliedOperation { Name findRelated Command ::rosea::InstCmds::findRelated RequiresStateModel false } { Name findUnrelated Command ::rosea::InstCmds::findById RequiresStateModel false } { Name findRelatedWhere Command ::rosea::InstCmds::findRelatedWhere RequiresStateModel false } { Name findUnrelatedWhere Command ::rosea::InstCmds::findUnrelatedWhere RequiresStateModel false } { Name updateAttribute Command ::rosea::InstCmds::updateAttribute RequiresStateModel false } { Name withAttribute Command ::rosea::InstCmds::withAttribute RequiresStateModel false } { Name readAttribute Command ::rosea::InstCmds::readAttribute RequiresStateModel false } { Name assignAttribute Command ::rosea::InstCmds::assignAttribute RequiresStateModel false } { Name delete Command ::rosea::InstCmds::delete RequiresStateModel false } { Name signal Command ::rosea::InstCmds::signal RequiresStateModel true } { Name delaysignal Command ::rosea::InstCmds::delaysignal RequiresStateModel true } { Name canceldelayed Command ::rosea::InstCmds::canceldelayed RequiresStateModel true } { Name delayremaining Command ::rosea::InstCmds::delayremaining RequiresStateModel true } { Name instop Command ::rosea::InstCmds::instop RequiresStateModel false } { Name deRef Command ::rosea::InstCmds::deRef RequiresStateModel false } { Name isEmptyRef Command ::rosea::InstCmds::isEmptyRef RequiresStateModel false } { Name isNotEmptyRef Command ::rosea::InstCmds::isNotEmptyRef RequiresStateModel false } { Name refMultiplicity Command ::rosea::InstCmds::refMultiplicity RequiresStateModel false } { Name isRefSingular Command ::rosea::InstCmds::isRefSingular RequiresStateModel false } { Name limitRef Command ::rosea::InstCmds::limitRef RequiresStateModel false } { Name isRefEqual Command ::rosea::InstCmds::isRefEqual RequiresStateModel false } { Name forAllRefs Command ::rosea::InstCmds::forAllRefs RequiresStateModel false } relvar insert SuppliedInstanceOperation { Name findRelated } { Name findUnrelated } { Name findRelatedWhere } { Name findUnrelatedWhere } { Name updateAttribute } { Name withAttribute } { Name readAttribute } { Name assignAttribute } { Name delete } { Name signal } { Name delaysignal } { Name canceldelayed } { Name delayremaining } { Name instop } { Name deRef } { Name isEmptyRef } { Name isNotEmptyRef } { Name refMultiplicity } { Name isRefSingular } { Name limitRef } { Name isRefEqual } { Name forAllRefs } } relvar create Association { Domain string Name string } {Domain Name} relvar create Generalization { Domain string Name string } {Domain Name} relvar partition R30 Relationship {Domain Name}\ Association {Domain Name}\ Generalization {Domain Name} relvar create SimpleAssociation { Domain string Name string } {Domain Name} relvar create ClassBasedAssociation { Domain string Name string } {Domain Name} relvar partition R31 Association {Domain Name}\ SimpleAssociation {Domain Name}\ ClassBasedAssociation {Domain Name} relvar create SimpleReferringClass { Domain string Class string Relationship string Role string Conditionality boolean Multiplicity boolean } {Domain Class Relationship Role} relvar association R32\ SimpleReferringClass {Domain Relationship} 1\ SimpleAssociation {Domain Name} 1 relvar create SimpleReferencedClass { Domain string Class string Relationship string Role string Conditionality boolean } {Domain Class Relationship Role} relvar association R33\ SimpleReferencedClass {Domain Relationship} 1\ SimpleAssociation {Domain Name} 1 relvar create SourceClass { Domain string Class string Relationship string Role string Conditionality boolean Multiplicity boolean } {Domain Class Relationship Role} relvar association R34\ SourceClass {Domain Relationship} 1\ ClassBasedAssociation {Domain Name} 1 relvar create TargetClass { Domain string Class string Relationship string Role string Conditionality boolean Multiplicity boolean } {Domain Class Relationship Role} relvar association R35\ TargetClass {Domain Relationship} 1\ ClassBasedAssociation {Domain Name} 1 relvar create AssociatorClass { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar association R42\ AssociatorClass {Domain Relationship} 1\ ClassBasedAssociation {Domain Name} 1 relvar create Superclass { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar association R36\ Superclass {Domain Relationship} 1\ Generalization {Domain Name} 1 relvar create Subclass { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar association R37\ Subclass {Domain Relationship} +\ Generalization {Domain Name} 1 relvar create ReferringClass { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar partition R38 ReferringClass {Domain Class Relationship Role}\ SimpleReferringClass {Domain Class Relationship Role}\ AssociatorClass {Domain Class Relationship Role}\ Subclass {Domain Class Relationship Role} relvar create ReferencedClass { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar partition R39 ReferencedClass {Domain Class Relationship Role}\ SimpleReferencedClass {Domain Class Relationship Role}\ SourceClass {Domain Class Relationship Role}\ TargetClass {Domain Class Relationship Role}\ Superclass {Domain Class Relationship Role} relvar create ClassRole { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar partition R40 ClassRole {Domain Class Relationship Role}\ ReferringClass {Domain Class Relationship Role}\ ReferencedClass {Domain Class Relationship Role} relvar correlation R41 ClassRole\ {Domain Relationship} + Relationship {Domain Name}\ {Domain Class} * Class {Domain Name} relvar correlation R11 ReferencedIdAttribute\ {Domain Class Relationship Role} +\ ReferencedClass {Domain Class Relationship Role}\ {Domain Class Attribute Number} *\ IdentifyingAttribute {Domain Class Attribute Number} relvar correlation R12 AttributeReference\ {Domain ReferringClass Relationship ReferringRole} +\ ReferringClass {Domain Class Relationship Role}\ {Domain ReferencedClass Relationship ReferencedRole ReferencedAttribute\ ReferencedIdNumber} +\ ReferencedIdAttribute {Domain Class Relationship Role Attribute Number} relvar create Config_AssocSpec { Spec string NeedsAssociator boolean ReflexiveAllowed boolean ReferringCond boolean ReferringMult boolean ReferencedCond boolean ReferencedMult boolean } Spec relvar insert Config_AssocSpec { Spec 1--1 NeedsAssociator false ReflexiveAllowed true ReferringCond false ReferringMult false ReferencedCond false ReferencedMult false } { Spec 0..1--1 NeedsAssociator false ReflexiveAllowed false ReferringCond true ReferringMult false ReferencedCond false ReferencedMult false } { Spec 0..1--0..1 NeedsAssociator false ReflexiveAllowed true ReferringCond true ReferringMult false ReferencedCond true ReferencedMult false } { Spec 1..*--1 NeedsAssociator false ReflexiveAllowed true ReferringCond false ReferringMult true ReferencedCond false ReferencedMult false } { Spec 0..*--1 NeedsAssociator false ReflexiveAllowed false ReferringCond true ReferringMult true ReferencedCond false ReferencedMult false } { Spec 1..*--0..1 NeedsAssociator false ReflexiveAllowed false ReferringCond false ReferringMult true ReferencedCond true ReferencedMult false } { Spec 0..*--0..1 NeedsAssociator false ReflexiveAllowed true ReferringCond true ReferringMult true ReferencedCond true ReferencedMult false } { Spec 1..*--1..* NeedsAssociator true ReflexiveAllowed true ReferringCond false ReferringMult true ReferencedCond false ReferencedMult true } { Spec 0..*--1..* NeedsAssociator true ReflexiveAllowed false ReferringCond true ReferringMult true ReferencedCond false ReferencedMult true } { Spec 1..*--0..* NeedsAssociator true ReflexiveAllowed false ReferringCond false ReferringMult true ReferencedCond true ReferencedMult true } { Spec 0..*--0..* NeedsAssociator true ReflexiveAllowed true ReferringCond true ReferringMult true ReferencedCond true ReferencedMult true } { Spec ?--1 NeedsAssociator false ReflexiveAllowed false ReferringCond true ReferringMult false ReferencedCond false ReferencedMult false } { Spec ?--? NeedsAssociator false ReflexiveAllowed true ReferringCond true ReferringMult false ReferencedCond true ReferencedMult false } { Spec +--1 NeedsAssociator false ReflexiveAllowed true ReferringCond false ReferringMult true ReferencedCond false ReferencedMult false } { Spec *--1 NeedsAssociator false ReflexiveAllowed false ReferringCond true ReferringMult true ReferencedCond false ReferencedMult false } { Spec +--? NeedsAssociator false ReflexiveAllowed false ReferringCond false ReferringMult true ReferencedCond true ReferencedMult false } { Spec *--? NeedsAssociator false ReflexiveAllowed true ReferringCond true ReferringMult true ReferencedCond true ReferencedMult false } { Spec +--+ NeedsAssociator true ReflexiveAllowed true ReferringCond false ReferringMult true ReferencedCond false ReferencedMult true } { Spec *--+ NeedsAssociator true ReflexiveAllowed false ReferringCond true ReferringMult true ReferencedCond false ReferencedMult true } { Spec +--* NeedsAssociator true ReflexiveAllowed false ReferringCond false ReferringMult true ReferencedCond true ReferencedMult true } { Spec *--* NeedsAssociator true ReflexiveAllowed true ReferringCond true ReferringMult true ReferencedCond true ReferencedMult true } relvar create Config_ClassAssoc { Domain string Relationship string AssocClass string SourceClass string } {Domain Relationship AssocClass SourceClass} relvar create Config_NonReflexiveAssoc { Domain string Relationship string AssocClass string SourceClass string TargetClass string } {Domain Relationship AssocClass SourceClass} relvar create Config_ReflexiveAssoc { Domain string Relationship string AssocClass string SourceClass string } {Domain Relationship AssocClass SourceClass} relvar create Config_ReflexivePath { Domain string Relationship string AssocClass string SourceClass string SourceAttr string TargetAttr string } {Domain Relationship AssocClass SourceClass SourceAttr} relvar partition Config1\ Config_ClassAssoc\ {Domain Relationship AssocClass SourceClass}\ Config_NonReflexiveAssoc\ {Domain Relationship AssocClass SourceClass}\ Config_ReflexiveAssoc\ {Domain Relationship AssocClass SourceClass} relvar association Config2\ Config_ReflexivePath {Domain Relationship AssocClass SourceClass} +\ Config_ReflexiveAssoc {Domain Relationship AssocClass SourceClass} 1 pipe { relvar set ::rosea::Config::AttributeReference | relation project ~ Domain ReferencedClass Relationship ReferencedRole\ ReferencedAttribute ReferencedIdNumber | relation rename ~ ReferencedClass Class ReferencedRole Role\ ReferencedAttribute Attribute ReferencedIdNumber Number | relvar union ::rosea::Config::ReferencedIdAttribute } refIdQuery relvar create StateModel { Domain string Model string InitialState string DefaultTrans string } {Domain Model} relvar create InstanceStateModel { Domain string Class string } {Domain Class} relvar association R51\ InstanceStateModel {Domain Class} ?\ Class {Domain Name} 1 relvar create AssignerStateModel { Domain string Relationship string } {Domain Relationship} relvar association R52\ AssignerStateModel {Domain Relationship} ?\ Association {Domain Name} 1 relvar partition R50 StateModel {Domain Model}\ InstanceStateModel {Domain Class}\ AssignerStateModel {Domain Relationship} relvar create SingleAssigner { Domain string Relationship string } {Domain Relationship} relvar create MultipleAssigner { Domain string Relationship string Class string Number int } {Domain Relationship} relvar partition R53 AssignerStateModel {Domain Relationship}\ SingleAssigner {Domain Relationship}\ MultipleAssigner {Domain Relationship} relvar association R54\ MultipleAssigner {Domain Class Number} ?\ Identifier {Domain Class Number} 1 relvar create State { Domain string Model string Name string Parameters string Action string IsFinal boolean } {Domain Model Name} relvar association R55\ State {Domain Model} +\ StateModel {Domain Model} 1 relvar association R58\ StateModel {Domain Model InitialState} ?\ State {Domain Model Name} 1 relvar create TransitionRule { Name string } Name relvar insert TransitionRule {Name IG} {Name CH} relvar association R59\ StateModel DefaultTrans *\ TransitionRule Name 1 relvar create CreationState { Domain string Model string Name string } {Domain Model Name} relvar create StatePlace { Domain string Model string Name string } {Domain Model Name} relvar partition R57 StatePlace {Domain Model Name}\ State {Domain Model Name}\ CreationState {Domain Model Name} relvar create Event { Domain string Model string Event string } {Domain Model Event} relvar create DeferredEvent { Domain string Model string Event string } {Domain Model Event} relvar create EffectiveEvent { Domain string Model string Event string } {Domain Model Event} relvar partition R80 Event {Domain Model Event}\ DeferredEvent {Domain Model Event}\ EffectiveEvent {Domain Model Event} relvar create DeferralPath { Domain string Model string Event string Relationship string Role string } {Domain Model Event Relationship Role} relvar correlation R86 DeferralPath\ {Domain Model Event} + DeferredEvent {Domain Model Event}\ {Domain Model Relationship Role} * Superclass\ {Domain Class Relationship Role} relvar create PolymorphicEvent { Domain string Model string Event string } {Domain Model Event} relvar create InheritedEvent { Domain string Model string Event string } {Domain Model Event} relvar partition R81 DeferredEvent {Domain Model Event}\ PolymorphicEvent {Domain Model Event}\ InheritedEvent {Domain Model Event} relvar create MappedEvent { Domain string Model string Event string ParentModel string } {Domain Model Event} relvar association R84\ MappedEvent {Domain ParentModel Event} *\ DeferredEvent {Domain Model Event} 1 relvar create LocalEvent { Domain string Model string Event string } {Domain Model Event} relvar partition R82 EffectiveEvent {Domain Model Event}\ MappedEvent {Domain Model Event}\ LocalEvent {Domain Model Event} relvar create NonLocalEvent { Domain string Model string Event string Relationship string Role string } {Domain Model Event} relvar partition R83 NonLocalEvent {Domain Model Event}\ MappedEvent {Domain Model Event}\ InheritedEvent {Domain Model Event} relvar association R85\ NonLocalEvent {Domain Model Relationship Role} *\ Subclass {Domain Class Relationship Role} 1 relvar association R87\ EffectiveEvent {Domain Model} +\ StateModel {Domain Model} 1 relvar create TransitionPlace { Domain string Model string State string Event string } {Domain Model State Event} relvar correlation R70 TransitionPlace\ {Domain Model State} * StatePlace {Domain Model Name}\ {Domain Model Event} * EffectiveEvent {Domain Model Event} relvar create StateTransition { Domain string Model string State string Event string NewState string } {Domain Model State Event} relvar create NonStateTransition { Domain string Model string State string Event string TransRule string } {Domain Model State Event} relvar partition R71 TransitionPlace {Domain Model State Event}\ StateTransition {Domain Model State Event}\ NonStateTransition {Domain Model State Event} relvar association R72\ StateTransition {Domain Model NewState} *\ State {Domain Model Name} 1 relvar association R73\ NonStateTransition TransRule *\ TransitionRule Name 1 relvar create Config_DataError { Relationship string RefClass string RefType string Format string } {Relationship RefClass RefType} relvar insert Config_DataError { Relationship R3 RefClass Class RefType notrefed Format {in domain, \"$Domain\", class, \"$Name\",\ has no attributes} } { Relationship R4 RefClass Class RefType notrefed Format {in domain, \"$Domain\", class, \"$Name\",\ has no identifiers} } { Relationship R11 RefClass ReferencedClass RefType notrefed Format {in domain, \"$Domain\", for relationship,\ \"$Relationship\", no class has defined a reference\ to class, \"$Class\"} } { Relationship R11 RefClass ReferencedIdAttribute RefType refnone Format {in domain, \"$Domain\", relationship,\ \"$Relationship\", references attribute,\ \"$Attribute\", in class, \"$Class\", which is\ not an identifying attribute, does not exist\ or \"$Relationship\" does not exist} } { Relationship R12 RefClass AttributeReference RefType refnone Format {in domain, \"$Domain\", the attribute,\ \"$ReferringAttribute\", in class, \"$ReferringClass\",\ refers to, \"$ReferencedAttribute\", in class,\ \"$ReferencedClass\", but the class, attribute or\ relationship does not exist} } { Relationship R12 RefClass ReferringClass RefType notrefed Format {in domain, \"$Domain\", in class, \"$Class\",\ makes a reference along relationship,\ \"$Relationship\", but $Class does not pariticipate\ in $Relationship} } { Relationship R13 RefClass AttributeReference RefType refnone Format {in domain, \"$Domain\", the attribute,\ \"$ReferringAttribute\", in class, \"$ReferringClass\",\ does not exist, but is used as a referential attribute} } { Relationship R41 RefClass ClassRole RefType refnone Format {in domain, \"$Domain\", relationship,\ \"$Relationship\", references class, \"$Class\",\ which does not exist} } { Relationship R52 RefClass AssignerStateModel RefType refnone Format {in domain, \"$Domain\", an assigner state model is\ defined on relationship, \"$Relationship\", which is\ not an association type relationship} } { Relationship R70 RefClass TransitionPlace RefType refnone Format {in domain, \"$Domain\", the state model for,\ \"$Model\", contains a transition for event,\ \"$Event\", but $Event was a polymorphic event\ consumed by a superclass of $Model} } { Relationship R72 RefClass StateTransition RefType refnone Format {in domain, \"$Domain\", the state model for,\ \"$Model\", contains the transition,\ \"$State - $Event -> $NewState\",\ but state \"$NewState\" does not exist} } { Relationship R81 RefClass DeferredEvent RefType multrefed Format {in domain, \"$Domain\", in the state model for,\ \"$Model\", event, \"$Event\", is both an inherited\ polymorphic event and a locally defined one} } { Relationship R86 RefClass DeferredEvent RefType notrefed Format {in domain, \"$Domain\", in the state model for,\ \"$Model\", event, \"$Event\", is defined as\ polymorphic but \"$Model\" is not a superclass\ of a generalization} } { Relationship R87 RefClass EffectiveEvent RefType refnone Format {in domain, \"$Domain\", event, \"$Event\" has been\ inherited, but no state model exists for, \"$Model\"} } namespace export ConfigEvaluate proc ConfigEvaluate {ns body} { variable evalLambda tailcall ::apply [concat $evalLambda [list $ns]] $body ; # <1> } proc domain {name body} { namespace upvar DomainDef DomainName DomainName ; # <1> set DomainName $name relvar insert ::rosea::Config::Domain [list Name $name Location {}] try { if {$name eq {}} { tailcall DeclError EMPTY_NAME domain } relvar eval { # <2> ConfigEvaluate [namespace current]::DomainDef $body # At this point we have the definition of the domain and enough # information to tie together the referential attributes and # the association definitions. variable Config_NonReflexiveAssoc relation foreach nra $Config_NonReflexiveAssoc { relation assign $nra relvar update ::rosea::Config::AttributeReference ar { [tuple extract $ar Domain] eq $Domain && [tuple extract $ar Relationship] eq $Relationship && [tuple extract $ar ReferringClass] eq $AssocClass } {tuple update $ar ReferringRole associator} relvar update ::rosea::Config::AttributeReference ar { [tuple extract $ar Domain] eq $Domain && [tuple extract $ar Relationship] eq $Relationship && [tuple extract $ar ReferringClass] eq $AssocClass && [tuple extract $ar ReferencedClass] eq $SourceClass } {tuple update $ar ReferencedRole source} } variable Config_ReflexivePath relation foreach rp $Config_ReflexivePath { relation assign $rp relvar update ::rosea::Config::AttributeReference ar { [tuple extract $ar Domain] eq $Domain && [tuple extract $ar Relationship] eq $Relationship && [tuple extract $ar ReferringClass] eq $AssocClass } {tuple update $ar ReferringRole associator} relvar update ::rosea::Config::AttributeReference ar { [tuple extract $ar Domain] eq $Domain && [tuple extract $ar Relationship] eq $Relationship && [tuple extract $ar ReferringClass] eq $AssocClass && [tuple extract $ar ReferringAttribute] eq $SourceAttr } {tuple update $ar ReferencedRole source} } variable refIdQuery eval $refIdQuery # We must also compute how polymorphic events are inherited # down generalization hierarchies. # Create Deferral Path instances variable PolymorphicEvent variable DeferredEvent variable Superclass variable Subclass variable DeferralPath set dpaths [pipe { relation restrictwith $PolymorphicEvent {$Domain eq $name} | relation semijoin ~ $DeferredEvent | relation join ~ $Superclass -using {Domain Domain Model Class} }] relvar insert ::rosea::Config::DeferralPath {*}[relation body $dpaths] set supers [relation semiminus $Subclass $Superclass\ -using {Domain Domain Class Class}] relation foreach super $supers { PropagatePolyEvents $super } } } on error {result} { # puts $::errorInfo ::rosea::Config::HandleConfigError $result } } proc HandleConfigError {result} { set lines [split [string trimright $result] \n] set nlines [llength $lines] set lineno 0 upvar #0 ::rosea::Config::errcount errcount while {$lineno < $nlines} { set line [lindex $lines $lineno] incr lineno if {[regexp {^for[^:]+([^(]+)\(.+\), in relvar (.+)$} $line\ match rnum refclass]} { set rnum [namespace tail $rnum] set refclass [namespace tail $refclass] # Now iterate over the "tuple" lines that follow the constraint message. while {$lineno < $nlines} { set tupline [lindex $lines $lineno] if {[regexp {^tuple {(.+)} (.+)$} $tupline match tuple phrase]} { incr lineno incr errcount if {[string match {is not referenced*} $phrase]} { set reftype notrefed } elseif {[string match {references no*} $phrase]} { set reftype refnone } elseif {[string match {*to by multiple*} $phrase]} { set reftype multrefed } elseif {[string match {is not referred to*} $phrase]} { set reftype notrefto } else { log::error "unknown constraint phrasing, \"$phrase\"" continue } set cde [relvar restrictone Config_DataError Relationship $rnum RefClass\ $refclass RefType $reftype] if {[relation isnotempty $cde]} { dict with tuple { log::error [subst -nocommands [relation extract $cde Format]] } } else { log::error "$line\n$tupline" } } else { break } } } else { log::error "unknown configuration error, \"$result\"" } } return } namespace eval DomainDef { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Config::ConfigEvaluate namespace import ::rosea::Helpers::DeclError proc class {name body} { namespace upvar [namespace current] DomainName DomainName ; # <1> namespace upvar ClassDef ClassName ClassName set ClassName $name if {![regexp {\A[[:alnum:]].*} $name]} { tailcall DeclError BAD_CLASS_NAME $name } try { relvar insert ::rosea::Config::DomainElement [list\ Domain $DomainName\ Element $name\ ] } trap {RAL relvar insert DUPLICATE_TUPLE} {} { tailcall DeclError DUP_ELEMENT_NAME $name } ; # <2> relvar insert ::rosea::Config::Class [list\ Domain $DomainName\ Name $name\ ] set instops [pipe { relvar set ::rosea::Config::SuppliedInstanceOperation | relation extend ~ ioptuple\ Domain string {[set DomainName]}\ Class string {[set ClassName]} }] relvar union ::rosea::Config::SystemInstanceOperation $instops relvar union ::rosea::Config::InstanceOperation $instops relvar union ::rosea::Config::Operation $instops set classops [pipe { relvar set ::rosea::Config::SuppliedClassOperation | relation extend ~ coptuple\ Domain string {[set DomainName]}\ Class string {[set ClassName]} }] relvar union ::rosea::Config::SystemClassOperation $classops relvar union ::rosea::Config::ClassOperation $classops relvar union ::rosea::Config::Operation $classops ConfigEvaluate [namespace current]::ClassDef $body } proc association {name source spec target args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } if {$name eq {}} { tailcall DeclError EMPTY_NAME association } if {[string index $name 0] eq "~"} { tailcall DeclError TILDE_NAME $name } # Obtain references to the domain and class context. namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName set associator {} set path {} foreach {option value} $args { switch -exact -- $option { -associator { set associator $value } -path { set path $value if {[llength $path] % 2 != 0} { tailcall DeclError ARG_FORMAT $path } } default { tailcall DeclError UNKNOWN_OPTION association $option } } } set cas [relvar restrictone ::rosea::Config::Config_AssocSpec Spec $spec] if {[relation isempty $cas]} { tailcall DeclError BAD_RELATIONSHIP_SPEC $spec } set needsassoc [relation extract $cas NeedsAssociator] if {$needsassoc && $associator eq {}} { tailcall DeclError NEED_ASSOCIATOR $spec } if {$source eq $target} { if {![relation extract $cas ReflexiveAllowed]} { tailcall DeclError REFLEXIVE_NOT_ALLOWED $spec } if {$needsassoc && $path eq {}} { tailcall DeclError NEED_REFLEXIVE_PATH $name $source $spec $target } } try { relvar insert ::rosea::Config::DomainElement [list\ Domain $DomainName\ Element $name\ ] } trap {RAL relvar insert DUPLICATE_TUPLE} {result opts} { tailcall DeclError DUP_ELEMENT_NAME $name } # Many relvars have tuples with the same heading, so we construct it # once here. set reltuple [list\ Domain $DomainName\ Name $name\ ] # Populate the data for a Relationship and Association since that # is what this command defines. relvar insert ::rosea::Config::Relationship $reltuple relvar insert ::rosea::Config::Association $reltuple # Populate the type of association we are dealing with. if {$associator eq {}} { relvar insert ::rosea::Config::SimpleAssociation $reltuple relvar insert ::rosea::Config::SimpleReferringClass [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ Conditionality [relation extract $cas ReferringCond]\ Multiplicity [relation extract $cas ReferringMult]\ ] relvar insert ::rosea::Config::ReferringClass [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ ] relvar insert ::rosea::Config::ClassRole [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ ] relvar insert ::rosea::Config::SimpleReferencedClass [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ Conditionality [relation extract $cas ReferencedCond]\ ] relvar insert ::rosea::Config::ReferencedClass [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ ] relvar insert ::rosea::Config::ClassRole [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ ] } else { relvar insert ::rosea::Config::Config_ClassAssoc [list\ Domain $DomainName\ Relationship $name\ AssocClass $associator\ SourceClass $source\ ] if {[llength $path] == 0} { relvar insert ::rosea::Config::Config_NonReflexiveAssoc [list\ Domain $DomainName\ Relationship $name\ AssocClass $associator\ SourceClass $source\ TargetClass $target\ ] } else { relvar insert ::rosea::Config::Config_ReflexiveAssoc [list\ Domain $DomainName\ Relationship $name\ AssocClass $associator\ SourceClass $source\ ] foreach {sourceattr targetattr} $path { relvar insert ::rosea::Config::Config_ReflexivePath [list\ Domain $DomainName\ Relationship $name\ AssocClass $associator\ SourceClass $source\ SourceAttr $sourceattr\ TargetAttr $targetattr\ ] } } relvar insert ::rosea::Config::ClassBasedAssociation $reltuple relvar insert ::rosea::Config::SourceClass [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ Conditionality [relation extract $cas ReferringCond]\ Multiplicity [relation extract $cas ReferringMult]\ ] relvar insert ::rosea::Config::ReferencedClass [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ ] relvar insert ::rosea::Config::ClassRole [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ ] relvar insert ::rosea::Config::TargetClass [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ Conditionality [relation extract $cas ReferencedCond]\ Multiplicity [relation extract $cas ReferencedMult]\ ] relvar insert ::rosea::Config::ReferencedClass [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ ] relvar insert ::rosea::Config::ClassRole [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ ] relvar insert ::rosea::Config::AssociatorClass [list\ Domain $DomainName\ Class $associator\ Relationship $name\ Role associator\ ] relvar insert ::rosea::Config::ReferringClass [list\ Domain $DomainName\ Class $associator\ Relationship $name\ Role associator\ ] relvar insert ::rosea::Config::ClassRole [list\ Domain $DomainName\ Class $associator\ Relationship $name\ Role associator\ ] } } proc generalization {name super args} { if {[llength $args] < 2} { tailcall DeclError TOO_FEW_SUBCLASSES [llength $args] } if {$name eq {}} { tailcall DeclError EMPTY_NAME generalization } if {[string index $name 0] eq "~"} { tailcall DeclError TILDE_NAME $name } namespace upvar ::rosea::Config::DomainDef DomainName DomainName try { relvar insert ::rosea::Config::DomainElement [list\ Domain $DomainName\ Element $name\ ] } trap {RAL relvar insert DUPLICATE_TUPLE} {result opts} { tailcall DeclError DUP_ELEMENT_NAME $name } set reltuple [list\ Domain $DomainName\ Name $name\ ] relvar insert ::rosea::Config::Relationship $reltuple relvar insert ::rosea::Config::Generalization $reltuple set supertuple [list\ Domain $DomainName\ Class $super\ Relationship $name\ Role target\ ] relvar insert ::rosea::Config::Superclass $supertuple relvar insert ::rosea::Config::ReferencedClass $supertuple relvar insert ::rosea::Config::ClassRole $supertuple set subtuple [dict create\ Domain $DomainName\ Relationship $name\ Role source\ ] foreach sub $args { dict set subtuple Class $sub relvar insert ::rosea::Config::Subclass $subtuple relvar insert ::rosea::Config::ReferringClass $subtuple relvar insert ::rosea::Config::ClassRole $subtuple } } proc assigner {rname body} { namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar AssignerDef\ RelationshipName RelationshipName\ multiClass multiClass\ multiIdNum multiIdNum\ InitialState InitialState\ DefaultTrans DefaultTrans set RelationshipName $rname set multiClass {} set multiIdNum 1 set InitialState {} set DefaultTrans {} try { ConfigEvaluate [namespace current]::AssignerDef $body if {$DefaultTrans eq {}} { set DefaultTrans CH } relvar insert ::rosea::Config::StateModel [list\ Domain $DomainName\ Model $rname\ InitialState $InitialState\ DefaultTrans $DefaultTrans\ ] set assigntuple [list\ Domain $DomainName\ Relationship $rname\ ] relvar insert ::rosea::Config::AssignerStateModel $assigntuple if {$multiClass eq {}} { relvar insert ::rosea::Config::SingleAssigner $assigntuple } else { lappend assigntuple Class $multiClass Number $multiIdNum relvar insert ::rosea::Config::MultipleAssigner $assigntuple } } on error {result opts} { log::error $result upvar #0 ::rosea::Config::errcount errcount incr errcount } } proc operation {name params body} { if {$name eq {}} { tailcall DeclError EMPTY_NAME operation } namespace upvar ::rosea::Config::DomainDef DomainName DomainName try { relvar insert ::rosea::Config::DomainElement [list\ Domain $DomainName\ Element $name\ ] } trap {RAL relvar insert DUPLICATE_TUPLE} {result opts} { tailcall DeclError DUP_ELEMENT_NAME $name } relvar insert ::rosea::Config::DomainOperation [list\ Domain $DomainName\ Name $name\ Parameters $params\ Body $body\ ] } namespace eval ClassDef { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Config::ConfigEvaluate namespace import ::rosea::Helpers::DeclError proc attribute {name type args} { if {$name eq {}} { tailcall DeclError EMPTY_NAME attribute } if {[string range $name 0 1] eq "__"} { tailcall DeclError RESERVED_NAME $name } if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName relvar insert ::rosea::Config::Attribute [list\ Domain $DomainName\ Class $ClassName\ Name $name\ Type $type\ ] foreach {option value} $args { switch -exact -- $option { -default { relvar insert ::rosea::Config::DefaultValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ ] relvar insert ::rosea::Config::UserSuppliedValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ Value $value\ ] } -system { if {$type ne "int"} { tailcall DeclError INT_TYPE_REQUIRED $type } if {![string is integer -strict $value]} { tailcall DeclError INT_VALUE_REQUIRED $value } relvar insert ::rosea::Config::DefaultValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ ] relvar insert ::rosea::Config::SystemSuppliedValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ StartValue $value\ ] } -generate { relvar insert ::rosea::Config::DefaultValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ ] relvar insert ::rosea::Config::GeneratedValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ Cmd $value\ ] } -id { relvar uinsert ::rosea::Config::Identifier [list\ Domain $DomainName\ Class $ClassName\ Number $value\ ] ; # <1> relvar insert ::rosea::Config::IdentifyingAttribute [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ Number $value\ ] } -check { relvar insert ::rosea::Config::ValueCheck [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ Expression $value\ ] } default { tailcall DeclError UNKNOWN_OPTION attribute $option } } } } proc reference {relname rclass args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName set refnum 1 set linkopts [list] foreach {option value} $args { switch -exact -- $option { -refid { set refnum $value } -link { if {[llength $value] < 1 || [llength $value] > 2} { tailcall DeclError ARG_FORMAT $value } lappend linkopts $value } default { tailcall DeclError UNKNOWN_OPTION reference $option } } } # We defer processing the link options until the end so as not # to impose an order on the -refid option. foreach linkopt $linkopts { lassign $linkopt referring referenced if {$referenced eq {}} { set referenced $referring } relvar insert ::rosea::Config::AttributeReference [list\ Domain $DomainName\ ReferringClass $ClassName\ ReferringAttribute $referring\ ReferringRole source\ ReferencedClass $rclass\ ReferencedAttribute $referenced\ ReferencedRole target\ ReferencedIdNumber $refnum\ Relationship $relname ] ; # <1> } } proc classop {name params body} { if {$name eq {}} { tailcall DeclError EMPTY_NAME "class operation" } elseif {[string first :: $name] != -1} { tailcall DeclError NS_QUALIFIERS $name } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName set sysop [relvar restrictone ::rosea::Config::Operation\ Domain $DomainName Class $ClassName Name $name] if {[relation isnotempty $sysop]} { tailcall DeclError DUP_OP_NAME $name } set optuple [list Domain $DomainName Class $ClassName Name $name] relvar insert ::rosea::Config::Operation $optuple relvar insert ::rosea::Config::ClassOperation $optuple lappend optuple Parameters $params Body $body relvar insert ::rosea::Config::UserClassOperation $optuple } proc instop {name params body} { if {$name eq {}} { tailcall DeclError EMPTY_NAME "instance operation" } elseif {[string first :: $name] != -1} { tailcall DeclError NS_QUALIFIERS $name } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName set sysop [relvar restrictone ::rosea::Config::Operation\ Domain $DomainName Class $ClassName Name $name] if {[relation isnotempty $sysop]} { tailcall DeclError DUP_OP_NAME $name } set optuple [list Domain $DomainName Class $ClassName Name $name] relvar insert ::rosea::Config::Operation $optuple relvar insert ::rosea::Config::InstanceOperation $optuple lappend optuple Parameters $params Body $body relvar insert ::rosea::Config::UserInstanceOperation $optuple } proc statemodel {body} { namespace upvar ::rosea::Config::DomainDef DomainName DomainName variable ClassName namespace upvar StateModelDef\ InitialState InitialState\ DefaultTrans DefaultTrans\ Terminals Terminals set InitialState {} set DefaultTrans {} set Terminals [list] try { ConfigEvaluate [namespace current]::StateModelDef $body if {$DefaultTrans eq {}} { set DefaultTrans CH } relvar insert ::rosea::Config::StateModel [list\ Domain $DomainName\ Model $ClassName\ InitialState $InitialState\ DefaultTrans $DefaultTrans\ ] relvar insert ::rosea::Config::InstanceStateModel [list\ Domain $DomainName\ Class $ClassName\ ] foreach terminal $Terminals { relvar updateone ::rosea::Config::State stup [list\ Domain $DomainName Model $ClassName Name $terminal] { tuple update $stup IsFinal true } } } on error {result opts} { log::error $result upvar #0 ::rosea::Config::errcount errcount incr errcount } } proc polymorphic {args} { namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName foreach polyevent $args { set eventtuple [list\ Domain $DomainName\ Model $ClassName\ Event $polyevent\ ] relvar insert ::rosea::Config::PolymorphicEvent $eventtuple relvar insert ::rosea::Config::DeferredEvent $eventtuple relvar insert ::rosea::Config::Event $eventtuple } return } namespace eval StateModelDef { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Config::ConfigEvaluate namespace import ::rosea::Helpers::DeclError proc state {name params body} { if {$name eq {}} { tailcall DeclError EMPTY_NAME state } if {$name in {@ CH IG}} { tailcall DeclError PSEUDO_STATE $name state } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName variable InitialState if {$InitialState eq {}} { set InitialState $name } relvar insert ::rosea::Config::State [list\ Domain $DomainName\ Model $ClassName\ Name $name\ Parameters $params\ Action $body\ IsFinal false\ ] relvar insert ::rosea::Config::StatePlace [list\ Domain $DomainName\ Model $ClassName\ Name $name\ ] return } proc transition {source - event -> target} { if {$event eq {}} { tailcall DeclError EMPTY_NAME event } if {$source in {CH IG}} { tailcall DeclError PSEUDO_STATE $source "transition source state" } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName if {$source eq "@"} { if {$target in {CH IG}} { tailcall DeclError BAD_CREATION_TARGET $target } set cstuple [list\ Domain $DomainName\ Model $ClassName\ Name @\ ] relvar uinsert ::rosea::Config::CreationState $cstuple relvar uinsert ::rosea::Config::StatePlace $cstuple } set eventtuple [list\ Domain $DomainName\ Model $ClassName\ Event $event\ ] relvar uinsert ::rosea::Config::Event $eventtuple ; # <1> relvar uinsert ::rosea::Config::EffectiveEvent $eventtuple relvar uinsert ::rosea::Config::LocalEvent $eventtuple set tranrule [relvar restrictone ::rosea::Config::TransitionRule\ Name $target] set transtuple [list\ Domain $DomainName\ Model $ClassName\ State $source\ Event $event\ ] relvar insert ::rosea::Config::TransitionPlace $transtuple if {[relation isnotempty $tranrule]} { lappend transtuple TransRule $target set tpsubtype NonStateTransition } else { lappend transtuple NewState $target set tpsubtype StateTransition } relvar insert ::rosea::Config::$tpsubtype $transtuple return } proc initialstate {name} { if {$name eq {}} { tailcall DeclError EMPTY_NAME initialstate } if {$name in {@ CH IG}} { tailcall DeclError PSEUDO_STATE $name initialstate } variable InitialState $name return } proc defaulttrans {name} { if {$name ni {CH IG}} { tailcall DeclError EXPECTED_PSEUDO_STATE $name } variable DefaultTrans $name return } proc terminal {args} { variable Terminals ::struct::set add Terminals $args return } } } namespace eval AssignerDef { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Config::ConfigEvaluate namespace import ::rosea::Helpers::DeclError proc state {name params body} { if {$name eq {}} { tailcall DeclError EMPTY_NAME state } if {$name in {CH IG}} { tailcall DeclError PSEUDO_STATE $name state } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::AssignerDef\ RelationshipName RelationshipName variable InitialState if {$InitialState eq {}} { set InitialState $name } relvar insert ::rosea::Config::State [list\ Domain $DomainName\ Model $RelationshipName\ Name $name\ Parameters $params\ Action $body\ IsFinal false\ ] relvar insert ::rosea::Config::StatePlace [list\ Domain $DomainName\ Model $RelationshipName\ Name $name\ ] return } proc transition {source - event -> target} { if {$event eq {}} { tailcall DeclError EMPTY_NAME event } if {$source in {CH IG}} { tailcall DeclError PSEUDO_STATE $name "transition source state" } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::AssignerDef\ RelationshipName RelationshipName set eventtuple [list\ Domain $DomainName\ Model $RelationshipName\ Event $event\ ] relvar uinsert ::rosea::Config::Event $eventtuple relvar uinsert ::rosea::Config::EffectiveEvent $eventtuple relvar uinsert ::rosea::Config::LocalEvent $eventtuple set tranrule [relvar restrictone ::rosea::Config::TransitionRule\ Name $target] set transtuple [list\ Domain $DomainName\ Model $RelationshipName\ State $source\ Event $event\ ] relvar insert ::rosea::Config::TransitionPlace $transtuple if {[relation isnotempty $tranrule]} { lappend transtuple TransRule $target set tpsubtype NonStateTransition } else { lappend transtuple NewState $target set tpsubtype StateTransition } relvar insert ::rosea::Config::$tpsubtype $transtuple return } proc initialstate {name} { if {$name eq {}} { tailcall DeclError EMPTY_NAME initialstate } if {$name in {CH IG}} { tailcall DeclError PSEUDO_STATE $name initialstate } variable InitialState $name return } proc defaulttrans {name} { if {$name ni {CH IG}} { tailcall DeclError EXPECTED_PSEUDO_STATE $name } variable DefaultTrans $name return } proc identifyby {name args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } variable multiClass $name foreach {option value} $args { switch -exact -- $option { -id { variable multiIdNum $value } default { tailcall DeclError UNKNOWN_OPTION identifyby $option } } } return } } } } namespace eval Populate { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Config::ConfigEvaluate namespace import ::rosea::Helpers::DeclError proc domain {name body} { set domain [relvar restrictone ::rosea::Config::Domain Name $name] if {[relation isempty $domain]} { tailcall DeclError UNKNOWN_DOMAIN $domain } namespace upvar DomainPop DomainName DomainName DomainLoc DomainLoc relation assign $domain {Name DomainName} {Location DomainLoc} try { relvar eval { ConfigEvaluate [namespace current]::DomainPop $body } } on error {result opts} { log::error $result upvar #0 ::rosea::Config::errcount errcount incr errcount } } namespace eval DomainPop { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path ::rosea::Helpers proc class {class heading args} { # Determine if we have one big list or a bunch of values. set popvalues [expr {[llength $args] == 1 ? [lindex $args 0] : $args}] set headlen [llength $heading] if {[llength $popvalues] % $headlen != 0} { tailcall DeclError ARG_MISMATCH $headlen [llength $popvalues] } # Iterate over the attribute values taking them in chunks that are the same # size as the heading. set body [list] for {set vindex 0} {$vindex < [llength $popvalues]} {incr vindex $headlen} { set values [lrange $popvalues $vindex [expr {$vindex + $headlen - 1}]] # Create a tuple as a list of attribute name / value pairs. set tuple [list] foreach attr $heading value $values { # Check if we are skipping a value to use a default. We must also # allow some way to specify the value as "-". if {$value eq "-"} { continue } elseif {$value eq "\\-"} { set value - } lappend tuple $attr $value } # Accumulate the tuples as a list to form the body that will be # inserted into the relvar. lappend body $tuple } # Insert the body into the relvar. namespace upvar [namespace current]\ DomainName DomainName\ DomainLoc DomainLoc set domns ${DomainLoc}::${DomainName} set relvar ${domns}::$class set insts [relvar insert $relvar {*}$body] # Now we have to deal with any state model that might be present. We have # to set up the initial state properly if such a thing exists for this # class. set idattrs [lindex [relvar identifiers $relvar] 0] relation foreach inst $insts { CreateInInitialState $domns $class [pipe { relation project $inst {*}$idattrs | relation tuple ~ | tuple get ~ }] } return [relation body $insts] } proc assigner {rname heading args} { # Determine if we have one big list or a bunch of values. set popvalues [expr {[llength $args] == 1 ? [lindex $args 0] : $args}] set headlen [llength $heading] if {[llength $popvalues] % $headlen != 0} { tailcall DeclError ARG_MISMATCH $headlen [llength $popvalues] } namespace upvar [namespace current]\ DomainName DomainName\ DomainLoc DomainLoc set domns ${DomainLoc}::${DomainName} set relvar ${domns}::${rname}__STATEINST set idattrs [lindex [relvar identifiers $relvar] 0] if {![struct::set equal $heading $idattrs]} { tailcall DeclError NO_IDENTIFIER $heading $idattrs } # Iterate over the attribute values taking them in chunks that are the same # size as the heading. for {set vindex 0} {$vindex < [llength $popvalues]} {incr vindex $headlen} { set values [lrange $popvalues $vindex [expr {$vindex + $headlen - 1}]] # Create a tuple as a list of attribute name / value pairs. We assume # the values are in the same order as the heading -- that is the point. set tuple [list] foreach attr $heading value $values { lappend tuple $attr $value } CreateInInitialState $domns $rname $tuple } return } } } namespace eval Info { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Helpers::DeclError proc domain {arglist} { set arglist [lassign $arglist subcmd domainname] set dominst [relvar restrictone ::rosea::Config::Domain Name $domainname] if {[relation isempty $dominst]} { tailcall DeclError UNKNOWN_DOMAIN $domainname } switch -exact -- $subcmd { classes { return [pipe { relvar set ::rosea::Config::Class | relation semijoin $dominst ~ -using {Name Domain} | relation list ~ Name }] } relationships { return [pipe { relvar set ::rosea::Config::Relationship | relation semijoin $dominst ~ -using {Name Domain} | relation list ~ Name }] } operations { return [FormatOpsInfo [pipe { relvar set ::rosea::Config::DomainOperation | relation semijoin $dominst ~ -using {Name Domain} | relation project ~ Name Parameters Body }]] } default { tailcall DeclError UNKNOWN_INFO_CMD $subcmd } } } proc FormatOpsInfo {ops} { set result [list] relation foreach op $ops { relation assign $op lappend result $Name $Parameters $Body } return $result } proc class {arglist} { set arglist [lassign $arglist subcmd domainname classname] set dominst [relvar restrictone ::rosea::Config::Domain Name $domainname] if {[relation isempty $dominst]} { tailcall DeclError UNKNOWN_DOMAIN $domainname } set classinst [pipe { relvar set ::rosea::Config::Class | relation semijoin $dominst ~ -using {Name Domain} | relation restrictwith ~ {$Name eq $classname} }] if {[relation isempty $classinst]} { tailcall DeclError UNKNOWN_CLASS $classname $domainname } switch -exact -- $subcmd { attributes { return [pipe { relvar set ::rosea::Config::Attribute | relation semijoin $classinst ~ -using {Domain Domain Name Class} | relation dict ~ Name Type }] } classops { return [FormatOpsInfo [pipe { relvar set ::rosea::Config::UserClassOperation | relation semijoin $classinst ~ -using {Domain Domain Name Class} | relation project ~ Name Parameters Body }]] } instops { return [FormatOpsInfo [pipe { relvar set ::rosea::Config::UserInstanceOperation | relation semijoin $classinst ~ -using {Domain Domain Name Class} | relation project ~ Name Parameters Body }]] } default { tailcall DeclError UNKNOWN_INFO_CMD $subcmd } } } proc statemodel {arglist} { set arglist [lassign $arglist subcmd domainname classname statename] set dominst [relvar restrictone ::rosea::Config::Domain Name $domainname] if {[relation isempty $dominst]} { tailcall DeclError UNKNOWN_DOMAIN $domainname } set domns [string cat [relation extract $dominst Location] :: $domainname] set classinst [pipe { relvar set ::rosea::Config::Class | relation semijoin $dominst ~ -using {Name Domain} | relation restrictwith ~ {$Name eq $classname} }] if {[relation isempty $classinst]} { tailcall DeclError UNKNOWN_CLASS $classname $domainname } switch -exact -- $subcmd { states { set states [pipe { relvar set ::rosea::Config::State | relation restrictwith ~\ {$Domain eq $domainname && $Model eq $classname} | relation project ~ Name Parameters Action }] set result [list] relation foreach state $states { relation assign $state lappend result $Name $Parameters $Action } return $result } events { return [pipe { relvar set ::rosea::Config::EffectiveEvent | relation restrictwith ~\ {$Domain eq $domainname && $Model eq $classname} | relation list ~ Event }] } transitions { return [pipe { relvar set ${domns}::__Arch_Transition | relation restrictwith ~ {$Class eq $classname} | relation eliminate ~ Class | relation group ~ Transition Event NewState | relation extend ~ trtup TranCol dict { [relation dict [tuple extract $trtup Transition] Event NewState]} | relation dict ~ State TranCol }] ; # <1> } activityproc { return ${domns}::${classname}::__Activity::${statename} } } } } namespace eval Trace { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path [list\ [namespace parent]::Helpers\ [namespace parent]::InstCmds\ ] relvar create Trace { Trace_Id int Timestamp bignum Source list Event string Target list Params list } Trace_Id relvar create Creation { Trace_Id int } Trace_Id relvar create Polymorphic { Trace_Id int SubInst string Linkage string } Trace_Id relvar create Transition { Trace_Id int CurrState string NewState string } Trace_Id relvar partition R1 Trace Trace_Id\ Creation Trace_Id\ Polymorphic Trace_Id\ Transition Trace_Id variable targetCmpFunc [lambda {instrefs target} { lassign $target trelvar tinst foreach instref $instrefs { lassign $instref crelvar cinst if {$trelvar eq $crelvar && [ral relation is $tinst subsetof $cinst]} { return true } } return false }] variable traceState off variable traceNumber 0 variable traceLogState off variable traceLogLevel info variable traceLogCmd [::logger::init rosea] proc QueryClassTraces {classes} { variable Trace return [relation restrictwith $Trace { [lindex $Target 0] in $classes ||\ [namespace tail [lindex $Target 0]] in $classes }] ; # <1> } proc QueryTargetTraces {targets} { variable Trace variable targetCmpFunc return [relation restrictwith $Trace {[{*}$targetCmpFunc $targets $Target]}] } proc TraceCreation {source event target params} { variable traceState if {$traceState} { relvar eval { set trace [NewTrace $source $event $target $params] relvar insert Creation [list\ Trace_Id [relation extract $trace Trace_Id]\ ] } LogTrace $trace } } proc TracePolymorphic {source event target sub link params} { variable traceState if {$traceState} { relvar eval { set trace [NewTrace $source $event $target $params] relvar insert Polymorphic [list\ Trace_Id [relation extract $trace Trace_Id]\ SubInst $sub\ Linkage $link\ ] } LogTrace $trace } } proc TraceTransition {source event target curr new params} { variable traceState if {$traceState} { relvar eval { set trace [NewTrace $source $event $target $params] relvar insert Transition [list\ Trace_Id [relation extract $trace Trace_Id]\ CurrState $curr\ NewState $new\ ] } LogTrace $trace } } proc NewTrace {src event target params} { variable traceNumber return [relvar insert Trace [list\ Trace_Id [incr traceNumber]\ Timestamp [clock microseconds]\ Source $src\ Event $event\ Target $target\ Params $params\ ]] } proc LogTrace {trace} { variable traceLogState if {$traceLogState} { set rec [FormatTraceRec [lindex [TracesToRecords $trace] 0]] ; # <1> variable traceLogCmd variable traceLogLevel ${traceLogCmd}::${traceLogLevel} $rec } } proc TracesToRecords {traces} { foreach rvname {Creation Polymorphic Transition} { # <1> set traces [::ralutil::rvajoin $traces [relvar set $rvname] $rvname] } set result [list] relation foreach trace $traces -ascending Trace_Id { # <2> relation assign $trace set labeled [dict create\ id $Trace_Id\ time $Timestamp\ source $Source\ event $Event\ target $Target\ params $Params\ class [lindex $Target 0]\ ] ; # <3> if {[relation isnotempty $Transition]} { # <4> relation assign $Transition dict set labeled type transition dict set labeled current $CurrState dict set labeled new $NewState } elseif {[relation isnotempty $Polymorphic]} { relation assign $Polymorphic dict set labeled type polymorphic dict set labeled sub $SubInst dict set labeled link $Linkage } elseif {[relation isnotempty $Creation]} { dict set labeled type creation } lappend result $labeled } return $result } proc DecodeAllTraces {} { variable Trace tailcall TracesToRecords $Trace } proc DecodeClassTraces {args} { return [TracesToRecords [QueryClassTraces $args]] } proc DecodeTargetTraces {args} { tailcall TracesToRecords [QueryTargetTraces $args] } proc FormatTraceRec {rec} { dict with rec { switch -exact -- $type { transition { append result\ "Transition: "\ [FormatTransition $source $event $params $target]\ " ==> $current -> $new" } polymorphic { append result\ "Polymorphic : "\ [FormatTransition $source $event $params $target]\ " ==> $link -> [FormatInstRef $sub]" } creation { append result\ "Creation: "\ "[FormatInstRef $source] - "\ "[FormatEvent $event $params] -> $class\ " ==> [FormatInstRef $target]" } default { DeclError BAD_TRACETYPE $type } } } return $result } proc FormatTransition {source event params target} { return "[FormatInstRef $source] - [FormatEvent $event $params] ->\ [FormatInstRef $target]" } proc FormatEvent {event params} { return [string cat\ "$event"\ [expr {[llength $params] != 0 ? " \([join $params {, }]\)" : {}}]\ ] } proc FormatInstRef {instref} { lassign $instref relvar inst if {$relvar eq {}} { return {()} } else { return "$relvar \([tuple get [relation tuple $inst]]\)" } } proc FormatTimestamp {time} { set sec [clock format [expr {$time / 1000000}] -format %T] ; # <1> set time [expr {$time % 1000000}] set msec [expr {$time / 1000}] set usec [expr {$time % 1000}] return [format %s.%03ld.%03ld $sec $msec $usec] } proc FormatTimeAsSec {time} { set sec [expr {$time / 1000000}] set time [expr {$time % 1000000}] set msec [expr {$time / 1000}] set usec [expr {$time % 1000}] return [format %3ld.%03ld.%03ld $sec $msec $usec] } proc DiagTraces {traces args} { set result {} append result "seqdiag \{\n" append result " activation = none;\n" foreach {option value} $args { append result " $option = $value;\n" } foreach rvname {Creation Polymorphic Transition} { set traces [::ralutil::rvajoin $traces [relvar set $rvname] $rvname] } relation foreach trace $traces -ascending Trace_Id { relation assign $trace if {[isEmptyRef $Source]} { set Source EXTERNAL } else { set Source [namespace tail [lindex $Source 0]] } set Target [namespace tail [lindex $Target 0]] set evtlabel [FormatEvent $Event $Params] if {[relation isnotempty $Polymorphic]} { relation assign $Polymorphic Linkage append evtlabel " <<Polymorphic $Linkage>>" } elseif {[relation isnotempty $Creation]} { append evtlabel " <<Creation>>" } append result " $Source ->> $Target \[label=\"$evtlabel\"\];\n" } append result "\}\n" return $result } proc DiagAllTraces {filename args} { set chan [open $filename w] variable Trace try { chan puts $chan [DiagTraces $Trace {*}$args] } finally { chan close $chan } return } proc DiagClassTraces {filename classes args} { set chan [open $filename w] try { chan puts $chan [DiagTraces [QueryClassTraces $classes] {*}$args] } finally { chan close $chan } return } proc DiagTargetTraces {filename targets args} { set chan [open $filename w] try { chan puts $chan [DiagTraces [QueryTargetTraces $targets] {*}$args] } finally { chan close $chan } return } } namespace path ::rosea::Helpers namespace import ::rosea::Config::ConfigEvaluate } package provide rosea $::rosea::version |
Deleted modules/rosea-1.9.tm.
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 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 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 |
# DO NOT EDIT THIS FILE! # THIS FILE IS AUTOMATICALLY GENERATED FROM A LITERATE PROGRAM SOURCE FILE. # # This software is copyrighted 2014-2015 by G. Andrew Mangogna. # The following terms apply to all files associated with the software unless # explicitly disclaimed in individual files. # # The authors hereby grant permission to use, copy, modify, distribute, # and license this software and its documentation for any purpose, provided # that existing copyright notices are retained in all copies and that this # notice is included verbatim in any distributions. No written agreement, # license, or royalty fee is required for any of the authorized uses. # Modifications to this software may be copyrighted by their authors and # need not follow the licensing terms described here, provided that the # new terms are clearly indicated on the first page of each file where # they apply. # # IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING # OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES # THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE # IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE # NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, # OR MODIFICATIONS. # # GOVERNMENT USE: If you are acquiring this software on behalf of the # U.S. government, the Government shall have only "Restricted Rights" # in the software and related documentation as defined in the Federal # Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you # are acquiring the software on behalf of the Department of Defense, # the software shall be classified as "Commercial Computer Software" # and the Government shall have only "Restricted Rights" as defined in # Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, # the authors grant the U.S. Government and others acting in its behalf # permission to use and distribute the software in accordance with the # terms specified in this license. package require Tcl 8.6 package require logger package require ral package require ralutil package require struct::set package require lambda proc ::K {x y} {set x} namespace eval ::rosea { namespace export configure namespace export configureFromChan namespace export configureFromFile namespace export generate namespace export populate namespace export populateFromChan namespace export populateFromFile namespace export save namespace export restore namespace export info namespace export tunnel namespace export trace namespace ensemble create variable version 1.9 logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar pipe { relation semijoin $class $Attribute -using {Domain Domain Name Class} | relation project ~ Name Type | relation dict ~ Name Type } headingQuery pipe { relation semijoin $class $Identifier -using {Domain Domain Name Class}\ $IdentifyingAttribute | relation group ~ Attributes Attribute } idQuery pipe { relation semijoin $class $Attribute -using {Domain Domain Name Class} | relation join ~ $UserSuppliedValue -using {Domain Domain Class Class Name Attribute} } defaultValuesQuery pipe { relation semijoin $class $Attribute -using {Domain Domain Name Class} | relation join ~ $SystemSuppliedValue -using {Domain Domain Class Class Name Attribute} } suppliedValuesQuery pipe { relation semijoin $class $Attribute -using {Domain Domain Name Class} | relation join ~ $GeneratedValue -using {Domain Domain Class Class Name Attribute} } generatedValuesQuery pipe { relation semijoin $class $Attribute -using {Domain Domain Name Class} | relation join ~ $ValueCheck -using {Domain Domain Class Class Name Attribute} } checkValuesQuery pipe { relation semijoin $class $StateModel -using {Domain Domain Name Model} | relation isnotempty } hasSMQuery pipe { relation semijoin $class $State -using {Domain Domain Name Model} | relation project ~ Name Parameters Action } statesQuery pipe { relation join $AttributeReference $refing\ -using {Domain Domain ReferringClass Class\ Relationship Relationship ReferringRole Role} | relation rename ~ Conditionality ReferringCond\ Multiplicity ReferringMult | relation join ~ $refed -using {Domain Domain\ ReferencedClass Class Relationship\ Relationship ReferencedRole Role} | relation project ~ Domain Relationship\ ReferringClass ReferringAttribute\ ReferencedClass ReferencedAttribute\ ReferringCond ReferringMult Conditionality | relation group ~ ReferringAttrs\ ReferringAttribute ReferencedAttribute | relation extend ~ rfa\ TagReferringAttrs {Relation {RefOrder int ReferringAttribute string\ ReferencedAttribute string}} { [relation tag [tuple extract $rfa ReferringAttrs] RefOrder] } | relation extend ~ wfa\ SrcAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferringAttribute -ascending RefOrder] }\ DstAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferencedAttribute -ascending RefOrder] } | relation extend ~ ram\ ForwAttrs list { [Interleave [tuple extract $ram SrcAttrs]\ [tuple extract $ram DstAttrs]] }\ RevAttrs list { [Interleave [tuple extract $ram DstAttrs]\ [tuple extract $ram SrcAttrs]] } | relation eliminate ~ TagReferringAttrs } referencesQuery pipe { relation semijoin $cassocs $AssociatorClass\ -using {Domain Domain Name Relationship}\ $ReferringClass $AttributeReference\ -using {Domain Domain Class ReferringClass\ Relationship Relationship Role ReferringRole} | relation project ~ Domain Relationship ReferringClass ReferringAttribute\ ReferencedClass ReferencedAttribute ReferencedRole | relation join ~ $bothclass -using {Domain Domain Relationship Relationship\ ReferencedClass Class ReferencedRole Role} | relation group ~ ReferringAttrs ReferringAttribute ReferencedAttribute | relation extend ~ rfa\ TagReferringAttrs {Relation {RefOrder int ReferringAttribute string\ ReferencedAttribute string}} { [relation tag [tuple extract $rfa ReferringAttrs] RefOrder] } | relation extend ~ wfa\ SrcAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferringAttribute -ascending RefOrder] }\ DstAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferencedAttribute -ascending RefOrder] } | relation extend ~ ram\ ForwAttrs list { [Interleave [tuple extract $ram SrcAttrs]\ [tuple extract $ram DstAttrs]] }\ RevAttrs list { [Interleave [tuple extract $ram DstAttrs]\ [tuple extract $ram SrcAttrs]] } | relation eliminate ~ TagReferringAttrs } assocrefsQuery pipe { relation semijoin $rships $Generalization\ $Subclass -using {Domain Domain Name Relationship}\ $ReferringClass $AttributeReference\ -using {Domain Domain Class ReferringClass\ Relationship Relationship Role ReferringRole} | relation project ~ Domain Relationship ReferringClass ReferringAttribute\ ReferencedClass ReferencedAttribute | relation group ~ ReferringAttrs\ ReferringAttribute ReferencedAttribute | relation extend ~ rfa\ TagReferringAttrs {Relation {RefOrder int ReferringAttribute string\ ReferencedAttribute string}} { [relation tag [tuple extract $rfa ReferringAttrs] RefOrder] } | relation extend ~ wfa\ SrcAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferringAttribute -ascending RefOrder] }\ DstAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferencedAttribute -ascending RefOrder] } | relation extend ~ ram\ ForwAttrs list { [Interleave [tuple extract $ram SrcAttrs]\ [tuple extract $ram DstAttrs]] }\ RevAttrs list { [Interleave [tuple extract $ram DstAttrs]\ [tuple extract $ram SrcAttrs]] } | relation eliminate ~ TagReferringAttrs } subrefsQuery proc configure {script} { namespace upvar Config errcount errcount configlineno configlineno set errcount 0 set configlineno 1 ConfigEvaluate ::rosea::Config $script if {$errcount > 0} { tailcall DeclError CONFIG_ERRORS $errcount } return $errcount } proc configureFromChan {chan} { tailcall configure [::chan read -nonewline $chan] } proc configureFromFile {filename} { set f [::open $filename r] try { configureFromChan $f } finally { ::chan close $f } } proc generate {{pattern *} {prefix {}}} { if {$prefix ne {}} { if {[string range $prefix 0 1] ne "::"} { set prefix [uplevel 1 {namespace current}]::$prefix } set prefix [string trimright $prefix :] } elseif {$prefix eq "::"} { set prefix {} ; # <1> } namespace upvar Config\ Domain Domain\ DomainElement DomainElement\ Class Class\ Attribute Attribute\ DefaultValue DefaultValue\ UserSuppliedValue UserSuppliedValue\ SystemSuppliedValue SystemSuppliedValue\ GeneratedValue GeneratedValue\ ValueCheck ValueCheck\ Identifier Identifier\ IdentifyingAttribute IdentifyingAttribute\ Relationship Relationship\ Association Association\ SimpleAssociation SimpleAssociation\ SimpleReferringClass SimpleReferringClass\ SimpleReferencedClass SimpleReferencedClass\ ClassBasedAssociation ClassBasedAssociation\ AssociatorClass AssociatorClass\ SourceClass SourceClass\ TargetClass TargetClass\ Generalization Generalization\ Superclass Superclass\ Subclass Subclass\ AttributeReference AttributeReference\ ReferencedIdAttribute ReferencedIdAttribute\ ReferringClass ReferringClass\ ReferencedClass ReferencedClass\ DomainOperation DomainOperation\ SuppliedOperation SuppliedOperation\ UserClassOperation UserClassOperation\ SystemClassOperation SystemClassOperation\ UserInstanceOperation UserInstanceOperation\ SystemInstanceOperation SystemInstanceOperation\ InstanceStateModel InstanceStateModel\ StateModel StateModel\ StatePlace StatePlace\ State State\ EffectiveEvent EffectiveEvent\ DeferredEvent DeferredEvent\ TransitionPlace TransitionPlace\ StateTransition StateTransition\ NonStateTransition NonStateTransition\ AssignerStateModel AssignerStateModel\ SingleAssigner SingleAssigner\ MultipleAssigner MultipleAssigner\ PolymorphicEvent PolymorphicEvent set genDomain [relation restrict $Domain dom { [string match $pattern [tuple extract $dom Name]] }] relation foreach domain $genDomain { set domainName [relation extract $domain Name] relvar updateone Config::Domain dtup [list Name $domainName] { tuple update $dtup Location $prefix } set domns ${prefix}::$domainName namespace eval $domns { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe ral relvar create __Arch_RefLink { Relationship string ReferringClass string ReferencedClass string ReferringAttrs {Relation {ReferringAttribute string ReferencedAttribute string}} } Relationship ral relvar create __Arch_AssocRef { Relationship string AssocClass string References {Relation\ {Participant string Role string ReferringAttrs {Relation\ {ReferringAttribute string ReferencedAttribute string}}}} } Relationship ral relvar create __Arch_SuperLink { Relationship string SuperClass string } Relationship ral relvar create __Arch_SubLink { Relationship string SubClass string ReferringAttrs {Relation\ {ReferringAttribute string ReferencedAttribute string}} } {Relationship SubClass} ral relvar association __Arch_R5\ __Arch_SubLink Relationship +\ __Arch_SuperLink Relationship 1 ral relvar create __Arch_Link { Name string SrcClass string } {Name SrcClass} ral relvar create __Arch_AssociationLink { Name string SrcClass string DstClass string Attrs list PrevSrcClass string } {Name SrcClass} ral relvar association __Arch_R4\ __Arch_AssociationLink {Name PrevSrcClass} ?\ __Arch_AssociationLink {Name SrcClass} ? ral relvar create __Arch_PartitionLink { Name string SrcClass string } {Name SrcClass} ral relvar partition __Arch_R3 __Arch_Link {Name SrcClass}\ __Arch_AssociationLink {Name SrcClass}\ __Arch_PartitionLink {Name SrcClass} ral relvar create __Arch_PartitionDst { Name string SrcClass string DstClass string Attrs list } {Name SrcClass DstClass} ral relvar association __Arch_R2\ __Arch_PartitionDst {Name SrcClass} +\ __Arch_PartitionLink {Name SrcClass} 1 ral relvar create __Arch_State { Class string State string } {Class State} ral relvar create __Arch_Event { Class string Event string } {Class Event} ral relvar create __Arch_Transition { Class string State string Event string NewState string } {Class State Event} ral relvar correlation __Arch_R1 __Arch_Transition\ {Class State} + __Arch_State {Class State}\ {Class Event} + __Arch_Event {Class Event} ral relvar create __Arch_InitialState { Class string State string } Class ral relvar association __Arch_R6\ __Arch_InitialState {Class State} ?\ __Arch_State {Class State} 1 ral relvar create __Arch_TerminalState { Class string State string } {Class State} ral relvar association __Arch_R7\ __Arch_TerminalState {Class State} *\ __Arch_State {Class State} 1 ral relvar create __Arch_PolymorphicEvent { Class string Event string } {Class Event} } namespace eval $domns namespace path ::rosea::InstCmds set domops [relation semijoin $domain $DomainOperation -using {Name Domain}] relation foreach domop $domops { relation assign $domop\ {Name name} {Parameters parameters} {Body body} proc ${domns}::$name $parameters [list ::ral relvar eval $body] ; # <1> } namespace eval $domns [list\ namespace export {*}[relation list $domops Name]\ ] namespace eval $domns namespace ensemble create set statemodels [relation semijoin $domain $StateModel\ -using {Name Domain}] relvar eval { relvar set ${domns}::__Arch_InitialState [pipe { relation project $statemodels Model InitialState | relation rename ~ Model Class InitialState State }] set states [relation semijoin $domain $StatePlace -using {Name Domain}] relvar set ${domns}::__Arch_State [pipe { relation project $states Model Name | relation rename ~ Model Class Name State }] relvar set ${domns}::__Arch_TerminalState [pipe { relation semijoin $domain $State -using {Name Domain} | relation restrict ~ termtuple {[tuple extract $termtuple IsFinal]} | relation project ~ Model Name | relation rename ~ Model Class Name State }] set events [relation semijoin $domain $EffectiveEvent\ -using {Name Domain}] relvar set ${domns}::__Arch_Event [pipe { relation project $events Model Event | relation rename ~ Model Class }] set alltrans [pipe { relation join $states $events | relation rename ~ Name State }] ; # <1> set statetrans [relation semijoin $domain $StateTransition\ -using {Name Domain}] set nontrans [pipe { relation semijoin $domain $NonStateTransition -using {Name Domain} | relation rename ~ TransRule NewState }] set deftrans [pipe { relation minus $alltrans $TransitionPlace | relation join ~ $StateModel | relation eliminate ~ InitialState | relation rename ~ DefaultTrans NewState | relation update ~ dttup {[tuple extract $dttup State] eq "@"} { tuple update $dttup NewState CH} }] relvar set ${domns}::__Arch_Transition [pipe { relation union $statetrans $nontrans $deftrans | relation eliminate ~ Domain | relation rename ~ Model Class }] relvar set ${domns}::__Arch_PolymorphicEvent [pipe { relation semijoin $domain $DeferredEvent\ -using {Name Domain} | relation project ~ Model Event | relation rename ~ Model Class }] } variable headingQuery variable idQuery variable defaultValuesQuery variable suppliedValuesQuery variable generatedValuesQuery variable checkValuesQuery variable hasSMQuery variable statesQuery set classes [relation semijoin $domain $DomainElement -using {Name Domain}\ $Class -using {Domain Domain Element Name}] relation foreach class $classes { set className ${domns}::[relation extract $class Name] namespace eval $className { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe } namespace eval $className [list namespace path\ [list ::rosea::InstCmds $domns]] set heading [eval $headingQuery] set idset [list] relation foreach id [eval $idQuery] -ascending Number { lappend idset [relation list\ [relation extract $id Attributes] Attribute] } relvar create $className $heading {*}$idset # <1> set checkvalues [eval $checkValuesQuery] if {[relation isnotempty $checkvalues]} { relvar trace add variable $className {insert update set} [list\ ::rosea::Helpers::CheckValueTrace\ [relation dict $checkvalues Name Expression]\ ] } set defaultvalues [eval $defaultValuesQuery] if {[relation isnotempty $defaultvalues]} { relvar trace add variable $className insert [list\ ::rosea::Helpers::UserDefaultTrace\ [relation dict $defaultvalues Name Type]\ [relation dict $defaultvalues Name Value]\ ] } set supplied [eval $suppliedValuesQuery] if {[relation isnotempty $supplied]} { pipe { relation extend $supplied stup ClassName string { [string cat [tuple extract $stup Class] , [tuple extract $stup Name]] } | relation array ~ ${domns}::__Arch_SuppliedDefault ClassName StartValue } ; # <1> relvar trace add variable $className insert [list\ ::rosea::Helpers::SupplyDefaultTrace\ [relation dict $supplied Name Type]\ ] } set generatecmds [eval $generatedValuesQuery] if {[relation isnotempty $generatecmds]} { relvar trace add variable $className insert [list\ ::rosea::Helpers::GenerateDefaultTrace\ [relation dict $generatecmds Name Type]\ [relation dict $generatecmds Name Cmd]\ ] } set hasStateModel [eval $hasSMQuery] if {$hasStateModel} { set instid [lindex $idset 0] set instheading [list] foreach attr $instid { lappend instheading $attr [dict get $heading $attr] ; # <1> } lappend instheading __State string relvar create ${domns}::[relation extract $class Name]__STATEINST\ $instheading $instid set actns ${className}::__Activity namespace eval $actns { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe } namespace eval $actns [list\ namespace path [list\ ::rosea::InstCmds\ $className\ $domns\ ]\ ] relation foreach state [eval $statesQuery] { relation assign $state\ {Name stateName}\ {Parameters params}\ {Action stateAction} proc ${actns}::$stateName [linsert $params 0 self] $stateAction } } set opmap [dict create] set classops [relation semijoin $class $UserClassOperation\ -using {Domain Domain Name Class}] relation foreach classop $classops { relation assign $classop\ {Name opname}\ {Parameters params}\ {Body opbody} proc ${className}::$opname $params $opbody dict set opmap $opname ${className}::$opname } set sysmap [QuerySystemClassOperations $className false] if {$hasStateModel} { set sysmap [dict merge $sysmap [QuerySystemClassOperations $className true]] } namespace ensemble create\ -command $className\ -map [dict merge $opmap $sysmap] set opmap [dict create] set instops [relation semijoin $class $UserInstanceOperation\ -using {Domain Domain Name Class}] relation foreach instop $instops { relation assign $instop\ {Name opname}\ {Parameters params}\ {Body opbody} proc ${className}::$opname [linsert $params 0 self] $opbody dict set opmap $opname ${className}::$opname } set sysmap [QuerySystemInstanceOperations false] set hasPolyEvents [relation isnotempty\ [relation semijoin $class $PolymorphicEvent\ -using {Domain Domain Name Model}]\ ] if {$hasStateModel || $hasPolyEvents} { set sysmap [dict merge $sysmap [QuerySystemInstanceOperations true]] } namespace ensemble create\ -command ${className}::Instance\ -parameters instref\ -map [dict merge $opmap $sysmap] } set rships [relation semijoin $domain $DomainElement -using {Name Domain}\ $Relationship -using {Domain Domain Element Name}] set sassocs [relation semijoin $rships $Association\ $SimpleAssociation] set refing [relation semijoin $sassocs $SimpleReferringClass\ -using {Domain Domain Name Relationship}] set refed [relation semijoin $sassocs $SimpleReferencedClass\ -using {Domain Domain Name Relationship}] variable referencesQuery set references [eval $referencesQuery] relvar eval { set flink [pipe { relation project $references Relationship ReferringClass | relation rename ~ Relationship Name ReferringClass SrcClass }] set blink [pipe { relation project $references Relationship ReferencedClass | relation rename % Relationship Name ReferencedClass SrcClass | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] ; # <1> relvar union ${domns}::__Arch_Link $flink $blink set flink [pipe { relation project $references Relationship ReferringClass\ ReferencedClass ForwAttrs | relation rename ~ Relationship Name ReferringClass SrcClass\ ReferencedClass DstClass ForwAttrs Attrs | relation extend ~ al PrevSrcClass string {{}} }] ; # <1> set blink [pipe { relation project $references Relationship ReferringClass\ ReferencedClass RevAttrs | relation rename % Relationship Name ReferencedClass SrcClass\ ReferringClass DstClass RevAttrs Attrs | relation extend % al PrevSrcClass string {{}} | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] relvar union ${domns}::__Arch_AssociationLink $flink $blink relvar union ${domns}::__Arch_RefLink [relation project $references\ Relationship ReferringClass ReferencedClass ReferringAttrs] } relation foreach reference $references { relation assign $reference\ {Relationship relationship}\ {ReferringClass referringClass}\ {ReferencedClass referencedClass}\ {ReferringCond referringCond}\ {ReferringMult referringMult}\ {Conditionality referencedCond}\ {SrcAttrs srcAttrs}\ {DstAttrs dstAttrs} # Create the relvar constraint. relvar association ${domns}::$relationship\ ${domns}::$referringClass $srcAttrs\ [MapCondMultToConstraint $referringCond $referringMult]\ ${domns}::$referencedClass $dstAttrs\ [MapCondMultToConstraint $referencedCond false] # All simple associations get a link and unlink command in their ensemble. set ensemblemap [dict create\ link [list ::rosea::RelCmds::linkSimple $relationship]\ unlink [list ::rosea::RelCmds::unlinkSimple $relationship]\ ] # Determine if we have any assigners assocated with the relationship. # Single assigners get different commands from multiple assigners. set rpath ${domns}::$relationship set assigner [relation semijoin $reference $SingleAssigner\ -using {Domain Domain Relationship Relationship}] if {[relation isnotempty $assigner]} { dict set ensemblemap signal\ [list ::rosea::RelCmds::signalAssigner $rpath] } else { set assigner [relation semijoin $reference $MultipleAssigner\ -using {Domain Domain Relationship Relationship}] if {[relation isnotempty $assigner]} { dict set ensemblemap signal [list\ ::rosea::RelCmds::signalMultiAssigner $rpath] dict set ensemblemap create [list\ ::rosea::RelCmds::createMultiAssigner $rpath] } } # Create the relationship ensemble command. namespace ensemble create -command $rpath -map $ensemblemap } set cassocs [relation semijoin $rships $Association\ $ClassBasedAssociation] set sourceclass [relation semijoin $cassocs $SourceClass\ -using {Domain Domain Name Relationship}] set targetclass [relation semijoin $cassocs $TargetClass\ -using {Domain Domain Name Relationship}] set bothclass [relation union $sourceclass $targetclass] ; # <1> variable assocrefsQuery set assocrefs [eval $assocrefsQuery] relvar eval { set aforw [pipe { relation project $assocrefs Relationship ReferringClass | relation rename ~ Relationship Name ReferringClass SrcClass }] set arev [relation update $aforw lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]}] set sources [pipe { relation restrict $assocrefs aref { [tuple extract $aref ReferencedRole] eq "source"} | relation eliminate ~ ReferencedRole }] set sforw [pipe { relation project $sources Relationship ReferencedClass | relation rename ~ Relationship Name ReferencedClass SrcClass }] set targets [pipe { relation restrict $assocrefs aref { [tuple extract $aref ReferencedRole] eq "target"} | relation eliminate ~ ReferencedRole }] set trev [pipe { relation project $targets Relationship ReferencedClass | relation rename % Relationship Name ReferencedClass SrcClass | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] relvar union ${domns}::__Arch_Link $aforw $arev $sforw $trev set sforw [pipe { relation project $sources Relationship ReferringClass ReferencedClass\ RevAttrs | relation rename ~ Relationship Name ReferringClass DstClass\ ReferencedClass SrcClass RevAttrs Attrs | relation extend ~ al PrevSrcClass string {{}} }] set trev [pipe { relation project $targets Relationship ReferringClass ReferencedClass\ RevAttrs | relation rename % Relationship Name ReferringClass DstClass\ ReferencedClass SrcClass RevAttrs Attrs | relation extend % al PrevSrcClass string {{}} | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] set onerefs [relation rename $sources ReferencedClass OneClass\ Conditionality OneCond Multiplicity OneMult\ ReferringAttrs OneReferringAttrs SrcAttrs OneSrcAttrs\ DstAttrs OneDstAttrs ForwAttrs OneForwAttrs RevAttrs OneRevAttrs] set otherrefs [relation rename $targets ReferencedClass OtherClass\ Conditionality OtherCond Multiplicity OtherMult ReferringAttrs\ OtherReferringAttrs SrcAttrs OtherSrcAttrs DstAttrs OtherDstAttrs\ ForwAttrs OtherForwAttrs RevAttrs OtherRevAttrs] set bothrefs [relation join $onerefs $otherrefs\ -using {Domain Domain ReferringClass ReferringClass\ Relationship Relationship}] set aforw [pipe { relation project $bothrefs Relationship ReferringClass OtherClass\ OtherForwAttrs OneClass | relation rename ~ Relationship Name ReferringClass SrcClass\ OtherClass DstClass OtherForwAttrs Attrs OneClass PrevSrcClass }] set arev [pipe { relation project $bothrefs Relationship ReferringClass OneClass\ OneForwAttrs OtherClass | relation rename % Relationship Name ReferringClass SrcClass\ OneClass DstClass OneForwAttrs Attrs OtherClass PrevSrcClass | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] relvar union ${domns}::__Arch_AssociationLink $sforw $trev $aforw $arev relvar union ${domns}::__Arch_AssocRef [pipe { relation project $assocrefs Relationship ReferringClass\ ReferencedClass ReferencedRole ReferringAttrs | relation rename ~ ReferringClass AssocClass ReferencedClass Participant\ ReferencedRole Role | relation group ~ References Participant Role ReferringAttrs }] } relation foreach bothref $bothrefs { relation assign $bothref\ {Relationship relationship}\ {ReferringClass associator}\ {OneClass sourceClass}\ {OneCond sourceCond}\ {OneMult sourceMult}\ {OneSrcAttrs sourceAssocAttrs}\ {OneDstAttrs sourceDstAttrs}\ {OtherClass targetClass}\ {OtherCond targetCond}\ {OtherMult targetMult}\ {OtherSrcAttrs targetAssocAttrs}\ {OtherDstAttrs targetDstAttrs} # Create the correlation constraint relvar correlation ${domns}::$relationship ${domns}::$associator\ $sourceAssocAttrs [MapCondMultToConstraint $targetCond $targetMult]\ ${domns}::$sourceClass $sourceDstAttrs\ $targetAssocAttrs [MapCondMultToConstraint $sourceCond $sourceMult]\ ${domns}::$targetClass $targetDstAttrs ; # <1> set ensemblemap [dict create\ link [list ::rosea::RelCmds::linkAssoc $relationship]\ reference [list ::rosea::RelCmds::referenceAssoc $relationship]\ unlink [list ::rosea::RelCmds::unlinkAssoc $relationship]\ ] # Determine if we have any assigners set rpath ${domns}::$relationship set assigner [relation semijoin $bothref $SingleAssigner\ -using {Domain Domain Relationship Relationship}] if {[relation isnotempty $assigner]} { dict set ensemblemap signal\ [list ::rosea::RelCmds::signalAssigner $rpath] } else { set assigner [relation semijoin $bothref $MultipleAssigner\ -using {Domain Domain Relationship Relationship}] if {[relation isnotempty $assigner]} { dict set ensemblemap signal [list\ ::rosea::RelCmds::signalMultiAssigner $rpath] dict set ensemblemap create [list\ ::rosea::RelCmds::createMultiAssigner $rpath] } } namespace ensemble create -command $rpath -map $ensemblemap } variable subrefsQuery set subrefs [eval $subrefsQuery] relvar eval { set sublinks [pipe { relation project $subrefs Relationship ReferringClass | relation rename ~ Relationship Name ReferringClass SrcClass }] set superlinks [pipe { relation project $subrefs Relationship ReferencedClass | relation rename % Relationship Name ReferencedClass SrcClass | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] relvar union ${domns}::__Arch_Link $sublinks $superlinks relvar union ${domns}::__Arch_AssociationLink [pipe { relation project $subrefs Relationship ReferringClass ReferencedClass\ ForwAttrs | relation rename ~ Relationship Name ReferringClass SrcClass\ ReferencedClass DstClass ForwAttrs Attrs | relation extend ~ al PrevSrcClass string {{}} }] relvar union ${domns}::__Arch_PartitionLink $superlinks relvar union ${domns}::__Arch_PartitionDst [pipe { relation project $subrefs Relationship ReferencedClass\ ReferringClass RevAttrs | relation rename % Relationship Name ReferencedClass SrcClass\ ReferringClass DstClass RevAttrs Attrs | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] relvar union ${domns}::__Arch_SuperLink [pipe { relation project $subrefs Relationship ReferencedClass | relation rename ~ ReferencedClass SuperClass }] relvar union ${domns}::__Arch_SubLink [pipe { relation project $subrefs Relationship ReferringClass ReferringAttrs | relation rename ~ ReferringClass SubClass }] } set partrefs [pipe { relation project $subrefs Relationship ReferencedClass DstAttrs\ ReferringClass SrcAttrs | relation extend ~ prs SubAttrMap list {[list\ ${domns}::[tuple extract $prs ReferringClass]\ [tuple extract $prs SrcAttrs]]} | relation eliminate ~ ReferringClass SrcAttrs | relation group ~ SubClassRefs SubAttrMap | relation extend ~ spt SubParts list { [concat {*}[relation list [tuple extract $spt SubClassRefs]]]} | relation eliminate ~ SubClassRefs }] relation foreach partref $partrefs { relation assign $partref\ {Relationship relationship}\ {ReferencedClass superclass}\ {DstAttrs superattrs}\ {SubParts subparts} relvar partition ${domns}::$relationship ${domns}::$superclass\ $superattrs {*}$subparts namespace ensemble create\ -command ${domns}::$relationship\ -map [dict create migrate [list ::rosea::RelCmds::migrate\ $relationship]] } set assigners [relation semijoin $domain $AssignerStateModel\ -using {Name Domain}] relation foreach assigner $assigners { set asgnns\ ${domns}::[relation extract $assigner Relationship]::__Activity namespace eval $asgnns { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe } namespace eval $asgnns [list\ namespace path [list\ ::rosea::InstCmds\ $domns\ ]\ ] set states [pipe { relation semijoin $assigner $State\ -using {Domain Domain Relationship Model} | relation project ~ Name Parameters Action }] relation foreach state $states { relation assign $state\ {Name stateName}\ {Parameters params}\ {Action stateAction} set params [linsert $params 0 self] proc ${asgnns}::$stateName $params $stateAction } } relation foreach sassigner\ [relation semijoin $domain $SingleAssigner\ -using {Name Domain}] { relation assign $sassigner {Relationship relationship} relvar create ${domns}::${relationship}__STATEINST { Id int __State string } Id CreateInInitialState $domns $relationship {Id 0} ; # <1> } relation foreach massigner\ [relation semijoin $domain $MultipleAssigner\ -using {Name Domain}] { relation assign $massigner {Relationship relationship} set assignvar ${domns}::${relationship}__STATEINST set idattrs [pipe { relation semijoin $massigner $Identifier\ $IdentifyingAttribute\ $Attribute -using {Domain Domain Class Class\ Attribute Name} | relation dict ~ Name Type }] relvar create $assignvar\ [concat $idattrs [list __State string]]\ [dict keys $idattrs] } } } proc populate {script} { namespace upvar Config errcount errcount configlineno configlineno set errcount 0 set configlineno 1 ConfigEvaluate ::rosea::Populate $script ; # <1> if {$errcount > 0} { tailcall DeclError CONFIG_ERRORS $errcount } return $errcount } proc populateFromChan {chan} { tailcall populate [::chan read -nonewline $chan] } proc populateFromFile {filename} { set f [::open $filename r] try { populateFromChan $f } finally { ::chan close $f } } proc save {args} { set savecmd ::ral::serializeToFile set asynccmd {} set options $args while {1} { if {[string index [lindex $options 0] 0] eq "-"} { set options [lassign $options option] switch -exact -- $option { -sqlite { set savecmd ::ral::storeToSQLite } -tclral { set savecmd ::ral::serializeToFile } -async { set options [lassign $options asynccmd] } default { tailcall DeclError UNKNOWN_OPTION save $option } } } else { break } } if {[llength $options] == 2} { lassign $options domain file if {[string range $domain 0 1] ne "::"} { # <1> set domrel [relvar restrictone ::rosea::Config::Domain Name $domain] if {[relation isempty $domrel]} { tailcall DeclError UNKNOWN_DOMAIN $domain } set domain [string cat [relation extract $domrel Location]\ :: $domain] } } else { tailcall DeclError SAVE_ARG_ERROR $args } set script "try \{$savecmd $file ${domain}::\\\[A-Za-z0-9\\\]*\}" ; # <2> if {$asynccmd ne {}} { append script " finally \{$asynccmd $domain $file\}" } after idle [list ::apply [list {} $script]] ; # <3> } proc restore {args} { set restorecmd ::ral::mergeFromFile set options $args while {1} { if {[string index [lindex $options 0] 0] eq "-"} { set options [lassign $options option] switch -exact -- $option { -sqlite { set restorecmd ::ral::mergeFromSQLite } -tclral { set restorecmd ::ral::mergeFromFile } default { tailcall DeclError UNKNOWN_OPTION restore $option } } } else { break } } if {[llength $options] == 2} { lassign $options domain file if {[string range $domain 0 1] ne "::"} { set domrel [relvar restrictone ::rosea::Config::Domain Name $domain] if {[relation isempty $domrel]} { tailcall DeclError UNKNOWN_DOMAIN $domain } set domain [string cat [relation extract $domrel Location]\ :: $domain] } } else { tailcall DeclError RESTORE_ARG_ERROR $args } eval [list $restorecmd $file $domain] # Determine the values for the system supplied defaults. We examine all # the classes that have such attributes and find the maximum value of the # attribute. This can then be placed in the array that is used when new # default values are generated. set domainname [namespace tail $domain] set supplied [pipe { relvar set ::rosea::Config::SystemSuppliedValue | relation restrictwith ~ {$Domain eq $domainname} }] relation foreach sup $supplied { relation assign $sup set classtups [relvar set ${domain}::$Class] if {[relation isempty $classtups]} { set maxvalue $StartValue } else { set maxvalue [pipe { relation summarizeby $classtups {} cv\ MaxValue int {rmax($cv, $Attribute)} | relation extract ~ MaxValue }] } set ${domain}::__Arch_SuppliedDefault($Class,$Attribute)\ [expr {$maxvalue + 1}] } return } proc info {args} { set args [lassign $args subcmd] switch -exact -- $subcmd { domain { Info::domain $args } class { Info::class $args } statemodel { Info::statemodel $args } default { tailcall DeclError UNKNOWN_INFO_CMD $subcmd } } } proc tunnel {instref op args} { relvar eval { set result [[lindex $instref 0]::Instance $instref $op {*}$args] } return $result } proc trace {subcmd args} { switch -exact -- $subcmd { control { tailcall traceControl {*}$args } decode { switch -exact -- [lindex $args 0] { all { tailcall Trace::DecodeAllTraces } class { tailcall Trace::DecodeClassTraces {*}[lrange $args 1 end] } target { tailcall Trace::DecodeTargetTraces {*}[lrange $args 1 end] } default { tailcall DeclError UNKNOWN_TRACE_CMD [lindex $args 0] } } } format { tailcall formatTraces {*}$args } diagram { switch -exact -- [lindex $args 0] { all { tailcall Trace::DiagAllTraces {*}[lrange $args 1 end] } class { tailcall Trace::DiagClassTraces {*}[lrange $args 1 end] } target { tailcall Trace::DiagTargetTraces {*}[lrange $args 1 end] } default { tailcall DeclError UNKNOWN_TRACE_CMD [lindex $args 0] } } } default { tailcall DeclError UNKNOWN_TRACE_CMD $subcmd } } } proc traceControl {op args} { switch -exact -- $op { on { namespace upvar Trace traceState traceState set traceState on } off { namespace upvar Trace traceState traceState set traceState off } status { namespace upvar Trace traceState traceState return $traceState } clear { relvar eval { foreach rvar {Trace Creation Polymorphic Transition} { relvar set Trace::$rvar\ [relation emptyof [relvar set Trace::$rvar]] } } namespace upvar Trace traceNumber traceNumber set traceNumber 0 } logon { namespace upvar Trace traceLogState traceLogState set traceLogState on } logoff { namespace upvar Trace traceLogState traceLogState set traceLogState off } loglevel { namespace upvar Trace traceLogLevel traceLogLevel if {[llength $args] != 0} { set traceLogLevel [lindex $args 0] } return $traceLogLevel } save { if {[llength $args] == 0} { DeclError NO_SAVEFILE } ral storeToSQLite [lindex $args 0] ::rosea::Trace::* } default { DeclError BAD_TRACEOP $op } } } proc formatTraces {tracerecs} { if {[llength $tracerecs] == 0} { return {} } set prevtime [dict get [lindex $tracerecs 0] time] foreach rec $tracerecs { dict with rec { append result "[Trace::FormatTimestamp $time]: " append result "[Trace::FormatTimeAsSec\ [expr {$time - $prevtime}]]: " set prevtime $time append result [Trace::FormatTraceRec $rec] \n } } return [string trimright $result] } namespace eval Helpers { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar variable errFormats set errFormats [dict create {*}{ SAME_CLASS {operation is only allowed for references to the same class,\ got "%s" and "%s"} UNKNOWN_STATE {unknown state, "%s", for class, "%s"} UNKNOWN_EVENT {unknown event, "%s", for class, "%s"} NO_CREATION_EVENTS {class, "%s", has no defined creation events} NO_CROSS_DOMAIN {cannot link instances across domains,\ got "%s" and "%s"} UNKNOWN_RELATIONSHIP {unknown relationship, "%s"} NON_PARTICIPANTS {"%s" and "%s" don't participate in %s,\ expected "%s" and "%s"} MUST_BE_SINGULAR {number of referred to instances for "%s" must be one,\ got %d} NOT_IN_ASSOCIATION {"%s" $relvar1 not a participant in "%s"} DIRECTION_REQUIRED {direction argument is required: got "%s"} AMBIGUOUS_UNLINK {"%s" is reflexive and linking via "%s" is ambiguous} NO_SUBCLASS {relationship "%s" does not have a "%s"} NO_ASSIGNER {relationship, "%s", does not have an assigner} NO_IDENTIFIER {bad identifying attributes, expected "%s", got "%s"} UNKNOWN_ASSIGNER {unknown assigner instance, "%s", for relationship, "%s"} UNKNOWN_LINKAGE {unknown relationship, "%s", for class, "%s"} PATH_ERROR {relationship, "%s", from "%s" to "%s", does not end at "%s"} GEN_PATH_ERROR {navigating from superclass, "%s", along generalization "%s",\ does not have "%s" as a subclass} ARG_ERROR {attribute updates must be name / value pairs, got "%s"} ID_UPDATE {cannot update identifying attributes, "%s"} UNKNOWN_ATTRIBUTE {unknown attribute, "%s"} WITH_ATTR_USAGE {wrong arguments, should be,\ "withAttribute attrvarpair1 ?attrvarpair2 ...? body"} ATTR_VAR_SPEC {attribute / variable argument must be a one or two element\ list, got "%s"} INVALID_TIME {invalid time value, "%s"} SINGLE_OR_EMPTY_REF_REQUIRED {single valued or nil reference required, %d found} SINGLE_REF_REQUIRED {single valued reference required, %d found} ASYNC_CREATION_FAILED {asynchronous creation of an instance of class, "%s",\ with attributes, "%s", failed: %s} EVENT_IN_FLIGHT {event, "%s", sent to "%s", which does not exist} CANT_HAPPEN_EVENT {can't happen transition, %s - %s -> %s ==> %s -> CH} CONFIG_ERRORS {encountered %d configuration script errors} EMPTY_NAME {the empty string is not a valid name for a %s} BAD_CLASS_NAME {class names must be begin with an alphanumeric\ character, got: "%s"} DUP_ELEMENT_NAME {a class, relationship or domain operation named, "%s",\ already exists} RESERVED_NAME {names beginning with two underscore characters are reserved,\ "%s" cannot be used as a name in this context} INT_TYPE_REQUIRED {attribute must be of "int" type, got "%s"} INT_VALUE_REQUIRED {an integer value is required, got "%s"} ARG_FORMAT {options and values must come in pairs, got "%s"} UNKNOWN_OPTION {unknown %s command option, "%s"} DUP_OP_NAME {operation call, "%s", already exists} NS_QUALIFIERS {name, "%s", contains namespace qualifiers} TILDE_NAME {names beginning with the tilde character are not allowed\ in this context, "%s"} BAD_RELATIONSHIP_SPEC {bad relationship specifier, "%s"} NEED_ASSOCIATOR {relationship of type, "%s", requires associative class} NEED_REFLEXIVE_PATH {traversal path must be specified for reflexive\ association, %s, %s %s %s} REFLEXIVE_NOT_ALLOWED {associations of type, "%s", cannot be reflexive} TOO_FEW_SUBCLASSES {at least 2 subclasses must be specified, got %d} BAD_CREATION_TARGET {the target of a creation event must be a state,\ got "%s"} PSEUDO_STATE {the transition action, "%s", is not valid as %s} EXPECTED_PSEUDO_STATE {expected CH or IG, got "%s"} RELVAR_TRACE_OP {unexpected relvar trace operation, "%s"} ATTR_CHECK_FAILED {check for attribute, "%s", failed:\ instance value was, "%s": "%s" evaluated to "%s"} UNKNOWN_DOMAIN {unknown domain, "%s"} ARG_MISMATCH {number of population values must be a multiple of %d, got %d} SAVE_ARG_ERROR {wrong number of arguments: expected:\ "save ?-sqlite | -tclral? ?-async <cmdprefix>?\ <domain> <filename>", got: "%s"} RESTORE_ARG_ERROR {wrong number of arguments: expected:\ "restore ?-sqlite | -tclral? <domain> <filename>", got: "%s"} UNKNOWN_INFO_CMD {unknown info request, "%s"} UNKNOWN_CLASS {unknown class, "%s", in domain, "%s"} UNKNOWN_TRACE_CMD {unknown trace subcomand, "%s"} BAD_TRACEOP {unknown trace operation, "%s"} NO_SAVEFILE {no save file name provided} BAD_TRACETYPE {unknown trace type, "%s"} }] proc ToRef {relvar relvalue} { tailcall list $relvar [relation project $relvalue\ {*}[lindex [relvar identifiers $relvar] 0]] ; # <1> } proc nilInstRef {} { return {{} {{} {}}} } proc CreateStateInstance {domns class state idattrs} { tailcall relvar insert ${domns}::${class}__STATEINST\ [concat $idattrs [list __State $state]] } proc CreateInInitialState {domns class idattrs} { set initstate [relvar restrictone ${domns}::__Arch_InitialState\ Class $class] if {[relation isnotempty $initstate]} { CreateStateInstance $domns $class [relation extract $initstate State]\ $idattrs } return } proc CreateStateInstanceFromRef {domns class state ref} { relation foreach inst [lindex $ref 1] { # <1> CreateStateInstance $domns $class $state\ [tuple get [relation tuple $inst]] } return } proc CreateInInitialStateFromRef {domns class ref} { set initstate [relvar restrictone ${domns}::__Arch_InitialState\ Class $class] if {[relation isnotempty $initstate]} { CreateStateInstanceFromRef $domns $class\ [relation extract $initstate State] $ref } return } proc SelfInstRef {{level 2}} { set foundRef false set ref [nilInstRef] for {set ns [uplevel $level namespace current]} {$ns ne "::"}\ {set ns [uplevel [incr level] namespace current]} { if {!$foundRef} { upvar $level self srcself if {[info exists srcself]} { set ref $srcself set foundRef true } } if {[string match {*__Activity*} $ns]} { return $ref ; # <1> } } return [nilInstRef] } namespace export DeclError proc DeclError {errcode args} { variable errFormats set errmsg [format [dict get $errFormats $errcode] {*}$args] tailcall throw [list ROSEA $errcode {*}$args $errmsg] $errmsg } proc SplitRelvarName {relvar {dvarname domain} {cvarname class}} { upvar 1 $dvarname domain $cvarname class set domain [namespace qualifiers $relvar] set class [namespace tail $relvar] } proc PropagatePolyEvents {super} { namespace upvar ::rosea::Config\ DeferredEvent DeferredEvent\ LocalEvent LocalEvent\ Superclass Superclass\ Subclass Subclass\ DeferralPath DeferralPath\ Generalization Generalization ; # <1> set supername [relation extract $super Class] set subs [pipe { relation semijoin $super\ $Generalization -using {Domain Domain Relationship Name}\ $Subclass -using {Domain Domain Name Relationship} }] relation foreach sub $subs { set defrdevents [pipe { relation semijoin $super $DeferralPath\ -using {Domain Domain Class Model Relationship Relationship}\ $DeferredEvent | relation update ~ deftup {1} { tuple update $deftup Model [relation extract $sub Class] } }] set multigens [relation semijoin $sub $Superclass\ -using {Domain Domain Class Class}] if {[relation isempty $multigens]} { relvar minus ::rosea::Config::LocalEvent $defrdevents relvar union ::rosea::Config::Event $defrdevents relvar union ::rosea::Config::EffectiveEvent $defrdevents relvar union ::rosea::Config::MappedEvent [relation extend\ $defrdevents metuple ParentModel string {$supername}] } else { set consumed [relation semijoin $defrdevents $LocalEvent] if {[relation isnotempty $consumed]} { relvar minus ::rosea::Config::LocalEvent $consumed ; # <1> relvar union ::rosea::Config::MappedEvent [relation extend\ $consumed ctup ParentModel string {$supername}] relvar union ::rosea::Config::NonLocalEvent [relation extend\ $consumed nletuple\ Relationship string {[relation extract $sub Relationship]}\ Role string {[relation extract $sub Role]}] set defrdevents [relation minus $defrdevents $consumed] ; # <2> set usedinsubs [pipe { FindSubclassesOf $multigens| relation tclose ~ | relation semijoin $consumed ~ -using {Model Super} | relation semijoin ~ $LocalEvent -using {Sub Model} | relation semijoin $consumed ~ -using {Domain Domain Event Event} }] relvar minus ::rosea::Config::LocalEvent $usedinsubs ; # <3> relvar minus ::rosea::Config::EffectiveEvent $usedinsubs relvar minus ::rosea::Config::Event $usedinsubs } relvar union ::rosea::Config::Event $defrdevents relvar union ::rosea::Config::DeferredEvent $defrdevents relvar union ::rosea::Config::InheritedEvent $defrdevents relvar union ::rosea::Config::DeferralPath [relation join\ $defrdevents $Superclass -using {Domain Domain Model Class}] } relvar union ::rosea::Config::NonLocalEvent [relation extend\ $defrdevents nletuple\ Relationship string {[relation extract $sub Relationship]}\ Role string {[relation extract $sub Role]}] relation foreach multigen $multigens { PropagatePolyEvents $multigen } } } proc FindSubclassesOf {supers} { namespace upvar ::rosea::Config\ Generalization Generalization\ Superclass Superclass\ Subclass Subclass if {[relation isempty $supers]} {# <1> return [relation create {Super string Sub string}] } set supnames [pipe { relation project $supers Class | relation rename ~ Class Super }] ; # <2> set subclasses [relation semijoin $supers\ $Generalization -using {Domain Domain Relationship Name}\ $Subclass -using {Domain Domain Name Relationship}] set subnames [pipe { relation project $subclasses Class | relation rename ~ Class Sub }] ; # <3> set uses [relation times $supnames $subnames] ; # <4> set nextsupers [relation semijoin $subclasses $Superclass\ -using {Domain Domain Class Class}] ; # <5> return [relation union $uses [FindSubclassesOf $nextsupers]] ; # <6> } proc UserDefaultTrace {defheading defvalues op relvar tuple} { tuple create\ [dict merge $defheading [tuple heading $tuple]]\ [dict merge $defvalues [tuple get $tuple]] } proc SupplyDefaultTrace {defheading op relvar tuple} { set attrs [tuple attributes $tuple] ; # <1> SplitRelvarName $relvar domain class ; # <2> foreach {attrname attrtype} $defheading { if {$attrname ni $attrs} { set value [set ${domain}::__Arch_SuppliedDefault($class,$attrname)] ; # <3> incr ${domain}::__Arch_SuppliedDefault($class,$attrname) set tuple [tuple extend $tuple $attrname $attrtype $value] ; # <4> } } return $tuple } proc GenerateDefaultTrace {defheading defcmds op relvar tuple} { set attrs [tuple attributes $tuple] foreach {attrname attrtype} $defheading { if {$attrname ni $attrs} { set value [eval [dict get $defcmds $attrname]] set tuple [tuple extend $tuple $attrname $attrtype $value] } } return $tuple } proc CheckValueTrace {attrchecks op relvar args} { if {$op eq "insert"} { set tuple [lindex $args 0] EvalAttrCheck $attrchecks $tuple return $tuple } elseif {$op eq "update"} { set tuple [lindex $args 1] EvalAttrCheck $attrchecks $tuple return $tuple } elseif {$op eq "set"} { set relvalue [lindex $args 0] relation foreach inst $relvalue { set tuple [relation tuple $inst] EvalAttrCheck $attrchecks $tuple } return $relvalue } else { tailcall DeclError RELVAR_TRACE_OP $op } } proc EvalAttrCheck {attrchecks tuple} { dict for {attrname checkexpr} $attrchecks { tuple assign $tuple set result [expr $checkexpr] if {!$result} { tailcall DeclError ATTR_CHECK_FAILED $attrname [tuple get $tuple]\ $checkexpr $result } } } proc QuerySystemOperations {which requiresSM} { return [pipe { relvar set ::rosea::Config::SuppliedOperation | relation restrictwith ~ {$RequiresStateModel == $requiresSM} | relation join [relvar set ::rosea::Config::$which] ~ }] } proc QuerySystemClassOperations {className requiresSM} { return [pipe { QuerySystemOperations SystemClassOperation $requiresSM | relation update ~ sco 1 { tuple update $sco Command\ [concat [tuple extract $sco Command]\ [list $className]] } | relation dict ~ Name Command }] } proc QuerySystemInstanceOperations {requiresSM} { return [pipe { QuerySystemOperations SystemInstanceOperation $requiresSM | relation dict ~ Name Command }] } proc Interleave {l1 l2} { set result [list] foreach a $l1 b $l2 { lappend result $a $b } return $result } proc MapCondMultToConstraint {cond mult} { if {$cond} { return [expr {$mult ? "*" : "?"}] } else { return [expr {$mult ? "+" : "1"}] } } } namespace eval ClassCmds { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path [namespace parent]::Helpers ; # <1> proc findAll {relvar} { tailcall ToRef $relvar [relvar set $relvar] } proc findById {relvar args} { tailcall ToRef $relvar [relvar restrictone $relvar {*}$args] } proc findWhere {relvar expr} { tailcall ToRef $relvar [uplevel 1 [list ::ral relation restrictwith\ [relvar set $relvar] $expr]] } proc create {relvar args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } set ref [ToRef $relvar [relvar insert $relvar $args]] ; # <1> SplitRelvarName $relvar domain class CreateInInitialStateFromRef $domain $class $ref return $ref } proc createin {relvar state args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } SplitRelvarName $relvar domain class set initstate [relvar restrictone ${domain}::__Arch_State\ Class $class State $state] if {[relation isempty $initstate]} { # <1> tailcall DeclError UNKNOWN_STATE $state $relvar } set ref [ToRef $relvar [relvar insert $relvar $args]] CreateStateInstanceFromRef $domain $class $state $ref return $ref } proc createasync {relvar event eventparams args} { SplitRelvarName $relvar domain class if {[relation isempty [relvar restrictone ${domain}::__Arch_Event\ Class $class Event $event]]} { tailcall DeclError UNKNOWN_EVENT $event $class } if {[relation isempty [relvar restrictone ${domain}::__Arch_State\ Class $class State @]]} { tailcall DeclError NO_CREATION_EVENTS $class } set srcref [SelfInstRef] set eventInfo [dict create\ type creation\ src $srcref\ dstClass $relvar\ dstAttrs $args\ event $event\ params $eventparams\ ] if {[::rosea::InstCmds::isRefEqual $srcref [nilInstRef]]} { lappend ::rosea::Dispatch::toc_queue $eventInfo } else { lappend ::rosea::Dispatch::event_queue $eventInfo } ::after 0 ::rosea::Dispatch::DispatchEvent return } proc update {relvar relvalue} { tailcall ToRef $relvar [relvar updateper $relvar $relvalue] } } namespace eval InstCmds { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace path [namespace parent]::Helpers pipe { relvar set ${domain}::$DstClass | relation $op $related ~ -using $Attrs } relatedQuery proc deRef {instref args} { lassign $instref relvar ref set inst [relation semijoin $ref [relvar set $relvar]] ; # <1> if {[llength $args] != 0} { set inst [relation project $inst\ {*}[relation attributes $ref] {*}$args] ; # <2> } return $inst } proc isEmptyRef {instref} { tailcall relation isempty [lindex $instref 1] } proc isNotEmptyRef {instref} { tailcall relation isnotempty [lindex $instref 1] } proc refMultiplicity {instref} { tailcall relation cardinality [lindex $instref 1] } proc isRefSingular {instref} { expr {[refMultiplicity $instref] == 1} } proc limitRef {instref {count 1}} { lassign $instref relvar insts return [pipe { relation tag $insts __Tag | relation restrictwith ~ {$__Tag >= 0 && $__Tag < $count} | ToRef $relvar ~ }] } proc isRefEqual {instref1 instref2} { lassign $instref1 relvar1 inst1 lassign $instref2 relvar2 inst2 return [expr {$relvar1 eq $relvar2 && [relation is $inst1 equal $inst2]}] } proc RefSetCommand {op instref1 instref2} { lassign $instref1 relvar1 inst1 lassign $instref2 relvar2 inst2 if {$relvar1 ne $relvar2} { tailcall DeclError SAME_CLASS $relvar1 $relvar2 } return [list $relvar1 [relation $op $inst1 $inst2]] } proc refUnion {instref1 instref2} { tailcall RefSetCommand union $instref1 $instref2 } proc refIntersect {instref1 instref2} { tailcall RefSetCommand intersect $instref1 $instref2 } proc refMinus {instref1 instref2} { tailcall RefSetCommand minus $instref1 $instref2 } proc forAllRefs {varname instref body} { lassign $instref relvar refs upvar 1 $varname inst relation foreach ref $refs { set inst [list $relvar $ref] uplevel 1 $body } ; # <1> return } proc FindRelatedInsts {instref op args} { set srcrelvar [lindex $instref 0] SplitRelvarName $srcrelvar domain class # This procedure queries the architectural data about relationship linkage, # so we bring the relvar variables into scope. namespace upvar ${domain}\ __Arch_Link Link\ __Arch_AssociationLink AssociationLink\ __Arch_PartitionLink PartitionLink\ __Arch_PartitionDst PartitionDst variable relatedQuery ; # <1> # We start by dereferencing the instance reference. set related [deRef $instref] foreach linkage $args { lassign $linkage lname dst ; # split out the linkage spec set link [relvar restrictone ${domain}::__Arch_Link\ Name $lname SrcClass $class] if {[ral relation isempty $link]} { tailcall DeclError UNKNOWN_LINKAGE $lname $class } # First we determine if we are dealing with an associative link or a # partition link. set assoc [relation join $link $AssociationLink] if {[relation isnotempty $assoc]} { relation assign $assoc DstClass Attrs # Check if additional path information was provided. if {$dst eq {}} { # Find the set of instances related to the current set. set related [eval $relatedQuery] # We must see if this is a class-based association. If so, then the first # traversal was to the associator and we must traverse again to the other # class. set assoc [relation semijoin $assoc $AssociationLink\ -using {Name Name SrcClass PrevSrcClass}] if {[relation isnotempty $assoc]} { relation assign $assoc DstClass Attrs set related [pipe {# <1> relvar set ${domain}::$DstClass | relation semijoin $related ~ -using $Attrs }] } } else { # If a destination was specified in the linkage, then we need to verify # that it is actually part of the relationship. if {$dst ne $DstClass} { tailcall DeclError PATH_ERROR $lname $class $DstClass\ $dst } set related [eval $relatedQuery] } } else { set partdst [relvar restrictone ${domain}::__Arch_PartitionDst\ Name $lname SrcClass $class DstClass $dst] if {[relation isempty $partdst]} { tailcall DeclError GEN_PATH_ERROR $class $lname $dst } relation assign $partdst DstClass Attrs set related [eval $relatedQuery] } # Continue the iteration by setting the next source to the current # destination class. set class $DstClass set srcrelvar ${domain}::$class } # N.B. that we are not returning an instance reference but rather the # complete relation value of the related instances. This allows us # to further filter the result in the "findRelatedWhere" command. return [list $srcrelvar $related] } proc findRelated {instref args} { tailcall ToRef {*}[FindRelatedInsts $instref semijoin {*}$args] ; # <1> } proc findUnrelated {instref args} { tailcall ToRef {*}[FindRelatedInsts $instref semiminus {*}$args] ; # <1> } proc findRelatedWhere {instref rchain expr} { lassign [FindRelatedInsts $instref semijoin {*}$rchain] relvar insts tailcall ToRef $relvar [uplevel 1\ [list ::ral relation restrictwith $insts $expr]] ; # <1> } proc findUnrelatedWhere {instref rchain expr} { lassign [FindRelatedInsts $instref semiminus {*}$rchain] relvar insts tailcall ToRef $relvar [uplevel 1\ [list ::ral relation restrictwith $insts $expr]] } proc idInstance {instref} { lassign $instref relvar insts SplitRelvarName $relvar domain relationship set assignrelvar ${domain}::${relationship}__STATEINST if {![relvar exists $assignrelvar]} { tailcall DeclError NO_ASSIGNER $rname } set idclass [pipe { relvar restrictone [namespace parent]::Config::MultipleAssigner\ Domain [string trim $domain :] Relationship $relationship | relation extract ~ Class }] return [pipe { relvar set ${domain}::$idclass | relation semijoin $insts ~ | ToRef ${domain}::$idclass ~ }] } proc updateAttribute {instref args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_ERROR $args } lassign $instref relvar insts if {[relation cardinality $insts] != 1} { tailcall MUST_BE_SINGULAR $relvar [relation cardinality $insts] } set idattrs [list] foreach identifier [relvar identifiers $relvar] { ::struct::set add idattrs $identifier } set idupdates [::struct::set intersect $idattrs $args] if {![::struct::set empty $idupdates]} { tailcall DeclError ID_UPDATE [join $idupdates {, }] } set extcmd [list relation extend $insts exttuple] set heading [relation heading [relvar set $relvar]] foreach {attr value} $args { if {![dict exists $heading $attr]} { tailcall DeclError UNKNOWN_ATTRIBUTE $attr } lappend extcmd $attr [dict get $heading $attr] \{$value\} } relvar updateper $relvar [eval $extcmd] return } proc withAttribute {instref args} { if {[llength $args] < 2} { tailcall DeclError WITH_ATTR_USAGE } lassign $instref relvar insts if {[relation cardinality $insts] != 1} { tailcall MUST_BE_SINGULAR $relvar [relation cardinality $insts] } set body [lindex $args end] set attrspecs [lrange $args 0 end-1] set attrnames [list] set varnames [list] foreach attrspec $attrspecs { set speclen [llength $attrspec] if {$speclen == 1} { lappend attrnames [lindex $attrspec 0] lappend varnames [lindex $attrspec 0] } elseif {$speclen == 2} { lappend attrnames [lindex $attrspec 0] lappend varnames [lindex $attrspec 1] } else { tailcall DeclError ATTR_VAR_SPEC $attrspec } } set idattrs [list] foreach identifier [relvar identifiers $relvar] { ::struct::set add idattrs $identifier } set idupdates [::struct::set intersect $idattrs $attrnames] if {![::struct::set empty $idupdates]} { tailcall DeclError ID_UPDATE [join $idupdates {, }] } uplevel 1 [list ral relation assign [deRef $instref] {*}$attrspecs] uplevel 1 $body set extcmd [list relation extend $insts exttuple] set heading [relation heading [relvar set $relvar]] foreach attr $attrnames var $varnames { if {[uplevel 1 [list info exists $var]]} { upvar 1 $var varvalue lappend extcmd $attr [dict get $heading $attr] \{$varvalue\} } } relvar updateper $relvar [eval $extcmd] return } proc readAttribute {ref args} { # We insist upon a singular reference for reading attributes. Multiple # references can be handled by dereferences and using TclRAL "relation" # commands. if {![isRefSingular $ref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $ref] } return [expr {[llength $args] == 0 ? {} :\ [relation extract [deRef $ref {*}$args] {*}$args]}] ; # <1> } proc assignAttribute {ref args} { # We must insist upon a singular references, since assigning to scalar # variables from a relation value doesn't make a lot of sense. if {![isRefSingular $ref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $ref] } uplevel 1 [list ral relation assign [deRef $ref] {*}$args] ; # <1> return } proc delete {args} { foreach instref $args { lassign $instref relvar insts relvar minus $relvar [deRef $instref] SplitRelvarName $relvar domain class set instrelvar ${domain}::${class}__STATEINST if {[relvar exists $instrelvar]} { relvar minus $instrelvar [relation semijoin $insts\ [relvar set $instrelvar]] } } return } proc signal {dstset event args} { set srcref [SelfInstRef] if {![::rosea::Dispatch::MapPolymorphicEvent ::rosea::Dispatch::SignalEvent\ $srcref $dstset $event $args]} { ::rosea::Dispatch::SignalEvent $srcref $dstset $event $args } return } proc delaysignal {time dstset event args} { if {!([string is integer -strict $time] && $time >= 0)} { tailcall DeclError INVALID_TIME $time } set srcref [SelfInstRef] if {![::rosea::Dispatch::MapPolymorphicEvent\ [list ::rosea::Dispatch::SignalDelayedEvent $time]\ $srcref $dstset $event $args]} { ::rosea::Dispatch::SignalDelayedEvent $time $srcref $dstset $event $args } return } proc canceldelayed {srcref dstset event} { set srcmult [refMultiplicity $srcref] if {$srcmult > 1} { tailcall DeclError SINGLE_OR_EMPTY_REF_REQUIRED $srcmult } forAllRefs dstref $dstset { ::rosea::Dispatch::CancelDelayedSignal $srcref $event $dstref } return } proc delayremaining {srcref dstref event} { set srcmult [refMultiplicity $srcref] if {$srcmult > 1} { tailcall DeclError SINGLE_OR_EMPTY_REF_REQUIRED $srcmult } if {![isRefSingular $dstref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $dstref] } tailcall ::rosea::Dispatch::SignalTimeRemaining $srcref $event $dstref } proc instop {instref op args} { tailcall [lindex $instref 0]::Instance $instref $op {*}$args } } namespace eval RelCmds { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path [list\ [namespace parent]::Helpers\ [namespace parent]::InstCmds\ ] proc linkSimple {rname instref1 instref2} { lassign $instref1 relvar1 inst1 SplitRelvarName $relvar1 domain1 class1 lassign $instref2 relvar2 inst2 SplitRelvarName $relvar2 domain2 class2 if {$domain1 ne $domain2} { tailcall DeclError NO_CROSS_DOMAIN $domain1 $domain2 } set reflink [relvar restrictone ${domain1}::__Arch_RefLink Relationship $rname] if {[relation isempty $reflink]} { tailcall DeclError UNKNOWN_RELATIONSHIP $rname } relation assign $reflink\ {ReferringClass referringClass}\ {ReferencedClass referencedClass}\ {ReferringAttrs referringAttrs} ; # <1> if {$class1 eq $referringClass && $class2 eq $referencedClass} { set fromrelvar $relvar1 set frominsts $inst1 set torelvar $relvar2 set toinst $inst2 } elseif {$class2 eq $referringClass && $class1 eq $referencedClass} { set fromrelvar $relvar2 set frominsts $inst2 set torelvar $relvar1 set toinst $inst1 } else { tailcall DeclError NON_PARTICIPANTS $relvar1 $relvar2 $rname\ $referringClass $referencedClass } if {[relation cardinality $toinst] != 1} { tailcall MUST_BE_SINGULAR $torelvar [relation cardinality $toinst] } set refedvalue [relation semijoin $toinst [relvar set $torelvar]] set tovalues [pipe { relation extend $referringAttrs rfa RefValue string { [relation extract $refedvalue\ [tuple extract $rfa ReferencedAttribute]]} | relation dict ~ ReferringAttribute RefValue }] relation foreach frominst $frominsts { relvar updateone $fromrelvar fromtup\ [tuple get [relation tuple $frominst]] { # <1> tuple update $fromtup {*}$tovalues ; # <2> } } return } proc linkAssoc {rname instref1 instref2 args} { lassign $instref1 relvar1 inst1 SplitRelvarName $relvar1 domain1 class1 lassign $instref2 relvar2 inst2 SplitRelvarName $relvar2 domain2 class2 if {$domain1 ne $domain2} { tailcall DeclError NO_CROSS_DOMAIN $domain1 $domain2 } set assocref [relvar restrictone ${domain1}::__Arch_AssocRef\ Relationship $rname] if {[relation isempty $assocref]} { tailcall DeclError UNKNOWN_RELATIONSHIP $rname } relation assign $assocref\ {AssocClass assocClass}\ {References references} set ref1 [relation restrictwith $references {$Participant eq $class1}] if {[relation isempty $ref1]} { tailcall DeclError NOT_IN_ASSOCIATION $class1 $rname } if {[relation cardinality $ref1] > 1} { set ref2 [relation restrictwith $ref1 {$Role eq "target"}] set ref1 [relation minus $ref1 $ref2] ; # <1> } else { set ref2 [relation restrictwith $references {$Participant eq $class2}] if {[relation isempty $ref2]} { tailcall DeclError NOT_IN_ASSOCIATION $class2 $rname } } set rattr1 [relation extract $ref1 ReferringAttrs] set rattr2 [relation extract $ref2 ReferringAttrs] set values1 [relation semijoin $inst1 [relvar set $relvar1]] set values2 [relation semijoin $inst2 [relvar set $relvar2]] set assoctuples [list] relation foreach v1 $values1 { # <1> set refto1 [pipe { relation extend $rattr1 rfa RefValue string { [relation extract $v1 [tuple extract $rfa ReferencedAttribute]] } | relation dict ~ ReferringAttribute RefValue }] relation foreach v2 $values2 { set refto2 [pipe { relation extend $rattr2 rfa RefValue string { [relation extract $v2\ [tuple extract $rfa ReferencedAttribute]] } | relation dict ~ ReferringAttribute RefValue }] lappend assoctuples [dict merge $args $refto1 $refto2] ; # <2> } } set ref [ToRef ${domain1}::$assocClass\ [relvar insert ${domain1}::$assocClass {*}$assoctuples]] CreateInInitialStateFromRef $domain1 $assocClass $ref ; # <1> return $ref } proc referenceAssoc {rname assocref instref {dir {}}} { if {![isRefSingular $assocref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $assocref] } lassign $assocref assocrelvar associnst SplitRelvarName $assocrelvar assocdomain assocclass if {![isRefSingular $instref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $instref] } lassign $instref instrelvar inst SplitRelvarName $instrelvar instdomain instclass if {$assocdomain ne $instdomain} { tailcall DeclError NO_CROSS_DOMAIN $domain1 $domain2 } set assocref [relvar restrictone ${instdomain}::__Arch_AssocRef\ Relationship $rname] if {[relation isempty $assocref]} { tailcall DeclError UNKNOWN_RELATIONSHIP $rname } relation assign $assocref\ {AssocClass assocClass}\ {References references} if {$assocClass ne $assocclass} { tailcall DeclError NOT_IN_ASSOCIATION $assocclass $rname } set ref [relation restrictwith $references {$Participant eq $instclass}] set refcard [relation cardinality $ref] if {$refcard == 2} { switch -exact -- $dir { forward { set role target } backward { set role source } default { tailcall DeclError DIRECTION_REQUIRED $dir } } set ref [relation restrictwith $ref {$Role eq $role}] } elseif {$refcard == 0} { tailcall DeclError NOT_IN_ASSOCIATION $instclass $rname } set referringAttrs [relation extract $ref ReferringAttrs] set refedvalue [relation semijoin $inst [relvar set $instrelvar]] set tovalues [pipe { relation extend $referringAttrs rfa RefValue string { [relation extract $refedvalue\ [tuple extract $rfa ReferencedAttribute]]} | relation dict ~ ReferringAttribute RefValue }] relvar updateone $assocrelvar assoctup [tuple get [relation tuple $associnst]] { tuple update $assoctup {*}$tovalues } } proc unlinkSimple {rname instref} { lassign $instref relvar inst SplitRelvarName $relvar domain class set reflink [relvar restrictone ${domain}::__Arch_RefLink\ Relationship $rname] if {[relation isempty $reflink]} { tailcall DeclError UNKNOWN_RELATIONSHIP $rname } relation assign $reflink\ {ReferringClass referringClass}\ {ReferencedClass referencedClass}\ {ReferringAttrs referringAttrs} if {$class eq $referringClass} { set fromrelvar $relvar set frominsts $inst } elseif {$class eq $referencedClass} { lassign [::rosea::InstCmds::findRelated $instref ~$rname]\ fromrelvar frominsts } else { tailcall DeclError NOT_IN_ASSOCIATION $relvar $rname } set tovalues [pipe { relation extend $referringAttrs rfa RefValue string {{}} | relation dict ~ ReferringAttribute RefValue }] relation foreach frominst $frominsts { relvar updateone $fromrelvar fromtup\ [tuple get [relation tuple $frominst]] { tuple update $fromtup {*}$tovalues } } return } proc unlinkAssoc {rname instref} { lassign $instref relvar insts SplitRelvarName $relvar domain class set assocref [relvar restrictone ${domain}::__Arch_AssocRef\ Relationship $rname] if {[relation isempty $assocref]} { tailcall DeclError UNKNOWN_RELATIONSHIP $rname } relation assign $assocref\ {Relationship relationship}\ {AssocClass associator}\ {References references} # If we are given instances to the associator class, then there is no # more work to do. if {$class ne $associator} { # Otherwise, we have to find the associator class instances ourselves. set part [relation restrictwith $references {$Participant eq $class}] set partcard [relation cardinality $part] if {$partcard == 0} { tailcall DeclError NOT_IN_ASSOCIATION $class $rname } elseif {$partcard > 1} { tailcall DeclError AMBIGUOUS_UNLINK $rname $relvar ; # <1> } else { # Find associative class instances. We have to determine the # direction of the relationship traversal. set navdir [expr {[relation extract $part Role] eq "source" ?\ "$relationship" : "~$relationship"}] set instref [::rosea::InstCmds::findRelated $instref\ [list $navdir [namespace tail $associator]]] lassign $instref relvar insts SplitRelvarName $relvar domain class } } # We are going to delete tuples from the relvar that holds the class # instances. set delrelvars [list ${domain}::$class] # If the associative class also has a state model, then we need to also # delete the state instance tuples. if {[relvar exists ${domain}::${class}__STATEINST]} { lappend delrelvars ${domain}::${class}__STATEINST } # Now, we iterate across the associative class instances and delete all the # tuples in class relvar and, if necessary, the state instances. relation foreach inst $insts { set idattrs [tuple get [relation tuple $inst]] foreach rv $delrelvars { relvar deleteone $rv {*}$idattrs } } return $instref } proc migrate {rname instref subclass args} { if {![isRefSingular $instref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $instref] } lassign $instref relvar inst SplitRelvarName $relvar domns class set link [relvar restrictone ${domns}::__Arch_AssociationLink Name $rname\ SrcClass $class] if {[relation isempty $link]} { tailcall DeclError NO_SUBCLASS $rname $relvar } # Traverse the relationship to the superclass. We need to get the values of # the referenced attributes to use in creating the new subclass instance. set superinst [pipe { relvar set ${domns}::[relation extract $link DstClass] | relation semijoin $inst ~ -using [relation extract $link Attrs] }] set sublink [relvar restrictone ${domns}::__Arch_SubLink\ Relationship $rname SubClass $subclass] if {[relation isempty $sublink]} { tailcall DeclError NO_SUBCLASS $rname $subclass } # Using the same relation extend strategy, we compute a dictionary of the # attribute names / values as they must appear in the subclass we are about # to create. set refedvalues [pipe { relation extract $sublink ReferringAttrs | relation extend ~ rval Value string { [relation extract $superinst\ [tuple extract $rval ReferencedAttribute]] } | relation dict ~ ReferringAttribute Value }] # We use the class commands to delete the old subclass instance and create # the new one. This will make sure that if the subclass has a state model # that the initial state is set correctly. # N.B. this is _not_ done in a relvar transaction. The transaction # boundaries should be set by the current thread of control or domain # operation. ::rosea::InstCmds::delete $instref return [::rosea::ClassCmds::create ${domns}::$subclass\ {*}[dict merge $args $refedvalues]] } proc signalAssigner {rname event args} { SplitRelvarName $rname domain relationship set assignrelvar ${domain}::${relationship}__STATEINST if {![relvar exists $assignrelvar]} { tailcall DeclError NO_ASSIGNER $rname } set dstref [pipe { relvar set $assignrelvar | relation project ~ {*}[lindex [relvar identifiers $assignrelvar] 0] | list $rname ~ }] ::rosea::Dispatch::SignalEvent [SelfInstRef] $dstref $event $args return } proc signalMultiAssigner {rname idvalues event args} { SplitRelvarName $rname domain relationship set assignrelvar ${domain}::${relationship}__STATEINST if {![relvar exists $assignrelvar]} { tailcall DeclError NO_ASSIGNER $rname } set idattrs [lindex [relvar identifiers $assignrelvar] 0] # We will insist that the idvalues contain the necessary identifying # attributes. if {![struct::set equal [dict keys $idvalues] $idattrs]} { tailcall DeclError NO_IDENTIFIER [dict keys $idvalues] $idattrs } set assigninsts [relvar set $assignrelvar] set assignrefs [relation project $assigninsts {*}$idattrs] # We need to find the tuple in "assignrefs" that matches the attributes and # values in "idvalues". We will do this by creating a relation value from # the idvalues list and semijoining that to "assignrefs". If we come up # non-empty, then we have found our multi-assigner instance. set heading [relation heading $assignrefs] set dstinst [pipe { tuple create $heading $idvalues | tuple relation ~ | relation semijoin ~ $assignrefs }] if {[relation isempty $dstinst]} { tailcall DeclError UNKNOWN_ASSIGNER $idvalues $rname } set dstref [list $rname $dstinst] ::rosea::Dispatch::SignalEvent [SelfInstRef] $dstref $event $args ; # <1> return } proc createMultiAssigner {rname args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } SplitRelvarName $rname domain relationship set assignrelvar ${domain}::${relationship}__STATEINST if {![relvar exists $assignrelvar]} { tailcall DeclError NO_ASSIGNER $rname } set idattrs [lindex [relvar identifiers $assignrelvar] 0] if {![struct::set equal [dict keys $args] $idattrs]} { tailcall DeclError NO_IDENTIFIER [dict keys $args] $idattrs } CreateInInitialState $domain $relationship $args } } namespace eval Dispatch { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path [list\ [namespace parent]::Helpers\ [namespace parent]::InstCmds\ ] variable toc_queue [list] variable event_queue [list] pipe { relvar restrictone ${domain}::__Arch_Transition\ Class $class State $currstate Event $event | relation extract ~ NewState } transitionQuery relvar create DelayedSignal { RefId int SrcInstRef list Event string DstInstRef list TimerId string Expire bignum } RefId {SrcInstRef Event DstInstRef} TimerId variable DelayedSignalId 0 pipe { relvar set ${domain}::__Arch_PartitionDst | relation restrictwith ~ {$SrcClass eq $dstclass} | relation group ~ DstLinks DstClass Attrs } polymapQuery proc SignalEvent {srcref dstset event arglist} { lassign $dstset relvar insts SplitRelvarName $relvar domain class if {[relation isempty [relvar restrictone ${domain}::__Arch_Event\ Class $class Event $event]]} { tailcall DeclError UNKNOWN_EVENT $event $class } set callback [namespace code DispatchEvent] set eventInfo [dict create\ type ordinary\ src $srcref\ event $event\ params $arglist\ ] if {[isRefEqual $srcref [nilInstRef]]} { variable toc_queue forAllRefs dstref $dstset { # Queue the thread of control events. dict set eventInfo dst $dstref lappend toc_queue $eventInfo ::after 0 $callback } } else { variable event_queue forAllRefs dstref $dstset { dict set eventInfo dst $dstref if {[isRefEqual $srcref $dstref]} { # <1> for {set eqindex 0} {$eqindex < [llength $event_queue]} {incr eqindex} { set cmpevent [lindex $event_queue $eqindex] if {![isRefEqual [dict get $cmpevent src] [dict get $cmpevent dst]]} { break } } set event_queue [linsert [K $event_queue [set event_queue {}]]\ $eqindex $eventInfo] ; # <1> } else { # Non-self directed events are always simply appended to the # event queue. lappend event_queue $eventInfo } ::after 0 $callback } } } proc DispatchEvent {} { variable event_queue variable toc_queue if {[llength $event_queue] != 0} { set eventInfo [lindex $event_queue 0] set event_queue [lrange [K $event_queue [set event_queue {}]] 1 end] ; # <1> } elseif {[llength $toc_queue] != 0} { set eventInfo [lindex $toc_queue 0] set toc_queue [lrange [K $toc_queue [set toc_queue {}]] 1 end] relvar transaction begin ; # <2> } else { return } if {[dict get $eventInfo type] eq "creation"} { try { set dstref [::rosea::ClassCmds::createin\ [dict get $eventInfo dstClass] @\ {*}[dict get $eventInfo dstAttrs]] ; # <1> } on error {result} { catch { if {[llength $event_queue] == 0} { relvar transaction end } } tailcall DeclError ASYNC_CREATION_FAILED [dict get $eventInfo dstClass]\ [dict get $eventInfo dstAttrs] $result } dict set eventInfo dst $dstref ; # <2> ::rosea::Trace::TraceCreation [dict get $eventInfo src]\ [dict get $eventInfo event] $dstref [dict get $eventInfo params] } set dstref [dict get $eventInfo dst] lassign $dstref relvar ref SplitRelvarName $relvar domain class set instrelvar ${domain}::${class}__STATEINST set state [relation semijoin $ref [relvar set $instrelvar]] if {[relation isempty $state]} { tailcall DeclError EVENT_IN_FLIGHT [dict get $eventInfo event] $ref } set currstate [relation extract $state __State] set event [dict get $eventInfo event] variable transitionQuery set newState [eval $transitionQuery] ::rosea::Trace::TraceTransition [dict get $eventInfo src]\ $event $dstref $currstate $newState [dict get $eventInfo params] ; # <1> try { if {$newState eq "CH"} { TransitionError [dict get $eventInfo src] $event $dstref $currstate } elseif {$newState ne "IG"} { set idattrs [tuple get [relation tuple $ref]] relvar updateone $instrelvar is $idattrs { tuple update $is __State $newState } try { ${relvar}::__Activity::$newState $dstref\ {*}[dict get $eventInfo params] ; # <1> } on error {result opts} { return -options $opts $result } finally { set term [relvar restrictone ${domain}::__Arch_TerminalState\ Class $class State $newState] if {[relation isnotempty $term]} { relvar deleteone $relvar {*}$idattrs relvar deleteone $instrelvar {*}$idattrs } } } } on error {result opts} { catch { if {[llength $event_queue] == 0} { relvar transaction end } } ; # <1> return -options $opts $result } if {[llength $event_queue] == 0} { relvar transaction end } return } proc TransitionError {src event dst currstate} { tailcall DeclError CANT_HAPPEN_EVENT $src $event $dst $currstate } proc FindDelayedSignal {srcref event dstref} { variable DelayedSignal return [relation restrictwith $DelayedSignal { [isRefEqual $SrcInstRef $srcref] && $Event eq $event &&\ [isRefEqual $DstInstRef $dstref]}] } proc DeleteDelayedSignal {srcref event dstref} { relvar delete DelayedSignal dsig { [isRefEqual [tuple extract $dsig SrcInstRef] $srcref] &&\ [tuple extract $dsig Event] eq $event &&\ [isRefEqual [tuple extract $dsig DstInstRef] $dstref] } } proc SignalDelayedEvent {time srcref dstset event arglist} { lassign $dstset relvar insts SplitRelvarName $relvar domain class if {[relation isempty [relvar restrictone ${domain}::__Arch_Event\ Class $class Event $event]]} { tailcall DeclError UNKNOWN_EVENT $event $class } variable DelayedSignalId set eventInfo [dict create\ id [incr DelayedSignalId]\ type ordinary\ src $srcref\ event $event\ params $arglist\ ] forAllRefs dstref $dstset { dict set eventInfo dst $dstref DeleteDelayedSignal $srcref $event $dstref ; # <1> relvar insert DelayedSignal [list\ RefId $DelayedSignalId\ SrcInstRef $srcref\ Event $event\ DstInstRef $dstref\ TimerId [::after $time [list\ ::rosea::Dispatch::DispatchDelayedEvent $eventInfo]]\ Expire [expr {entier([clock milliseconds]) + entier($time)}]\ ] } return } proc DispatchDelayedEvent {eventInfo} { relvar deleteone DelayedSignal RefId [dict get $eventInfo id] variable toc_queue lappend toc_queue $eventInfo tailcall DispatchEvent } proc CancelDelayedSignal {srcref event dstref} { variable DelayedSignal set sig [FindDelayedSignal $srcref $event $dstref] if {[relation isnotempty $sig]} { ::after cancel [relation extract $sig TimerId] DeleteDelayedSignal $srcref $event $dstref } else { # Search the toc_queue to see if the signal delay has already expired # and the event is awaiting dispatch. variable toc_queue for {set i 0} {$i < [llength $toc_queue]} {incr i} { set eventInfo [lindex $toc_queue $i] dict update eventInfo src evtsrc dst evtdst event evtevent { if {[isRefEqual $evtsrc $srcref] &&\ [isRefEqual $evtdst $dstref] &&\ $evtevent eq $event} { set toc_queue [lreplace\ [K $toc_queue [set toc_queue {}]] $i $i] break } } } } } proc SignalTimeRemaining {srcref event dstref} { set sig [FindDelayedSignal $srcref $event $dstref] return [expr {[relation isempty $sig] ? 0 :\ max([relation extract $sig Expire] - [clock milliseconds], 0)}] ; # <1> } proc MapPolymorphicEvent {frwdcmd srcref dstrefs event arglist} { lassign $dstrefs dstrelvar dstinsts SplitRelvarName $dstrelvar domain dstclass set polyevent [relvar restrictone ${domain}::__Arch_PolymorphicEvent\ Class $dstclass Event $event] if {[relation isempty $polyevent]} { return false } variable polymapQuery set partitions [eval $polymapQuery] relation foreach inst $dstinsts { relation foreach partition $partitions { relation assign $partition relation foreach dstlink $DstLinks { relation assign $dstlink set related [relation semijoin $inst\ [relvar set ${domain}::$DstClass] -using $Attrs] if {[relation isnotempty $related]} { set dstreference [ToRef ${domain}::${DstClass} $related] set target [ToRef $dstrelvar $inst] ::rosea::Trace::TracePolymorphic $srcref $event $target $dstreference $Name\ $arglist if {![MapPolymorphicEvent $frwdcmd $srcref $dstreference $event $arglist]} { {*}$frwdcmd $srcref $dstreference $event $arglist ; # <1> } break } } } } return true } } namespace eval Config { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path [namespace parent]::Helpers variable evalLambda {{body} { upvar #0 ::rosea::Config::errcount errcount ; # <1> upvar #0 ::rosea::Config::configlineno configlineno set lineno $configlineno set command {} foreach line [split $body \n] { # <2> append command $line \n incr lineno ; # <3> if {[info complete $command]} { try { eval $command } on error {result} { log::error "line $configlineno: \"$result\"" incr errcount } set command {} ; # <4> set configlineno $lineno } } return $errcount }} relvar create Domain { Name string Location string } Name relvar create DomainElement { Domain string Element string } {Domain Element} relvar association R1\ DomainElement Domain *\ Domain Name 1 relvar create Class { Domain string Name string } {Domain Name} relvar create Relationship { Domain string Name string } {Domain Name} relvar create DomainOperation { Domain string Name string Parameters list Body string } {Domain Name} relvar partition R2 DomainElement {Domain Element}\ Class {Domain Name}\ Relationship {Domain Name}\ DomainOperation {Domain Name} relvar create Attribute { Domain string Class string Name string Type string } {Domain Class Name} relvar association R3\ Attribute {Domain Class} +\ Class {Domain Name} 1 relvar create Identifier { Domain string Class string Number int } {Domain Class Number} relvar association R4\ Identifier {Domain Class} +\ Class {Domain Name} 1 relvar create IdentifyingAttribute { Domain string Class string Attribute string Number int } {Domain Class Attribute Number} relvar correlation R5 IdentifyingAttribute\ {Domain Class Number} + Identifier {Domain Class Number}\ {Domain Class Attribute} * Attribute {Domain Class Name} relvar create DefaultValue { Domain string Class string Attribute string } {Domain Class Attribute} relvar association R6\ DefaultValue {Domain Class Attribute} ?\ Attribute {Domain Class Name} 1 relvar create UserSuppliedValue { Domain string Class string Attribute string Value string } {Domain Class Attribute} relvar create SystemSuppliedValue { Domain string Class string Attribute string StartValue int } {Domain Class Attribute} relvar create GeneratedValue { Domain string Class string Attribute string Cmd string } {Domain Class Attribute} relvar partition R18 DefaultValue {Domain Class Attribute}\ UserSuppliedValue {Domain Class Attribute}\ SystemSuppliedValue {Domain Class Attribute}\ GeneratedValue {Domain Class Attribute} relvar create ValueCheck { Domain string Class string Attribute string Expression string } {Domain Class Attribute} relvar association R17\ ValueCheck {Domain Class Attribute} ?\ Attribute {Domain Class Name} 1 relvar create AttributeReference { Domain string ReferringClass string ReferringAttribute string ReferringRole string ReferencedClass string ReferencedAttribute string ReferencedRole string ReferencedIdNumber int Relationship string } {Domain ReferringClass ReferringAttribute ReferringRole\ ReferencedClass ReferencedAttribute ReferencedRole ReferencedIdNumber\ Relationship} relvar association R13\ AttributeReference {Domain ReferringClass ReferringAttribute} *\ Attribute {Domain Class Name} 1 relvar create ReferencedIdAttribute { Domain string Class string Relationship string Role string Attribute string Number int } {Domain Class Relationship Role Attribute Number} relvar create Operation { Domain string Class string Name string } {Domain Class Name} relvar association R8\ Operation {Domain Class} * Class {Domain Name} 1 relvar create InstanceOperation { Domain string Class string Name string } {Domain Class Name} relvar create ClassOperation { Domain string Class string Name string } {Domain Class Name} relvar partition R7 Operation {Domain Class Name}\ InstanceOperation {Domain Class Name}\ ClassOperation {Domain Class Name} relvar create UserInstanceOperation { Domain string Class string Name string Parameters string Body string } {Domain Class Name} relvar create SystemInstanceOperation { Domain string Class string Name string } {Domain Class Name} relvar partition R9 InstanceOperation {Domain Class Name}\ UserInstanceOperation {Domain Class Name}\ SystemInstanceOperation {Domain Class Name} relvar create UserClassOperation { Domain string Class string Name string Parameters string Body string } {Domain Class Name} relvar create SystemClassOperation { Domain string Class string Name string } {Domain Class Name} relvar partition R10 ClassOperation {Domain Class Name}\ UserClassOperation {Domain Class Name}\ SystemClassOperation {Domain Class Name} relvar create SuppliedOperation { Name string Command string RequiresStateModel boolean } Name relvar create SuppliedClassOperation { Name string } Name relvar create SuppliedInstanceOperation { Name string } Name relvar partition R14 SuppliedOperation Name\ SuppliedClassOperation Name\ SuppliedInstanceOperation Name relvar association R15\ SystemClassOperation Name *\ SuppliedClassOperation Name 1 relvar association R16\ SystemInstanceOperation Name *\ SuppliedInstanceOperation Name 1 relvar eval { relvar insert SuppliedOperation { Name findAll Command ::rosea::ClassCmds::findAll RequiresStateModel false } { Name findById Command ::rosea::ClassCmds::findById RequiresStateModel false } { Name findWhere Command ::rosea::ClassCmds::findWhere RequiresStateModel false } { Name create Command ::rosea::ClassCmds::create RequiresStateModel false } { Name createin Command ::rosea::ClassCmds::createin RequiresStateModel true } { Name createasync Command ::rosea::ClassCmds::createasync RequiresStateModel true } { Name update Command ::rosea::ClassCmds::update RequiresStateModel false } relvar insert SuppliedClassOperation { Name findAll } { Name findById } { Name findWhere } { Name create } { Name createin } { Name createasync } { Name update } } relvar eval { relvar insert SuppliedOperation { Name findRelated Command ::rosea::InstCmds::findRelated RequiresStateModel false } { Name findUnrelated Command ::rosea::InstCmds::findById RequiresStateModel false } { Name findRelatedWhere Command ::rosea::InstCmds::findRelatedWhere RequiresStateModel false } { Name findUnrelatedWhere Command ::rosea::InstCmds::findUnrelatedWhere RequiresStateModel false } { Name updateAttribute Command ::rosea::InstCmds::updateAttribute RequiresStateModel false } { Name withAttribute Command ::rosea::InstCmds::withAttribute RequiresStateModel false } { Name readAttribute Command ::rosea::InstCmds::readAttribute RequiresStateModel false } { Name assignAttribute Command ::rosea::InstCmds::assignAttribute RequiresStateModel false } { Name delete Command ::rosea::InstCmds::delete RequiresStateModel false } { Name signal Command ::rosea::InstCmds::signal RequiresStateModel true } { Name delaysignal Command ::rosea::InstCmds::delaysignal RequiresStateModel true } { Name canceldelayed Command ::rosea::InstCmds::canceldelayed RequiresStateModel true } { Name delayremaining Command ::rosea::InstCmds::delayremaining RequiresStateModel true } { Name instop Command ::rosea::InstCmds::instop RequiresStateModel false } { Name deRef Command ::rosea::InstCmds::deRef RequiresStateModel false } { Name isEmptyRef Command ::rosea::InstCmds::isEmptyRef RequiresStateModel false } { Name isNotEmptyRef Command ::rosea::InstCmds::isNotEmptyRef RequiresStateModel false } { Name refMultiplicity Command ::rosea::InstCmds::refMultiplicity RequiresStateModel false } { Name isRefSingular Command ::rosea::InstCmds::isRefSingular RequiresStateModel false } { Name limitRef Command ::rosea::InstCmds::limitRef RequiresStateModel false } { Name isRefEqual Command ::rosea::InstCmds::isRefEqual RequiresStateModel false } { Name forAllRefs Command ::rosea::InstCmds::forAllRefs RequiresStateModel false } relvar insert SuppliedInstanceOperation { Name findRelated } { Name findUnrelated } { Name findRelatedWhere } { Name findUnrelatedWhere } { Name updateAttribute } { Name withAttribute } { Name readAttribute } { Name assignAttribute } { Name delete } { Name signal } { Name delaysignal } { Name canceldelayed } { Name delayremaining } { Name instop } { Name deRef } { Name isEmptyRef } { Name isNotEmptyRef } { Name refMultiplicity } { Name isRefSingular } { Name limitRef } { Name isRefEqual } { Name forAllRefs } } relvar create Association { Domain string Name string } {Domain Name} relvar create Generalization { Domain string Name string } {Domain Name} relvar partition R30 Relationship {Domain Name}\ Association {Domain Name}\ Generalization {Domain Name} relvar create SimpleAssociation { Domain string Name string } {Domain Name} relvar create ClassBasedAssociation { Domain string Name string } {Domain Name} relvar partition R31 Association {Domain Name}\ SimpleAssociation {Domain Name}\ ClassBasedAssociation {Domain Name} relvar create SimpleReferringClass { Domain string Class string Relationship string Role string Conditionality boolean Multiplicity boolean } {Domain Class Relationship Role} relvar association R32\ SimpleReferringClass {Domain Relationship} 1\ SimpleAssociation {Domain Name} 1 relvar create SimpleReferencedClass { Domain string Class string Relationship string Role string Conditionality boolean } {Domain Class Relationship Role} relvar association R33\ SimpleReferencedClass {Domain Relationship} 1\ SimpleAssociation {Domain Name} 1 relvar create SourceClass { Domain string Class string Relationship string Role string Conditionality boolean Multiplicity boolean } {Domain Class Relationship Role} relvar association R34\ SourceClass {Domain Relationship} 1\ ClassBasedAssociation {Domain Name} 1 relvar create TargetClass { Domain string Class string Relationship string Role string Conditionality boolean Multiplicity boolean } {Domain Class Relationship Role} relvar association R35\ TargetClass {Domain Relationship} 1\ ClassBasedAssociation {Domain Name} 1 relvar create AssociatorClass { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar association R42\ AssociatorClass {Domain Relationship} 1\ ClassBasedAssociation {Domain Name} 1 relvar create Superclass { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar association R36\ Superclass {Domain Relationship} 1\ Generalization {Domain Name} 1 relvar create Subclass { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar association R37\ Subclass {Domain Relationship} +\ Generalization {Domain Name} 1 relvar create ReferringClass { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar partition R38 ReferringClass {Domain Class Relationship Role}\ SimpleReferringClass {Domain Class Relationship Role}\ AssociatorClass {Domain Class Relationship Role}\ Subclass {Domain Class Relationship Role} relvar create ReferencedClass { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar partition R39 ReferencedClass {Domain Class Relationship Role}\ SimpleReferencedClass {Domain Class Relationship Role}\ SourceClass {Domain Class Relationship Role}\ TargetClass {Domain Class Relationship Role}\ Superclass {Domain Class Relationship Role} relvar create ClassRole { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar partition R40 ClassRole {Domain Class Relationship Role}\ ReferringClass {Domain Class Relationship Role}\ ReferencedClass {Domain Class Relationship Role} relvar correlation R41 ClassRole\ {Domain Relationship} + Relationship {Domain Name}\ {Domain Class} * Class {Domain Name} relvar correlation R11 ReferencedIdAttribute\ {Domain Class Relationship Role} +\ ReferencedClass {Domain Class Relationship Role}\ {Domain Class Attribute Number} *\ IdentifyingAttribute {Domain Class Attribute Number} relvar correlation R12 AttributeReference\ {Domain ReferringClass Relationship ReferringRole} +\ ReferringClass {Domain Class Relationship Role}\ {Domain ReferencedClass Relationship ReferencedRole ReferencedAttribute\ ReferencedIdNumber} +\ ReferencedIdAttribute {Domain Class Relationship Role Attribute Number} relvar create Config_AssocSpec { Spec string NeedsAssociator boolean ReflexiveAllowed boolean ReferringCond boolean ReferringMult boolean ReferencedCond boolean ReferencedMult boolean } Spec relvar insert Config_AssocSpec { Spec 1--1 NeedsAssociator false ReflexiveAllowed true ReferringCond false ReferringMult false ReferencedCond false ReferencedMult false } { Spec 0..1--1 NeedsAssociator false ReflexiveAllowed false ReferringCond true ReferringMult false ReferencedCond false ReferencedMult false } { Spec 0..1--0..1 NeedsAssociator false ReflexiveAllowed true ReferringCond true ReferringMult false ReferencedCond true ReferencedMult false } { Spec 1..*--1 NeedsAssociator false ReflexiveAllowed true ReferringCond false ReferringMult true ReferencedCond false ReferencedMult false } { Spec 0..*--1 NeedsAssociator false ReflexiveAllowed false ReferringCond true ReferringMult true ReferencedCond false ReferencedMult false } { Spec 1..*--0..1 NeedsAssociator false ReflexiveAllowed false ReferringCond false ReferringMult true ReferencedCond true ReferencedMult false } { Spec 0..*--0..1 NeedsAssociator false ReflexiveAllowed true ReferringCond true ReferringMult true ReferencedCond true ReferencedMult false } { Spec 1..*--1..* NeedsAssociator true ReflexiveAllowed true ReferringCond false ReferringMult true ReferencedCond false ReferencedMult true } { Spec 0..*--1..* NeedsAssociator true ReflexiveAllowed false ReferringCond true ReferringMult true ReferencedCond false ReferencedMult true } { Spec 1..*--0..* NeedsAssociator true ReflexiveAllowed false ReferringCond false ReferringMult true ReferencedCond true ReferencedMult true } { Spec 0..*--0..* NeedsAssociator true ReflexiveAllowed true ReferringCond true ReferringMult true ReferencedCond true ReferencedMult true } { Spec ?--1 NeedsAssociator false ReflexiveAllowed false ReferringCond true ReferringMult false ReferencedCond false ReferencedMult false } { Spec ?--? NeedsAssociator false ReflexiveAllowed true ReferringCond true ReferringMult false ReferencedCond true ReferencedMult false } { Spec +--1 NeedsAssociator false ReflexiveAllowed true ReferringCond false ReferringMult true ReferencedCond false ReferencedMult false } { Spec *--1 NeedsAssociator false ReflexiveAllowed false ReferringCond true ReferringMult true ReferencedCond false ReferencedMult false } { Spec +--? NeedsAssociator false ReflexiveAllowed false ReferringCond false ReferringMult true ReferencedCond true ReferencedMult false } { Spec *--? NeedsAssociator false ReflexiveAllowed true ReferringCond true ReferringMult true ReferencedCond true ReferencedMult false } { Spec +--+ NeedsAssociator true ReflexiveAllowed true ReferringCond false ReferringMult true ReferencedCond false ReferencedMult true } { Spec *--+ NeedsAssociator true ReflexiveAllowed false ReferringCond true ReferringMult true ReferencedCond false ReferencedMult true } { Spec +--* NeedsAssociator true ReflexiveAllowed false ReferringCond false ReferringMult true ReferencedCond true ReferencedMult true } { Spec *--* NeedsAssociator true ReflexiveAllowed true ReferringCond true ReferringMult true ReferencedCond true ReferencedMult true } relvar create Config_ClassAssoc { Domain string Relationship string AssocClass string SourceClass string } {Domain Relationship AssocClass SourceClass} relvar create Config_NonReflexiveAssoc { Domain string Relationship string AssocClass string SourceClass string TargetClass string } {Domain Relationship AssocClass SourceClass} relvar create Config_ReflexiveAssoc { Domain string Relationship string AssocClass string SourceClass string } {Domain Relationship AssocClass SourceClass} relvar create Config_ReflexivePath { Domain string Relationship string AssocClass string SourceClass string SourceAttr string TargetAttr string } {Domain Relationship AssocClass SourceClass SourceAttr} relvar partition Config1\ Config_ClassAssoc\ {Domain Relationship AssocClass SourceClass}\ Config_NonReflexiveAssoc\ {Domain Relationship AssocClass SourceClass}\ Config_ReflexiveAssoc\ {Domain Relationship AssocClass SourceClass} relvar association Config2\ Config_ReflexivePath {Domain Relationship AssocClass SourceClass} +\ Config_ReflexiveAssoc {Domain Relationship AssocClass SourceClass} 1 pipe { relvar set ::rosea::Config::AttributeReference | relation project ~ Domain ReferencedClass Relationship ReferencedRole\ ReferencedAttribute ReferencedIdNumber | relation rename ~ ReferencedClass Class ReferencedRole Role\ ReferencedAttribute Attribute ReferencedIdNumber Number | relvar union ::rosea::Config::ReferencedIdAttribute } refIdQuery relvar create StateModel { Domain string Model string InitialState string DefaultTrans string } {Domain Model} relvar create InstanceStateModel { Domain string Class string } {Domain Class} relvar association R51\ InstanceStateModel {Domain Class} ?\ Class {Domain Name} 1 relvar create AssignerStateModel { Domain string Relationship string } {Domain Relationship} relvar association R52\ AssignerStateModel {Domain Relationship} ?\ Association {Domain Name} 1 relvar partition R50 StateModel {Domain Model}\ InstanceStateModel {Domain Class}\ AssignerStateModel {Domain Relationship} relvar create SingleAssigner { Domain string Relationship string } {Domain Relationship} relvar create MultipleAssigner { Domain string Relationship string Class string Number int } {Domain Relationship} relvar partition R53 AssignerStateModel {Domain Relationship}\ SingleAssigner {Domain Relationship}\ MultipleAssigner {Domain Relationship} relvar association R54\ MultipleAssigner {Domain Class Number} ?\ Identifier {Domain Class Number} 1 relvar create State { Domain string Model string Name string Parameters string Action string IsFinal boolean } {Domain Model Name} relvar association R55\ State {Domain Model} +\ StateModel {Domain Model} 1 relvar association R58\ StateModel {Domain Model InitialState} ?\ State {Domain Model Name} 1 relvar create TransitionRule { Name string } Name relvar insert TransitionRule {Name IG} {Name CH} relvar association R59\ StateModel DefaultTrans *\ TransitionRule Name 1 relvar create CreationState { Domain string Model string Name string } {Domain Model Name} relvar create StatePlace { Domain string Model string Name string } {Domain Model Name} relvar partition R57 StatePlace {Domain Model Name}\ State {Domain Model Name}\ CreationState {Domain Model Name} relvar create Event { Domain string Model string Event string } {Domain Model Event} relvar create DeferredEvent { Domain string Model string Event string } {Domain Model Event} relvar create EffectiveEvent { Domain string Model string Event string } {Domain Model Event} relvar partition R80 Event {Domain Model Event}\ DeferredEvent {Domain Model Event}\ EffectiveEvent {Domain Model Event} relvar create DeferralPath { Domain string Model string Event string Relationship string Role string } {Domain Model Event Relationship Role} relvar correlation R86 DeferralPath\ {Domain Model Event} + DeferredEvent {Domain Model Event}\ {Domain Model Relationship Role} * Superclass\ {Domain Class Relationship Role} relvar create PolymorphicEvent { Domain string Model string Event string } {Domain Model Event} relvar create InheritedEvent { Domain string Model string Event string } {Domain Model Event} relvar partition R81 DeferredEvent {Domain Model Event}\ PolymorphicEvent {Domain Model Event}\ InheritedEvent {Domain Model Event} relvar create MappedEvent { Domain string Model string Event string ParentModel string } {Domain Model Event} relvar association R84\ MappedEvent {Domain ParentModel Event} *\ DeferredEvent {Domain Model Event} 1 relvar create LocalEvent { Domain string Model string Event string } {Domain Model Event} relvar partition R82 EffectiveEvent {Domain Model Event}\ MappedEvent {Domain Model Event}\ LocalEvent {Domain Model Event} relvar create NonLocalEvent { Domain string Model string Event string Relationship string Role string } {Domain Model Event} relvar partition R83 NonLocalEvent {Domain Model Event}\ MappedEvent {Domain Model Event}\ InheritedEvent {Domain Model Event} relvar association R85\ NonLocalEvent {Domain Model Relationship Role} *\ Subclass {Domain Class Relationship Role} 1 relvar association R87\ EffectiveEvent {Domain Model} +\ StateModel {Domain Model} 1 relvar create TransitionPlace { Domain string Model string State string Event string } {Domain Model State Event} relvar correlation R70 TransitionPlace\ {Domain Model State} * StatePlace {Domain Model Name}\ {Domain Model Event} * EffectiveEvent {Domain Model Event} relvar create StateTransition { Domain string Model string State string Event string NewState string } {Domain Model State Event} relvar create NonStateTransition { Domain string Model string State string Event string TransRule string } {Domain Model State Event} relvar partition R71 TransitionPlace {Domain Model State Event}\ StateTransition {Domain Model State Event}\ NonStateTransition {Domain Model State Event} relvar association R72\ StateTransition {Domain Model NewState} *\ State {Domain Model Name} 1 relvar association R73\ NonStateTransition TransRule *\ TransitionRule Name 1 relvar create Config_DataError { Relationship string RefClass string RefType string Format string } {Relationship RefClass RefType} relvar insert Config_DataError { Relationship R3 RefClass Class RefType notrefed Format {in domain, \"$Domain\", class, \"$Name\",\ has no attributes} } { Relationship R4 RefClass Class RefType notrefed Format {in domain, \"$Domain\", class, \"$Name\",\ has no identifiers} } { Relationship R11 RefClass ReferencedClass RefType notrefed Format {in domain, \"$Domain\", for relationship,\ \"$Relationship\", no class has defined a reference\ to class, \"$Class\"} } { Relationship R11 RefClass ReferencedIdAttribute RefType refnone Format {in domain, \"$Domain\", relationship,\ \"$Relationship\", references attribute,\ \"$Attribute\", in class, \"$Class\", which is\ not an identifying attribute, does not exist\ or \"$Relationship\" does not exist} } { Relationship R12 RefClass AttributeReference RefType refnone Format {in domain, \"$Domain\", the attribute,\ \"$ReferringAttribute\", in class, \"$ReferringClass\",\ refers to, \"$ReferencedAttribute\", in class,\ \"$ReferencedClass\", but the class, attribute or\ relationship does not exist} } { Relationship R12 RefClass ReferringClass RefType notrefed Format {in domain, \"$Domain\", in class, \"$Class\",\ makes a reference along relationship,\ \"$Relationship\", but $Class does not pariticipate\ in $Relationship} } { Relationship R13 RefClass AttributeReference RefType refnone Format {in domain, \"$Domain\", the attribute,\ \"$ReferringAttribute\", in class, \"$ReferringClass\",\ does not exist, but is used as a referential attribute} } { Relationship R41 RefClass ClassRole RefType refnone Format {in domain, \"$Domain\", relationship,\ \"$Relationship\", references class, \"$Class\",\ which does not exist} } { Relationship R52 RefClass AssignerStateModel RefType refnone Format {in domain, \"$Domain\", an assigner state model is\ defined on relationship, \"$Relationship\", which is\ not an association type relationship} } { Relationship R70 RefClass TransitionPlace RefType refnone Format {in domain, \"$Domain\", the state model for,\ \"$Model\", contains a transition for event,\ \"$Event\", but $Event was a polymorphic event\ consumed by a superclass of $Model} } { Relationship R72 RefClass StateTransition RefType refnone Format {in domain, \"$Domain\", the state model for,\ \"$Model\", contains the transition,\ \"$State - $Event -> $NewState\",\ but state \"$NewState\" does not exist} } { Relationship R81 RefClass DeferredEvent RefType multrefed Format {in domain, \"$Domain\", in the state model for,\ \"$Model\", event, \"$Event\", is both an inherited\ polymorphic event and a locally defined one} } { Relationship R86 RefClass DeferredEvent RefType notrefed Format {in domain, \"$Domain\", in the state model for,\ \"$Model\", event, \"$Event\", is defined as\ polymorphic but \"$Model\" is not a superclass\ of a generalization} } { Relationship R87 RefClass EffectiveEvent RefType refnone Format {in domain, \"$Domain\", event, \"$Event\" has been\ inherited, but no state model exists for, \"$Model\"} } namespace export ConfigEvaluate proc ConfigEvaluate {ns body} { variable evalLambda tailcall ::apply [concat $evalLambda [list $ns]] $body ; # <1> } proc domain {name body} { namespace upvar DomainDef DomainName DomainName ; # <1> set DomainName $name relvar insert ::rosea::Config::Domain [list Name $name Location {}] try { if {$name eq {}} { tailcall DeclError EMPTY_NAME domain } relvar eval { # <2> ConfigEvaluate [namespace current]::DomainDef $body # At this point we have the definition of the domain and enough # information to tie together the referential attributes and # the association definitions. variable Config_NonReflexiveAssoc relation foreach nra $Config_NonReflexiveAssoc { relation assign $nra relvar update ::rosea::Config::AttributeReference ar { [tuple extract $ar Domain] eq $Domain && [tuple extract $ar Relationship] eq $Relationship && [tuple extract $ar ReferringClass] eq $AssocClass } {tuple update $ar ReferringRole associator} relvar update ::rosea::Config::AttributeReference ar { [tuple extract $ar Domain] eq $Domain && [tuple extract $ar Relationship] eq $Relationship && [tuple extract $ar ReferringClass] eq $AssocClass && [tuple extract $ar ReferencedClass] eq $SourceClass } {tuple update $ar ReferencedRole source} } variable Config_ReflexivePath relation foreach rp $Config_ReflexivePath { relation assign $rp relvar update ::rosea::Config::AttributeReference ar { [tuple extract $ar Domain] eq $Domain && [tuple extract $ar Relationship] eq $Relationship && [tuple extract $ar ReferringClass] eq $AssocClass } {tuple update $ar ReferringRole associator} relvar update ::rosea::Config::AttributeReference ar { [tuple extract $ar Domain] eq $Domain && [tuple extract $ar Relationship] eq $Relationship && [tuple extract $ar ReferringClass] eq $AssocClass && [tuple extract $ar ReferringAttribute] eq $SourceAttr } {tuple update $ar ReferencedRole source} } variable refIdQuery eval $refIdQuery # We must also compute how polymorphic events are inherited # down generalization hierarchies. # Create Deferral Path instances variable PolymorphicEvent variable DeferredEvent variable Superclass variable Subclass variable DeferralPath set dpaths [pipe { relation restrictwith $PolymorphicEvent {$Domain eq $name} | relation semijoin ~ $DeferredEvent | relation join ~ $Superclass -using {Domain Domain Model Class} }] relvar insert ::rosea::Config::DeferralPath {*}[relation body $dpaths] set supers [relation semiminus $Subclass $Superclass\ -using {Domain Domain Class Class}] relation foreach super $supers { PropagatePolyEvents $super } } } on error {result} { # puts $::errorInfo ::rosea::Config::HandleConfigError $result } } proc HandleConfigError {result} { set lines [split [string trimright $result] \n] set nlines [llength $lines] set lineno 0 upvar #0 ::rosea::Config::errcount errcount while {$lineno < $nlines} { set line [lindex $lines $lineno] incr lineno if {[regexp {^for[^:]+([^(]+)\(.+\), in relvar (.+)$} $line\ match rnum refclass]} { set rnum [namespace tail $rnum] set refclass [namespace tail $refclass] # Now iterate over the "tuple" lines that follow the constraint message. while {$lineno < $nlines} { set tupline [lindex $lines $lineno] if {[regexp {^tuple {(.+)} (.+)$} $tupline match tuple phrase]} { incr lineno incr errcount if {[string match {is not referenced*} $phrase]} { set reftype notrefed } elseif {[string match {references no*} $phrase]} { set reftype refnone } elseif {[string match {*to by multiple*} $phrase]} { set reftype multrefed } elseif {[string match {is not referred to*} $phrase]} { set reftype notrefto } else { log::error "unknown constraint phrasing, \"$phrase\"" continue } set cde [relvar restrictone Config_DataError Relationship $rnum RefClass\ $refclass RefType $reftype] if {[relation isnotempty $cde]} { dict with tuple { log::error [subst -nocommands [relation extract $cde Format]] } } else { log::error "$line\n$tupline" } } else { break } } } else { log::error "unknown configuration error, \"$result\"" } } return } namespace eval DomainDef { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Config::ConfigEvaluate namespace import ::rosea::Helpers::DeclError proc class {name body} { namespace upvar [namespace current] DomainName DomainName ; # <1> namespace upvar ClassDef ClassName ClassName set ClassName $name if {![regexp {\A[[:alnum:]].*} $name]} { tailcall DeclError BAD_CLASS_NAME $name } try { relvar insert ::rosea::Config::DomainElement [list\ Domain $DomainName\ Element $name\ ] } trap {RAL relvar insert DUPLICATE_TUPLE} {} { tailcall DeclError DUP_ELEMENT_NAME $name } ; # <2> relvar insert ::rosea::Config::Class [list\ Domain $DomainName\ Name $name\ ] set instops [pipe { relvar set ::rosea::Config::SuppliedInstanceOperation | relation extend ~ ioptuple\ Domain string {[set DomainName]}\ Class string {[set ClassName]} }] relvar union ::rosea::Config::SystemInstanceOperation $instops relvar union ::rosea::Config::InstanceOperation $instops relvar union ::rosea::Config::Operation $instops set classops [pipe { relvar set ::rosea::Config::SuppliedClassOperation | relation extend ~ coptuple\ Domain string {[set DomainName]}\ Class string {[set ClassName]} }] relvar union ::rosea::Config::SystemClassOperation $classops relvar union ::rosea::Config::ClassOperation $classops relvar union ::rosea::Config::Operation $classops ConfigEvaluate [namespace current]::ClassDef $body } proc association {name source spec target args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } if {$name eq {}} { tailcall DeclError EMPTY_NAME association } if {[string index $name 0] eq "~"} { tailcall DeclError TILDE_NAME $name } # Obtain references to the domain and class context. namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName set associator {} set path {} foreach {option value} $args { switch -exact -- $option { -associator { set associator $value } -path { set path $value if {[llength $path] % 2 != 0} { tailcall DeclError ARG_FORMAT $path } } default { tailcall DeclError UNKNOWN_OPTION association $option } } } set cas [relvar restrictone ::rosea::Config::Config_AssocSpec Spec $spec] if {[relation isempty $cas]} { tailcall DeclError BAD_RELATIONSHIP_SPEC $spec } set needsassoc [relation extract $cas NeedsAssociator] if {$needsassoc && $associator eq {}} { tailcall DeclError NEED_ASSOCIATOR $spec } if {$source eq $target} { if {![relation extract $cas ReflexiveAllowed]} { tailcall DeclError REFLEXIVE_NOT_ALLOWED $spec } if {$needsassoc && $path eq {}} { tailcall DeclError NEED_REFLEXIVE_PATH $name $source $spec $target } } try { relvar insert ::rosea::Config::DomainElement [list\ Domain $DomainName\ Element $name\ ] } trap {RAL relvar insert DUPLICATE_TUPLE} {result opts} { tailcall DeclError DUP_ELEMENT_NAME $name } # Many relvars have tuples with the same heading, so we construct it # once here. set reltuple [list\ Domain $DomainName\ Name $name\ ] # Populate the data for a Relationship and Association since that # is what this command defines. relvar insert ::rosea::Config::Relationship $reltuple relvar insert ::rosea::Config::Association $reltuple # Populate the type of association we are dealing with. if {$associator eq {}} { relvar insert ::rosea::Config::SimpleAssociation $reltuple relvar insert ::rosea::Config::SimpleReferringClass [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ Conditionality [relation extract $cas ReferringCond]\ Multiplicity [relation extract $cas ReferringMult]\ ] relvar insert ::rosea::Config::ReferringClass [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ ] relvar insert ::rosea::Config::ClassRole [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ ] relvar insert ::rosea::Config::SimpleReferencedClass [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ Conditionality [relation extract $cas ReferencedCond]\ ] relvar insert ::rosea::Config::ReferencedClass [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ ] relvar insert ::rosea::Config::ClassRole [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ ] } else { relvar insert ::rosea::Config::Config_ClassAssoc [list\ Domain $DomainName\ Relationship $name\ AssocClass $associator\ SourceClass $source\ ] if {[llength $path] == 0} { relvar insert ::rosea::Config::Config_NonReflexiveAssoc [list\ Domain $DomainName\ Relationship $name\ AssocClass $associator\ SourceClass $source\ TargetClass $target\ ] } else { relvar insert ::rosea::Config::Config_ReflexiveAssoc [list\ Domain $DomainName\ Relationship $name\ AssocClass $associator\ SourceClass $source\ ] foreach {sourceattr targetattr} $path { relvar insert ::rosea::Config::Config_ReflexivePath [list\ Domain $DomainName\ Relationship $name\ AssocClass $associator\ SourceClass $source\ SourceAttr $sourceattr\ TargetAttr $targetattr\ ] } } relvar insert ::rosea::Config::ClassBasedAssociation $reltuple relvar insert ::rosea::Config::SourceClass [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ Conditionality [relation extract $cas ReferringCond]\ Multiplicity [relation extract $cas ReferringMult]\ ] relvar insert ::rosea::Config::ReferencedClass [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ ] relvar insert ::rosea::Config::ClassRole [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ ] relvar insert ::rosea::Config::TargetClass [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ Conditionality [relation extract $cas ReferencedCond]\ Multiplicity [relation extract $cas ReferencedMult]\ ] relvar insert ::rosea::Config::ReferencedClass [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ ] relvar insert ::rosea::Config::ClassRole [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ ] relvar insert ::rosea::Config::AssociatorClass [list\ Domain $DomainName\ Class $associator\ Relationship $name\ Role associator\ ] relvar insert ::rosea::Config::ReferringClass [list\ Domain $DomainName\ Class $associator\ Relationship $name\ Role associator\ ] relvar insert ::rosea::Config::ClassRole [list\ Domain $DomainName\ Class $associator\ Relationship $name\ Role associator\ ] } } proc generalization {name super args} { if {[llength $args] < 2} { tailcall DeclError TOO_FEW_SUBCLASSES [llength $args] } if {$name eq {}} { tailcall DeclError EMPTY_NAME generalization } if {[string index $name 0] eq "~"} { tailcall DeclError TILDE_NAME $name } namespace upvar ::rosea::Config::DomainDef DomainName DomainName try { relvar insert ::rosea::Config::DomainElement [list\ Domain $DomainName\ Element $name\ ] } trap {RAL relvar insert DUPLICATE_TUPLE} {result opts} { tailcall DeclError DUP_ELEMENT_NAME $name } set reltuple [list\ Domain $DomainName\ Name $name\ ] relvar insert ::rosea::Config::Relationship $reltuple relvar insert ::rosea::Config::Generalization $reltuple set supertuple [list\ Domain $DomainName\ Class $super\ Relationship $name\ Role target\ ] relvar insert ::rosea::Config::Superclass $supertuple relvar insert ::rosea::Config::ReferencedClass $supertuple relvar insert ::rosea::Config::ClassRole $supertuple set subtuple [dict create\ Domain $DomainName\ Relationship $name\ Role source\ ] foreach sub $args { dict set subtuple Class $sub relvar insert ::rosea::Config::Subclass $subtuple relvar insert ::rosea::Config::ReferringClass $subtuple relvar insert ::rosea::Config::ClassRole $subtuple } } proc assigner {rname body} { namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar AssignerDef\ RelationshipName RelationshipName\ multiClass multiClass\ multiIdNum multiIdNum\ InitialState InitialState\ DefaultTrans DefaultTrans set RelationshipName $rname set multiClass {} set multiIdNum 1 set InitialState {} set DefaultTrans {} try { ConfigEvaluate [namespace current]::AssignerDef $body if {$DefaultTrans eq {}} { set DefaultTrans CH } relvar insert ::rosea::Config::StateModel [list\ Domain $DomainName\ Model $rname\ InitialState $InitialState\ DefaultTrans $DefaultTrans\ ] set assigntuple [list\ Domain $DomainName\ Relationship $rname\ ] relvar insert ::rosea::Config::AssignerStateModel $assigntuple if {$multiClass eq {}} { relvar insert ::rosea::Config::SingleAssigner $assigntuple } else { lappend assigntuple Class $multiClass Number $multiIdNum relvar insert ::rosea::Config::MultipleAssigner $assigntuple } } on error {result opts} { log::error $result upvar #0 ::rosea::Config::errcount errcount incr errcount } } proc operation {name params body} { if {$name eq {}} { tailcall DeclError EMPTY_NAME operation } namespace upvar ::rosea::Config::DomainDef DomainName DomainName try { relvar insert ::rosea::Config::DomainElement [list\ Domain $DomainName\ Element $name\ ] } trap {RAL relvar insert DUPLICATE_TUPLE} {result opts} { tailcall DeclError DUP_ELEMENT_NAME $name } relvar insert ::rosea::Config::DomainOperation [list\ Domain $DomainName\ Name $name\ Parameters $params\ Body $body\ ] } namespace eval ClassDef { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Config::ConfigEvaluate namespace import ::rosea::Helpers::DeclError proc attribute {name type args} { if {$name eq {}} { tailcall DeclError EMPTY_NAME attribute } if {[string range $name 0 1] eq "__"} { tailcall DeclError RESERVED_NAME $name } if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName relvar insert ::rosea::Config::Attribute [list\ Domain $DomainName\ Class $ClassName\ Name $name\ Type $type\ ] foreach {option value} $args { switch -exact -- $option { -default { relvar insert ::rosea::Config::DefaultValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ ] relvar insert ::rosea::Config::UserSuppliedValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ Value $value\ ] } -system { if {$type ne "int"} { tailcall DeclError INT_TYPE_REQUIRED $type } if {![string is integer -strict $value]} { tailcall DeclError INT_VALUE_REQUIRED $value } relvar insert ::rosea::Config::DefaultValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ ] relvar insert ::rosea::Config::SystemSuppliedValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ StartValue $value\ ] } -generate { relvar insert ::rosea::Config::DefaultValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ ] relvar insert ::rosea::Config::GeneratedValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ Cmd $value\ ] } -id { relvar uinsert ::rosea::Config::Identifier [list\ Domain $DomainName\ Class $ClassName\ Number $value\ ] ; # <1> relvar insert ::rosea::Config::IdentifyingAttribute [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ Number $value\ ] } -check { relvar insert ::rosea::Config::ValueCheck [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ Expression $value\ ] } default { tailcall DeclError UNKNOWN_OPTION attribute $option } } } } proc reference {relname rclass args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName set refnum 1 set linkopts [list] foreach {option value} $args { switch -exact -- $option { -refid { set refnum $value } -link { if {[llength $value] < 1 || [llength $value] > 2} { tailcall DeclError ARG_FORMAT $value } lappend linkopts $value } default { tailcall DeclError UNKNOWN_OPTION reference $option } } } # We defer processing the link options until the end so as not # to impose an order on the -refid option. foreach linkopt $linkopts { lassign $linkopt referring referenced if {$referenced eq {}} { set referenced $referring } relvar insert ::rosea::Config::AttributeReference [list\ Domain $DomainName\ ReferringClass $ClassName\ ReferringAttribute $referring\ ReferringRole source\ ReferencedClass $rclass\ ReferencedAttribute $referenced\ ReferencedRole target\ ReferencedIdNumber $refnum\ Relationship $relname ] ; # <1> } } proc classop {name params body} { if {$name eq {}} { tailcall DeclError EMPTY_NAME "class operation" } elseif {[string first :: $name] != -1} { tailcall DeclError NS_QUALIFIERS $name } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName set sysop [relvar restrictone ::rosea::Config::Operation\ Domain $DomainName Class $ClassName Name $name] if {[relation isnotempty $sysop]} { tailcall DeclError DUP_OP_NAME $name } set optuple [list Domain $DomainName Class $ClassName Name $name] relvar insert ::rosea::Config::Operation $optuple relvar insert ::rosea::Config::ClassOperation $optuple lappend optuple Parameters $params Body $body relvar insert ::rosea::Config::UserClassOperation $optuple } proc instop {name params body} { if {$name eq {}} { tailcall DeclError EMPTY_NAME "instance operation" } elseif {[string first :: $name] != -1} { tailcall DeclError NS_QUALIFIERS $name } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName set sysop [relvar restrictone ::rosea::Config::Operation\ Domain $DomainName Class $ClassName Name $name] if {[relation isnotempty $sysop]} { tailcall DeclError DUP_OP_NAME $name } set optuple [list Domain $DomainName Class $ClassName Name $name] relvar insert ::rosea::Config::Operation $optuple relvar insert ::rosea::Config::InstanceOperation $optuple lappend optuple Parameters $params Body $body relvar insert ::rosea::Config::UserInstanceOperation $optuple } proc statemodel {body} { namespace upvar ::rosea::Config::DomainDef DomainName DomainName variable ClassName namespace upvar StateModelDef\ InitialState InitialState\ DefaultTrans DefaultTrans\ Terminals Terminals set InitialState {} set DefaultTrans {} set Terminals [list] try { ConfigEvaluate [namespace current]::StateModelDef $body if {$DefaultTrans eq {}} { set DefaultTrans CH } relvar insert ::rosea::Config::StateModel [list\ Domain $DomainName\ Model $ClassName\ InitialState $InitialState\ DefaultTrans $DefaultTrans\ ] relvar insert ::rosea::Config::InstanceStateModel [list\ Domain $DomainName\ Class $ClassName\ ] foreach terminal $Terminals { relvar updateone ::rosea::Config::State stup [list\ Domain $DomainName Model $ClassName Name $terminal] { tuple update $stup IsFinal true } } } on error {result opts} { log::error $result upvar #0 ::rosea::Config::errcount errcount incr errcount } } proc polymorphic {args} { namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName foreach polyevent $args { set eventtuple [list\ Domain $DomainName\ Model $ClassName\ Event $polyevent\ ] relvar insert ::rosea::Config::PolymorphicEvent $eventtuple relvar insert ::rosea::Config::DeferredEvent $eventtuple relvar insert ::rosea::Config::Event $eventtuple } return } namespace eval StateModelDef { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Config::ConfigEvaluate namespace import ::rosea::Helpers::DeclError proc state {name params body} { if {$name eq {}} { tailcall DeclError EMPTY_NAME state } if {$name in {@ CH IG}} { tailcall DeclError PSEUDO_STATE $name state } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName variable InitialState if {$InitialState eq {}} { set InitialState $name } relvar insert ::rosea::Config::State [list\ Domain $DomainName\ Model $ClassName\ Name $name\ Parameters $params\ Action $body\ IsFinal false\ ] relvar insert ::rosea::Config::StatePlace [list\ Domain $DomainName\ Model $ClassName\ Name $name\ ] return } proc transition {source - event -> target} { if {$event eq {}} { tailcall DeclError EMPTY_NAME event } if {$source in {CH IG}} { tailcall DeclError PSEUDO_STATE $source "transition source state" } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName if {$source eq "@"} { if {$target in {CH IG}} { tailcall DeclError BAD_CREATION_TARGET $target } set cstuple [list\ Domain $DomainName\ Model $ClassName\ Name @\ ] relvar uinsert ::rosea::Config::CreationState $cstuple relvar uinsert ::rosea::Config::StatePlace $cstuple } set eventtuple [list\ Domain $DomainName\ Model $ClassName\ Event $event\ ] relvar uinsert ::rosea::Config::Event $eventtuple ; # <1> relvar uinsert ::rosea::Config::EffectiveEvent $eventtuple relvar uinsert ::rosea::Config::LocalEvent $eventtuple set tranrule [relvar restrictone ::rosea::Config::TransitionRule\ Name $target] set transtuple [list\ Domain $DomainName\ Model $ClassName\ State $source\ Event $event\ ] relvar insert ::rosea::Config::TransitionPlace $transtuple if {[relation isnotempty $tranrule]} { lappend transtuple TransRule $target set tpsubtype NonStateTransition } else { lappend transtuple NewState $target set tpsubtype StateTransition } relvar insert ::rosea::Config::$tpsubtype $transtuple return } proc initialstate {name} { if {$name eq {}} { tailcall DeclError EMPTY_NAME initialstate } if {$name in {@ CH IG}} { tailcall DeclError PSEUDO_STATE $name initialstate } variable InitialState $name return } proc defaulttrans {name} { if {$name ni {CH IG}} { tailcall DeclError EXPECTED_PSEUDO_STATE $name } variable DefaultTrans $name return } proc terminal {args} { variable Terminals ::struct::set add Terminals $args return } } } namespace eval AssignerDef { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Config::ConfigEvaluate namespace import ::rosea::Helpers::DeclError proc state {name params body} { if {$name eq {}} { tailcall DeclError EMPTY_NAME state } if {$name in {CH IG}} { tailcall DeclError PSEUDO_STATE $name state } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::AssignerDef\ RelationshipName RelationshipName variable InitialState if {$InitialState eq {}} { set InitialState $name } relvar insert ::rosea::Config::State [list\ Domain $DomainName\ Model $RelationshipName\ Name $name\ Parameters $params\ Action $body\ IsFinal false\ ] relvar insert ::rosea::Config::StatePlace [list\ Domain $DomainName\ Model $RelationshipName\ Name $name\ ] return } proc transition {source - event -> target} { if {$event eq {}} { tailcall DeclError EMPTY_NAME event } if {$source in {CH IG}} { tailcall DeclError PSEUDO_STATE $name "transition source state" } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::AssignerDef\ RelationshipName RelationshipName set eventtuple [list\ Domain $DomainName\ Model $RelationshipName\ Event $event\ ] relvar uinsert ::rosea::Config::Event $eventtuple relvar uinsert ::rosea::Config::EffectiveEvent $eventtuple relvar uinsert ::rosea::Config::LocalEvent $eventtuple set tranrule [relvar restrictone ::rosea::Config::TransitionRule\ Name $target] set transtuple [list\ Domain $DomainName\ Model $RelationshipName\ State $source\ Event $event\ ] relvar insert ::rosea::Config::TransitionPlace $transtuple if {[relation isnotempty $tranrule]} { lappend transtuple TransRule $target set tpsubtype NonStateTransition } else { lappend transtuple NewState $target set tpsubtype StateTransition } relvar insert ::rosea::Config::$tpsubtype $transtuple return } proc initialstate {name} { if {$name eq {}} { tailcall DeclError EMPTY_NAME initialstate } if {$name in {CH IG}} { tailcall DeclError PSEUDO_STATE $name initialstate } variable InitialState $name return } proc defaulttrans {name} { if {$name ni {CH IG}} { tailcall DeclError EXPECTED_PSEUDO_STATE $name } variable DefaultTrans $name return } proc identifyby {name args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } variable multiClass $name foreach {option value} $args { switch -exact -- $option { -id { variable multiIdNum $value } default { tailcall DeclError UNKNOWN_OPTION identifyby $option } } } return } } } } namespace eval Populate { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Config::ConfigEvaluate namespace import ::rosea::Helpers::DeclError proc domain {name body} { set domain [relvar restrictone ::rosea::Config::Domain Name $name] if {[relation isempty $domain]} { tailcall DeclError UNKNOWN_DOMAIN $domain } namespace upvar DomainPop DomainName DomainName DomainLoc DomainLoc relation assign $domain {Name DomainName} {Location DomainLoc} try { relvar eval { ConfigEvaluate [namespace current]::DomainPop $body } } on error {result opts} { log::error $result upvar #0 ::rosea::Config::errcount errcount incr errcount } } namespace eval DomainPop { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path ::rosea::Helpers proc class {class heading args} { # Determine if we have one big list or a bunch of values. set popvalues [expr {[llength $args] == 1 ? [lindex $args 0] : $args}] set headlen [llength $heading] if {[llength $popvalues] % $headlen != 0} { tailcall DeclError ARG_MISMATCH $headlen [llength $popvalues] } # Iterate over the attribute values taking them in chunks that are the same # size as the heading. set body [list] for {set vindex 0} {$vindex < [llength $popvalues]} {incr vindex $headlen} { set values [lrange $popvalues $vindex [expr {$vindex + $headlen - 1}]] # Create a tuple as a list of attribute name / value pairs. set tuple [list] foreach attr $heading value $values { # Check if we are skipping a value to use a default. We must also # allow some way to specify the value as "-". if {$value eq "-"} { continue } elseif {$value eq "\\-"} { set value - } lappend tuple $attr $value } # Accumulate the tuples as a list to form the body that will be # inserted into the relvar. lappend body $tuple } # Insert the body into the relvar. namespace upvar [namespace current]\ DomainName DomainName\ DomainLoc DomainLoc set domns ${DomainLoc}::${DomainName} set relvar ${domns}::$class set insts [relvar insert $relvar {*}$body] # Now we have to deal with any state model that might be present. We have # to set up the initial state properly if such a thing exists for this # class. set idattrs [lindex [relvar identifiers $relvar] 0] relation foreach inst $insts { CreateInInitialState $domns $class [pipe { relation project $inst {*}$idattrs | relation tuple ~ | tuple get ~ }] } return [relation body $insts] } proc assigner {rname heading args} { # Determine if we have one big list or a bunch of values. set popvalues [expr {[llength $args] == 1 ? [lindex $args 0] : $args}] set headlen [llength $heading] if {[llength $popvalues] % $headlen != 0} { tailcall DeclError ARG_MISMATCH $headlen [llength $popvalues] } namespace upvar [namespace current]\ DomainName DomainName\ DomainLoc DomainLoc set domns ${DomainLoc}::${DomainName} set relvar ${domns}::${rname}__STATEINST set idattrs [lindex [relvar identifiers $relvar] 0] if {![struct::set equal $heading $idattrs]} { tailcall DeclError NO_IDENTIFIER $heading $idattrs } # Iterate over the attribute values taking them in chunks that are the same # size as the heading. for {set vindex 0} {$vindex < [llength $popvalues]} {incr vindex $headlen} { set values [lrange $popvalues $vindex [expr {$vindex + $headlen - 1}]] # Create a tuple as a list of attribute name / value pairs. We assume # the values are in the same order as the heading -- that is the point. set tuple [list] foreach attr $heading value $values { lappend tuple $attr $value } CreateInInitialState $domns $rname $tuple } return } } } namespace eval Info { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Helpers::DeclError proc domain {arglist} { set arglist [lassign $arglist subcmd domainname] set dominst [relvar restrictone ::rosea::Config::Domain Name $domainname] if {[relation isempty $dominst]} { tailcall DeclError UNKNOWN_DOMAIN $domainname } switch -exact -- $subcmd { classes { return [pipe { relvar set ::rosea::Config::Class | relation semijoin $dominst ~ -using {Name Domain} | relation list ~ Name }] } relationships { return [pipe { relvar set ::rosea::Config::Relationship | relation semijoin $dominst ~ -using {Name Domain} | relation list ~ Name }] } operations { return [FormatOpsInfo [pipe { relvar set ::rosea::Config::DomainOperation | relation semijoin $dominst ~ -using {Name Domain} | relation project ~ Name Parameters Body }]] } default { tailcall DeclError UNKNOWN_INFO_CMD $subcmd } } } proc FormatOpsInfo {ops} { set result [list] relation foreach op $ops { relation assign $op lappend result $Name $Parameters $Body } return $result } proc class {arglist} { set arglist [lassign $arglist subcmd domainname classname] set dominst [relvar restrictone ::rosea::Config::Domain Name $domainname] if {[relation isempty $dominst]} { tailcall DeclError UNKNOWN_DOMAIN $domainname } set classinst [pipe { relvar set ::rosea::Config::Class | relation semijoin $dominst ~ -using {Name Domain} | relation restrictwith ~ {$Name eq $classname} }] if {[relation isempty $classinst]} { tailcall DeclError UNKNOWN_CLASS $classname $domainname } switch -exact -- $subcmd { attributes { return [pipe { relvar set ::rosea::Config::Attribute | relation semijoin $classinst ~ -using {Domain Domain Name Class} | relation dict ~ Name Type }] } classops { return [FormatOpsInfo [pipe { relvar set ::rosea::Config::UserClassOperation | relation semijoin $classinst ~ -using {Domain Domain Name Class} | relation project ~ Name Parameters Body }]] } instops { return [FormatOpsInfo [pipe { relvar set ::rosea::Config::UserInstanceOperation | relation semijoin $classinst ~ -using {Domain Domain Name Class} | relation project ~ Name Parameters Body }]] } default { tailcall DeclError UNKNOWN_INFO_CMD $subcmd } } } proc statemodel {arglist} { set arglist [lassign $arglist subcmd domainname classname statename] set dominst [relvar restrictone ::rosea::Config::Domain Name $domainname] if {[relation isempty $dominst]} { tailcall DeclError UNKNOWN_DOMAIN $domainname } set domns [string cat [relation extract $dominst Location] :: $domainname] set classinst [pipe { relvar set ::rosea::Config::Class | relation semijoin $dominst ~ -using {Name Domain} | relation restrictwith ~ {$Name eq $classname} }] if {[relation isempty $classinst]} { tailcall DeclError UNKNOWN_CLASS $classname $domainname } switch -exact -- $subcmd { states { set states [pipe { relvar set ::rosea::Config::State | relation restrictwith ~\ {$Domain eq $domainname && $Model eq $classname} | relation project ~ Name Parameters Action }] set result [list] relation foreach state $states { relation assign $state lappend result $Name $Parameters $Action } return $result } events { return [pipe { relvar set ::rosea::Config::EffectiveEvent | relation restrictwith ~\ {$Domain eq $domainname && $Model eq $classname} | relation list ~ Event }] } transitions { return [pipe { relvar set ${domns}::__Arch_Transition | relation restrictwith ~ {$Class eq $classname} | relation eliminate ~ Class | relation group ~ Transition Event NewState | relation extend ~ trtup TranCol dict { [relation dict [tuple extract $trtup Transition] Event NewState]} | relation dict ~ State TranCol }] ; # <1> } activityproc { return ${domns}::${classname}::__Activity::${statename} } } } } namespace eval Trace { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path [list\ [namespace parent]::Helpers\ [namespace parent]::InstCmds\ ] relvar create Trace { Trace_Id int Timestamp bignum Source list Event string Target list Params list } Trace_Id relvar create Creation { Trace_Id int } Trace_Id relvar create Polymorphic { Trace_Id int SubInst string Linkage string } Trace_Id relvar create Transition { Trace_Id int CurrState string NewState string } Trace_Id relvar partition R1 Trace Trace_Id\ Creation Trace_Id\ Polymorphic Trace_Id\ Transition Trace_Id variable targetCmpFunc [lambda {instrefs target} { lassign $target trelvar tinst foreach instref $instrefs { lassign $instref crelvar cinst if {$trelvar eq $crelvar && [ral relation is $tinst subsetof $cinst]} { return true } } return false }] variable traceState off variable traceNumber 0 variable traceLogState off variable traceLogLevel info variable traceLogCmd [::logger::init rosea] proc QueryClassTraces {classes} { variable Trace return [relation restrictwith $Trace { [lindex $Target 0] in $classes ||\ [namespace tail [lindex $Target 0]] in $classes }] ; # <1> } proc QueryTargetTraces {targets} { variable Trace variable targetCmpFunc return [relation restrictwith $Trace {[{*}$targetCmpFunc $targets $Target]}] } proc TraceCreation {source event target params} { variable traceState if {$traceState} { relvar eval { set trace [NewTrace $source $event $target $params] relvar insert Creation [list\ Trace_Id [relation extract $trace Trace_Id]\ ] } LogTrace $trace } } proc TracePolymorphic {source event target sub link params} { variable traceState if {$traceState} { relvar eval { set trace [NewTrace $source $event $target $params] relvar insert Polymorphic [list\ Trace_Id [relation extract $trace Trace_Id]\ SubInst $sub\ Linkage $link\ ] } LogTrace $trace } } proc TraceTransition {source event target curr new params} { variable traceState if {$traceState} { relvar eval { set trace [NewTrace $source $event $target $params] relvar insert Transition [list\ Trace_Id [relation extract $trace Trace_Id]\ CurrState $curr\ NewState $new\ ] } LogTrace $trace } } proc NewTrace {src event target params} { variable traceNumber return [relvar insert Trace [list\ Trace_Id [incr traceNumber]\ Timestamp [clock microseconds]\ Source $src\ Event $event\ Target $target\ Params $params\ ]] } proc LogTrace {trace} { variable traceLogState if {$traceLogState} { set rec [FormatTraceRec [lindex [TracesToRecords $trace] 0]] ; # <1> variable traceLogCmd variable traceLogLevel ${traceLogCmd}::${traceLogLevel} $rec } } proc TracesToRecords {traces} { foreach rvname {Creation Polymorphic Transition} { # <1> set traces [::ralutil::rvajoin $traces [relvar set $rvname] $rvname] } set result [list] relation foreach trace $traces -ascending Trace_Id { # <2> relation assign $trace set labeled [dict create\ id $Trace_Id\ time $Timestamp\ source $Source\ event $Event\ target $Target\ params $Params\ class [lindex $Target 0]\ ] ; # <3> if {[relation isnotempty $Transition]} { # <4> relation assign $Transition dict set labeled type transition dict set labeled current $CurrState dict set labeled new $NewState } elseif {[relation isnotempty $Polymorphic]} { relation assign $Polymorphic dict set labeled type polymorphic dict set labeled sub $SubInst dict set labeled link $Linkage } elseif {[relation isnotempty $Creation]} { dict set labeled type creation } lappend result $labeled } return $result } proc DecodeAllTraces {} { variable Trace tailcall TracesToRecords $Trace } proc DecodeClassTraces {args} { return [TracesToRecords [QueryClassTraces $args]] } proc DecodeTargetTraces {args} { tailcall TracesToRecords [QueryTargetTraces $args] } proc FormatTraceRec {rec} { dict with rec { switch -exact -- $type { transition { append result\ "Transition: "\ [FormatTransition $source $event $params $target]\ " ==> $current -> $new" } polymorphic { append result\ "Polymorphic : "\ [FormatTransition $source $event $params $target]\ " ==> $link -> [FormatInstRef $sub]" } creation { append result\ "Creation: "\ "[FormatInstRef $source] - "\ "[FormatEvent $event $params] -> $class\ " ==> [FormatInstRef $target]" } default { DeclError BAD_TRACETYPE $type } } } return $result } proc FormatTransition {source event params target} { return "[FormatInstRef $source] - [FormatEvent $event $params] ->\ [FormatInstRef $target]" } proc FormatEvent {event params} { return [string cat\ $event\ [expr {[llength $params] != 0 ? "\([join $params {, }]\)" : {}}]\ ] } proc FormatInstRef {instref} { lassign $instref relvar inst if {$relvar eq {}} { return {{}} } else { return "$relvar\{[tuple get [relation tuple $inst]]\}" } } proc FormatTimestamp {time} { set sec [clock format [expr {$time / 1000000}] -format %T] ; # <1> set time [expr {$time % 1000000}] set msec [expr {$time / 1000}] set usec [expr {$time % 1000}] return [format %s.%03ld.%03ld $sec $msec $usec] } proc FormatTimeAsSec {time} { set sec [expr {$time / 1000000}] set time [expr {$time % 1000000}] set msec [expr {$time / 1000}] set usec [expr {$time % 1000}] return [format %3ld.%03ld.%03ld $sec $msec $usec] } proc DiagTraces {traces args} { set result {} append result "seqdiag \{\n" append result " activation = none;\n" foreach {option value} $args { append result " $option = $value;\n" } foreach rvname {Creation Polymorphic Transition} { set traces [::ralutil::rvajoin $traces [relvar set $rvname] $rvname] } relation foreach trace $traces -ascending Trace_Id { relation assign $trace if {[isEmptyRef $Source]} { set Source EXTERNAL } else { set Source [namespace tail [lindex $Source 0]] } set Target [namespace tail [lindex $Target 0]] set evtlabel [FormatEvent $Event $Params] if {[relation isnotempty $Polymorphic]} { relation assign $Transition Linkage append evtlabel " <<Polymorphic $Linkage>>" } elseif {[relation isnotempty $Creation]} { append evtlabel " <<Creation>>" } append result " $Source ->> $Target \[label=\"$evtlabel\"\];\n" } append result "\}\n" return $result } proc DiagAllTraces {filename args} { set chan [open $filename w] variable Trace try { chan puts $chan [DiagTraces $Trace {*}$args] } finally { chan close $chan } return } proc DiagClassTraces {filename classes args} { set chan [open $filename w] try { chan puts $chan [DiagTraces [QueryClassTraces $classes] {*}$args] } finally { chan close $chan } return } proc DiagTargetTraces {filename targets args} { set chan [open $filename w] try { chan puts $chan [DiagTraces [QueryTargetTraces $targets] {*}$args] } finally { chan close $chan } return } } namespace path ::rosea::Helpers namespace import ::rosea::Config::ConfigEvaluate } package provide rosea $::rosea::version |
< < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted packages/package-rosea-1.9-tcl.tm.
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 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 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 |
# ACTIVESTATE TEAPOT-PKG BEGIN TM -*- tcl -*- # -- Tcl Module # @@ Meta Begin # Package rosea 1.9 # Meta description Rosea is a data and execution architecture for # Meta description translating XUML models using Tcl as the implementation # Meta description language. # Meta platform tcl # Meta require {Tcl 8.6} # Meta require logger # Meta require ral # Meta require ralutil # Meta require struct::set # Meta require lambda # Meta summary Rosea -- XUML Software Architecture # @@ Meta End # ACTIVESTATE TEAPOT-PKG BEGIN REQUIREMENTS package require Tcl 8.6 package require logger package require ral package require ralutil package require struct::set package require lambda # ACTIVESTATE TEAPOT-PKG END REQUIREMENTS # ACTIVESTATE TEAPOT-PKG BEGIN DECLARE package provide rosea 1.9 # ACTIVESTATE TEAPOT-PKG END DECLARE # ACTIVESTATE TEAPOT-PKG END TM # DO NOT EDIT THIS FILE! # THIS FILE IS AUTOMATICALLY GENERATED FROM A LITERATE PROGRAM SOURCE FILE. # # This software is copyrighted 2014-2015 by G. Andrew Mangogna. # The following terms apply to all files associated with the software unless # explicitly disclaimed in individual files. # # The authors hereby grant permission to use, copy, modify, distribute, # and license this software and its documentation for any purpose, provided # that existing copyright notices are retained in all copies and that this # notice is included verbatim in any distributions. No written agreement, # license, or royalty fee is required for any of the authorized uses. # Modifications to this software may be copyrighted by their authors and # need not follow the licensing terms described here, provided that the # new terms are clearly indicated on the first page of each file where # they apply. # # IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING # OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES # THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE # IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE # NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, # OR MODIFICATIONS. # # GOVERNMENT USE: If you are acquiring this software on behalf of the # U.S. government, the Government shall have only "Restricted Rights" # in the software and related documentation as defined in the Federal # Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you # are acquiring the software on behalf of the Department of Defense, # the software shall be classified as "Commercial Computer Software" # and the Government shall have only "Restricted Rights" as defined in # Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, # the authors grant the U.S. Government and others acting in its behalf # permission to use and distribute the software in accordance with the # terms specified in this license. package require Tcl 8.6 package require logger package require ral package require ralutil package require struct::set package require lambda proc ::K {x y} {set x} namespace eval ::rosea { namespace export configure namespace export configureFromChan namespace export configureFromFile namespace export generate namespace export populate namespace export populateFromChan namespace export populateFromFile namespace export save namespace export restore namespace export info namespace export tunnel namespace export trace namespace ensemble create variable version 1.9 logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar pipe { relation semijoin $class $Attribute -using {Domain Domain Name Class} | relation project ~ Name Type | relation dict ~ Name Type } headingQuery pipe { relation semijoin $class $Identifier -using {Domain Domain Name Class}\ $IdentifyingAttribute | relation group ~ Attributes Attribute } idQuery pipe { relation semijoin $class $Attribute -using {Domain Domain Name Class} | relation join ~ $UserSuppliedValue -using {Domain Domain Class Class Name Attribute} } defaultValuesQuery pipe { relation semijoin $class $Attribute -using {Domain Domain Name Class} | relation join ~ $SystemSuppliedValue -using {Domain Domain Class Class Name Attribute} } suppliedValuesQuery pipe { relation semijoin $class $Attribute -using {Domain Domain Name Class} | relation join ~ $GeneratedValue -using {Domain Domain Class Class Name Attribute} } generatedValuesQuery pipe { relation semijoin $class $Attribute -using {Domain Domain Name Class} | relation join ~ $ValueCheck -using {Domain Domain Class Class Name Attribute} } checkValuesQuery pipe { relation semijoin $class $StateModel -using {Domain Domain Name Model} | relation isnotempty } hasSMQuery pipe { relation semijoin $class $State -using {Domain Domain Name Model} | relation project ~ Name Parameters Action } statesQuery pipe { relation join $AttributeReference $refing\ -using {Domain Domain ReferringClass Class\ Relationship Relationship ReferringRole Role} | relation rename ~ Conditionality ReferringCond\ Multiplicity ReferringMult | relation join ~ $refed -using {Domain Domain\ ReferencedClass Class Relationship\ Relationship ReferencedRole Role} | relation project ~ Domain Relationship\ ReferringClass ReferringAttribute\ ReferencedClass ReferencedAttribute\ ReferringCond ReferringMult Conditionality | relation group ~ ReferringAttrs\ ReferringAttribute ReferencedAttribute | relation extend ~ rfa\ TagReferringAttrs {Relation {RefOrder int ReferringAttribute string\ ReferencedAttribute string}} { [relation tag [tuple extract $rfa ReferringAttrs] RefOrder] } | relation extend ~ wfa\ SrcAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferringAttribute -ascending RefOrder] }\ DstAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferencedAttribute -ascending RefOrder] } | relation extend ~ ram\ ForwAttrs list { [Interleave [tuple extract $ram SrcAttrs]\ [tuple extract $ram DstAttrs]] }\ RevAttrs list { [Interleave [tuple extract $ram DstAttrs]\ [tuple extract $ram SrcAttrs]] } | relation eliminate ~ TagReferringAttrs } referencesQuery pipe { relation semijoin $cassocs $AssociatorClass\ -using {Domain Domain Name Relationship}\ $ReferringClass $AttributeReference\ -using {Domain Domain Class ReferringClass\ Relationship Relationship Role ReferringRole} | relation project ~ Domain Relationship ReferringClass ReferringAttribute\ ReferencedClass ReferencedAttribute ReferencedRole | relation join ~ $bothclass -using {Domain Domain Relationship Relationship\ ReferencedClass Class ReferencedRole Role} | relation group ~ ReferringAttrs ReferringAttribute ReferencedAttribute | relation extend ~ rfa\ TagReferringAttrs {Relation {RefOrder int ReferringAttribute string\ ReferencedAttribute string}} { [relation tag [tuple extract $rfa ReferringAttrs] RefOrder] } | relation extend ~ wfa\ SrcAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferringAttribute -ascending RefOrder] }\ DstAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferencedAttribute -ascending RefOrder] } | relation extend ~ ram\ ForwAttrs list { [Interleave [tuple extract $ram SrcAttrs]\ [tuple extract $ram DstAttrs]] }\ RevAttrs list { [Interleave [tuple extract $ram DstAttrs]\ [tuple extract $ram SrcAttrs]] } | relation eliminate ~ TagReferringAttrs } assocrefsQuery pipe { relation semijoin $rships $Generalization\ $Subclass -using {Domain Domain Name Relationship}\ $ReferringClass $AttributeReference\ -using {Domain Domain Class ReferringClass\ Relationship Relationship Role ReferringRole} | relation project ~ Domain Relationship ReferringClass ReferringAttribute\ ReferencedClass ReferencedAttribute | relation group ~ ReferringAttrs\ ReferringAttribute ReferencedAttribute | relation extend ~ rfa\ TagReferringAttrs {Relation {RefOrder int ReferringAttribute string\ ReferencedAttribute string}} { [relation tag [tuple extract $rfa ReferringAttrs] RefOrder] } | relation extend ~ wfa\ SrcAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferringAttribute -ascending RefOrder] }\ DstAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferencedAttribute -ascending RefOrder] } | relation extend ~ ram\ ForwAttrs list { [Interleave [tuple extract $ram SrcAttrs]\ [tuple extract $ram DstAttrs]] }\ RevAttrs list { [Interleave [tuple extract $ram DstAttrs]\ [tuple extract $ram SrcAttrs]] } | relation eliminate ~ TagReferringAttrs } subrefsQuery proc configure {script} { namespace upvar Config errcount errcount configlineno configlineno set errcount 0 set configlineno 1 ConfigEvaluate ::rosea::Config $script if {$errcount > 0} { tailcall DeclError CONFIG_ERRORS $errcount } return $errcount } proc configureFromChan {chan} { tailcall configure [::chan read -nonewline $chan] } proc configureFromFile {filename} { set f [::open $filename r] try { configureFromChan $f } finally { ::chan close $f } } proc generate {{pattern *} {prefix {}}} { if {$prefix ne {}} { if {[string range $prefix 0 1] ne "::"} { set prefix [uplevel 1 {namespace current}]::$prefix } set prefix [string trimright $prefix :] } elseif {$prefix eq "::"} { set prefix {} ; # <1> } namespace upvar Config\ Domain Domain\ DomainElement DomainElement\ Class Class\ Attribute Attribute\ DefaultValue DefaultValue\ UserSuppliedValue UserSuppliedValue\ SystemSuppliedValue SystemSuppliedValue\ GeneratedValue GeneratedValue\ ValueCheck ValueCheck\ Identifier Identifier\ IdentifyingAttribute IdentifyingAttribute\ Relationship Relationship\ Association Association\ SimpleAssociation SimpleAssociation\ SimpleReferringClass SimpleReferringClass\ SimpleReferencedClass SimpleReferencedClass\ ClassBasedAssociation ClassBasedAssociation\ AssociatorClass AssociatorClass\ SourceClass SourceClass\ TargetClass TargetClass\ Generalization Generalization\ Superclass Superclass\ Subclass Subclass\ AttributeReference AttributeReference\ ReferencedIdAttribute ReferencedIdAttribute\ ReferringClass ReferringClass\ ReferencedClass ReferencedClass\ DomainOperation DomainOperation\ SuppliedOperation SuppliedOperation\ UserClassOperation UserClassOperation\ SystemClassOperation SystemClassOperation\ UserInstanceOperation UserInstanceOperation\ SystemInstanceOperation SystemInstanceOperation\ InstanceStateModel InstanceStateModel\ StateModel StateModel\ StatePlace StatePlace\ State State\ EffectiveEvent EffectiveEvent\ DeferredEvent DeferredEvent\ TransitionPlace TransitionPlace\ StateTransition StateTransition\ NonStateTransition NonStateTransition\ AssignerStateModel AssignerStateModel\ SingleAssigner SingleAssigner\ MultipleAssigner MultipleAssigner\ PolymorphicEvent PolymorphicEvent set genDomain [relation restrict $Domain dom { [string match $pattern [tuple extract $dom Name]] }] relation foreach domain $genDomain { set domainName [relation extract $domain Name] relvar updateone Config::Domain dtup [list Name $domainName] { tuple update $dtup Location $prefix } set domns ${prefix}::$domainName namespace eval $domns { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe ral relvar create __Arch_RefLink { Relationship string ReferringClass string ReferencedClass string ReferringAttrs {Relation {ReferringAttribute string ReferencedAttribute string}} } Relationship ral relvar create __Arch_AssocRef { Relationship string AssocClass string References {Relation\ {Participant string Role string ReferringAttrs {Relation\ {ReferringAttribute string ReferencedAttribute string}}}} } Relationship ral relvar create __Arch_SuperLink { Relationship string SuperClass string } Relationship ral relvar create __Arch_SubLink { Relationship string SubClass string ReferringAttrs {Relation\ {ReferringAttribute string ReferencedAttribute string}} } {Relationship SubClass} ral relvar association __Arch_R5\ __Arch_SubLink Relationship +\ __Arch_SuperLink Relationship 1 ral relvar create __Arch_Link { Name string SrcClass string } {Name SrcClass} ral relvar create __Arch_AssociationLink { Name string SrcClass string DstClass string Attrs list PrevSrcClass string } {Name SrcClass} ral relvar association __Arch_R4\ __Arch_AssociationLink {Name PrevSrcClass} ?\ __Arch_AssociationLink {Name SrcClass} ? ral relvar create __Arch_PartitionLink { Name string SrcClass string } {Name SrcClass} ral relvar partition __Arch_R3 __Arch_Link {Name SrcClass}\ __Arch_AssociationLink {Name SrcClass}\ __Arch_PartitionLink {Name SrcClass} ral relvar create __Arch_PartitionDst { Name string SrcClass string DstClass string Attrs list } {Name SrcClass DstClass} ral relvar association __Arch_R2\ __Arch_PartitionDst {Name SrcClass} +\ __Arch_PartitionLink {Name SrcClass} 1 ral relvar create __Arch_State { Class string State string } {Class State} ral relvar create __Arch_Event { Class string Event string } {Class Event} ral relvar create __Arch_Transition { Class string State string Event string NewState string } {Class State Event} ral relvar correlation __Arch_R1 __Arch_Transition\ {Class State} + __Arch_State {Class State}\ {Class Event} + __Arch_Event {Class Event} ral relvar create __Arch_InitialState { Class string State string } Class ral relvar association __Arch_R6\ __Arch_InitialState {Class State} ?\ __Arch_State {Class State} 1 ral relvar create __Arch_TerminalState { Class string State string } {Class State} ral relvar association __Arch_R7\ __Arch_TerminalState {Class State} *\ __Arch_State {Class State} 1 ral relvar create __Arch_PolymorphicEvent { Class string Event string } {Class Event} } namespace eval $domns namespace path ::rosea::InstCmds set domops [relation semijoin $domain $DomainOperation -using {Name Domain}] relation foreach domop $domops { relation assign $domop\ {Name name} {Parameters parameters} {Body body} proc ${domns}::$name $parameters [list ::ral relvar eval $body] ; # <1> } namespace eval $domns [list\ namespace export {*}[relation list $domops Name]\ ] namespace eval $domns namespace ensemble create set statemodels [relation semijoin $domain $StateModel\ -using {Name Domain}] relvar eval { relvar set ${domns}::__Arch_InitialState [pipe { relation project $statemodels Model InitialState | relation rename ~ Model Class InitialState State }] set states [relation semijoin $domain $StatePlace -using {Name Domain}] relvar set ${domns}::__Arch_State [pipe { relation project $states Model Name | relation rename ~ Model Class Name State }] relvar set ${domns}::__Arch_TerminalState [pipe { relation semijoin $domain $State -using {Name Domain} | relation restrict ~ termtuple {[tuple extract $termtuple IsFinal]} | relation project ~ Model Name | relation rename ~ Model Class Name State }] set events [relation semijoin $domain $EffectiveEvent\ -using {Name Domain}] relvar set ${domns}::__Arch_Event [pipe { relation project $events Model Event | relation rename ~ Model Class }] set alltrans [pipe { relation join $states $events | relation rename ~ Name State }] ; # <1> set statetrans [relation semijoin $domain $StateTransition\ -using {Name Domain}] set nontrans [pipe { relation semijoin $domain $NonStateTransition -using {Name Domain} | relation rename ~ TransRule NewState }] set deftrans [pipe { relation minus $alltrans $TransitionPlace | relation join ~ $StateModel | relation eliminate ~ InitialState | relation rename ~ DefaultTrans NewState | relation update ~ dttup {[tuple extract $dttup State] eq "@"} { tuple update $dttup NewState CH} }] relvar set ${domns}::__Arch_Transition [pipe { relation union $statetrans $nontrans $deftrans | relation eliminate ~ Domain | relation rename ~ Model Class }] relvar set ${domns}::__Arch_PolymorphicEvent [pipe { relation semijoin $domain $DeferredEvent\ -using {Name Domain} | relation project ~ Model Event | relation rename ~ Model Class }] } variable headingQuery variable idQuery variable defaultValuesQuery variable suppliedValuesQuery variable generatedValuesQuery variable checkValuesQuery variable hasSMQuery variable statesQuery set classes [relation semijoin $domain $DomainElement -using {Name Domain}\ $Class -using {Domain Domain Element Name}] relation foreach class $classes { set className ${domns}::[relation extract $class Name] namespace eval $className { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe } namespace eval $className [list namespace path\ [list ::rosea::InstCmds $domns]] set heading [eval $headingQuery] set idset [list] relation foreach id [eval $idQuery] -ascending Number { lappend idset [relation list\ [relation extract $id Attributes] Attribute] } relvar create $className $heading {*}$idset # <1> set checkvalues [eval $checkValuesQuery] if {[relation isnotempty $checkvalues]} { relvar trace add variable $className {insert update set} [list\ ::rosea::Helpers::CheckValueTrace\ [relation dict $checkvalues Name Expression]\ ] } set defaultvalues [eval $defaultValuesQuery] if {[relation isnotempty $defaultvalues]} { relvar trace add variable $className insert [list\ ::rosea::Helpers::UserDefaultTrace\ [relation dict $defaultvalues Name Type]\ [relation dict $defaultvalues Name Value]\ ] } set supplied [eval $suppliedValuesQuery] if {[relation isnotempty $supplied]} { pipe { relation extend $supplied stup ClassName string { [string cat [tuple extract $stup Class] , [tuple extract $stup Name]] } | relation array ~ ${domns}::__Arch_SuppliedDefault ClassName StartValue } ; # <1> relvar trace add variable $className insert [list\ ::rosea::Helpers::SupplyDefaultTrace\ [relation dict $supplied Name Type]\ ] } set generatecmds [eval $generatedValuesQuery] if {[relation isnotempty $generatecmds]} { relvar trace add variable $className insert [list\ ::rosea::Helpers::GenerateDefaultTrace\ [relation dict $generatecmds Name Type]\ [relation dict $generatecmds Name Cmd]\ ] } set hasStateModel [eval $hasSMQuery] if {$hasStateModel} { set instid [lindex $idset 0] set instheading [list] foreach attr $instid { lappend instheading $attr [dict get $heading $attr] ; # <1> } lappend instheading __State string relvar create ${domns}::[relation extract $class Name]__STATEINST\ $instheading $instid set actns ${className}::__Activity namespace eval $actns { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe } namespace eval $actns [list\ namespace path [list\ ::rosea::InstCmds\ $className\ $domns\ ]\ ] relation foreach state [eval $statesQuery] { relation assign $state\ {Name stateName}\ {Parameters params}\ {Action stateAction} proc ${actns}::$stateName [linsert $params 0 self] $stateAction } } set opmap [dict create] set classops [relation semijoin $class $UserClassOperation\ -using {Domain Domain Name Class}] relation foreach classop $classops { relation assign $classop\ {Name opname}\ {Parameters params}\ {Body opbody} proc ${className}::$opname $params $opbody dict set opmap $opname ${className}::$opname } set sysmap [QuerySystemClassOperations $className false] if {$hasStateModel} { set sysmap [dict merge $sysmap [QuerySystemClassOperations $className true]] } namespace ensemble create\ -command $className\ -map [dict merge $opmap $sysmap] set opmap [dict create] set instops [relation semijoin $class $UserInstanceOperation\ -using {Domain Domain Name Class}] relation foreach instop $instops { relation assign $instop\ {Name opname}\ {Parameters params}\ {Body opbody} proc ${className}::$opname [linsert $params 0 self] $opbody dict set opmap $opname ${className}::$opname } set sysmap [QuerySystemInstanceOperations false] set hasPolyEvents [relation isnotempty\ [relation semijoin $class $PolymorphicEvent\ -using {Domain Domain Name Model}]\ ] if {$hasStateModel || $hasPolyEvents} { set sysmap [dict merge $sysmap [QuerySystemInstanceOperations true]] } namespace ensemble create\ -command ${className}::Instance\ -parameters instref\ -map [dict merge $opmap $sysmap] } set rships [relation semijoin $domain $DomainElement -using {Name Domain}\ $Relationship -using {Domain Domain Element Name}] set sassocs [relation semijoin $rships $Association\ $SimpleAssociation] set refing [relation semijoin $sassocs $SimpleReferringClass\ -using {Domain Domain Name Relationship}] set refed [relation semijoin $sassocs $SimpleReferencedClass\ -using {Domain Domain Name Relationship}] variable referencesQuery set references [eval $referencesQuery] relvar eval { set flink [pipe { relation project $references Relationship ReferringClass | relation rename ~ Relationship Name ReferringClass SrcClass }] set blink [pipe { relation project $references Relationship ReferencedClass | relation rename % Relationship Name ReferencedClass SrcClass | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] ; # <1> relvar union ${domns}::__Arch_Link $flink $blink set flink [pipe { relation project $references Relationship ReferringClass\ ReferencedClass ForwAttrs | relation rename ~ Relationship Name ReferringClass SrcClass\ ReferencedClass DstClass ForwAttrs Attrs | relation extend ~ al PrevSrcClass string {{}} }] ; # <1> set blink [pipe { relation project $references Relationship ReferringClass\ ReferencedClass RevAttrs | relation rename % Relationship Name ReferencedClass SrcClass\ ReferringClass DstClass RevAttrs Attrs | relation extend % al PrevSrcClass string {{}} | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] relvar union ${domns}::__Arch_AssociationLink $flink $blink relvar union ${domns}::__Arch_RefLink [relation project $references\ Relationship ReferringClass ReferencedClass ReferringAttrs] } relation foreach reference $references { relation assign $reference\ {Relationship relationship}\ {ReferringClass referringClass}\ {ReferencedClass referencedClass}\ {ReferringCond referringCond}\ {ReferringMult referringMult}\ {Conditionality referencedCond}\ {SrcAttrs srcAttrs}\ {DstAttrs dstAttrs} # Create the relvar constraint. relvar association ${domns}::$relationship\ ${domns}::$referringClass $srcAttrs\ [MapCondMultToConstraint $referringCond $referringMult]\ ${domns}::$referencedClass $dstAttrs\ [MapCondMultToConstraint $referencedCond false] # All simple associations get a link and unlink command in their ensemble. set ensemblemap [dict create\ link [list ::rosea::RelCmds::linkSimple $relationship]\ unlink [list ::rosea::RelCmds::unlinkSimple $relationship]\ ] # Determine if we have any assigners assocated with the relationship. # Single assigners get different commands from multiple assigners. set rpath ${domns}::$relationship set assigner [relation semijoin $reference $SingleAssigner\ -using {Domain Domain Relationship Relationship}] if {[relation isnotempty $assigner]} { dict set ensemblemap signal\ [list ::rosea::RelCmds::signalAssigner $rpath] } else { set assigner [relation semijoin $reference $MultipleAssigner\ -using {Domain Domain Relationship Relationship}] if {[relation isnotempty $assigner]} { dict set ensemblemap signal [list\ ::rosea::RelCmds::signalMultiAssigner $rpath] dict set ensemblemap create [list\ ::rosea::RelCmds::createMultiAssigner $rpath] } } # Create the relationship ensemble command. namespace ensemble create -command $rpath -map $ensemblemap } set cassocs [relation semijoin $rships $Association\ $ClassBasedAssociation] set sourceclass [relation semijoin $cassocs $SourceClass\ -using {Domain Domain Name Relationship}] set targetclass [relation semijoin $cassocs $TargetClass\ -using {Domain Domain Name Relationship}] set bothclass [relation union $sourceclass $targetclass] ; # <1> variable assocrefsQuery set assocrefs [eval $assocrefsQuery] relvar eval { set aforw [pipe { relation project $assocrefs Relationship ReferringClass | relation rename ~ Relationship Name ReferringClass SrcClass }] set arev [relation update $aforw lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]}] set sources [pipe { relation restrict $assocrefs aref { [tuple extract $aref ReferencedRole] eq "source"} | relation eliminate ~ ReferencedRole }] set sforw [pipe { relation project $sources Relationship ReferencedClass | relation rename ~ Relationship Name ReferencedClass SrcClass }] set targets [pipe { relation restrict $assocrefs aref { [tuple extract $aref ReferencedRole] eq "target"} | relation eliminate ~ ReferencedRole }] set trev [pipe { relation project $targets Relationship ReferencedClass | relation rename % Relationship Name ReferencedClass SrcClass | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] relvar union ${domns}::__Arch_Link $aforw $arev $sforw $trev set sforw [pipe { relation project $sources Relationship ReferringClass ReferencedClass\ RevAttrs | relation rename ~ Relationship Name ReferringClass DstClass\ ReferencedClass SrcClass RevAttrs Attrs | relation extend ~ al PrevSrcClass string {{}} }] set trev [pipe { relation project $targets Relationship ReferringClass ReferencedClass\ RevAttrs | relation rename % Relationship Name ReferringClass DstClass\ ReferencedClass SrcClass RevAttrs Attrs | relation extend % al PrevSrcClass string {{}} | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] set onerefs [relation rename $sources ReferencedClass OneClass\ Conditionality OneCond Multiplicity OneMult\ ReferringAttrs OneReferringAttrs SrcAttrs OneSrcAttrs\ DstAttrs OneDstAttrs ForwAttrs OneForwAttrs RevAttrs OneRevAttrs] set otherrefs [relation rename $targets ReferencedClass OtherClass\ Conditionality OtherCond Multiplicity OtherMult ReferringAttrs\ OtherReferringAttrs SrcAttrs OtherSrcAttrs DstAttrs OtherDstAttrs\ ForwAttrs OtherForwAttrs RevAttrs OtherRevAttrs] set bothrefs [relation join $onerefs $otherrefs\ -using {Domain Domain ReferringClass ReferringClass\ Relationship Relationship}] set aforw [pipe { relation project $bothrefs Relationship ReferringClass OtherClass\ OtherForwAttrs OneClass | relation rename ~ Relationship Name ReferringClass SrcClass\ OtherClass DstClass OtherForwAttrs Attrs OneClass PrevSrcClass }] set arev [pipe { relation project $bothrefs Relationship ReferringClass OneClass\ OneForwAttrs OtherClass | relation rename % Relationship Name ReferringClass SrcClass\ OneClass DstClass OneForwAttrs Attrs OtherClass PrevSrcClass | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] relvar union ${domns}::__Arch_AssociationLink $sforw $trev $aforw $arev relvar union ${domns}::__Arch_AssocRef [pipe { relation project $assocrefs Relationship ReferringClass\ ReferencedClass ReferencedRole ReferringAttrs | relation rename ~ ReferringClass AssocClass ReferencedClass Participant\ ReferencedRole Role | relation group ~ References Participant Role ReferringAttrs }] } relation foreach bothref $bothrefs { relation assign $bothref\ {Relationship relationship}\ {ReferringClass associator}\ {OneClass sourceClass}\ {OneCond sourceCond}\ {OneMult sourceMult}\ {OneSrcAttrs sourceAssocAttrs}\ {OneDstAttrs sourceDstAttrs}\ {OtherClass targetClass}\ {OtherCond targetCond}\ {OtherMult targetMult}\ {OtherSrcAttrs targetAssocAttrs}\ {OtherDstAttrs targetDstAttrs} # Create the correlation constraint relvar correlation ${domns}::$relationship ${domns}::$associator\ $sourceAssocAttrs [MapCondMultToConstraint $targetCond $targetMult]\ ${domns}::$sourceClass $sourceDstAttrs\ $targetAssocAttrs [MapCondMultToConstraint $sourceCond $sourceMult]\ ${domns}::$targetClass $targetDstAttrs ; # <1> set ensemblemap [dict create\ link [list ::rosea::RelCmds::linkAssoc $relationship]\ reference [list ::rosea::RelCmds::referenceAssoc $relationship]\ unlink [list ::rosea::RelCmds::unlinkAssoc $relationship]\ ] # Determine if we have any assigners set rpath ${domns}::$relationship set assigner [relation semijoin $bothref $SingleAssigner\ -using {Domain Domain Relationship Relationship}] if {[relation isnotempty $assigner]} { dict set ensemblemap signal\ [list ::rosea::RelCmds::signalAssigner $rpath] } else { set assigner [relation semijoin $bothref $MultipleAssigner\ -using {Domain Domain Relationship Relationship}] if {[relation isnotempty $assigner]} { dict set ensemblemap signal [list\ ::rosea::RelCmds::signalMultiAssigner $rpath] dict set ensemblemap create [list\ ::rosea::RelCmds::createMultiAssigner $rpath] } } namespace ensemble create -command $rpath -map $ensemblemap } variable subrefsQuery set subrefs [eval $subrefsQuery] relvar eval { set sublinks [pipe { relation project $subrefs Relationship ReferringClass | relation rename ~ Relationship Name ReferringClass SrcClass }] set superlinks [pipe { relation project $subrefs Relationship ReferencedClass | relation rename % Relationship Name ReferencedClass SrcClass | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] relvar union ${domns}::__Arch_Link $sublinks $superlinks relvar union ${domns}::__Arch_AssociationLink [pipe { relation project $subrefs Relationship ReferringClass ReferencedClass\ ForwAttrs | relation rename ~ Relationship Name ReferringClass SrcClass\ ReferencedClass DstClass ForwAttrs Attrs | relation extend ~ al PrevSrcClass string {{}} }] relvar union ${domns}::__Arch_PartitionLink $superlinks relvar union ${domns}::__Arch_PartitionDst [pipe { relation project $subrefs Relationship ReferencedClass\ ReferringClass RevAttrs | relation rename % Relationship Name ReferencedClass SrcClass\ ReferringClass DstClass RevAttrs Attrs | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] relvar union ${domns}::__Arch_SuperLink [pipe { relation project $subrefs Relationship ReferencedClass | relation rename ~ ReferencedClass SuperClass }] relvar union ${domns}::__Arch_SubLink [pipe { relation project $subrefs Relationship ReferringClass ReferringAttrs | relation rename ~ ReferringClass SubClass }] } set partrefs [pipe { relation project $subrefs Relationship ReferencedClass DstAttrs\ ReferringClass SrcAttrs | relation extend ~ prs SubAttrMap list {[list\ ${domns}::[tuple extract $prs ReferringClass]\ [tuple extract $prs SrcAttrs]]} | relation eliminate ~ ReferringClass SrcAttrs | relation group ~ SubClassRefs SubAttrMap | relation extend ~ spt SubParts list { [concat {*}[relation list [tuple extract $spt SubClassRefs]]]} | relation eliminate ~ SubClassRefs }] relation foreach partref $partrefs { relation assign $partref\ {Relationship relationship}\ {ReferencedClass superclass}\ {DstAttrs superattrs}\ {SubParts subparts} relvar partition ${domns}::$relationship ${domns}::$superclass\ $superattrs {*}$subparts namespace ensemble create\ -command ${domns}::$relationship\ -map [dict create migrate [list ::rosea::RelCmds::migrate\ $relationship]] } set assigners [relation semijoin $domain $AssignerStateModel\ -using {Name Domain}] relation foreach assigner $assigners { set asgnns\ ${domns}::[relation extract $assigner Relationship]::__Activity namespace eval $asgnns { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe } namespace eval $asgnns [list\ namespace path [list\ ::rosea::InstCmds\ $domns\ ]\ ] set states [pipe { relation semijoin $assigner $State\ -using {Domain Domain Relationship Model} | relation project ~ Name Parameters Action }] relation foreach state $states { relation assign $state\ {Name stateName}\ {Parameters params}\ {Action stateAction} set params [linsert $params 0 self] proc ${asgnns}::$stateName $params $stateAction } } relation foreach sassigner\ [relation semijoin $domain $SingleAssigner\ -using {Name Domain}] { relation assign $sassigner {Relationship relationship} relvar create ${domns}::${relationship}__STATEINST { Id int __State string } Id CreateInInitialState $domns $relationship {Id 0} ; # <1> } relation foreach massigner\ [relation semijoin $domain $MultipleAssigner\ -using {Name Domain}] { relation assign $massigner {Relationship relationship} set assignvar ${domns}::${relationship}__STATEINST set idattrs [pipe { relation semijoin $massigner $Identifier\ $IdentifyingAttribute\ $Attribute -using {Domain Domain Class Class\ Attribute Name} | relation dict ~ Name Type }] relvar create $assignvar\ [concat $idattrs [list __State string]]\ [dict keys $idattrs] } } } proc populate {script} { namespace upvar Config errcount errcount configlineno configlineno set errcount 0 set configlineno 1 ConfigEvaluate ::rosea::Populate $script ; # <1> if {$errcount > 0} { tailcall DeclError CONFIG_ERRORS $errcount } return $errcount } proc populateFromChan {chan} { tailcall populate [::chan read -nonewline $chan] } proc populateFromFile {filename} { set f [::open $filename r] try { populateFromChan $f } finally { ::chan close $f } } proc save {args} { set savecmd ::ral::serializeToFile set asynccmd {} set options $args while {1} { if {[string index [lindex $options 0] 0] eq "-"} { set options [lassign $options option] switch -exact -- $option { -sqlite { set savecmd ::ral::storeToSQLite } -tclral { set savecmd ::ral::serializeToFile } -async { set options [lassign $options asynccmd] } default { tailcall DeclError UNKNOWN_OPTION save $option } } } else { break } } if {[llength $options] == 2} { lassign $options domain file if {[string range $domain 0 1] ne "::"} { # <1> set domrel [relvar restrictone ::rosea::Config::Domain Name $domain] if {[relation isempty $domrel]} { tailcall DeclError UNKNOWN_DOMAIN $domain } set domain [string cat [relation extract $domrel Location]\ :: $domain] } } else { tailcall DeclError SAVE_ARG_ERROR $args } set script "try \{$savecmd $file ${domain}::\\\[A-Za-z0-9\\\]*\}" ; # <2> if {$asynccmd ne {}} { append script " finally \{$asynccmd $domain $file\}" } after idle [list ::apply [list {} $script]] ; # <3> } proc restore {args} { set restorecmd ::ral::mergeFromFile set options $args while {1} { if {[string index [lindex $options 0] 0] eq "-"} { set options [lassign $options option] switch -exact -- $option { -sqlite { set restorecmd ::ral::mergeFromSQLite } -tclral { set restorecmd ::ral::mergeFromFile } default { tailcall DeclError UNKNOWN_OPTION restore $option } } } else { break } } if {[llength $options] == 2} { lassign $options domain file if {[string range $domain 0 1] ne "::"} { set domrel [relvar restrictone ::rosea::Config::Domain Name $domain] if {[relation isempty $domrel]} { tailcall DeclError UNKNOWN_DOMAIN $domain } set domain [string cat [relation extract $domrel Location]\ :: $domain] } } else { tailcall DeclError RESTORE_ARG_ERROR $args } eval [list $restorecmd $file $domain] # Determine the values for the system supplied defaults. We examine all # the classes that have such attributes and find the maximum value of the # attribute. This can then be placed in the array that is used when new # default values are generated. set domainname [namespace tail $domain] set supplied [pipe { relvar set ::rosea::Config::SystemSuppliedValue | relation restrictwith ~ {$Domain eq $domainname} }] relation foreach sup $supplied { relation assign $sup set classtups [relvar set ${domain}::$Class] if {[relation isempty $classtups]} { set maxvalue $StartValue } else { set maxvalue [pipe { relation summarizeby $classtups {} cv\ MaxValue int {rmax($cv, $Attribute)} | relation extract ~ MaxValue }] } set ${domain}::__Arch_SuppliedDefault($Class,$Attribute)\ [expr {$maxvalue + 1}] } return } proc info {args} { set args [lassign $args subcmd] switch -exact -- $subcmd { domain { Info::domain $args } class { Info::class $args } statemodel { Info::statemodel $args } default { tailcall DeclError UNKNOWN_INFO_CMD $subcmd } } } proc tunnel {instref op args} { relvar eval { set result [[lindex $instref 0]::Instance $instref $op {*}$args] } return $result } proc trace {subcmd args} { switch -exact -- $subcmd { control { tailcall traceControl {*}$args } decode { switch -exact -- [lindex $args 0] { all { tailcall Trace::DecodeAllTraces } class { tailcall Trace::DecodeClassTraces {*}[lrange $args 1 end] } target { tailcall Trace::DecodeTargetTraces {*}[lrange $args 1 end] } default { tailcall DeclError UNKNOWN_TRACE_CMD [lindex $args 0] } } } format { tailcall formatTraces {*}$args } diagram { switch -exact -- [lindex $args 0] { all { tailcall Trace::DiagAllTraces {*}[lrange $args 1 end] } class { tailcall Trace::DiagClassTraces {*}[lrange $args 1 end] } target { tailcall Trace::DiagTargetTraces {*}[lrange $args 1 end] } default { tailcall DeclError UNKNOWN_TRACE_CMD [lindex $args 0] } } } default { tailcall DeclError UNKNOWN_TRACE_CMD $subcmd } } } proc traceControl {op args} { switch -exact -- $op { on { namespace upvar Trace traceState traceState set traceState on } off { namespace upvar Trace traceState traceState set traceState off } status { namespace upvar Trace traceState traceState return $traceState } clear { relvar eval { foreach rvar {Trace Creation Polymorphic Transition} { relvar set Trace::$rvar\ [relation emptyof [relvar set Trace::$rvar]] } } namespace upvar Trace traceNumber traceNumber set traceNumber 0 } logon { namespace upvar Trace traceLogState traceLogState set traceLogState on } logoff { namespace upvar Trace traceLogState traceLogState set traceLogState off } loglevel { namespace upvar Trace traceLogLevel traceLogLevel if {[llength $args] != 0} { set traceLogLevel [lindex $args 0] } return $traceLogLevel } save { if {[llength $args] == 0} { DeclError NO_SAVEFILE } ral storeToSQLite [lindex $args 0] ::rosea::Trace::* } default { DeclError BAD_TRACEOP $op } } } proc formatTraces {tracerecs} { if {[llength $tracerecs] == 0} { return {} } set prevtime [dict get [lindex $tracerecs 0] time] foreach rec $tracerecs { dict with rec { append result "[Trace::FormatTimestamp $time]: " append result "[Trace::FormatTimeAsSec\ [expr {$time - $prevtime}]]: " set prevtime $time append result [Trace::FormatTraceRec $rec] \n } } return [string trimright $result] } namespace eval Helpers { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar variable errFormats set errFormats [dict create {*}{ SAME_CLASS {operation is only allowed for references to the same class,\ got "%s" and "%s"} UNKNOWN_STATE {unknown state, "%s", for class, "%s"} UNKNOWN_EVENT {unknown event, "%s", for class, "%s"} NO_CREATION_EVENTS {class, "%s", has no defined creation events} NO_CROSS_DOMAIN {cannot link instances across domains,\ got "%s" and "%s"} UNKNOWN_RELATIONSHIP {unknown relationship, "%s"} NON_PARTICIPANTS {"%s" and "%s" don't participate in %s,\ expected "%s" and "%s"} MUST_BE_SINGULAR {number of referred to instances for "%s" must be one,\ got %d} NOT_IN_ASSOCIATION {"%s" $relvar1 not a participant in "%s"} DIRECTION_REQUIRED {direction argument is required: got "%s"} AMBIGUOUS_UNLINK {"%s" is reflexive and linking via "%s" is ambiguous} NO_SUBCLASS {relationship "%s" does not have a "%s"} NO_ASSIGNER {relationship, "%s", does not have an assigner} NO_IDENTIFIER {bad identifying attributes, expected "%s", got "%s"} UNKNOWN_ASSIGNER {unknown assigner instance, "%s", for relationship, "%s"} UNKNOWN_LINKAGE {unknown relationship, "%s", for class, "%s"} PATH_ERROR {relationship, "%s", from "%s" to "%s", does not end at "%s"} GEN_PATH_ERROR {navigating from superclass, "%s", along generalization "%s",\ does not have "%s" as a subclass} ARG_ERROR {attribute updates must be name / value pairs, got "%s"} ID_UPDATE {cannot update identifying attributes, "%s"} UNKNOWN_ATTRIBUTE {unknown attribute, "%s"} WITH_ATTR_USAGE {wrong arguments, should be,\ "withAttribute attrvarpair1 ?attrvarpair2 ...? body"} ATTR_VAR_SPEC {attribute / variable argument must be a one or two element\ list, got "%s"} INVALID_TIME {invalid time value, "%s"} SINGLE_OR_EMPTY_REF_REQUIRED {single valued or nil reference required, %d found} SINGLE_REF_REQUIRED {single valued reference required, %d found} ASYNC_CREATION_FAILED {asynchronous creation of an instance of class, "%s",\ with attributes, "%s", failed: %s} EVENT_IN_FLIGHT {event, "%s", sent to "%s", which does not exist} CANT_HAPPEN_EVENT {can't happen transition, %s - %s -> %s ==> %s -> CH} CONFIG_ERRORS {encountered %d configuration script errors} EMPTY_NAME {the empty string is not a valid name for a %s} BAD_CLASS_NAME {class names must be begin with an alphanumeric\ character, got: "%s"} DUP_ELEMENT_NAME {a class, relationship or domain operation named, "%s",\ already exists} RESERVED_NAME {names beginning with two underscore characters are reserved,\ "%s" cannot be used as a name in this context} INT_TYPE_REQUIRED {attribute must be of "int" type, got "%s"} INT_VALUE_REQUIRED {an integer value is required, got "%s"} ARG_FORMAT {options and values must come in pairs, got "%s"} UNKNOWN_OPTION {unknown %s command option, "%s"} DUP_OP_NAME {operation call, "%s", already exists} NS_QUALIFIERS {name, "%s", contains namespace qualifiers} TILDE_NAME {names beginning with the tilde character are not allowed\ in this context, "%s"} BAD_RELATIONSHIP_SPEC {bad relationship specifier, "%s"} NEED_ASSOCIATOR {relationship of type, "%s", requires associative class} NEED_REFLEXIVE_PATH {traversal path must be specified for reflexive\ association, %s, %s %s %s} REFLEXIVE_NOT_ALLOWED {associations of type, "%s", cannot be reflexive} TOO_FEW_SUBCLASSES {at least 2 subclasses must be specified, got %d} BAD_CREATION_TARGET {the target of a creation event must be a state,\ got "%s"} PSEUDO_STATE {the transition action, "%s", is not valid as %s} EXPECTED_PSEUDO_STATE {expected CH or IG, got "%s"} RELVAR_TRACE_OP {unexpected relvar trace operation, "%s"} ATTR_CHECK_FAILED {check for attribute, "%s", failed:\ instance value was, "%s": "%s" evaluated to "%s"} UNKNOWN_DOMAIN {unknown domain, "%s"} ARG_MISMATCH {number of population values must be a multiple of %d, got %d} SAVE_ARG_ERROR {wrong number of arguments: expected:\ "save ?-sqlite | -tclral? ?-async <cmdprefix>?\ <domain> <filename>", got: "%s"} RESTORE_ARG_ERROR {wrong number of arguments: expected:\ "restore ?-sqlite | -tclral? <domain> <filename>", got: "%s"} UNKNOWN_INFO_CMD {unknown info request, "%s"} UNKNOWN_CLASS {unknown class, "%s", in domain, "%s"} UNKNOWN_TRACE_CMD {unknown trace subcomand, "%s"} BAD_TRACEOP {unknown trace operation, "%s"} NO_SAVEFILE {no save file name provided} BAD_TRACETYPE {unknown trace type, "%s"} }] proc ToRef {relvar relvalue} { tailcall list $relvar [relation project $relvalue\ {*}[lindex [relvar identifiers $relvar] 0]] ; # <1> } proc nilInstRef {} { return {{} {{} {}}} } proc CreateStateInstance {domns class state idattrs} { tailcall relvar insert ${domns}::${class}__STATEINST\ [concat $idattrs [list __State $state]] } proc CreateInInitialState {domns class idattrs} { set initstate [relvar restrictone ${domns}::__Arch_InitialState\ Class $class] if {[relation isnotempty $initstate]} { CreateStateInstance $domns $class [relation extract $initstate State]\ $idattrs } return } proc CreateStateInstanceFromRef {domns class state ref} { relation foreach inst [lindex $ref 1] { # <1> CreateStateInstance $domns $class $state\ [tuple get [relation tuple $inst]] } return } proc CreateInInitialStateFromRef {domns class ref} { set initstate [relvar restrictone ${domns}::__Arch_InitialState\ Class $class] if {[relation isnotempty $initstate]} { CreateStateInstanceFromRef $domns $class\ [relation extract $initstate State] $ref } return } proc SelfInstRef {{level 2}} { set foundRef false set ref [nilInstRef] for {set ns [uplevel $level namespace current]} {$ns ne "::"}\ {set ns [uplevel [incr level] namespace current]} { if {!$foundRef} { upvar $level self srcself if {[info exists srcself]} { set ref $srcself set foundRef true } } if {[string match {*__Activity*} $ns]} { return $ref ; # <1> } } return [nilInstRef] } namespace export DeclError proc DeclError {errcode args} { variable errFormats set errmsg [format [dict get $errFormats $errcode] {*}$args] tailcall throw [list ROSEA $errcode {*}$args $errmsg] $errmsg } proc SplitRelvarName {relvar {dvarname domain} {cvarname class}} { upvar 1 $dvarname domain $cvarname class set domain [namespace qualifiers $relvar] set class [namespace tail $relvar] } proc PropagatePolyEvents {super} { namespace upvar ::rosea::Config\ DeferredEvent DeferredEvent\ LocalEvent LocalEvent\ Superclass Superclass\ Subclass Subclass\ DeferralPath DeferralPath\ Generalization Generalization ; # <1> set supername [relation extract $super Class] set subs [pipe { relation semijoin $super\ $Generalization -using {Domain Domain Relationship Name}\ $Subclass -using {Domain Domain Name Relationship} }] relation foreach sub $subs { set defrdevents [pipe { relation semijoin $super $DeferralPath\ -using {Domain Domain Class Model Relationship Relationship}\ $DeferredEvent | relation update ~ deftup {1} { tuple update $deftup Model [relation extract $sub Class] } }] set multigens [relation semijoin $sub $Superclass\ -using {Domain Domain Class Class}] if {[relation isempty $multigens]} { relvar minus ::rosea::Config::LocalEvent $defrdevents relvar union ::rosea::Config::Event $defrdevents relvar union ::rosea::Config::EffectiveEvent $defrdevents relvar union ::rosea::Config::MappedEvent [relation extend\ $defrdevents metuple ParentModel string {$supername}] } else { set consumed [relation semijoin $defrdevents $LocalEvent] if {[relation isnotempty $consumed]} { relvar minus ::rosea::Config::LocalEvent $consumed ; # <1> relvar union ::rosea::Config::MappedEvent [relation extend\ $consumed ctup ParentModel string {$supername}] relvar union ::rosea::Config::NonLocalEvent [relation extend\ $consumed nletuple\ Relationship string {[relation extract $sub Relationship]}\ Role string {[relation extract $sub Role]}] set defrdevents [relation minus $defrdevents $consumed] ; # <2> set usedinsubs [pipe { FindSubclassesOf $multigens| relation tclose ~ | relation semijoin $consumed ~ -using {Model Super} | relation semijoin ~ $LocalEvent -using {Sub Model} | relation semijoin $consumed ~ -using {Domain Domain Event Event} }] relvar minus ::rosea::Config::LocalEvent $usedinsubs ; # <3> relvar minus ::rosea::Config::EffectiveEvent $usedinsubs relvar minus ::rosea::Config::Event $usedinsubs } relvar union ::rosea::Config::Event $defrdevents relvar union ::rosea::Config::DeferredEvent $defrdevents relvar union ::rosea::Config::InheritedEvent $defrdevents relvar union ::rosea::Config::DeferralPath [relation join\ $defrdevents $Superclass -using {Domain Domain Model Class}] } relvar union ::rosea::Config::NonLocalEvent [relation extend\ $defrdevents nletuple\ Relationship string {[relation extract $sub Relationship]}\ Role string {[relation extract $sub Role]}] relation foreach multigen $multigens { PropagatePolyEvents $multigen } } } proc FindSubclassesOf {supers} { namespace upvar ::rosea::Config\ Generalization Generalization\ Superclass Superclass\ Subclass Subclass if {[relation isempty $supers]} {# <1> return [relation create {Super string Sub string}] } set supnames [pipe { relation project $supers Class | relation rename ~ Class Super }] ; # <2> set subclasses [relation semijoin $supers\ $Generalization -using {Domain Domain Relationship Name}\ $Subclass -using {Domain Domain Name Relationship}] set subnames [pipe { relation project $subclasses Class | relation rename ~ Class Sub }] ; # <3> set uses [relation times $supnames $subnames] ; # <4> set nextsupers [relation semijoin $subclasses $Superclass\ -using {Domain Domain Class Class}] ; # <5> return [relation union $uses [FindSubclassesOf $nextsupers]] ; # <6> } proc UserDefaultTrace {defheading defvalues op relvar tuple} { tuple create\ [dict merge $defheading [tuple heading $tuple]]\ [dict merge $defvalues [tuple get $tuple]] } proc SupplyDefaultTrace {defheading op relvar tuple} { set attrs [tuple attributes $tuple] ; # <1> SplitRelvarName $relvar domain class ; # <2> foreach {attrname attrtype} $defheading { if {$attrname ni $attrs} { set value [set ${domain}::__Arch_SuppliedDefault($class,$attrname)] ; # <3> incr ${domain}::__Arch_SuppliedDefault($class,$attrname) set tuple [tuple extend $tuple $attrname $attrtype $value] ; # <4> } } return $tuple } proc GenerateDefaultTrace {defheading defcmds op relvar tuple} { set attrs [tuple attributes $tuple] foreach {attrname attrtype} $defheading { if {$attrname ni $attrs} { set value [eval [dict get $defcmds $attrname]] set tuple [tuple extend $tuple $attrname $attrtype $value] } } return $tuple } proc CheckValueTrace {attrchecks op relvar args} { if {$op eq "insert"} { set tuple [lindex $args 0] EvalAttrCheck $attrchecks $tuple return $tuple } elseif {$op eq "update"} { set tuple [lindex $args 1] EvalAttrCheck $attrchecks $tuple return $tuple } elseif {$op eq "set"} { set relvalue [lindex $args 0] relation foreach inst $relvalue { set tuple [relation tuple $inst] EvalAttrCheck $attrchecks $tuple } return $relvalue } else { tailcall DeclError RELVAR_TRACE_OP $op } } proc EvalAttrCheck {attrchecks tuple} { dict for {attrname checkexpr} $attrchecks { tuple assign $tuple set result [expr $checkexpr] if {!$result} { tailcall DeclError ATTR_CHECK_FAILED $attrname [tuple get $tuple]\ $checkexpr $result } } } proc QuerySystemOperations {which requiresSM} { return [pipe { relvar set ::rosea::Config::SuppliedOperation | relation restrictwith ~ {$RequiresStateModel == $requiresSM} | relation join [relvar set ::rosea::Config::$which] ~ }] } proc QuerySystemClassOperations {className requiresSM} { return [pipe { QuerySystemOperations SystemClassOperation $requiresSM | relation update ~ sco 1 { tuple update $sco Command\ [concat [tuple extract $sco Command]\ [list $className]] } | relation dict ~ Name Command }] } proc QuerySystemInstanceOperations {requiresSM} { return [pipe { QuerySystemOperations SystemInstanceOperation $requiresSM | relation dict ~ Name Command }] } proc Interleave {l1 l2} { set result [list] foreach a $l1 b $l2 { lappend result $a $b } return $result } proc MapCondMultToConstraint {cond mult} { if {$cond} { return [expr {$mult ? "*" : "?"}] } else { return [expr {$mult ? "+" : "1"}] } } } namespace eval ClassCmds { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path [namespace parent]::Helpers ; # <1> proc findAll {relvar} { tailcall ToRef $relvar [relvar set $relvar] } proc findById {relvar args} { tailcall ToRef $relvar [relvar restrictone $relvar {*}$args] } proc findWhere {relvar expr} { tailcall ToRef $relvar [uplevel 1 [list ::ral relation restrictwith\ [relvar set $relvar] $expr]] } proc create {relvar args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } set ref [ToRef $relvar [relvar insert $relvar $args]] ; # <1> SplitRelvarName $relvar domain class CreateInInitialStateFromRef $domain $class $ref return $ref } proc createin {relvar state args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } SplitRelvarName $relvar domain class set initstate [relvar restrictone ${domain}::__Arch_State\ Class $class State $state] if {[relation isempty $initstate]} { # <1> tailcall DeclError UNKNOWN_STATE $state $relvar } set ref [ToRef $relvar [relvar insert $relvar $args]] CreateStateInstanceFromRef $domain $class $state $ref return $ref } proc createasync {relvar event eventparams args} { SplitRelvarName $relvar domain class if {[relation isempty [relvar restrictone ${domain}::__Arch_Event\ Class $class Event $event]]} { tailcall DeclError UNKNOWN_EVENT $event $class } if {[relation isempty [relvar restrictone ${domain}::__Arch_State\ Class $class State @]]} { tailcall DeclError NO_CREATION_EVENTS $class } set srcref [SelfInstRef] set eventInfo [dict create\ type creation\ src $srcref\ dstClass $relvar\ dstAttrs $args\ event $event\ params $eventparams\ ] if {[::rosea::InstCmds::isRefEqual $srcref [nilInstRef]]} { lappend ::rosea::Dispatch::toc_queue $eventInfo } else { lappend ::rosea::Dispatch::event_queue $eventInfo } ::after 0 ::rosea::Dispatch::DispatchEvent return } proc update {relvar relvalue} { tailcall ToRef $relvar [relvar updateper $relvar $relvalue] } } namespace eval InstCmds { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace path [namespace parent]::Helpers pipe { relvar set ${domain}::$DstClass | relation $op $related ~ -using $Attrs } relatedQuery proc deRef {instref args} { lassign $instref relvar ref set inst [relation semijoin $ref [relvar set $relvar]] ; # <1> if {[llength $args] != 0} { set inst [relation project $inst\ {*}[relation attributes $ref] {*}$args] ; # <2> } return $inst } proc isEmptyRef {instref} { tailcall relation isempty [lindex $instref 1] } proc isNotEmptyRef {instref} { tailcall relation isnotempty [lindex $instref 1] } proc refMultiplicity {instref} { tailcall relation cardinality [lindex $instref 1] } proc isRefSingular {instref} { expr {[refMultiplicity $instref] == 1} } proc limitRef {instref {count 1}} { lassign $instref relvar insts return [pipe { relation tag $insts __Tag | relation restrictwith ~ {$__Tag >= 0 && $__Tag < $count} | ToRef $relvar ~ }] } proc isRefEqual {instref1 instref2} { lassign $instref1 relvar1 inst1 lassign $instref2 relvar2 inst2 return [expr {$relvar1 eq $relvar2 && [relation is $inst1 equal $inst2]}] } proc RefSetCommand {op instref1 instref2} { lassign $instref1 relvar1 inst1 lassign $instref2 relvar2 inst2 if {$relvar1 ne $relvar2} { tailcall DeclError SAME_CLASS $relvar1 $relvar2 } return [list $relvar1 [relation $op $inst1 $inst2]] } proc refUnion {instref1 instref2} { tailcall RefSetCommand union $instref1 $instref2 } proc refIntersect {instref1 instref2} { tailcall RefSetCommand intersect $instref1 $instref2 } proc refMinus {instref1 instref2} { tailcall RefSetCommand minus $instref1 $instref2 } proc forAllRefs {varname instref body} { lassign $instref relvar refs upvar 1 $varname inst relation foreach ref $refs { set inst [list $relvar $ref] uplevel 1 $body } ; # <1> return } proc FindRelatedInsts {instref op args} { set srcrelvar [lindex $instref 0] SplitRelvarName $srcrelvar domain class # This procedure queries the architectural data about relationship linkage, # so we bring the relvar variables into scope. namespace upvar ${domain}\ __Arch_Link Link\ __Arch_AssociationLink AssociationLink\ __Arch_PartitionLink PartitionLink\ __Arch_PartitionDst PartitionDst variable relatedQuery ; # <1> # We start by dereferencing the instance reference. set related [deRef $instref] foreach linkage $args { lassign $linkage lname dst ; # split out the linkage spec set link [relvar restrictone ${domain}::__Arch_Link\ Name $lname SrcClass $class] if {[ral relation isempty $link]} { tailcall DeclError UNKNOWN_LINKAGE $lname $class } # First we determine if we are dealing with an associative link or a # partition link. set assoc [relation join $link $AssociationLink] if {[relation isnotempty $assoc]} { relation assign $assoc DstClass Attrs # Check if additional path information was provided. if {$dst eq {}} { # Find the set of instances related to the current set. set related [eval $relatedQuery] # We must see if this is a class-based association. If so, then the first # traversal was to the associator and we must traverse again to the other # class. set assoc [relation semijoin $assoc $AssociationLink\ -using {Name Name SrcClass PrevSrcClass}] if {[relation isnotempty $assoc]} { relation assign $assoc DstClass Attrs set related [pipe {# <1> relvar set ${domain}::$DstClass | relation semijoin $related ~ -using $Attrs }] } } else { # If a destination was specified in the linkage, then we need to verify # that it is actually part of the relationship. if {$dst ne $DstClass} { tailcall DeclError PATH_ERROR $lname $class $DstClass\ $dst } set related [eval $relatedQuery] } } else { set partdst [relvar restrictone ${domain}::__Arch_PartitionDst\ Name $lname SrcClass $class DstClass $dst] if {[relation isempty $partdst]} { tailcall DeclError GEN_PATH_ERROR $class $lname $dst } relation assign $partdst DstClass Attrs set related [eval $relatedQuery] } # Continue the iteration by setting the next source to the current # destination class. set class $DstClass set srcrelvar ${domain}::$class } # N.B. that we are not returning an instance reference but rather the # complete relation value of the related instances. This allows us # to further filter the result in the "findRelatedWhere" command. return [list $srcrelvar $related] } proc findRelated {instref args} { tailcall ToRef {*}[FindRelatedInsts $instref semijoin {*}$args] ; # <1> } proc findUnrelated {instref args} { tailcall ToRef {*}[FindRelatedInsts $instref semiminus {*}$args] ; # <1> } proc findRelatedWhere {instref rchain expr} { lassign [FindRelatedInsts $instref semijoin {*}$rchain] relvar insts tailcall ToRef $relvar [uplevel 1\ [list ::ral relation restrictwith $insts $expr]] ; # <1> } proc findUnrelatedWhere {instref rchain expr} { lassign [FindRelatedInsts $instref semiminus {*}$rchain] relvar insts tailcall ToRef $relvar [uplevel 1\ [list ::ral relation restrictwith $insts $expr]] } proc idInstance {instref} { lassign $instref relvar insts SplitRelvarName $relvar domain relationship set assignrelvar ${domain}::${relationship}__STATEINST if {![relvar exists $assignrelvar]} { tailcall DeclError NO_ASSIGNER $rname } set idclass [pipe { relvar restrictone [namespace parent]::Config::MultipleAssigner\ Domain [string trim $domain :] Relationship $relationship | relation extract ~ Class }] return [pipe { relvar set ${domain}::$idclass | relation semijoin $insts ~ | ToRef ${domain}::$idclass ~ }] } proc updateAttribute {instref args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_ERROR $args } lassign $instref relvar insts if {[relation cardinality $insts] != 1} { tailcall MUST_BE_SINGULAR $relvar [relation cardinality $insts] } set idattrs [list] foreach identifier [relvar identifiers $relvar] { ::struct::set add idattrs $identifier } set idupdates [::struct::set intersect $idattrs $args] if {![::struct::set empty $idupdates]} { tailcall DeclError ID_UPDATE [join $idupdates {, }] } set extcmd [list relation extend $insts exttuple] set heading [relation heading [relvar set $relvar]] foreach {attr value} $args { if {![dict exists $heading $attr]} { tailcall DeclError UNKNOWN_ATTRIBUTE $attr } lappend extcmd $attr [dict get $heading $attr] \{$value\} } relvar updateper $relvar [eval $extcmd] return } proc withAttribute {instref args} { if {[llength $args] < 2} { tailcall DeclError WITH_ATTR_USAGE } lassign $instref relvar insts if {[relation cardinality $insts] != 1} { tailcall MUST_BE_SINGULAR $relvar [relation cardinality $insts] } set body [lindex $args end] set attrspecs [lrange $args 0 end-1] set attrnames [list] set varnames [list] foreach attrspec $attrspecs { set speclen [llength $attrspec] if {$speclen == 1} { lappend attrnames [lindex $attrspec 0] lappend varnames [lindex $attrspec 0] } elseif {$speclen == 2} { lappend attrnames [lindex $attrspec 0] lappend varnames [lindex $attrspec 1] } else { tailcall DeclError ATTR_VAR_SPEC $attrspec } } set idattrs [list] foreach identifier [relvar identifiers $relvar] { ::struct::set add idattrs $identifier } set idupdates [::struct::set intersect $idattrs $attrnames] if {![::struct::set empty $idupdates]} { tailcall DeclError ID_UPDATE [join $idupdates {, }] } uplevel 1 [list ral relation assign [deRef $instref] {*}$attrspecs] uplevel 1 $body set extcmd [list relation extend $insts exttuple] set heading [relation heading [relvar set $relvar]] foreach attr $attrnames var $varnames { if {[uplevel 1 [list info exists $var]]} { upvar 1 $var varvalue lappend extcmd $attr [dict get $heading $attr] \{$varvalue\} } } relvar updateper $relvar [eval $extcmd] return } proc readAttribute {ref args} { # We insist upon a singular reference for reading attributes. Multiple # references can be handled by dereferences and using TclRAL "relation" # commands. if {![isRefSingular $ref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $ref] } return [expr {[llength $args] == 0 ? {} :\ [relation extract [deRef $ref {*}$args] {*}$args]}] ; # <1> } proc assignAttribute {ref args} { # We must insist upon a singular references, since assigning to scalar # variables from a relation value doesn't make a lot of sense. if {![isRefSingular $ref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $ref] } uplevel 1 [list ral relation assign [deRef $ref] {*}$args] ; # <1> return } proc delete {args} { foreach instref $args { lassign $instref relvar insts relvar minus $relvar [deRef $instref] SplitRelvarName $relvar domain class set instrelvar ${domain}::${class}__STATEINST if {[relvar exists $instrelvar]} { relvar minus $instrelvar [relation semijoin $insts\ [relvar set $instrelvar]] } } return } proc signal {dstset event args} { set srcref [SelfInstRef] if {![::rosea::Dispatch::MapPolymorphicEvent ::rosea::Dispatch::SignalEvent\ $srcref $dstset $event $args]} { ::rosea::Dispatch::SignalEvent $srcref $dstset $event $args } return } proc delaysignal {time dstset event args} { if {!([string is integer -strict $time] && $time >= 0)} { tailcall DeclError INVALID_TIME $time } set srcref [SelfInstRef] if {![::rosea::Dispatch::MapPolymorphicEvent\ [list ::rosea::Dispatch::SignalDelayedEvent $time]\ $srcref $dstset $event $args]} { ::rosea::Dispatch::SignalDelayedEvent $time $srcref $dstset $event $args } return } proc canceldelayed {srcref dstset event} { set srcmult [refMultiplicity $srcref] if {$srcmult > 1} { tailcall DeclError SINGLE_OR_EMPTY_REF_REQUIRED $srcmult } forAllRefs dstref $dstset { ::rosea::Dispatch::CancelDelayedSignal $srcref $event $dstref } return } proc delayremaining {srcref dstref event} { set srcmult [refMultiplicity $srcref] if {$srcmult > 1} { tailcall DeclError SINGLE_OR_EMPTY_REF_REQUIRED $srcmult } if {![isRefSingular $dstref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $dstref] } tailcall ::rosea::Dispatch::SignalTimeRemaining $srcref $event $dstref } proc instop {instref op args} { tailcall [lindex $instref 0]::Instance $instref $op {*}$args } } namespace eval RelCmds { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path [list\ [namespace parent]::Helpers\ [namespace parent]::InstCmds\ ] proc linkSimple {rname instref1 instref2} { lassign $instref1 relvar1 inst1 SplitRelvarName $relvar1 domain1 class1 lassign $instref2 relvar2 inst2 SplitRelvarName $relvar2 domain2 class2 if {$domain1 ne $domain2} { tailcall DeclError NO_CROSS_DOMAIN $domain1 $domain2 } set reflink [relvar restrictone ${domain1}::__Arch_RefLink Relationship $rname] if {[relation isempty $reflink]} { tailcall DeclError UNKNOWN_RELATIONSHIP $rname } relation assign $reflink\ {ReferringClass referringClass}\ {ReferencedClass referencedClass}\ {ReferringAttrs referringAttrs} ; # <1> if {$class1 eq $referringClass && $class2 eq $referencedClass} { set fromrelvar $relvar1 set frominsts $inst1 set torelvar $relvar2 set toinst $inst2 } elseif {$class2 eq $referringClass && $class1 eq $referencedClass} { set fromrelvar $relvar2 set frominsts $inst2 set torelvar $relvar1 set toinst $inst1 } else { tailcall DeclError NON_PARTICIPANTS $relvar1 $relvar2 $rname\ $referringClass $referencedClass } if {[relation cardinality $toinst] != 1} { tailcall MUST_BE_SINGULAR $torelvar [relation cardinality $toinst] } set refedvalue [relation semijoin $toinst [relvar set $torelvar]] set tovalues [pipe { relation extend $referringAttrs rfa RefValue string { [relation extract $refedvalue\ [tuple extract $rfa ReferencedAttribute]]} | relation dict ~ ReferringAttribute RefValue }] relation foreach frominst $frominsts { relvar updateone $fromrelvar fromtup\ [tuple get [relation tuple $frominst]] { # <1> tuple update $fromtup {*}$tovalues ; # <2> } } return } proc linkAssoc {rname instref1 instref2 args} { lassign $instref1 relvar1 inst1 SplitRelvarName $relvar1 domain1 class1 lassign $instref2 relvar2 inst2 SplitRelvarName $relvar2 domain2 class2 if {$domain1 ne $domain2} { tailcall DeclError NO_CROSS_DOMAIN $domain1 $domain2 } set assocref [relvar restrictone ${domain1}::__Arch_AssocRef\ Relationship $rname] if {[relation isempty $assocref]} { tailcall DeclError UNKNOWN_RELATIONSHIP $rname } relation assign $assocref\ {AssocClass assocClass}\ {References references} set ref1 [relation restrictwith $references {$Participant eq $class1}] if {[relation isempty $ref1]} { tailcall DeclError NOT_IN_ASSOCIATION $class1 $rname } if {[relation cardinality $ref1] > 1} { set ref2 [relation restrictwith $ref1 {$Role eq "target"}] set ref1 [relation minus $ref1 $ref2] ; # <1> } else { set ref2 [relation restrictwith $references {$Participant eq $class2}] if {[relation isempty $ref2]} { tailcall DeclError NOT_IN_ASSOCIATION $class2 $rname } } set rattr1 [relation extract $ref1 ReferringAttrs] set rattr2 [relation extract $ref2 ReferringAttrs] set values1 [relation semijoin $inst1 [relvar set $relvar1]] set values2 [relation semijoin $inst2 [relvar set $relvar2]] set assoctuples [list] relation foreach v1 $values1 { # <1> set refto1 [pipe { relation extend $rattr1 rfa RefValue string { [relation extract $v1 [tuple extract $rfa ReferencedAttribute]] } | relation dict ~ ReferringAttribute RefValue }] relation foreach v2 $values2 { set refto2 [pipe { relation extend $rattr2 rfa RefValue string { [relation extract $v2\ [tuple extract $rfa ReferencedAttribute]] } | relation dict ~ ReferringAttribute RefValue }] lappend assoctuples [dict merge $args $refto1 $refto2] ; # <2> } } set ref [ToRef ${domain1}::$assocClass\ [relvar insert ${domain1}::$assocClass {*}$assoctuples]] CreateInInitialStateFromRef $domain1 $assocClass $ref ; # <1> return $ref } proc referenceAssoc {rname assocref instref {dir {}}} { if {![isRefSingular $assocref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $assocref] } lassign $assocref assocrelvar associnst SplitRelvarName $assocrelvar assocdomain assocclass if {![isRefSingular $instref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $instref] } lassign $instref instrelvar inst SplitRelvarName $instrelvar instdomain instclass if {$assocdomain ne $instdomain} { tailcall DeclError NO_CROSS_DOMAIN $domain1 $domain2 } set assocref [relvar restrictone ${instdomain}::__Arch_AssocRef\ Relationship $rname] if {[relation isempty $assocref]} { tailcall DeclError UNKNOWN_RELATIONSHIP $rname } relation assign $assocref\ {AssocClass assocClass}\ {References references} if {$assocClass ne $assocclass} { tailcall DeclError NOT_IN_ASSOCIATION $assocclass $rname } set ref [relation restrictwith $references {$Participant eq $instclass}] set refcard [relation cardinality $ref] if {$refcard == 2} { switch -exact -- $dir { forward { set role target } backward { set role source } default { tailcall DeclError DIRECTION_REQUIRED $dir } } set ref [relation restrictwith $ref {$Role eq $role}] } elseif {$refcard == 0} { tailcall DeclError NOT_IN_ASSOCIATION $instclass $rname } set referringAttrs [relation extract $ref ReferringAttrs] set refedvalue [relation semijoin $inst [relvar set $instrelvar]] set tovalues [pipe { relation extend $referringAttrs rfa RefValue string { [relation extract $refedvalue\ [tuple extract $rfa ReferencedAttribute]]} | relation dict ~ ReferringAttribute RefValue }] relvar updateone $assocrelvar assoctup [tuple get [relation tuple $associnst]] { tuple update $assoctup {*}$tovalues } } proc unlinkSimple {rname instref} { lassign $instref relvar inst SplitRelvarName $relvar domain class set reflink [relvar restrictone ${domain}::__Arch_RefLink\ Relationship $rname] if {[relation isempty $reflink]} { tailcall DeclError UNKNOWN_RELATIONSHIP $rname } relation assign $reflink\ {ReferringClass referringClass}\ {ReferencedClass referencedClass}\ {ReferringAttrs referringAttrs} if {$class eq $referringClass} { set fromrelvar $relvar set frominsts $inst } elseif {$class eq $referencedClass} { lassign [::rosea::InstCmds::findRelated $instref ~$rname]\ fromrelvar frominsts } else { tailcall DeclError NOT_IN_ASSOCIATION $relvar $rname } set tovalues [pipe { relation extend $referringAttrs rfa RefValue string {{}} | relation dict ~ ReferringAttribute RefValue }] relation foreach frominst $frominsts { relvar updateone $fromrelvar fromtup\ [tuple get [relation tuple $frominst]] { tuple update $fromtup {*}$tovalues } } return } proc unlinkAssoc {rname instref} { lassign $instref relvar insts SplitRelvarName $relvar domain class set assocref [relvar restrictone ${domain}::__Arch_AssocRef\ Relationship $rname] if {[relation isempty $assocref]} { tailcall DeclError UNKNOWN_RELATIONSHIP $rname } relation assign $assocref\ {Relationship relationship}\ {AssocClass associator}\ {References references} # If we are given instances to the associator class, then there is no # more work to do. if {$class ne $associator} { # Otherwise, we have to find the associator class instances ourselves. set part [relation restrictwith $references {$Participant eq $class}] set partcard [relation cardinality $part] if {$partcard == 0} { tailcall DeclError NOT_IN_ASSOCIATION $class $rname } elseif {$partcard > 1} { tailcall DeclError AMBIGUOUS_UNLINK $rname $relvar ; # <1> } else { # Find associative class instances. We have to determine the # direction of the relationship traversal. set navdir [expr {[relation extract $part Role] eq "source" ?\ "$relationship" : "~$relationship"}] set instref [::rosea::InstCmds::findRelated $instref\ [list $navdir [namespace tail $associator]]] lassign $instref relvar insts SplitRelvarName $relvar domain class } } # We are going to delete tuples from the relvar that holds the class # instances. set delrelvars [list ${domain}::$class] # If the associative class also has a state model, then we need to also # delete the state instance tuples. if {[relvar exists ${domain}::${class}__STATEINST]} { lappend delrelvars ${domain}::${class}__STATEINST } # Now, we iterate across the associative class instances and delete all the # tuples in class relvar and, if necessary, the state instances. relation foreach inst $insts { set idattrs [tuple get [relation tuple $inst]] foreach rv $delrelvars { relvar deleteone $rv {*}$idattrs } } return $instref } proc migrate {rname instref subclass args} { if {![isRefSingular $instref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $instref] } lassign $instref relvar inst SplitRelvarName $relvar domns class set link [relvar restrictone ${domns}::__Arch_AssociationLink Name $rname\ SrcClass $class] if {[relation isempty $link]} { tailcall DeclError NO_SUBCLASS $rname $relvar } # Traverse the relationship to the superclass. We need to get the values of # the referenced attributes to use in creating the new subclass instance. set superinst [pipe { relvar set ${domns}::[relation extract $link DstClass] | relation semijoin $inst ~ -using [relation extract $link Attrs] }] set sublink [relvar restrictone ${domns}::__Arch_SubLink\ Relationship $rname SubClass $subclass] if {[relation isempty $sublink]} { tailcall DeclError NO_SUBCLASS $rname $subclass } # Using the same relation extend strategy, we compute a dictionary of the # attribute names / values as they must appear in the subclass we are about # to create. set refedvalues [pipe { relation extract $sublink ReferringAttrs | relation extend ~ rval Value string { [relation extract $superinst\ [tuple extract $rval ReferencedAttribute]] } | relation dict ~ ReferringAttribute Value }] # We use the class commands to delete the old subclass instance and create # the new one. This will make sure that if the subclass has a state model # that the initial state is set correctly. # N.B. this is _not_ done in a relvar transaction. The transaction # boundaries should be set by the current thread of control or domain # operation. ::rosea::InstCmds::delete $instref return [::rosea::ClassCmds::create ${domns}::$subclass\ {*}[dict merge $args $refedvalues]] } proc signalAssigner {rname event args} { SplitRelvarName $rname domain relationship set assignrelvar ${domain}::${relationship}__STATEINST if {![relvar exists $assignrelvar]} { tailcall DeclError NO_ASSIGNER $rname } set dstref [pipe { relvar set $assignrelvar | relation project ~ {*}[lindex [relvar identifiers $assignrelvar] 0] | list $rname ~ }] ::rosea::Dispatch::SignalEvent [SelfInstRef] $dstref $event $args return } proc signalMultiAssigner {rname idvalues event args} { SplitRelvarName $rname domain relationship set assignrelvar ${domain}::${relationship}__STATEINST if {![relvar exists $assignrelvar]} { tailcall DeclError NO_ASSIGNER $rname } set idattrs [lindex [relvar identifiers $assignrelvar] 0] # We will insist that the idvalues contain the necessary identifying # attributes. if {![struct::set equal [dict keys $idvalues] $idattrs]} { tailcall DeclError NO_IDENTIFIER [dict keys $idvalues] $idattrs } set assigninsts [relvar set $assignrelvar] set assignrefs [relation project $assigninsts {*}$idattrs] # We need to find the tuple in "assignrefs" that matches the attributes and # values in "idvalues". We will do this by creating a relation value from # the idvalues list and semijoining that to "assignrefs". If we come up # non-empty, then we have found our multi-assigner instance. set heading [relation heading $assignrefs] set dstinst [pipe { tuple create $heading $idvalues | tuple relation ~ | relation semijoin ~ $assignrefs }] if {[relation isempty $dstinst]} { tailcall DeclError UNKNOWN_ASSIGNER $idvalues $rname } set dstref [list $rname $dstinst] ::rosea::Dispatch::SignalEvent [SelfInstRef] $dstref $event $args ; # <1> return } proc createMultiAssigner {rname args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } SplitRelvarName $rname domain relationship set assignrelvar ${domain}::${relationship}__STATEINST if {![relvar exists $assignrelvar]} { tailcall DeclError NO_ASSIGNER $rname } set idattrs [lindex [relvar identifiers $assignrelvar] 0] if {![struct::set equal [dict keys $args] $idattrs]} { tailcall DeclError NO_IDENTIFIER [dict keys $args] $idattrs } CreateInInitialState $domain $relationship $args } } namespace eval Dispatch { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path [list\ [namespace parent]::Helpers\ [namespace parent]::InstCmds\ ] variable toc_queue [list] variable event_queue [list] pipe { relvar restrictone ${domain}::__Arch_Transition\ Class $class State $currstate Event $event | relation extract ~ NewState } transitionQuery relvar create DelayedSignal { RefId int SrcInstRef list Event string DstInstRef list TimerId string Expire bignum } RefId {SrcInstRef Event DstInstRef} TimerId variable DelayedSignalId 0 pipe { relvar set ${domain}::__Arch_PartitionDst | relation restrictwith ~ {$SrcClass eq $dstclass} | relation group ~ DstLinks DstClass Attrs } polymapQuery proc SignalEvent {srcref dstset event arglist} { lassign $dstset relvar insts SplitRelvarName $relvar domain class if {[relation isempty [relvar restrictone ${domain}::__Arch_Event\ Class $class Event $event]]} { tailcall DeclError UNKNOWN_EVENT $event $class } set callback [namespace code DispatchEvent] set eventInfo [dict create\ type ordinary\ src $srcref\ event $event\ params $arglist\ ] if {[isRefEqual $srcref [nilInstRef]]} { variable toc_queue forAllRefs dstref $dstset { # Queue the thread of control events. dict set eventInfo dst $dstref lappend toc_queue $eventInfo ::after 0 $callback } } else { variable event_queue forAllRefs dstref $dstset { dict set eventInfo dst $dstref if {[isRefEqual $srcref $dstref]} { # <1> for {set eqindex 0} {$eqindex < [llength $event_queue]} {incr eqindex} { set cmpevent [lindex $event_queue $eqindex] if {![isRefEqual [dict get $cmpevent src] [dict get $cmpevent dst]]} { break } } set event_queue [linsert [K $event_queue [set event_queue {}]]\ $eqindex $eventInfo] ; # <1> } else { # Non-self directed events are always simply appended to the # event queue. lappend event_queue $eventInfo } ::after 0 $callback } } } proc DispatchEvent {} { variable event_queue variable toc_queue if {[llength $event_queue] != 0} { set eventInfo [lindex $event_queue 0] set event_queue [lrange [K $event_queue [set event_queue {}]] 1 end] ; # <1> } elseif {[llength $toc_queue] != 0} { set eventInfo [lindex $toc_queue 0] set toc_queue [lrange [K $toc_queue [set toc_queue {}]] 1 end] relvar transaction begin ; # <2> } else { return } if {[dict get $eventInfo type] eq "creation"} { try { set dstref [::rosea::ClassCmds::createin\ [dict get $eventInfo dstClass] @\ {*}[dict get $eventInfo dstAttrs]] ; # <1> } on error {result} { catch { if {[llength $event_queue] == 0} { relvar transaction end } } tailcall DeclError ASYNC_CREATION_FAILED [dict get $eventInfo dstClass]\ [dict get $eventInfo dstAttrs] $result } dict set eventInfo dst $dstref ; # <2> ::rosea::Trace::TraceCreation [dict get $eventInfo src]\ [dict get $eventInfo event] $dstref [dict get $eventInfo params] } set dstref [dict get $eventInfo dst] lassign $dstref relvar ref SplitRelvarName $relvar domain class set instrelvar ${domain}::${class}__STATEINST set state [relation semijoin $ref [relvar set $instrelvar]] if {[relation isempty $state]} { tailcall DeclError EVENT_IN_FLIGHT [dict get $eventInfo event] $ref } set currstate [relation extract $state __State] set event [dict get $eventInfo event] variable transitionQuery set newState [eval $transitionQuery] ::rosea::Trace::TraceTransition [dict get $eventInfo src]\ $event $dstref $currstate $newState [dict get $eventInfo params] ; # <1> try { if {$newState eq "CH"} { TransitionError [dict get $eventInfo src] $event $dstref $currstate } elseif {$newState ne "IG"} { set idattrs [tuple get [relation tuple $ref]] relvar updateone $instrelvar is $idattrs { tuple update $is __State $newState } try { ${relvar}::__Activity::$newState $dstref\ {*}[dict get $eventInfo params] ; # <1> } on error {result opts} { return -options $opts $result } finally { set term [relvar restrictone ${domain}::__Arch_TerminalState\ Class $class State $newState] if {[relation isnotempty $term]} { relvar deleteone $relvar {*}$idattrs relvar deleteone $instrelvar {*}$idattrs } } } } on error {result opts} { catch { if {[llength $event_queue] == 0} { relvar transaction end } } ; # <1> return -options $opts $result } if {[llength $event_queue] == 0} { relvar transaction end } return } proc TransitionError {src event dst currstate} { tailcall DeclError CANT_HAPPEN_EVENT $src $event $dst $currstate } proc FindDelayedSignal {srcref event dstref} { variable DelayedSignal return [relation restrictwith $DelayedSignal { [isRefEqual $SrcInstRef $srcref] && $Event eq $event &&\ [isRefEqual $DstInstRef $dstref]}] } proc DeleteDelayedSignal {srcref event dstref} { relvar delete DelayedSignal dsig { [isRefEqual [tuple extract $dsig SrcInstRef] $srcref] &&\ [tuple extract $dsig Event] eq $event &&\ [isRefEqual [tuple extract $dsig DstInstRef] $dstref] } } proc SignalDelayedEvent {time srcref dstset event arglist} { lassign $dstset relvar insts SplitRelvarName $relvar domain class if {[relation isempty [relvar restrictone ${domain}::__Arch_Event\ Class $class Event $event]]} { tailcall DeclError UNKNOWN_EVENT $event $class } variable DelayedSignalId set eventInfo [dict create\ id [incr DelayedSignalId]\ type ordinary\ src $srcref\ event $event\ params $arglist\ ] forAllRefs dstref $dstset { dict set eventInfo dst $dstref DeleteDelayedSignal $srcref $event $dstref ; # <1> relvar insert DelayedSignal [list\ RefId $DelayedSignalId\ SrcInstRef $srcref\ Event $event\ DstInstRef $dstref\ TimerId [::after $time [list\ ::rosea::Dispatch::DispatchDelayedEvent $eventInfo]]\ Expire [expr {entier([clock milliseconds]) + entier($time)}]\ ] } return } proc DispatchDelayedEvent {eventInfo} { relvar deleteone DelayedSignal RefId [dict get $eventInfo id] variable toc_queue lappend toc_queue $eventInfo tailcall DispatchEvent } proc CancelDelayedSignal {srcref event dstref} { variable DelayedSignal set sig [FindDelayedSignal $srcref $event $dstref] if {[relation isnotempty $sig]} { ::after cancel [relation extract $sig TimerId] DeleteDelayedSignal $srcref $event $dstref } else { # Search the toc_queue to see if the signal delay has already expired # and the event is awaiting dispatch. variable toc_queue for {set i 0} {$i < [llength $toc_queue]} {incr i} { set eventInfo [lindex $toc_queue $i] dict update eventInfo src evtsrc dst evtdst event evtevent { if {[isRefEqual $evtsrc $srcref] &&\ [isRefEqual $evtdst $dstref] &&\ $evtevent eq $event} { set toc_queue [lreplace\ [K $toc_queue [set toc_queue {}]] $i $i] break } } } } } proc SignalTimeRemaining {srcref event dstref} { set sig [FindDelayedSignal $srcref $event $dstref] return [expr {[relation isempty $sig] ? 0 :\ max([relation extract $sig Expire] - [clock milliseconds], 0)}] ; # <1> } proc MapPolymorphicEvent {frwdcmd srcref dstrefs event arglist} { lassign $dstrefs dstrelvar dstinsts SplitRelvarName $dstrelvar domain dstclass set polyevent [relvar restrictone ${domain}::__Arch_PolymorphicEvent\ Class $dstclass Event $event] if {[relation isempty $polyevent]} { return false } variable polymapQuery set partitions [eval $polymapQuery] relation foreach inst $dstinsts { relation foreach partition $partitions { relation assign $partition relation foreach dstlink $DstLinks { relation assign $dstlink set related [relation semijoin $inst\ [relvar set ${domain}::$DstClass] -using $Attrs] if {[relation isnotempty $related]} { set dstreference [ToRef ${domain}::${DstClass} $related] set target [ToRef $dstrelvar $inst] ::rosea::Trace::TracePolymorphic $srcref $event $target $dstreference $Name\ $arglist if {![MapPolymorphicEvent $frwdcmd $srcref $dstreference $event $arglist]} { {*}$frwdcmd $srcref $dstreference $event $arglist ; # <1> } break } } } } return true } } namespace eval Config { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path [namespace parent]::Helpers variable evalLambda {{body} { upvar #0 ::rosea::Config::errcount errcount ; # <1> upvar #0 ::rosea::Config::configlineno configlineno set lineno $configlineno set command {} foreach line [split $body \n] { # <2> append command $line \n incr lineno ; # <3> if {[info complete $command]} { try { eval $command } on error {result} { log::error "line $configlineno: \"$result\"" incr errcount } set command {} ; # <4> set configlineno $lineno } } return $errcount }} relvar create Domain { Name string Location string } Name relvar create DomainElement { Domain string Element string } {Domain Element} relvar association R1\ DomainElement Domain *\ Domain Name 1 relvar create Class { Domain string Name string } {Domain Name} relvar create Relationship { Domain string Name string } {Domain Name} relvar create DomainOperation { Domain string Name string Parameters list Body string } {Domain Name} relvar partition R2 DomainElement {Domain Element}\ Class {Domain Name}\ Relationship {Domain Name}\ DomainOperation {Domain Name} relvar create Attribute { Domain string Class string Name string Type string } {Domain Class Name} relvar association R3\ Attribute {Domain Class} +\ Class {Domain Name} 1 relvar create Identifier { Domain string Class string Number int } {Domain Class Number} relvar association R4\ Identifier {Domain Class} +\ Class {Domain Name} 1 relvar create IdentifyingAttribute { Domain string Class string Attribute string Number int } {Domain Class Attribute Number} relvar correlation R5 IdentifyingAttribute\ {Domain Class Number} + Identifier {Domain Class Number}\ {Domain Class Attribute} * Attribute {Domain Class Name} relvar create DefaultValue { Domain string Class string Attribute string } {Domain Class Attribute} relvar association R6\ DefaultValue {Domain Class Attribute} ?\ Attribute {Domain Class Name} 1 relvar create UserSuppliedValue { Domain string Class string Attribute string Value string } {Domain Class Attribute} relvar create SystemSuppliedValue { Domain string Class string Attribute string StartValue int } {Domain Class Attribute} relvar create GeneratedValue { Domain string Class string Attribute string Cmd string } {Domain Class Attribute} relvar partition R18 DefaultValue {Domain Class Attribute}\ UserSuppliedValue {Domain Class Attribute}\ SystemSuppliedValue {Domain Class Attribute}\ GeneratedValue {Domain Class Attribute} relvar create ValueCheck { Domain string Class string Attribute string Expression string } {Domain Class Attribute} relvar association R17\ ValueCheck {Domain Class Attribute} ?\ Attribute {Domain Class Name} 1 relvar create AttributeReference { Domain string ReferringClass string ReferringAttribute string ReferringRole string ReferencedClass string ReferencedAttribute string ReferencedRole string ReferencedIdNumber int Relationship string } {Domain ReferringClass ReferringAttribute ReferringRole\ ReferencedClass ReferencedAttribute ReferencedRole ReferencedIdNumber\ Relationship} relvar association R13\ AttributeReference {Domain ReferringClass ReferringAttribute} *\ Attribute {Domain Class Name} 1 relvar create ReferencedIdAttribute { Domain string Class string Relationship string Role string Attribute string Number int } {Domain Class Relationship Role Attribute Number} relvar create Operation { Domain string Class string Name string } {Domain Class Name} relvar association R8\ Operation {Domain Class} * Class {Domain Name} 1 relvar create InstanceOperation { Domain string Class string Name string } {Domain Class Name} relvar create ClassOperation { Domain string Class string Name string } {Domain Class Name} relvar partition R7 Operation {Domain Class Name}\ InstanceOperation {Domain Class Name}\ ClassOperation {Domain Class Name} relvar create UserInstanceOperation { Domain string Class string Name string Parameters string Body string } {Domain Class Name} relvar create SystemInstanceOperation { Domain string Class string Name string } {Domain Class Name} relvar partition R9 InstanceOperation {Domain Class Name}\ UserInstanceOperation {Domain Class Name}\ SystemInstanceOperation {Domain Class Name} relvar create UserClassOperation { Domain string Class string Name string Parameters string Body string } {Domain Class Name} relvar create SystemClassOperation { Domain string Class string Name string } {Domain Class Name} relvar partition R10 ClassOperation {Domain Class Name}\ UserClassOperation {Domain Class Name}\ SystemClassOperation {Domain Class Name} relvar create SuppliedOperation { Name string Command string RequiresStateModel boolean } Name relvar create SuppliedClassOperation { Name string } Name relvar create SuppliedInstanceOperation { Name string } Name relvar partition R14 SuppliedOperation Name\ SuppliedClassOperation Name\ SuppliedInstanceOperation Name relvar association R15\ SystemClassOperation Name *\ SuppliedClassOperation Name 1 relvar association R16\ SystemInstanceOperation Name *\ SuppliedInstanceOperation Name 1 relvar eval { relvar insert SuppliedOperation { Name findAll Command ::rosea::ClassCmds::findAll RequiresStateModel false } { Name findById Command ::rosea::ClassCmds::findById RequiresStateModel false } { Name findWhere Command ::rosea::ClassCmds::findWhere RequiresStateModel false } { Name create Command ::rosea::ClassCmds::create RequiresStateModel false } { Name createin Command ::rosea::ClassCmds::createin RequiresStateModel true } { Name createasync Command ::rosea::ClassCmds::createasync RequiresStateModel true } { Name update Command ::rosea::ClassCmds::update RequiresStateModel false } relvar insert SuppliedClassOperation { Name findAll } { Name findById } { Name findWhere } { Name create } { Name createin } { Name createasync } { Name update } } relvar eval { relvar insert SuppliedOperation { Name findRelated Command ::rosea::InstCmds::findRelated RequiresStateModel false } { Name findUnrelated Command ::rosea::InstCmds::findById RequiresStateModel false } { Name findRelatedWhere Command ::rosea::InstCmds::findRelatedWhere RequiresStateModel false } { Name findUnrelatedWhere Command ::rosea::InstCmds::findUnrelatedWhere RequiresStateModel false } { Name updateAttribute Command ::rosea::InstCmds::updateAttribute RequiresStateModel false } { Name withAttribute Command ::rosea::InstCmds::withAttribute RequiresStateModel false } { Name readAttribute Command ::rosea::InstCmds::readAttribute RequiresStateModel false } { Name assignAttribute Command ::rosea::InstCmds::assignAttribute RequiresStateModel false } { Name delete Command ::rosea::InstCmds::delete RequiresStateModel false } { Name signal Command ::rosea::InstCmds::signal RequiresStateModel true } { Name delaysignal Command ::rosea::InstCmds::delaysignal RequiresStateModel true } { Name canceldelayed Command ::rosea::InstCmds::canceldelayed RequiresStateModel true } { Name delayremaining Command ::rosea::InstCmds::delayremaining RequiresStateModel true } { Name instop Command ::rosea::InstCmds::instop RequiresStateModel false } { Name deRef Command ::rosea::InstCmds::deRef RequiresStateModel false } { Name isEmptyRef Command ::rosea::InstCmds::isEmptyRef RequiresStateModel false } { Name isNotEmptyRef Command ::rosea::InstCmds::isNotEmptyRef RequiresStateModel false } { Name refMultiplicity Command ::rosea::InstCmds::refMultiplicity RequiresStateModel false } { Name isRefSingular Command ::rosea::InstCmds::isRefSingular RequiresStateModel false } { Name limitRef Command ::rosea::InstCmds::limitRef RequiresStateModel false } { Name isRefEqual Command ::rosea::InstCmds::isRefEqual RequiresStateModel false } { Name forAllRefs Command ::rosea::InstCmds::forAllRefs RequiresStateModel false } relvar insert SuppliedInstanceOperation { Name findRelated } { Name findUnrelated } { Name findRelatedWhere } { Name findUnrelatedWhere } { Name updateAttribute } { Name withAttribute } { Name readAttribute } { Name assignAttribute } { Name delete } { Name signal } { Name delaysignal } { Name canceldelayed } { Name delayremaining } { Name instop } { Name deRef } { Name isEmptyRef } { Name isNotEmptyRef } { Name refMultiplicity } { Name isRefSingular } { Name limitRef } { Name isRefEqual } { Name forAllRefs } } relvar create Association { Domain string Name string } {Domain Name} relvar create Generalization { Domain string Name string } {Domain Name} relvar partition R30 Relationship {Domain Name}\ Association {Domain Name}\ Generalization {Domain Name} relvar create SimpleAssociation { Domain string Name string } {Domain Name} relvar create ClassBasedAssociation { Domain string Name string } {Domain Name} relvar partition R31 Association {Domain Name}\ SimpleAssociation {Domain Name}\ ClassBasedAssociation {Domain Name} relvar create SimpleReferringClass { Domain string Class string Relationship string Role string Conditionality boolean Multiplicity boolean } {Domain Class Relationship Role} relvar association R32\ SimpleReferringClass {Domain Relationship} 1\ SimpleAssociation {Domain Name} 1 relvar create SimpleReferencedClass { Domain string Class string Relationship string Role string Conditionality boolean } {Domain Class Relationship Role} relvar association R33\ SimpleReferencedClass {Domain Relationship} 1\ SimpleAssociation {Domain Name} 1 relvar create SourceClass { Domain string Class string Relationship string Role string Conditionality boolean Multiplicity boolean } {Domain Class Relationship Role} relvar association R34\ SourceClass {Domain Relationship} 1\ ClassBasedAssociation {Domain Name} 1 relvar create TargetClass { Domain string Class string Relationship string Role string Conditionality boolean Multiplicity boolean } {Domain Class Relationship Role} relvar association R35\ TargetClass {Domain Relationship} 1\ ClassBasedAssociation {Domain Name} 1 relvar create AssociatorClass { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar association R42\ AssociatorClass {Domain Relationship} 1\ ClassBasedAssociation {Domain Name} 1 relvar create Superclass { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar association R36\ Superclass {Domain Relationship} 1\ Generalization {Domain Name} 1 relvar create Subclass { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar association R37\ Subclass {Domain Relationship} +\ Generalization {Domain Name} 1 relvar create ReferringClass { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar partition R38 ReferringClass {Domain Class Relationship Role}\ SimpleReferringClass {Domain Class Relationship Role}\ AssociatorClass {Domain Class Relationship Role}\ Subclass {Domain Class Relationship Role} relvar create ReferencedClass { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar partition R39 ReferencedClass {Domain Class Relationship Role}\ SimpleReferencedClass {Domain Class Relationship Role}\ SourceClass {Domain Class Relationship Role}\ TargetClass {Domain Class Relationship Role}\ Superclass {Domain Class Relationship Role} relvar create ClassRole { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar partition R40 ClassRole {Domain Class Relationship Role}\ ReferringClass {Domain Class Relationship Role}\ ReferencedClass {Domain Class Relationship Role} relvar correlation R41 ClassRole\ {Domain Relationship} + Relationship {Domain Name}\ {Domain Class} * Class {Domain Name} relvar correlation R11 ReferencedIdAttribute\ {Domain Class Relationship Role} +\ ReferencedClass {Domain Class Relationship Role}\ {Domain Class Attribute Number} *\ IdentifyingAttribute {Domain Class Attribute Number} relvar correlation R12 AttributeReference\ {Domain ReferringClass Relationship ReferringRole} +\ ReferringClass {Domain Class Relationship Role}\ {Domain ReferencedClass Relationship ReferencedRole ReferencedAttribute\ ReferencedIdNumber} +\ ReferencedIdAttribute {Domain Class Relationship Role Attribute Number} relvar create Config_AssocSpec { Spec string NeedsAssociator boolean ReflexiveAllowed boolean ReferringCond boolean ReferringMult boolean ReferencedCond boolean ReferencedMult boolean } Spec relvar insert Config_AssocSpec { Spec 1--1 NeedsAssociator false ReflexiveAllowed true ReferringCond false ReferringMult false ReferencedCond false ReferencedMult false } { Spec 0..1--1 NeedsAssociator false ReflexiveAllowed false ReferringCond true ReferringMult false ReferencedCond false ReferencedMult false } { Spec 0..1--0..1 NeedsAssociator false ReflexiveAllowed true ReferringCond true ReferringMult false ReferencedCond true ReferencedMult false } { Spec 1..*--1 NeedsAssociator false ReflexiveAllowed true ReferringCond false ReferringMult true ReferencedCond false ReferencedMult false } { Spec 0..*--1 NeedsAssociator false ReflexiveAllowed false ReferringCond true ReferringMult true ReferencedCond false ReferencedMult false } { Spec 1..*--0..1 NeedsAssociator false ReflexiveAllowed false ReferringCond false ReferringMult true ReferencedCond true ReferencedMult false } { Spec 0..*--0..1 NeedsAssociator false ReflexiveAllowed true ReferringCond true ReferringMult true ReferencedCond true ReferencedMult false } { Spec 1..*--1..* NeedsAssociator true ReflexiveAllowed true ReferringCond false ReferringMult true ReferencedCond false ReferencedMult true } { Spec 0..*--1..* NeedsAssociator true ReflexiveAllowed false ReferringCond true ReferringMult true ReferencedCond false ReferencedMult true } { Spec 1..*--0..* NeedsAssociator true ReflexiveAllowed false ReferringCond false ReferringMult true ReferencedCond true ReferencedMult true } { Spec 0..*--0..* NeedsAssociator true ReflexiveAllowed true ReferringCond true ReferringMult true ReferencedCond true ReferencedMult true } { Spec ?--1 NeedsAssociator false ReflexiveAllowed false ReferringCond true ReferringMult false ReferencedCond false ReferencedMult false } { Spec ?--? NeedsAssociator false ReflexiveAllowed true ReferringCond true ReferringMult false ReferencedCond true ReferencedMult false } { Spec +--1 NeedsAssociator false ReflexiveAllowed true ReferringCond false ReferringMult true ReferencedCond false ReferencedMult false } { Spec *--1 NeedsAssociator false ReflexiveAllowed false ReferringCond true ReferringMult true ReferencedCond false ReferencedMult false } { Spec +--? NeedsAssociator false ReflexiveAllowed false ReferringCond false ReferringMult true ReferencedCond true ReferencedMult false } { Spec *--? NeedsAssociator false ReflexiveAllowed true ReferringCond true ReferringMult true ReferencedCond true ReferencedMult false } { Spec +--+ NeedsAssociator true ReflexiveAllowed true ReferringCond false ReferringMult true ReferencedCond false ReferencedMult true } { Spec *--+ NeedsAssociator true ReflexiveAllowed false ReferringCond true ReferringMult true ReferencedCond false ReferencedMult true } { Spec +--* NeedsAssociator true ReflexiveAllowed false ReferringCond false ReferringMult true ReferencedCond true ReferencedMult true } { Spec *--* NeedsAssociator true ReflexiveAllowed true ReferringCond true ReferringMult true ReferencedCond true ReferencedMult true } relvar create Config_ClassAssoc { Domain string Relationship string AssocClass string SourceClass string } {Domain Relationship AssocClass SourceClass} relvar create Config_NonReflexiveAssoc { Domain string Relationship string AssocClass string SourceClass string TargetClass string } {Domain Relationship AssocClass SourceClass} relvar create Config_ReflexiveAssoc { Domain string Relationship string AssocClass string SourceClass string } {Domain Relationship AssocClass SourceClass} relvar create Config_ReflexivePath { Domain string Relationship string AssocClass string SourceClass string SourceAttr string TargetAttr string } {Domain Relationship AssocClass SourceClass SourceAttr} relvar partition Config1\ Config_ClassAssoc\ {Domain Relationship AssocClass SourceClass}\ Config_NonReflexiveAssoc\ {Domain Relationship AssocClass SourceClass}\ Config_ReflexiveAssoc\ {Domain Relationship AssocClass SourceClass} relvar association Config2\ Config_ReflexivePath {Domain Relationship AssocClass SourceClass} +\ Config_ReflexiveAssoc {Domain Relationship AssocClass SourceClass} 1 pipe { relvar set ::rosea::Config::AttributeReference | relation project ~ Domain ReferencedClass Relationship ReferencedRole\ ReferencedAttribute ReferencedIdNumber | relation rename ~ ReferencedClass Class ReferencedRole Role\ ReferencedAttribute Attribute ReferencedIdNumber Number | relvar union ::rosea::Config::ReferencedIdAttribute } refIdQuery relvar create StateModel { Domain string Model string InitialState string DefaultTrans string } {Domain Model} relvar create InstanceStateModel { Domain string Class string } {Domain Class} relvar association R51\ InstanceStateModel {Domain Class} ?\ Class {Domain Name} 1 relvar create AssignerStateModel { Domain string Relationship string } {Domain Relationship} relvar association R52\ AssignerStateModel {Domain Relationship} ?\ Association {Domain Name} 1 relvar partition R50 StateModel {Domain Model}\ InstanceStateModel {Domain Class}\ AssignerStateModel {Domain Relationship} relvar create SingleAssigner { Domain string Relationship string } {Domain Relationship} relvar create MultipleAssigner { Domain string Relationship string Class string Number int } {Domain Relationship} relvar partition R53 AssignerStateModel {Domain Relationship}\ SingleAssigner {Domain Relationship}\ MultipleAssigner {Domain Relationship} relvar association R54\ MultipleAssigner {Domain Class Number} ?\ Identifier {Domain Class Number} 1 relvar create State { Domain string Model string Name string Parameters string Action string IsFinal boolean } {Domain Model Name} relvar association R55\ State {Domain Model} +\ StateModel {Domain Model} 1 relvar association R58\ StateModel {Domain Model InitialState} ?\ State {Domain Model Name} 1 relvar create TransitionRule { Name string } Name relvar insert TransitionRule {Name IG} {Name CH} relvar association R59\ StateModel DefaultTrans *\ TransitionRule Name 1 relvar create CreationState { Domain string Model string Name string } {Domain Model Name} relvar create StatePlace { Domain string Model string Name string } {Domain Model Name} relvar partition R57 StatePlace {Domain Model Name}\ State {Domain Model Name}\ CreationState {Domain Model Name} relvar create Event { Domain string Model string Event string } {Domain Model Event} relvar create DeferredEvent { Domain string Model string Event string } {Domain Model Event} relvar create EffectiveEvent { Domain string Model string Event string } {Domain Model Event} relvar partition R80 Event {Domain Model Event}\ DeferredEvent {Domain Model Event}\ EffectiveEvent {Domain Model Event} relvar create DeferralPath { Domain string Model string Event string Relationship string Role string } {Domain Model Event Relationship Role} relvar correlation R86 DeferralPath\ {Domain Model Event} + DeferredEvent {Domain Model Event}\ {Domain Model Relationship Role} * Superclass\ {Domain Class Relationship Role} relvar create PolymorphicEvent { Domain string Model string Event string } {Domain Model Event} relvar create InheritedEvent { Domain string Model string Event string } {Domain Model Event} relvar partition R81 DeferredEvent {Domain Model Event}\ PolymorphicEvent {Domain Model Event}\ InheritedEvent {Domain Model Event} relvar create MappedEvent { Domain string Model string Event string ParentModel string } {Domain Model Event} relvar association R84\ MappedEvent {Domain ParentModel Event} *\ DeferredEvent {Domain Model Event} 1 relvar create LocalEvent { Domain string Model string Event string } {Domain Model Event} relvar partition R82 EffectiveEvent {Domain Model Event}\ MappedEvent {Domain Model Event}\ LocalEvent {Domain Model Event} relvar create NonLocalEvent { Domain string Model string Event string Relationship string Role string } {Domain Model Event} relvar partition R83 NonLocalEvent {Domain Model Event}\ MappedEvent {Domain Model Event}\ InheritedEvent {Domain Model Event} relvar association R85\ NonLocalEvent {Domain Model Relationship Role} *\ Subclass {Domain Class Relationship Role} 1 relvar association R87\ EffectiveEvent {Domain Model} +\ StateModel {Domain Model} 1 relvar create TransitionPlace { Domain string Model string State string Event string } {Domain Model State Event} relvar correlation R70 TransitionPlace\ {Domain Model State} * StatePlace {Domain Model Name}\ {Domain Model Event} * EffectiveEvent {Domain Model Event} relvar create StateTransition { Domain string Model string State string Event string NewState string } {Domain Model State Event} relvar create NonStateTransition { Domain string Model string State string Event string TransRule string } {Domain Model State Event} relvar partition R71 TransitionPlace {Domain Model State Event}\ StateTransition {Domain Model State Event}\ NonStateTransition {Domain Model State Event} relvar association R72\ StateTransition {Domain Model NewState} *\ State {Domain Model Name} 1 relvar association R73\ NonStateTransition TransRule *\ TransitionRule Name 1 relvar create Config_DataError { Relationship string RefClass string RefType string Format string } {Relationship RefClass RefType} relvar insert Config_DataError { Relationship R3 RefClass Class RefType notrefed Format {in domain, \"$Domain\", class, \"$Name\",\ has no attributes} } { Relationship R4 RefClass Class RefType notrefed Format {in domain, \"$Domain\", class, \"$Name\",\ has no identifiers} } { Relationship R11 RefClass ReferencedClass RefType notrefed Format {in domain, \"$Domain\", for relationship,\ \"$Relationship\", no class has defined a reference\ to class, \"$Class\"} } { Relationship R11 RefClass ReferencedIdAttribute RefType refnone Format {in domain, \"$Domain\", relationship,\ \"$Relationship\", references attribute,\ \"$Attribute\", in class, \"$Class\", which is\ not an identifying attribute, does not exist\ or \"$Relationship\" does not exist} } { Relationship R12 RefClass AttributeReference RefType refnone Format {in domain, \"$Domain\", the attribute,\ \"$ReferringAttribute\", in class, \"$ReferringClass\",\ refers to, \"$ReferencedAttribute\", in class,\ \"$ReferencedClass\", but the class, attribute or\ relationship does not exist} } { Relationship R12 RefClass ReferringClass RefType notrefed Format {in domain, \"$Domain\", in class, \"$Class\",\ makes a reference along relationship,\ \"$Relationship\", but $Class does not pariticipate\ in $Relationship} } { Relationship R13 RefClass AttributeReference RefType refnone Format {in domain, \"$Domain\", the attribute,\ \"$ReferringAttribute\", in class, \"$ReferringClass\",\ does not exist, but is used as a referential attribute} } { Relationship R41 RefClass ClassRole RefType refnone Format {in domain, \"$Domain\", relationship,\ \"$Relationship\", references class, \"$Class\",\ which does not exist} } { Relationship R52 RefClass AssignerStateModel RefType refnone Format {in domain, \"$Domain\", an assigner state model is\ defined on relationship, \"$Relationship\", which is\ not an association type relationship} } { Relationship R70 RefClass TransitionPlace RefType refnone Format {in domain, \"$Domain\", the state model for,\ \"$Model\", contains a transition for event,\ \"$Event\", but $Event was a polymorphic event\ consumed by a superclass of $Model} } { Relationship R72 RefClass StateTransition RefType refnone Format {in domain, \"$Domain\", the state model for,\ \"$Model\", contains the transition,\ \"$State - $Event -> $NewState\",\ but state \"$NewState\" does not exist} } { Relationship R81 RefClass DeferredEvent RefType multrefed Format {in domain, \"$Domain\", in the state model for,\ \"$Model\", event, \"$Event\", is both an inherited\ polymorphic event and a locally defined one} } { Relationship R86 RefClass DeferredEvent RefType notrefed Format {in domain, \"$Domain\", in the state model for,\ \"$Model\", event, \"$Event\", is defined as\ polymorphic but \"$Model\" is not a superclass\ of a generalization} } { Relationship R87 RefClass EffectiveEvent RefType refnone Format {in domain, \"$Domain\", event, \"$Event\" has been\ inherited, but no state model exists for, \"$Model\"} } namespace export ConfigEvaluate proc ConfigEvaluate {ns body} { variable evalLambda tailcall ::apply [concat $evalLambda [list $ns]] $body ; # <1> } proc domain {name body} { namespace upvar DomainDef DomainName DomainName ; # <1> set DomainName $name relvar insert ::rosea::Config::Domain [list Name $name Location {}] try { if {$name eq {}} { tailcall DeclError EMPTY_NAME domain } relvar eval { # <2> ConfigEvaluate [namespace current]::DomainDef $body # At this point we have the definition of the domain and enough # information to tie together the referential attributes and # the association definitions. variable Config_NonReflexiveAssoc relation foreach nra $Config_NonReflexiveAssoc { relation assign $nra relvar update ::rosea::Config::AttributeReference ar { [tuple extract $ar Domain] eq $Domain && [tuple extract $ar Relationship] eq $Relationship && [tuple extract $ar ReferringClass] eq $AssocClass } {tuple update $ar ReferringRole associator} relvar update ::rosea::Config::AttributeReference ar { [tuple extract $ar Domain] eq $Domain && [tuple extract $ar Relationship] eq $Relationship && [tuple extract $ar ReferringClass] eq $AssocClass && [tuple extract $ar ReferencedClass] eq $SourceClass } {tuple update $ar ReferencedRole source} } variable Config_ReflexivePath relation foreach rp $Config_ReflexivePath { relation assign $rp relvar update ::rosea::Config::AttributeReference ar { [tuple extract $ar Domain] eq $Domain && [tuple extract $ar Relationship] eq $Relationship && [tuple extract $ar ReferringClass] eq $AssocClass } {tuple update $ar ReferringRole associator} relvar update ::rosea::Config::AttributeReference ar { [tuple extract $ar Domain] eq $Domain && [tuple extract $ar Relationship] eq $Relationship && [tuple extract $ar ReferringClass] eq $AssocClass && [tuple extract $ar ReferringAttribute] eq $SourceAttr } {tuple update $ar ReferencedRole source} } variable refIdQuery eval $refIdQuery # We must also compute how polymorphic events are inherited # down generalization hierarchies. # Create Deferral Path instances variable PolymorphicEvent variable DeferredEvent variable Superclass variable Subclass variable DeferralPath set dpaths [pipe { relation restrictwith $PolymorphicEvent {$Domain eq $name} | relation semijoin ~ $DeferredEvent | relation join ~ $Superclass -using {Domain Domain Model Class} }] relvar insert ::rosea::Config::DeferralPath {*}[relation body $dpaths] set supers [relation semiminus $Subclass $Superclass\ -using {Domain Domain Class Class}] relation foreach super $supers { PropagatePolyEvents $super } } } on error {result} { # puts $::errorInfo ::rosea::Config::HandleConfigError $result } } proc HandleConfigError {result} { set lines [split [string trimright $result] \n] set nlines [llength $lines] set lineno 0 upvar #0 ::rosea::Config::errcount errcount while {$lineno < $nlines} { set line [lindex $lines $lineno] incr lineno if {[regexp {^for[^:]+([^(]+)\(.+\), in relvar (.+)$} $line\ match rnum refclass]} { set rnum [namespace tail $rnum] set refclass [namespace tail $refclass] # Now iterate over the "tuple" lines that follow the constraint message. while {$lineno < $nlines} { set tupline [lindex $lines $lineno] if {[regexp {^tuple {(.+)} (.+)$} $tupline match tuple phrase]} { incr lineno incr errcount if {[string match {is not referenced*} $phrase]} { set reftype notrefed } elseif {[string match {references no*} $phrase]} { set reftype refnone } elseif {[string match {*to by multiple*} $phrase]} { set reftype multrefed } elseif {[string match {is not referred to*} $phrase]} { set reftype notrefto } else { log::error "unknown constraint phrasing, \"$phrase\"" continue } set cde [relvar restrictone Config_DataError Relationship $rnum RefClass\ $refclass RefType $reftype] if {[relation isnotempty $cde]} { dict with tuple { log::error [subst -nocommands [relation extract $cde Format]] } } else { log::error "$line\n$tupline" } } else { break } } } else { log::error "unknown configuration error, \"$result\"" } } return } namespace eval DomainDef { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Config::ConfigEvaluate namespace import ::rosea::Helpers::DeclError proc class {name body} { namespace upvar [namespace current] DomainName DomainName ; # <1> namespace upvar ClassDef ClassName ClassName set ClassName $name if {![regexp {\A[[:alnum:]].*} $name]} { tailcall DeclError BAD_CLASS_NAME $name } try { relvar insert ::rosea::Config::DomainElement [list\ Domain $DomainName\ Element $name\ ] } trap {RAL relvar insert DUPLICATE_TUPLE} {} { tailcall DeclError DUP_ELEMENT_NAME $name } ; # <2> relvar insert ::rosea::Config::Class [list\ Domain $DomainName\ Name $name\ ] set instops [pipe { relvar set ::rosea::Config::SuppliedInstanceOperation | relation extend ~ ioptuple\ Domain string {[set DomainName]}\ Class string {[set ClassName]} }] relvar union ::rosea::Config::SystemInstanceOperation $instops relvar union ::rosea::Config::InstanceOperation $instops relvar union ::rosea::Config::Operation $instops set classops [pipe { relvar set ::rosea::Config::SuppliedClassOperation | relation extend ~ coptuple\ Domain string {[set DomainName]}\ Class string {[set ClassName]} }] relvar union ::rosea::Config::SystemClassOperation $classops relvar union ::rosea::Config::ClassOperation $classops relvar union ::rosea::Config::Operation $classops ConfigEvaluate [namespace current]::ClassDef $body } proc association {name source spec target args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } if {$name eq {}} { tailcall DeclError EMPTY_NAME association } if {[string index $name 0] eq "~"} { tailcall DeclError TILDE_NAME $name } # Obtain references to the domain and class context. namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName set associator {} set path {} foreach {option value} $args { switch -exact -- $option { -associator { set associator $value } -path { set path $value if {[llength $path] % 2 != 0} { tailcall DeclError ARG_FORMAT $path } } default { tailcall DeclError UNKNOWN_OPTION association $option } } } set cas [relvar restrictone ::rosea::Config::Config_AssocSpec Spec $spec] if {[relation isempty $cas]} { tailcall DeclError BAD_RELATIONSHIP_SPEC $spec } set needsassoc [relation extract $cas NeedsAssociator] if {$needsassoc && $associator eq {}} { tailcall DeclError NEED_ASSOCIATOR $spec } if {$source eq $target} { if {![relation extract $cas ReflexiveAllowed]} { tailcall DeclError REFLEXIVE_NOT_ALLOWED $spec } if {$needsassoc && $path eq {}} { tailcall DeclError NEED_REFLEXIVE_PATH $name $source $spec $target } } try { relvar insert ::rosea::Config::DomainElement [list\ Domain $DomainName\ Element $name\ ] } trap {RAL relvar insert DUPLICATE_TUPLE} {result opts} { tailcall DeclError DUP_ELEMENT_NAME $name } # Many relvars have tuples with the same heading, so we construct it # once here. set reltuple [list\ Domain $DomainName\ Name $name\ ] # Populate the data for a Relationship and Association since that # is what this command defines. relvar insert ::rosea::Config::Relationship $reltuple relvar insert ::rosea::Config::Association $reltuple # Populate the type of association we are dealing with. if {$associator eq {}} { relvar insert ::rosea::Config::SimpleAssociation $reltuple relvar insert ::rosea::Config::SimpleReferringClass [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ Conditionality [relation extract $cas ReferringCond]\ Multiplicity [relation extract $cas ReferringMult]\ ] relvar insert ::rosea::Config::ReferringClass [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ ] relvar insert ::rosea::Config::ClassRole [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ ] relvar insert ::rosea::Config::SimpleReferencedClass [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ Conditionality [relation extract $cas ReferencedCond]\ ] relvar insert ::rosea::Config::ReferencedClass [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ ] relvar insert ::rosea::Config::ClassRole [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ ] } else { relvar insert ::rosea::Config::Config_ClassAssoc [list\ Domain $DomainName\ Relationship $name\ AssocClass $associator\ SourceClass $source\ ] if {[llength $path] == 0} { relvar insert ::rosea::Config::Config_NonReflexiveAssoc [list\ Domain $DomainName\ Relationship $name\ AssocClass $associator\ SourceClass $source\ TargetClass $target\ ] } else { relvar insert ::rosea::Config::Config_ReflexiveAssoc [list\ Domain $DomainName\ Relationship $name\ AssocClass $associator\ SourceClass $source\ ] foreach {sourceattr targetattr} $path { relvar insert ::rosea::Config::Config_ReflexivePath [list\ Domain $DomainName\ Relationship $name\ AssocClass $associator\ SourceClass $source\ SourceAttr $sourceattr\ TargetAttr $targetattr\ ] } } relvar insert ::rosea::Config::ClassBasedAssociation $reltuple relvar insert ::rosea::Config::SourceClass [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ Conditionality [relation extract $cas ReferringCond]\ Multiplicity [relation extract $cas ReferringMult]\ ] relvar insert ::rosea::Config::ReferencedClass [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ ] relvar insert ::rosea::Config::ClassRole [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ ] relvar insert ::rosea::Config::TargetClass [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ Conditionality [relation extract $cas ReferencedCond]\ Multiplicity [relation extract $cas ReferencedMult]\ ] relvar insert ::rosea::Config::ReferencedClass [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ ] relvar insert ::rosea::Config::ClassRole [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ ] relvar insert ::rosea::Config::AssociatorClass [list\ Domain $DomainName\ Class $associator\ Relationship $name\ Role associator\ ] relvar insert ::rosea::Config::ReferringClass [list\ Domain $DomainName\ Class $associator\ Relationship $name\ Role associator\ ] relvar insert ::rosea::Config::ClassRole [list\ Domain $DomainName\ Class $associator\ Relationship $name\ Role associator\ ] } } proc generalization {name super args} { if {[llength $args] < 2} { tailcall DeclError TOO_FEW_SUBCLASSES [llength $args] } if {$name eq {}} { tailcall DeclError EMPTY_NAME generalization } if {[string index $name 0] eq "~"} { tailcall DeclError TILDE_NAME $name } namespace upvar ::rosea::Config::DomainDef DomainName DomainName try { relvar insert ::rosea::Config::DomainElement [list\ Domain $DomainName\ Element $name\ ] } trap {RAL relvar insert DUPLICATE_TUPLE} {result opts} { tailcall DeclError DUP_ELEMENT_NAME $name } set reltuple [list\ Domain $DomainName\ Name $name\ ] relvar insert ::rosea::Config::Relationship $reltuple relvar insert ::rosea::Config::Generalization $reltuple set supertuple [list\ Domain $DomainName\ Class $super\ Relationship $name\ Role target\ ] relvar insert ::rosea::Config::Superclass $supertuple relvar insert ::rosea::Config::ReferencedClass $supertuple relvar insert ::rosea::Config::ClassRole $supertuple set subtuple [dict create\ Domain $DomainName\ Relationship $name\ Role source\ ] foreach sub $args { dict set subtuple Class $sub relvar insert ::rosea::Config::Subclass $subtuple relvar insert ::rosea::Config::ReferringClass $subtuple relvar insert ::rosea::Config::ClassRole $subtuple } } proc assigner {rname body} { namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar AssignerDef\ RelationshipName RelationshipName\ multiClass multiClass\ multiIdNum multiIdNum\ InitialState InitialState\ DefaultTrans DefaultTrans set RelationshipName $rname set multiClass {} set multiIdNum 1 set InitialState {} set DefaultTrans {} try { ConfigEvaluate [namespace current]::AssignerDef $body if {$DefaultTrans eq {}} { set DefaultTrans CH } relvar insert ::rosea::Config::StateModel [list\ Domain $DomainName\ Model $rname\ InitialState $InitialState\ DefaultTrans $DefaultTrans\ ] set assigntuple [list\ Domain $DomainName\ Relationship $rname\ ] relvar insert ::rosea::Config::AssignerStateModel $assigntuple if {$multiClass eq {}} { relvar insert ::rosea::Config::SingleAssigner $assigntuple } else { lappend assigntuple Class $multiClass Number $multiIdNum relvar insert ::rosea::Config::MultipleAssigner $assigntuple } } on error {result opts} { log::error $result upvar #0 ::rosea::Config::errcount errcount incr errcount } } proc operation {name params body} { if {$name eq {}} { tailcall DeclError EMPTY_NAME operation } namespace upvar ::rosea::Config::DomainDef DomainName DomainName try { relvar insert ::rosea::Config::DomainElement [list\ Domain $DomainName\ Element $name\ ] } trap {RAL relvar insert DUPLICATE_TUPLE} {result opts} { tailcall DeclError DUP_ELEMENT_NAME $name } relvar insert ::rosea::Config::DomainOperation [list\ Domain $DomainName\ Name $name\ Parameters $params\ Body $body\ ] } namespace eval ClassDef { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Config::ConfigEvaluate namespace import ::rosea::Helpers::DeclError proc attribute {name type args} { if {$name eq {}} { tailcall DeclError EMPTY_NAME attribute } if {[string range $name 0 1] eq "__"} { tailcall DeclError RESERVED_NAME $name } if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName relvar insert ::rosea::Config::Attribute [list\ Domain $DomainName\ Class $ClassName\ Name $name\ Type $type\ ] foreach {option value} $args { switch -exact -- $option { -default { relvar insert ::rosea::Config::DefaultValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ ] relvar insert ::rosea::Config::UserSuppliedValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ Value $value\ ] } -system { if {$type ne "int"} { tailcall DeclError INT_TYPE_REQUIRED $type } if {![string is integer -strict $value]} { tailcall DeclError INT_VALUE_REQUIRED $value } relvar insert ::rosea::Config::DefaultValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ ] relvar insert ::rosea::Config::SystemSuppliedValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ StartValue $value\ ] } -generate { relvar insert ::rosea::Config::DefaultValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ ] relvar insert ::rosea::Config::GeneratedValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ Cmd $value\ ] } -id { relvar uinsert ::rosea::Config::Identifier [list\ Domain $DomainName\ Class $ClassName\ Number $value\ ] ; # <1> relvar insert ::rosea::Config::IdentifyingAttribute [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ Number $value\ ] } -check { relvar insert ::rosea::Config::ValueCheck [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ Expression $value\ ] } default { tailcall DeclError UNKNOWN_OPTION attribute $option } } } } proc reference {relname rclass args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName set refnum 1 set linkopts [list] foreach {option value} $args { switch -exact -- $option { -refid { set refnum $value } -link { if {[llength $value] < 1 || [llength $value] > 2} { tailcall DeclError ARG_FORMAT $value } lappend linkopts $value } default { tailcall DeclError UNKNOWN_OPTION reference $option } } } # We defer processing the link options until the end so as not # to impose an order on the -refid option. foreach linkopt $linkopts { lassign $linkopt referring referenced if {$referenced eq {}} { set referenced $referring } relvar insert ::rosea::Config::AttributeReference [list\ Domain $DomainName\ ReferringClass $ClassName\ ReferringAttribute $referring\ ReferringRole source\ ReferencedClass $rclass\ ReferencedAttribute $referenced\ ReferencedRole target\ ReferencedIdNumber $refnum\ Relationship $relname ] ; # <1> } } proc classop {name params body} { if {$name eq {}} { tailcall DeclError EMPTY_NAME "class operation" } elseif {[string first :: $name] != -1} { tailcall DeclError NS_QUALIFIERS $name } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName set sysop [relvar restrictone ::rosea::Config::Operation\ Domain $DomainName Class $ClassName Name $name] if {[relation isnotempty $sysop]} { tailcall DeclError DUP_OP_NAME $name } set optuple [list Domain $DomainName Class $ClassName Name $name] relvar insert ::rosea::Config::Operation $optuple relvar insert ::rosea::Config::ClassOperation $optuple lappend optuple Parameters $params Body $body relvar insert ::rosea::Config::UserClassOperation $optuple } proc instop {name params body} { if {$name eq {}} { tailcall DeclError EMPTY_NAME "instance operation" } elseif {[string first :: $name] != -1} { tailcall DeclError NS_QUALIFIERS $name } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName set sysop [relvar restrictone ::rosea::Config::Operation\ Domain $DomainName Class $ClassName Name $name] if {[relation isnotempty $sysop]} { tailcall DeclError DUP_OP_NAME $name } set optuple [list Domain $DomainName Class $ClassName Name $name] relvar insert ::rosea::Config::Operation $optuple relvar insert ::rosea::Config::InstanceOperation $optuple lappend optuple Parameters $params Body $body relvar insert ::rosea::Config::UserInstanceOperation $optuple } proc statemodel {body} { namespace upvar ::rosea::Config::DomainDef DomainName DomainName variable ClassName namespace upvar StateModelDef\ InitialState InitialState\ DefaultTrans DefaultTrans\ Terminals Terminals set InitialState {} set DefaultTrans {} set Terminals [list] try { ConfigEvaluate [namespace current]::StateModelDef $body if {$DefaultTrans eq {}} { set DefaultTrans CH } relvar insert ::rosea::Config::StateModel [list\ Domain $DomainName\ Model $ClassName\ InitialState $InitialState\ DefaultTrans $DefaultTrans\ ] relvar insert ::rosea::Config::InstanceStateModel [list\ Domain $DomainName\ Class $ClassName\ ] foreach terminal $Terminals { relvar updateone ::rosea::Config::State stup [list\ Domain $DomainName Model $ClassName Name $terminal] { tuple update $stup IsFinal true } } } on error {result opts} { log::error $result upvar #0 ::rosea::Config::errcount errcount incr errcount } } proc polymorphic {args} { namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName foreach polyevent $args { set eventtuple [list\ Domain $DomainName\ Model $ClassName\ Event $polyevent\ ] relvar insert ::rosea::Config::PolymorphicEvent $eventtuple relvar insert ::rosea::Config::DeferredEvent $eventtuple relvar insert ::rosea::Config::Event $eventtuple } return } namespace eval StateModelDef { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Config::ConfigEvaluate namespace import ::rosea::Helpers::DeclError proc state {name params body} { if {$name eq {}} { tailcall DeclError EMPTY_NAME state } if {$name in {@ CH IG}} { tailcall DeclError PSEUDO_STATE $name state } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName variable InitialState if {$InitialState eq {}} { set InitialState $name } relvar insert ::rosea::Config::State [list\ Domain $DomainName\ Model $ClassName\ Name $name\ Parameters $params\ Action $body\ IsFinal false\ ] relvar insert ::rosea::Config::StatePlace [list\ Domain $DomainName\ Model $ClassName\ Name $name\ ] return } proc transition {source - event -> target} { if {$event eq {}} { tailcall DeclError EMPTY_NAME event } if {$source in {CH IG}} { tailcall DeclError PSEUDO_STATE $source "transition source state" } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName if {$source eq "@"} { if {$target in {CH IG}} { tailcall DeclError BAD_CREATION_TARGET $target } set cstuple [list\ Domain $DomainName\ Model $ClassName\ Name @\ ] relvar uinsert ::rosea::Config::CreationState $cstuple relvar uinsert ::rosea::Config::StatePlace $cstuple } set eventtuple [list\ Domain $DomainName\ Model $ClassName\ Event $event\ ] relvar uinsert ::rosea::Config::Event $eventtuple ; # <1> relvar uinsert ::rosea::Config::EffectiveEvent $eventtuple relvar uinsert ::rosea::Config::LocalEvent $eventtuple set tranrule [relvar restrictone ::rosea::Config::TransitionRule\ Name $target] set transtuple [list\ Domain $DomainName\ Model $ClassName\ State $source\ Event $event\ ] relvar insert ::rosea::Config::TransitionPlace $transtuple if {[relation isnotempty $tranrule]} { lappend transtuple TransRule $target set tpsubtype NonStateTransition } else { lappend transtuple NewState $target set tpsubtype StateTransition } relvar insert ::rosea::Config::$tpsubtype $transtuple return } proc initialstate {name} { if {$name eq {}} { tailcall DeclError EMPTY_NAME initialstate } if {$name in {@ CH IG}} { tailcall DeclError PSEUDO_STATE $name initialstate } variable InitialState $name return } proc defaulttrans {name} { if {$name ni {CH IG}} { tailcall DeclError EXPECTED_PSEUDO_STATE $name } variable DefaultTrans $name return } proc terminal {args} { variable Terminals ::struct::set add Terminals $args return } } } namespace eval AssignerDef { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Config::ConfigEvaluate namespace import ::rosea::Helpers::DeclError proc state {name params body} { if {$name eq {}} { tailcall DeclError EMPTY_NAME state } if {$name in {CH IG}} { tailcall DeclError PSEUDO_STATE $name state } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::AssignerDef\ RelationshipName RelationshipName variable InitialState if {$InitialState eq {}} { set InitialState $name } relvar insert ::rosea::Config::State [list\ Domain $DomainName\ Model $RelationshipName\ Name $name\ Parameters $params\ Action $body\ IsFinal false\ ] relvar insert ::rosea::Config::StatePlace [list\ Domain $DomainName\ Model $RelationshipName\ Name $name\ ] return } proc transition {source - event -> target} { if {$event eq {}} { tailcall DeclError EMPTY_NAME event } if {$source in {CH IG}} { tailcall DeclError PSEUDO_STATE $name "transition source state" } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::AssignerDef\ RelationshipName RelationshipName set eventtuple [list\ Domain $DomainName\ Model $RelationshipName\ Event $event\ ] relvar uinsert ::rosea::Config::Event $eventtuple relvar uinsert ::rosea::Config::EffectiveEvent $eventtuple relvar uinsert ::rosea::Config::LocalEvent $eventtuple set tranrule [relvar restrictone ::rosea::Config::TransitionRule\ Name $target] set transtuple [list\ Domain $DomainName\ Model $RelationshipName\ State $source\ Event $event\ ] relvar insert ::rosea::Config::TransitionPlace $transtuple if {[relation isnotempty $tranrule]} { lappend transtuple TransRule $target set tpsubtype NonStateTransition } else { lappend transtuple NewState $target set tpsubtype StateTransition } relvar insert ::rosea::Config::$tpsubtype $transtuple return } proc initialstate {name} { if {$name eq {}} { tailcall DeclError EMPTY_NAME initialstate } if {$name in {CH IG}} { tailcall DeclError PSEUDO_STATE $name initialstate } variable InitialState $name return } proc defaulttrans {name} { if {$name ni {CH IG}} { tailcall DeclError EXPECTED_PSEUDO_STATE $name } variable DefaultTrans $name return } proc identifyby {name args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } variable multiClass $name foreach {option value} $args { switch -exact -- $option { -id { variable multiIdNum $value } default { tailcall DeclError UNKNOWN_OPTION identifyby $option } } } return } } } } namespace eval Populate { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Config::ConfigEvaluate namespace import ::rosea::Helpers::DeclError proc domain {name body} { set domain [relvar restrictone ::rosea::Config::Domain Name $name] if {[relation isempty $domain]} { tailcall DeclError UNKNOWN_DOMAIN $domain } namespace upvar DomainPop DomainName DomainName DomainLoc DomainLoc relation assign $domain {Name DomainName} {Location DomainLoc} try { relvar eval { ConfigEvaluate [namespace current]::DomainPop $body } } on error {result opts} { log::error $result upvar #0 ::rosea::Config::errcount errcount incr errcount } } namespace eval DomainPop { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path ::rosea::Helpers proc class {class heading args} { # Determine if we have one big list or a bunch of values. set popvalues [expr {[llength $args] == 1 ? [lindex $args 0] : $args}] set headlen [llength $heading] if {[llength $popvalues] % $headlen != 0} { tailcall DeclError ARG_MISMATCH $headlen [llength $popvalues] } # Iterate over the attribute values taking them in chunks that are the same # size as the heading. set body [list] for {set vindex 0} {$vindex < [llength $popvalues]} {incr vindex $headlen} { set values [lrange $popvalues $vindex [expr {$vindex + $headlen - 1}]] # Create a tuple as a list of attribute name / value pairs. set tuple [list] foreach attr $heading value $values { # Check if we are skipping a value to use a default. We must also # allow some way to specify the value as "-". if {$value eq "-"} { continue } elseif {$value eq "\\-"} { set value - } lappend tuple $attr $value } # Accumulate the tuples as a list to form the body that will be # inserted into the relvar. lappend body $tuple } # Insert the body into the relvar. namespace upvar [namespace current]\ DomainName DomainName\ DomainLoc DomainLoc set domns ${DomainLoc}::${DomainName} set relvar ${domns}::$class set insts [relvar insert $relvar {*}$body] # Now we have to deal with any state model that might be present. We have # to set up the initial state properly if such a thing exists for this # class. set idattrs [lindex [relvar identifiers $relvar] 0] relation foreach inst $insts { CreateInInitialState $domns $class [pipe { relation project $inst {*}$idattrs | relation tuple ~ | tuple get ~ }] } return [relation body $insts] } proc assigner {rname heading args} { # Determine if we have one big list or a bunch of values. set popvalues [expr {[llength $args] == 1 ? [lindex $args 0] : $args}] set headlen [llength $heading] if {[llength $popvalues] % $headlen != 0} { tailcall DeclError ARG_MISMATCH $headlen [llength $popvalues] } namespace upvar [namespace current]\ DomainName DomainName\ DomainLoc DomainLoc set domns ${DomainLoc}::${DomainName} set relvar ${domns}::${rname}__STATEINST set idattrs [lindex [relvar identifiers $relvar] 0] if {![struct::set equal $heading $idattrs]} { tailcall DeclError NO_IDENTIFIER $heading $idattrs } # Iterate over the attribute values taking them in chunks that are the same # size as the heading. for {set vindex 0} {$vindex < [llength $popvalues]} {incr vindex $headlen} { set values [lrange $popvalues $vindex [expr {$vindex + $headlen - 1}]] # Create a tuple as a list of attribute name / value pairs. We assume # the values are in the same order as the heading -- that is the point. set tuple [list] foreach attr $heading value $values { lappend tuple $attr $value } CreateInInitialState $domns $rname $tuple } return } } } namespace eval Info { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Helpers::DeclError proc domain {arglist} { set arglist [lassign $arglist subcmd domainname] set dominst [relvar restrictone ::rosea::Config::Domain Name $domainname] if {[relation isempty $dominst]} { tailcall DeclError UNKNOWN_DOMAIN $domainname } switch -exact -- $subcmd { classes { return [pipe { relvar set ::rosea::Config::Class | relation semijoin $dominst ~ -using {Name Domain} | relation list ~ Name }] } relationships { return [pipe { relvar set ::rosea::Config::Relationship | relation semijoin $dominst ~ -using {Name Domain} | relation list ~ Name }] } operations { return [FormatOpsInfo [pipe { relvar set ::rosea::Config::DomainOperation | relation semijoin $dominst ~ -using {Name Domain} | relation project ~ Name Parameters Body }]] } default { tailcall DeclError UNKNOWN_INFO_CMD $subcmd } } } proc FormatOpsInfo {ops} { set result [list] relation foreach op $ops { relation assign $op lappend result $Name $Parameters $Body } return $result } proc class {arglist} { set arglist [lassign $arglist subcmd domainname classname] set dominst [relvar restrictone ::rosea::Config::Domain Name $domainname] if {[relation isempty $dominst]} { tailcall DeclError UNKNOWN_DOMAIN $domainname } set classinst [pipe { relvar set ::rosea::Config::Class | relation semijoin $dominst ~ -using {Name Domain} | relation restrictwith ~ {$Name eq $classname} }] if {[relation isempty $classinst]} { tailcall DeclError UNKNOWN_CLASS $classname $domainname } switch -exact -- $subcmd { attributes { return [pipe { relvar set ::rosea::Config::Attribute | relation semijoin $classinst ~ -using {Domain Domain Name Class} | relation dict ~ Name Type }] } classops { return [FormatOpsInfo [pipe { relvar set ::rosea::Config::UserClassOperation | relation semijoin $classinst ~ -using {Domain Domain Name Class} | relation project ~ Name Parameters Body }]] } instops { return [FormatOpsInfo [pipe { relvar set ::rosea::Config::UserInstanceOperation | relation semijoin $classinst ~ -using {Domain Domain Name Class} | relation project ~ Name Parameters Body }]] } default { tailcall DeclError UNKNOWN_INFO_CMD $subcmd } } } proc statemodel {arglist} { set arglist [lassign $arglist subcmd domainname classname statename] set dominst [relvar restrictone ::rosea::Config::Domain Name $domainname] if {[relation isempty $dominst]} { tailcall DeclError UNKNOWN_DOMAIN $domainname } set domns [string cat [relation extract $dominst Location] :: $domainname] set classinst [pipe { relvar set ::rosea::Config::Class | relation semijoin $dominst ~ -using {Name Domain} | relation restrictwith ~ {$Name eq $classname} }] if {[relation isempty $classinst]} { tailcall DeclError UNKNOWN_CLASS $classname $domainname } switch -exact -- $subcmd { states { set states [pipe { relvar set ::rosea::Config::State | relation restrictwith ~\ {$Domain eq $domainname && $Model eq $classname} | relation project ~ Name Parameters Action }] set result [list] relation foreach state $states { relation assign $state lappend result $Name $Parameters $Action } return $result } events { return [pipe { relvar set ::rosea::Config::EffectiveEvent | relation restrictwith ~\ {$Domain eq $domainname && $Model eq $classname} | relation list ~ Event }] } transitions { return [pipe { relvar set ${domns}::__Arch_Transition | relation restrictwith ~ {$Class eq $classname} | relation eliminate ~ Class | relation group ~ Transition Event NewState | relation extend ~ trtup TranCol dict { [relation dict [tuple extract $trtup Transition] Event NewState]} | relation dict ~ State TranCol }] ; # <1> } activityproc { return ${domns}::${classname}::__Activity::${statename} } } } } namespace eval Trace { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path [list\ [namespace parent]::Helpers\ [namespace parent]::InstCmds\ ] relvar create Trace { Trace_Id int Timestamp bignum Source list Event string Target list Params list } Trace_Id relvar create Creation { Trace_Id int } Trace_Id relvar create Polymorphic { Trace_Id int SubInst string Linkage string } Trace_Id relvar create Transition { Trace_Id int CurrState string NewState string } Trace_Id relvar partition R1 Trace Trace_Id\ Creation Trace_Id\ Polymorphic Trace_Id\ Transition Trace_Id variable targetCmpFunc [lambda {instrefs target} { lassign $target trelvar tinst foreach instref $instrefs { lassign $instref crelvar cinst if {$trelvar eq $crelvar && [ral relation is $tinst subsetof $cinst]} { return true } } return false }] variable traceState off variable traceNumber 0 variable traceLogState off variable traceLogLevel info variable traceLogCmd [::logger::init rosea] proc QueryClassTraces {classes} { variable Trace return [relation restrictwith $Trace { [lindex $Target 0] in $classes ||\ [namespace tail [lindex $Target 0]] in $classes }] ; # <1> } proc QueryTargetTraces {targets} { variable Trace variable targetCmpFunc return [relation restrictwith $Trace {[{*}$targetCmpFunc $targets $Target]}] } proc TraceCreation {source event target params} { variable traceState if {$traceState} { relvar eval { set trace [NewTrace $source $event $target $params] relvar insert Creation [list\ Trace_Id [relation extract $trace Trace_Id]\ ] } LogTrace $trace } } proc TracePolymorphic {source event target sub link params} { variable traceState if {$traceState} { relvar eval { set trace [NewTrace $source $event $target $params] relvar insert Polymorphic [list\ Trace_Id [relation extract $trace Trace_Id]\ SubInst $sub\ Linkage $link\ ] } LogTrace $trace } } proc TraceTransition {source event target curr new params} { variable traceState if {$traceState} { relvar eval { set trace [NewTrace $source $event $target $params] relvar insert Transition [list\ Trace_Id [relation extract $trace Trace_Id]\ CurrState $curr\ NewState $new\ ] } LogTrace $trace } } proc NewTrace {src event target params} { variable traceNumber return [relvar insert Trace [list\ Trace_Id [incr traceNumber]\ Timestamp [clock microseconds]\ Source $src\ Event $event\ Target $target\ Params $params\ ]] } proc LogTrace {trace} { variable traceLogState if {$traceLogState} { set rec [FormatTraceRec [lindex [TracesToRecords $trace] 0]] ; # <1> variable traceLogCmd variable traceLogLevel ${traceLogCmd}::${traceLogLevel} $rec } } proc TracesToRecords {traces} { foreach rvname {Creation Polymorphic Transition} { # <1> set traces [::ralutil::rvajoin $traces [relvar set $rvname] $rvname] } set result [list] relation foreach trace $traces -ascending Trace_Id { # <2> relation assign $trace set labeled [dict create\ id $Trace_Id\ time $Timestamp\ source $Source\ event $Event\ target $Target\ params $Params\ class [lindex $Target 0]\ ] ; # <3> if {[relation isnotempty $Transition]} { # <4> relation assign $Transition dict set labeled type transition dict set labeled current $CurrState dict set labeled new $NewState } elseif {[relation isnotempty $Polymorphic]} { relation assign $Polymorphic dict set labeled type polymorphic dict set labeled sub $SubInst dict set labeled link $Linkage } elseif {[relation isnotempty $Creation]} { dict set labeled type creation } lappend result $labeled } return $result } proc DecodeAllTraces {} { variable Trace tailcall TracesToRecords $Trace } proc DecodeClassTraces {args} { return [TracesToRecords [QueryClassTraces $args]] } proc DecodeTargetTraces {args} { tailcall TracesToRecords [QueryTargetTraces $args] } proc FormatTraceRec {rec} { dict with rec { switch -exact -- $type { transition { append result\ "Transition: "\ [FormatTransition $source $event $params $target]\ " ==> $current -> $new" } polymorphic { append result\ "Polymorphic : "\ [FormatTransition $source $event $params $target]\ " ==> $link -> [FormatInstRef $sub]" } creation { append result\ "Creation: "\ "[FormatInstRef $source] - "\ "[FormatEvent $event $params] -> $class\ " ==> [FormatInstRef $target]" } default { DeclError BAD_TRACETYPE $type } } } return $result } proc FormatTransition {source event params target} { return "[FormatInstRef $source] - [FormatEvent $event $params] ->\ [FormatInstRef $target]" } proc FormatEvent {event params} { return [string cat\ $event\ [expr {[llength $params] != 0 ? "\([join $params {, }]\)" : {}}]\ ] } proc FormatInstRef {instref} { lassign $instref relvar inst if {$relvar eq {}} { return {{}} } else { return "$relvar\{[tuple get [relation tuple $inst]]\}" } } proc FormatTimestamp {time} { set sec [clock format [expr {$time / 1000000}] -format %T] ; # <1> set time [expr {$time % 1000000}] set msec [expr {$time / 1000}] set usec [expr {$time % 1000}] return [format %s.%03ld.%03ld $sec $msec $usec] } proc FormatTimeAsSec {time} { set sec [expr {$time / 1000000}] set time [expr {$time % 1000000}] set msec [expr {$time / 1000}] set usec [expr {$time % 1000}] return [format %3ld.%03ld.%03ld $sec $msec $usec] } proc DiagTraces {traces args} { set result {} append result "seqdiag \{\n" append result " activation = none;\n" foreach {option value} $args { append result " $option = $value;\n" } foreach rvname {Creation Polymorphic Transition} { set traces [::ralutil::rvajoin $traces [relvar set $rvname] $rvname] } relation foreach trace $traces -ascending Trace_Id { relation assign $trace if {[isEmptyRef $Source]} { set Source EXTERNAL } else { set Source [namespace tail [lindex $Source 0]] } set Target [namespace tail [lindex $Target 0]] set evtlabel [FormatEvent $Event $Params] if {[relation isnotempty $Polymorphic]} { relation assign $Transition Linkage append evtlabel " <<Polymorphic $Linkage>>" } elseif {[relation isnotempty $Creation]} { append evtlabel " <<Creation>>" } append result " $Source ->> $Target \[label=\"$evtlabel\"\];\n" } append result "\}\n" return $result } proc DiagAllTraces {filename args} { set chan [open $filename w] variable Trace try { chan puts $chan [DiagTraces $Trace {*}$args] } finally { chan close $chan } return } proc DiagClassTraces {filename classes args} { set chan [open $filename w] try { chan puts $chan [DiagTraces [QueryClassTraces $classes] {*}$args] } finally { chan close $chan } return } proc DiagTargetTraces {filename targets args} { set chan [open $filename w] try { chan puts $chan [DiagTraces [QueryTargetTraces $targets] {*}$args] } finally { chan close $chan } return } } namespace path ::rosea::Helpers namespace import ::rosea::Config::ConfigEvaluate } package provide rosea $::rosea::version |
< < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Added packages/package-rosea-1.9.1-tcl.tm.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 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 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 |
# ACTIVESTATE TEAPOT-PKG BEGIN TM -*- tcl -*- # -- Tcl Module # @@ Meta Begin # Package rosea 1.9.1 # Meta description Rosea is a data and execution architecture for # Meta description translating XUML models using Tcl as the implementation # Meta description language. # Meta platform tcl # Meta require {Tcl 8.6} # Meta require logger # Meta require ral # Meta require ralutil # Meta require struct::set # Meta require lambda # Meta summary Rosea -- XUML Software Architecture # @@ Meta End # ACTIVESTATE TEAPOT-PKG BEGIN REQUIREMENTS package require Tcl 8.6 package require logger package require ral package require ralutil package require struct::set package require lambda # ACTIVESTATE TEAPOT-PKG END REQUIREMENTS # ACTIVESTATE TEAPOT-PKG BEGIN DECLARE package provide rosea 1.9.1 # ACTIVESTATE TEAPOT-PKG END DECLARE # ACTIVESTATE TEAPOT-PKG END TM # DO NOT EDIT THIS FILE! # THIS FILE IS AUTOMATICALLY GENERATED FROM A LITERATE PROGRAM SOURCE FILE. # # This software is copyrighted 2014-2015 by G. Andrew Mangogna. # The following terms apply to all files associated with the software unless # explicitly disclaimed in individual files. # # The authors hereby grant permission to use, copy, modify, distribute, # and license this software and its documentation for any purpose, provided # that existing copyright notices are retained in all copies and that this # notice is included verbatim in any distributions. No written agreement, # license, or royalty fee is required for any of the authorized uses. # Modifications to this software may be copyrighted by their authors and # need not follow the licensing terms described here, provided that the # new terms are clearly indicated on the first page of each file where # they apply. # # IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING # OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES # THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE # IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE # NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, # OR MODIFICATIONS. # # GOVERNMENT USE: If you are acquiring this software on behalf of the # U.S. government, the Government shall have only "Restricted Rights" # in the software and related documentation as defined in the Federal # Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you # are acquiring the software on behalf of the Department of Defense, # the software shall be classified as "Commercial Computer Software" # and the Government shall have only "Restricted Rights" as defined in # Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, # the authors grant the U.S. Government and others acting in its behalf # permission to use and distribute the software in accordance with the # terms specified in this license. package require Tcl 8.6 package require logger package require ral package require ralutil package require struct::set package require lambda proc ::K {x y} {set x} namespace eval ::rosea { namespace export configure namespace export configureFromChan namespace export configureFromFile namespace export generate namespace export populate namespace export populateFromChan namespace export populateFromFile namespace export save namespace export restore namespace export info namespace export tunnel namespace export trace namespace ensemble create variable version 1.9.1 logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar pipe { relation semijoin $class $Attribute -using {Domain Domain Name Class} | relation project ~ Name Type | relation dict ~ Name Type } headingQuery pipe { relation semijoin $class $Identifier -using {Domain Domain Name Class}\ $IdentifyingAttribute | relation group ~ Attributes Attribute } idQuery pipe { relation semijoin $class $Attribute -using {Domain Domain Name Class} | relation join ~ $UserSuppliedValue -using {Domain Domain Class Class Name Attribute} } defaultValuesQuery pipe { relation semijoin $class $Attribute -using {Domain Domain Name Class} | relation join ~ $SystemSuppliedValue -using {Domain Domain Class Class Name Attribute} } suppliedValuesQuery pipe { relation semijoin $class $Attribute -using {Domain Domain Name Class} | relation join ~ $GeneratedValue -using {Domain Domain Class Class Name Attribute} } generatedValuesQuery pipe { relation semijoin $class $Attribute -using {Domain Domain Name Class} | relation join ~ $ValueCheck -using {Domain Domain Class Class Name Attribute} } checkValuesQuery pipe { relation semijoin $class $StateModel -using {Domain Domain Name Model} | relation isnotempty } hasSMQuery pipe { relation semijoin $class $State -using {Domain Domain Name Model} | relation project ~ Name Parameters Action } statesQuery pipe { relation join $AttributeReference $refing\ -using {Domain Domain ReferringClass Class\ Relationship Relationship ReferringRole Role} | relation rename ~ Conditionality ReferringCond\ Multiplicity ReferringMult | relation join ~ $refed -using {Domain Domain\ ReferencedClass Class Relationship\ Relationship ReferencedRole Role} | relation project ~ Domain Relationship\ ReferringClass ReferringAttribute\ ReferencedClass ReferencedAttribute\ ReferringCond ReferringMult Conditionality | relation group ~ ReferringAttrs\ ReferringAttribute ReferencedAttribute | relation extend ~ rfa\ TagReferringAttrs {Relation {RefOrder int ReferringAttribute string\ ReferencedAttribute string}} { [relation tag [tuple extract $rfa ReferringAttrs] RefOrder] } | relation extend ~ wfa\ SrcAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferringAttribute -ascending RefOrder] }\ DstAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferencedAttribute -ascending RefOrder] } | relation extend ~ ram\ ForwAttrs list { [Interleave [tuple extract $ram SrcAttrs]\ [tuple extract $ram DstAttrs]] }\ RevAttrs list { [Interleave [tuple extract $ram DstAttrs]\ [tuple extract $ram SrcAttrs]] } | relation eliminate ~ TagReferringAttrs } referencesQuery pipe { relation semijoin $cassocs $AssociatorClass\ -using {Domain Domain Name Relationship}\ $ReferringClass $AttributeReference\ -using {Domain Domain Class ReferringClass\ Relationship Relationship Role ReferringRole} | relation project ~ Domain Relationship ReferringClass ReferringAttribute\ ReferencedClass ReferencedAttribute ReferencedRole | relation join ~ $bothclass -using {Domain Domain Relationship Relationship\ ReferencedClass Class ReferencedRole Role} | relation group ~ ReferringAttrs ReferringAttribute ReferencedAttribute | relation extend ~ rfa\ TagReferringAttrs {Relation {RefOrder int ReferringAttribute string\ ReferencedAttribute string}} { [relation tag [tuple extract $rfa ReferringAttrs] RefOrder] } | relation extend ~ wfa\ SrcAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferringAttribute -ascending RefOrder] }\ DstAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferencedAttribute -ascending RefOrder] } | relation extend ~ ram\ ForwAttrs list { [Interleave [tuple extract $ram SrcAttrs]\ [tuple extract $ram DstAttrs]] }\ RevAttrs list { [Interleave [tuple extract $ram DstAttrs]\ [tuple extract $ram SrcAttrs]] } | relation eliminate ~ TagReferringAttrs } assocrefsQuery pipe { relation semijoin $rships $Generalization\ $Subclass -using {Domain Domain Name Relationship}\ $ReferringClass $AttributeReference\ -using {Domain Domain Class ReferringClass\ Relationship Relationship Role ReferringRole} | relation project ~ Domain Relationship ReferringClass ReferringAttribute\ ReferencedClass ReferencedAttribute | relation group ~ ReferringAttrs\ ReferringAttribute ReferencedAttribute | relation extend ~ rfa\ TagReferringAttrs {Relation {RefOrder int ReferringAttribute string\ ReferencedAttribute string}} { [relation tag [tuple extract $rfa ReferringAttrs] RefOrder] } | relation extend ~ wfa\ SrcAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferringAttribute -ascending RefOrder] }\ DstAttrs list { [relation list [tuple extract $wfa TagReferringAttrs]\ ReferencedAttribute -ascending RefOrder] } | relation extend ~ ram\ ForwAttrs list { [Interleave [tuple extract $ram SrcAttrs]\ [tuple extract $ram DstAttrs]] }\ RevAttrs list { [Interleave [tuple extract $ram DstAttrs]\ [tuple extract $ram SrcAttrs]] } | relation eliminate ~ TagReferringAttrs } subrefsQuery proc configure {script} { namespace upvar Config errcount errcount configlineno configlineno set errcount 0 set configlineno 1 ConfigEvaluate ::rosea::Config $script if {$errcount > 0} { tailcall DeclError CONFIG_ERRORS $errcount } return $errcount } proc configureFromChan {chan} { tailcall configure [::chan read -nonewline $chan] } proc configureFromFile {filename} { set f [::open $filename r] try { configureFromChan $f } finally { ::chan close $f } } proc generate {{pattern *} {prefix {}}} { if {$prefix ne {}} { if {[string range $prefix 0 1] ne "::"} { set prefix [uplevel 1 {namespace current}]::$prefix } set prefix [string trimright $prefix :] } elseif {$prefix eq "::"} { set prefix {} ; # <1> } namespace upvar Config\ Domain Domain\ DomainElement DomainElement\ Class Class\ Attribute Attribute\ DefaultValue DefaultValue\ UserSuppliedValue UserSuppliedValue\ SystemSuppliedValue SystemSuppliedValue\ GeneratedValue GeneratedValue\ ValueCheck ValueCheck\ Identifier Identifier\ IdentifyingAttribute IdentifyingAttribute\ Relationship Relationship\ Association Association\ SimpleAssociation SimpleAssociation\ SimpleReferringClass SimpleReferringClass\ SimpleReferencedClass SimpleReferencedClass\ ClassBasedAssociation ClassBasedAssociation\ AssociatorClass AssociatorClass\ SourceClass SourceClass\ TargetClass TargetClass\ Generalization Generalization\ Superclass Superclass\ Subclass Subclass\ AttributeReference AttributeReference\ ReferencedIdAttribute ReferencedIdAttribute\ ReferringClass ReferringClass\ ReferencedClass ReferencedClass\ DomainOperation DomainOperation\ SuppliedOperation SuppliedOperation\ UserClassOperation UserClassOperation\ SystemClassOperation SystemClassOperation\ UserInstanceOperation UserInstanceOperation\ SystemInstanceOperation SystemInstanceOperation\ InstanceStateModel InstanceStateModel\ StateModel StateModel\ StatePlace StatePlace\ State State\ EffectiveEvent EffectiveEvent\ DeferredEvent DeferredEvent\ TransitionPlace TransitionPlace\ StateTransition StateTransition\ NonStateTransition NonStateTransition\ AssignerStateModel AssignerStateModel\ SingleAssigner SingleAssigner\ MultipleAssigner MultipleAssigner\ PolymorphicEvent PolymorphicEvent set genDomain [relation restrict $Domain dom { [string match $pattern [tuple extract $dom Name]] }] relation foreach domain $genDomain { set domainName [relation extract $domain Name] relvar updateone Config::Domain dtup [list Name $domainName] { tuple update $dtup Location $prefix } set domns ${prefix}::$domainName namespace eval $domns { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe ral relvar create __Arch_RefLink { Relationship string ReferringClass string ReferencedClass string ReferringAttrs {Relation {ReferringAttribute string ReferencedAttribute string}} } Relationship ral relvar create __Arch_AssocRef { Relationship string AssocClass string References {Relation\ {Participant string Role string ReferringAttrs {Relation\ {ReferringAttribute string ReferencedAttribute string}}}} } Relationship ral relvar create __Arch_SuperLink { Relationship string SuperClass string } Relationship ral relvar create __Arch_SubLink { Relationship string SubClass string ReferringAttrs {Relation\ {ReferringAttribute string ReferencedAttribute string}} } {Relationship SubClass} ral relvar association __Arch_R5\ __Arch_SubLink Relationship +\ __Arch_SuperLink Relationship 1 ral relvar create __Arch_Link { Name string SrcClass string } {Name SrcClass} ral relvar create __Arch_AssociationLink { Name string SrcClass string DstClass string Attrs list PrevSrcClass string } {Name SrcClass} ral relvar association __Arch_R4\ __Arch_AssociationLink {Name PrevSrcClass} ?\ __Arch_AssociationLink {Name SrcClass} ? ral relvar create __Arch_PartitionLink { Name string SrcClass string } {Name SrcClass} ral relvar partition __Arch_R3 __Arch_Link {Name SrcClass}\ __Arch_AssociationLink {Name SrcClass}\ __Arch_PartitionLink {Name SrcClass} ral relvar create __Arch_PartitionDst { Name string SrcClass string DstClass string Attrs list } {Name SrcClass DstClass} ral relvar association __Arch_R2\ __Arch_PartitionDst {Name SrcClass} +\ __Arch_PartitionLink {Name SrcClass} 1 ral relvar create __Arch_State { Class string State string } {Class State} ral relvar create __Arch_Event { Class string Event string } {Class Event} ral relvar create __Arch_Transition { Class string State string Event string NewState string } {Class State Event} ral relvar correlation __Arch_R1 __Arch_Transition\ {Class State} + __Arch_State {Class State}\ {Class Event} + __Arch_Event {Class Event} ral relvar create __Arch_InitialState { Class string State string } Class ral relvar association __Arch_R6\ __Arch_InitialState {Class State} ?\ __Arch_State {Class State} 1 ral relvar create __Arch_TerminalState { Class string State string } {Class State} ral relvar association __Arch_R7\ __Arch_TerminalState {Class State} *\ __Arch_State {Class State} 1 ral relvar create __Arch_PolymorphicEvent { Class string Event string } {Class Event} } namespace eval $domns namespace path ::rosea::InstCmds set domops [relation semijoin $domain $DomainOperation -using {Name Domain}] relation foreach domop $domops { relation assign $domop\ {Name name} {Parameters parameters} {Body body} proc ${domns}::$name $parameters [list ::ral relvar eval $body] ; # <1> } namespace eval $domns [list\ namespace export {*}[relation list $domops Name]\ ] namespace eval $domns namespace ensemble create set statemodels [relation semijoin $domain $StateModel\ -using {Name Domain}] relvar eval { relvar set ${domns}::__Arch_InitialState [pipe { relation project $statemodels Model InitialState | relation rename ~ Model Class InitialState State }] set states [relation semijoin $domain $StatePlace -using {Name Domain}] relvar set ${domns}::__Arch_State [pipe { relation project $states Model Name | relation rename ~ Model Class Name State }] relvar set ${domns}::__Arch_TerminalState [pipe { relation semijoin $domain $State -using {Name Domain} | relation restrict ~ termtuple {[tuple extract $termtuple IsFinal]} | relation project ~ Model Name | relation rename ~ Model Class Name State }] set events [relation semijoin $domain $EffectiveEvent\ -using {Name Domain}] relvar set ${domns}::__Arch_Event [pipe { relation project $events Model Event | relation rename ~ Model Class }] set alltrans [pipe { relation join $states $events | relation rename ~ Name State }] ; # <1> set statetrans [relation semijoin $domain $StateTransition\ -using {Name Domain}] set nontrans [pipe { relation semijoin $domain $NonStateTransition -using {Name Domain} | relation rename ~ TransRule NewState }] set deftrans [pipe { relation minus $alltrans $TransitionPlace | relation join ~ $StateModel | relation eliminate ~ InitialState | relation rename ~ DefaultTrans NewState | relation update ~ dttup {[tuple extract $dttup State] eq "@"} { tuple update $dttup NewState CH} }] relvar set ${domns}::__Arch_Transition [pipe { relation union $statetrans $nontrans $deftrans | relation eliminate ~ Domain | relation rename ~ Model Class }] relvar set ${domns}::__Arch_PolymorphicEvent [pipe { relation semijoin $domain $DeferredEvent\ -using {Name Domain} | relation project ~ Model Event | relation rename ~ Model Class }] } variable headingQuery variable idQuery variable defaultValuesQuery variable suppliedValuesQuery variable generatedValuesQuery variable checkValuesQuery variable hasSMQuery variable statesQuery set classes [relation semijoin $domain $DomainElement -using {Name Domain}\ $Class -using {Domain Domain Element Name}] relation foreach class $classes { set className ${domns}::[relation extract $class Name] namespace eval $className { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe } namespace eval $className [list namespace path\ [list ::rosea::InstCmds $domns]] set heading [eval $headingQuery] set idset [list] relation foreach id [eval $idQuery] -ascending Number { lappend idset [relation list\ [relation extract $id Attributes] Attribute] } relvar create $className $heading {*}$idset # <1> set checkvalues [eval $checkValuesQuery] if {[relation isnotempty $checkvalues]} { relvar trace add variable $className {insert update set} [list\ ::rosea::Helpers::CheckValueTrace\ [relation dict $checkvalues Name Expression]\ ] } set defaultvalues [eval $defaultValuesQuery] if {[relation isnotempty $defaultvalues]} { relvar trace add variable $className insert [list\ ::rosea::Helpers::UserDefaultTrace\ [relation dict $defaultvalues Name Type]\ [relation dict $defaultvalues Name Value]\ ] } set supplied [eval $suppliedValuesQuery] if {[relation isnotempty $supplied]} { pipe { relation extend $supplied stup ClassName string { [string cat [tuple extract $stup Class] , [tuple extract $stup Name]] } | relation array ~ ${domns}::__Arch_SuppliedDefault ClassName StartValue } ; # <1> relvar trace add variable $className insert [list\ ::rosea::Helpers::SupplyDefaultTrace\ [relation dict $supplied Name Type]\ ] } set generatecmds [eval $generatedValuesQuery] if {[relation isnotempty $generatecmds]} { relvar trace add variable $className insert [list\ ::rosea::Helpers::GenerateDefaultTrace\ [relation dict $generatecmds Name Type]\ [relation dict $generatecmds Name Cmd]\ ] } set hasStateModel [eval $hasSMQuery] if {$hasStateModel} { set instid [lindex $idset 0] set instheading [list] foreach attr $instid { lappend instheading $attr [dict get $heading $attr] ; # <1> } lappend instheading __State string relvar create ${domns}::[relation extract $class Name]__STATEINST\ $instheading $instid set actns ${className}::__Activity namespace eval $actns { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe } namespace eval $actns [list\ namespace path [list\ ::rosea::InstCmds\ $className\ $domns\ ]\ ] relation foreach state [eval $statesQuery] { relation assign $state\ {Name stateName}\ {Parameters params}\ {Action stateAction} proc ${actns}::$stateName [linsert $params 0 self] $stateAction } } set opmap [dict create] set classops [relation semijoin $class $UserClassOperation\ -using {Domain Domain Name Class}] relation foreach classop $classops { relation assign $classop\ {Name opname}\ {Parameters params}\ {Body opbody} proc ${className}::$opname $params $opbody dict set opmap $opname ${className}::$opname } set sysmap [QuerySystemClassOperations $className false] if {$hasStateModel} { set sysmap [dict merge $sysmap [QuerySystemClassOperations $className true]] } namespace ensemble create\ -command $className\ -map [dict merge $opmap $sysmap] set opmap [dict create] set instops [relation semijoin $class $UserInstanceOperation\ -using {Domain Domain Name Class}] relation foreach instop $instops { relation assign $instop\ {Name opname}\ {Parameters params}\ {Body opbody} proc ${className}::$opname [linsert $params 0 self] $opbody dict set opmap $opname ${className}::$opname } set sysmap [QuerySystemInstanceOperations false] set hasPolyEvents [relation isnotempty\ [relation semijoin $class $PolymorphicEvent\ -using {Domain Domain Name Model}]\ ] if {$hasStateModel || $hasPolyEvents} { set sysmap [dict merge $sysmap [QuerySystemInstanceOperations true]] } namespace ensemble create\ -command ${className}::Instance\ -parameters instref\ -map [dict merge $opmap $sysmap] } set rships [relation semijoin $domain $DomainElement -using {Name Domain}\ $Relationship -using {Domain Domain Element Name}] set sassocs [relation semijoin $rships $Association\ $SimpleAssociation] set refing [relation semijoin $sassocs $SimpleReferringClass\ -using {Domain Domain Name Relationship}] set refed [relation semijoin $sassocs $SimpleReferencedClass\ -using {Domain Domain Name Relationship}] variable referencesQuery set references [eval $referencesQuery] relvar eval { set flink [pipe { relation project $references Relationship ReferringClass | relation rename ~ Relationship Name ReferringClass SrcClass }] set blink [pipe { relation project $references Relationship ReferencedClass | relation rename % Relationship Name ReferencedClass SrcClass | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] ; # <1> relvar union ${domns}::__Arch_Link $flink $blink set flink [pipe { relation project $references Relationship ReferringClass\ ReferencedClass ForwAttrs | relation rename ~ Relationship Name ReferringClass SrcClass\ ReferencedClass DstClass ForwAttrs Attrs | relation extend ~ al PrevSrcClass string {{}} }] ; # <1> set blink [pipe { relation project $references Relationship ReferringClass\ ReferencedClass RevAttrs | relation rename % Relationship Name ReferencedClass SrcClass\ ReferringClass DstClass RevAttrs Attrs | relation extend % al PrevSrcClass string {{}} | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] relvar union ${domns}::__Arch_AssociationLink $flink $blink relvar union ${domns}::__Arch_RefLink [relation project $references\ Relationship ReferringClass ReferencedClass ReferringAttrs] } relation foreach reference $references { relation assign $reference\ {Relationship relationship}\ {ReferringClass referringClass}\ {ReferencedClass referencedClass}\ {ReferringCond referringCond}\ {ReferringMult referringMult}\ {Conditionality referencedCond}\ {SrcAttrs srcAttrs}\ {DstAttrs dstAttrs} # Create the relvar constraint. relvar association ${domns}::$relationship\ ${domns}::$referringClass $srcAttrs\ [MapCondMultToConstraint $referringCond $referringMult]\ ${domns}::$referencedClass $dstAttrs\ [MapCondMultToConstraint $referencedCond false] # All simple associations get a link and unlink command in their ensemble. set ensemblemap [dict create\ link [list ::rosea::RelCmds::linkSimple $relationship]\ unlink [list ::rosea::RelCmds::unlinkSimple $relationship]\ ] # Determine if we have any assigners assocated with the relationship. # Single assigners get different commands from multiple assigners. set rpath ${domns}::$relationship set assigner [relation semijoin $reference $SingleAssigner\ -using {Domain Domain Relationship Relationship}] if {[relation isnotempty $assigner]} { dict set ensemblemap signal\ [list ::rosea::RelCmds::signalAssigner $rpath] } else { set assigner [relation semijoin $reference $MultipleAssigner\ -using {Domain Domain Relationship Relationship}] if {[relation isnotempty $assigner]} { dict set ensemblemap signal [list\ ::rosea::RelCmds::signalMultiAssigner $rpath] dict set ensemblemap create [list\ ::rosea::RelCmds::createMultiAssigner $rpath] } } # Create the relationship ensemble command. namespace ensemble create -command $rpath -map $ensemblemap } set cassocs [relation semijoin $rships $Association\ $ClassBasedAssociation] set sourceclass [relation semijoin $cassocs $SourceClass\ -using {Domain Domain Name Relationship}] set targetclass [relation semijoin $cassocs $TargetClass\ -using {Domain Domain Name Relationship}] set bothclass [relation union $sourceclass $targetclass] ; # <1> variable assocrefsQuery set assocrefs [eval $assocrefsQuery] relvar eval { set aforw [pipe { relation project $assocrefs Relationship ReferringClass | relation rename ~ Relationship Name ReferringClass SrcClass }] set arev [relation update $aforw lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]}] set sources [pipe { relation restrict $assocrefs aref { [tuple extract $aref ReferencedRole] eq "source"} | relation eliminate ~ ReferencedRole }] set sforw [pipe { relation project $sources Relationship ReferencedClass | relation rename ~ Relationship Name ReferencedClass SrcClass }] set targets [pipe { relation restrict $assocrefs aref { [tuple extract $aref ReferencedRole] eq "target"} | relation eliminate ~ ReferencedRole }] set trev [pipe { relation project $targets Relationship ReferencedClass | relation rename % Relationship Name ReferencedClass SrcClass | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] relvar union ${domns}::__Arch_Link $aforw $arev $sforw $trev set sforw [pipe { relation project $sources Relationship ReferringClass ReferencedClass\ RevAttrs | relation rename ~ Relationship Name ReferringClass DstClass\ ReferencedClass SrcClass RevAttrs Attrs | relation extend ~ al PrevSrcClass string {{}} }] set trev [pipe { relation project $targets Relationship ReferringClass ReferencedClass\ RevAttrs | relation rename % Relationship Name ReferringClass DstClass\ ReferencedClass SrcClass RevAttrs Attrs | relation extend % al PrevSrcClass string {{}} | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] set onerefs [relation rename $sources ReferencedClass OneClass\ Conditionality OneCond Multiplicity OneMult\ ReferringAttrs OneReferringAttrs SrcAttrs OneSrcAttrs\ DstAttrs OneDstAttrs ForwAttrs OneForwAttrs RevAttrs OneRevAttrs] set otherrefs [relation rename $targets ReferencedClass OtherClass\ Conditionality OtherCond Multiplicity OtherMult ReferringAttrs\ OtherReferringAttrs SrcAttrs OtherSrcAttrs DstAttrs OtherDstAttrs\ ForwAttrs OtherForwAttrs RevAttrs OtherRevAttrs] set bothrefs [relation join $onerefs $otherrefs\ -using {Domain Domain ReferringClass ReferringClass\ Relationship Relationship}] set aforw [pipe { relation project $bothrefs Relationship ReferringClass OtherClass\ OtherForwAttrs OneClass | relation rename ~ Relationship Name ReferringClass SrcClass\ OtherClass DstClass OtherForwAttrs Attrs OneClass PrevSrcClass }] set arev [pipe { relation project $bothrefs Relationship ReferringClass OneClass\ OneForwAttrs OtherClass | relation rename % Relationship Name ReferringClass SrcClass\ OneClass DstClass OneForwAttrs Attrs OtherClass PrevSrcClass | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] relvar union ${domns}::__Arch_AssociationLink $sforw $trev $aforw $arev relvar union ${domns}::__Arch_AssocRef [pipe { relation project $assocrefs Relationship ReferringClass\ ReferencedClass ReferencedRole ReferringAttrs | relation rename ~ ReferringClass AssocClass ReferencedClass Participant\ ReferencedRole Role | relation group ~ References Participant Role ReferringAttrs }] } relation foreach bothref $bothrefs { relation assign $bothref\ {Relationship relationship}\ {ReferringClass associator}\ {OneClass sourceClass}\ {OneCond sourceCond}\ {OneMult sourceMult}\ {OneSrcAttrs sourceAssocAttrs}\ {OneDstAttrs sourceDstAttrs}\ {OtherClass targetClass}\ {OtherCond targetCond}\ {OtherMult targetMult}\ {OtherSrcAttrs targetAssocAttrs}\ {OtherDstAttrs targetDstAttrs} # Create the correlation constraint relvar correlation ${domns}::$relationship ${domns}::$associator\ $sourceAssocAttrs [MapCondMultToConstraint $targetCond $targetMult]\ ${domns}::$sourceClass $sourceDstAttrs\ $targetAssocAttrs [MapCondMultToConstraint $sourceCond $sourceMult]\ ${domns}::$targetClass $targetDstAttrs ; # <1> set ensemblemap [dict create\ link [list ::rosea::RelCmds::linkAssoc $relationship]\ reference [list ::rosea::RelCmds::referenceAssoc $relationship]\ unlink [list ::rosea::RelCmds::unlinkAssoc $relationship]\ ] # Determine if we have any assigners set rpath ${domns}::$relationship set assigner [relation semijoin $bothref $SingleAssigner\ -using {Domain Domain Relationship Relationship}] if {[relation isnotempty $assigner]} { dict set ensemblemap signal\ [list ::rosea::RelCmds::signalAssigner $rpath] } else { set assigner [relation semijoin $bothref $MultipleAssigner\ -using {Domain Domain Relationship Relationship}] if {[relation isnotempty $assigner]} { dict set ensemblemap signal [list\ ::rosea::RelCmds::signalMultiAssigner $rpath] dict set ensemblemap create [list\ ::rosea::RelCmds::createMultiAssigner $rpath] } } namespace ensemble create -command $rpath -map $ensemblemap } variable subrefsQuery set subrefs [eval $subrefsQuery] relvar eval { set sublinks [pipe { relation project $subrefs Relationship ReferringClass | relation rename ~ Relationship Name ReferringClass SrcClass }] set superlinks [pipe { relation project $subrefs Relationship ReferencedClass | relation rename % Relationship Name ReferencedClass SrcClass | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] relvar union ${domns}::__Arch_Link $sublinks $superlinks relvar union ${domns}::__Arch_AssociationLink [pipe { relation project $subrefs Relationship ReferringClass ReferencedClass\ ForwAttrs | relation rename ~ Relationship Name ReferringClass SrcClass\ ReferencedClass DstClass ForwAttrs Attrs | relation extend ~ al PrevSrcClass string {{}} }] relvar union ${domns}::__Arch_PartitionLink $superlinks relvar union ${domns}::__Arch_PartitionDst [pipe { relation project $subrefs Relationship ReferencedClass\ ReferringClass RevAttrs | relation rename % Relationship Name ReferencedClass SrcClass\ ReferringClass DstClass RevAttrs Attrs | relation update % lnk {1} { tuple update $lnk Name ~[tuple extract $lnk Name]} } {} |%] relvar union ${domns}::__Arch_SuperLink [pipe { relation project $subrefs Relationship ReferencedClass | relation rename ~ ReferencedClass SuperClass }] relvar union ${domns}::__Arch_SubLink [pipe { relation project $subrefs Relationship ReferringClass ReferringAttrs | relation rename ~ ReferringClass SubClass }] } set partrefs [pipe { relation project $subrefs Relationship ReferencedClass DstAttrs\ ReferringClass SrcAttrs | relation extend ~ prs SubAttrMap list {[list\ ${domns}::[tuple extract $prs ReferringClass]\ [tuple extract $prs SrcAttrs]]} | relation eliminate ~ ReferringClass SrcAttrs | relation group ~ SubClassRefs SubAttrMap | relation extend ~ spt SubParts list { [concat {*}[relation list [tuple extract $spt SubClassRefs]]]} | relation eliminate ~ SubClassRefs }] relation foreach partref $partrefs { relation assign $partref\ {Relationship relationship}\ {ReferencedClass superclass}\ {DstAttrs superattrs}\ {SubParts subparts} relvar partition ${domns}::$relationship ${domns}::$superclass\ $superattrs {*}$subparts namespace ensemble create\ -command ${domns}::$relationship\ -map [dict create migrate [list ::rosea::RelCmds::migrate\ $relationship]] } set assigners [relation semijoin $domain $AssignerStateModel\ -using {Name Domain}] relation foreach assigner $assigners { set asgnns\ ${domns}::[relation extract $assigner Relationship]::__Activity namespace eval $asgnns { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe } namespace eval $asgnns [list\ namespace path [list\ ::rosea::InstCmds\ $domns\ ]\ ] set states [pipe { relation semijoin $assigner $State\ -using {Domain Domain Relationship Model} | relation project ~ Name Parameters Action }] relation foreach state $states { relation assign $state\ {Name stateName}\ {Parameters params}\ {Action stateAction} set params [linsert $params 0 self] proc ${asgnns}::$stateName $params $stateAction } } relation foreach sassigner\ [relation semijoin $domain $SingleAssigner\ -using {Name Domain}] { relation assign $sassigner {Relationship relationship} relvar create ${domns}::${relationship}__STATEINST { Id int __State string } Id CreateInInitialState $domns $relationship {Id 0} ; # <1> } relation foreach massigner\ [relation semijoin $domain $MultipleAssigner\ -using {Name Domain}] { relation assign $massigner {Relationship relationship} set assignvar ${domns}::${relationship}__STATEINST set idattrs [pipe { relation semijoin $massigner $Identifier\ $IdentifyingAttribute\ $Attribute -using {Domain Domain Class Class\ Attribute Name} | relation dict ~ Name Type }] relvar create $assignvar\ [concat $idattrs [list __State string]]\ [dict keys $idattrs] } } } proc populate {script} { namespace upvar Config errcount errcount configlineno configlineno set errcount 0 set configlineno 1 ConfigEvaluate ::rosea::Populate $script ; # <1> if {$errcount > 0} { tailcall DeclError CONFIG_ERRORS $errcount } return $errcount } proc populateFromChan {chan} { tailcall populate [::chan read -nonewline $chan] } proc populateFromFile {filename} { set f [::open $filename r] try { populateFromChan $f } finally { ::chan close $f } } proc save {args} { set savecmd ::ral::serializeToFile set asynccmd {} set options $args while {1} { if {[string index [lindex $options 0] 0] eq "-"} { set options [lassign $options option] switch -exact -- $option { -sqlite { set savecmd ::ral::storeToSQLite } -tclral { set savecmd ::ral::serializeToFile } -async { set options [lassign $options asynccmd] } default { tailcall DeclError UNKNOWN_OPTION save $option } } } else { break } } if {[llength $options] == 2} { lassign $options domain file if {[string range $domain 0 1] ne "::"} { # <1> set domrel [relvar restrictone ::rosea::Config::Domain Name $domain] if {[relation isempty $domrel]} { tailcall DeclError UNKNOWN_DOMAIN $domain } set domain [string cat [relation extract $domrel Location]\ :: $domain] } } else { tailcall DeclError SAVE_ARG_ERROR $args } set script "try \{$savecmd $file ${domain}::\\\[A-Za-z0-9\\\]*\}" ; # <2> if {$asynccmd ne {}} { append script " finally \{$asynccmd $domain $file\}" } after idle [list ::apply [list {} $script]] ; # <3> } proc restore {args} { set restorecmd ::ral::mergeFromFile set options $args while {1} { if {[string index [lindex $options 0] 0] eq "-"} { set options [lassign $options option] switch -exact -- $option { -sqlite { set restorecmd ::ral::mergeFromSQLite } -tclral { set restorecmd ::ral::mergeFromFile } default { tailcall DeclError UNKNOWN_OPTION restore $option } } } else { break } } if {[llength $options] == 2} { lassign $options domain file if {[string range $domain 0 1] ne "::"} { set domrel [relvar restrictone ::rosea::Config::Domain Name $domain] if {[relation isempty $domrel]} { tailcall DeclError UNKNOWN_DOMAIN $domain } set domain [string cat [relation extract $domrel Location]\ :: $domain] } } else { tailcall DeclError RESTORE_ARG_ERROR $args } eval [list $restorecmd $file $domain] # Determine the values for the system supplied defaults. We examine all # the classes that have such attributes and find the maximum value of the # attribute. This can then be placed in the array that is used when new # default values are generated. set domainname [namespace tail $domain] set supplied [pipe { relvar set ::rosea::Config::SystemSuppliedValue | relation restrictwith ~ {$Domain eq $domainname} }] relation foreach sup $supplied { relation assign $sup set classtups [relvar set ${domain}::$Class] if {[relation isempty $classtups]} { set maxvalue $StartValue } else { set maxvalue [pipe { relation summarizeby $classtups {} cv\ MaxValue int {rmax($cv, $Attribute)} | relation extract ~ MaxValue }] } set ${domain}::__Arch_SuppliedDefault($Class,$Attribute)\ [expr {$maxvalue + 1}] } return } proc info {args} { set args [lassign $args subcmd] switch -exact -- $subcmd { domain { Info::domain $args } class { Info::class $args } statemodel { Info::statemodel $args } default { tailcall DeclError UNKNOWN_INFO_CMD $subcmd } } } proc tunnel {instref op args} { relvar eval { set result [[lindex $instref 0]::Instance $instref $op {*}$args] } return $result } proc trace {subcmd args} { switch -exact -- $subcmd { control { tailcall traceControl {*}$args } decode { switch -exact -- [lindex $args 0] { all { tailcall Trace::DecodeAllTraces } class { tailcall Trace::DecodeClassTraces {*}[lrange $args 1 end] } target { tailcall Trace::DecodeTargetTraces {*}[lrange $args 1 end] } default { tailcall DeclError UNKNOWN_TRACE_CMD [lindex $args 0] } } } format { tailcall formatTraces {*}$args } diagram { switch -exact -- [lindex $args 0] { all { tailcall Trace::DiagAllTraces {*}[lrange $args 1 end] } class { tailcall Trace::DiagClassTraces {*}[lrange $args 1 end] } target { tailcall Trace::DiagTargetTraces {*}[lrange $args 1 end] } default { tailcall DeclError UNKNOWN_TRACE_CMD [lindex $args 0] } } } default { tailcall DeclError UNKNOWN_TRACE_CMD $subcmd } } } proc traceControl {op args} { switch -exact -- $op { on { namespace upvar Trace traceState traceState set traceState on } off { namespace upvar Trace traceState traceState set traceState off } status { namespace upvar Trace traceState traceState return $traceState } clear { relvar eval { foreach rvar {Trace Creation Polymorphic Transition} { relvar set Trace::$rvar\ [relation emptyof [relvar set Trace::$rvar]] } } namespace upvar Trace traceNumber traceNumber set traceNumber 0 } logon { namespace upvar Trace traceLogState traceLogState set traceLogState on } logoff { namespace upvar Trace traceLogState traceLogState set traceLogState off } loglevel { namespace upvar Trace traceLogLevel traceLogLevel if {[llength $args] != 0} { set traceLogLevel [lindex $args 0] } return $traceLogLevel } save { if {[llength $args] == 0} { DeclError NO_SAVEFILE } ral storeToSQLite [lindex $args 0] ::rosea::Trace::* } default { DeclError BAD_TRACEOP $op } } } proc formatTraces {tracerecs} { if {[llength $tracerecs] == 0} { return {} } set prevtime [dict get [lindex $tracerecs 0] time] foreach rec $tracerecs { dict with rec { append result "[Trace::FormatTimestamp $time]: " append result "[Trace::FormatTimeAsSec\ [expr {$time - $prevtime}]]: " set prevtime $time append result [Trace::FormatTraceRec $rec] \n } } return [string trimright $result] } namespace eval Helpers { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar variable errFormats set errFormats [dict create {*}{ SAME_CLASS {operation is only allowed for references to the same class,\ got "%s" and "%s"} UNKNOWN_STATE {unknown state, "%s", for class, "%s"} UNKNOWN_EVENT {unknown event, "%s", for class, "%s"} NO_CREATION_EVENTS {class, "%s", has no defined creation events} NO_CROSS_DOMAIN {cannot link instances across domains,\ got "%s" and "%s"} UNKNOWN_RELATIONSHIP {unknown relationship, "%s"} NON_PARTICIPANTS {"%s" and "%s" don't participate in %s,\ expected "%s" and "%s"} MUST_BE_SINGULAR {number of referred to instances for "%s" must be one,\ got %d} NOT_IN_ASSOCIATION {"%s" $relvar1 not a participant in "%s"} DIRECTION_REQUIRED {direction argument is required: got "%s"} AMBIGUOUS_UNLINK {"%s" is reflexive and linking via "%s" is ambiguous} NO_SUBCLASS {relationship "%s" does not have a "%s"} NO_ASSIGNER {relationship, "%s", does not have an assigner} NO_IDENTIFIER {bad identifying attributes, expected "%s", got "%s"} UNKNOWN_ASSIGNER {unknown assigner instance, "%s", for relationship, "%s"} UNKNOWN_LINKAGE {unknown relationship, "%s", for class, "%s"} PATH_ERROR {relationship, "%s", from "%s" to "%s", does not end at "%s"} GEN_PATH_ERROR {navigating from superclass, "%s", along generalization "%s",\ does not have "%s" as a subclass} ARG_ERROR {attribute updates must be name / value pairs, got "%s"} ID_UPDATE {cannot update identifying attributes, "%s"} UNKNOWN_ATTRIBUTE {unknown attribute, "%s"} WITH_ATTR_USAGE {wrong arguments, should be,\ "withAttribute attrvarpair1 ?attrvarpair2 ...? body"} ATTR_VAR_SPEC {attribute / variable argument must be a one or two element\ list, got "%s"} INVALID_TIME {invalid time value, "%s"} SINGLE_OR_EMPTY_REF_REQUIRED {single valued or nil reference required, %d found} SINGLE_REF_REQUIRED {single valued reference required, %d found} ASYNC_CREATION_FAILED {asynchronous creation of an instance of class, "%s",\ with attributes, "%s", failed: %s} EVENT_IN_FLIGHT {event, "%s", sent to "%s", which does not exist} CANT_HAPPEN_EVENT {can't happen transition, %s - %s -> %s ==> %s -> CH} CONFIG_ERRORS {encountered %d configuration script errors} EMPTY_NAME {the empty string is not a valid name for a %s} BAD_CLASS_NAME {class names must be begin with an alphanumeric\ character, got: "%s"} DUP_ELEMENT_NAME {a class, relationship or domain operation named, "%s",\ already exists} RESERVED_NAME {names beginning with two underscore characters are reserved,\ "%s" cannot be used as a name in this context} INT_TYPE_REQUIRED {attribute must be of "int" type, got "%s"} INT_VALUE_REQUIRED {an integer value is required, got "%s"} ARG_FORMAT {options and values must come in pairs, got "%s"} UNKNOWN_OPTION {unknown %s command option, "%s"} DUP_OP_NAME {operation call, "%s", already exists} NS_QUALIFIERS {name, "%s", contains namespace qualifiers} TILDE_NAME {names beginning with the tilde character are not allowed\ in this context, "%s"} BAD_RELATIONSHIP_SPEC {bad relationship specifier, "%s"} NEED_ASSOCIATOR {relationship of type, "%s", requires associative class} NEED_REFLEXIVE_PATH {traversal path must be specified for reflexive\ association, %s, %s %s %s} REFLEXIVE_NOT_ALLOWED {associations of type, "%s", cannot be reflexive} TOO_FEW_SUBCLASSES {at least 2 subclasses must be specified, got %d} BAD_CREATION_TARGET {the target of a creation event must be a state,\ got "%s"} PSEUDO_STATE {the transition action, "%s", is not valid as %s} EXPECTED_PSEUDO_STATE {expected CH or IG, got "%s"} RELVAR_TRACE_OP {unexpected relvar trace operation, "%s"} ATTR_CHECK_FAILED {check for attribute, "%s", failed:\ instance value was, "%s": "%s" evaluated to "%s"} UNKNOWN_DOMAIN {unknown domain, "%s"} ARG_MISMATCH {number of population values must be a multiple of %d, got %d} SAVE_ARG_ERROR {wrong number of arguments: expected:\ "save ?-sqlite | -tclral? ?-async <cmdprefix>?\ <domain> <filename>", got: "%s"} RESTORE_ARG_ERROR {wrong number of arguments: expected:\ "restore ?-sqlite | -tclral? <domain> <filename>", got: "%s"} UNKNOWN_INFO_CMD {unknown info request, "%s"} UNKNOWN_CLASS {unknown class, "%s", in domain, "%s"} UNKNOWN_TRACE_CMD {unknown trace subcomand, "%s"} BAD_TRACEOP {unknown trace operation, "%s"} NO_SAVEFILE {no save file name provided} BAD_TRACETYPE {unknown trace type, "%s"} }] proc ToRef {relvar relvalue} { tailcall list $relvar [relation project $relvalue\ {*}[lindex [relvar identifiers $relvar] 0]] ; # <1> } proc nilInstRef {} { return {{} {{} {}}} } proc CreateStateInstance {domns class state idattrs} { tailcall relvar insert ${domns}::${class}__STATEINST\ [concat $idattrs [list __State $state]] } proc CreateInInitialState {domns class idattrs} { set initstate [relvar restrictone ${domns}::__Arch_InitialState\ Class $class] if {[relation isnotempty $initstate]} { CreateStateInstance $domns $class [relation extract $initstate State]\ $idattrs } return } proc CreateStateInstanceFromRef {domns class state ref} { relation foreach inst [lindex $ref 1] { # <1> CreateStateInstance $domns $class $state\ [tuple get [relation tuple $inst]] } return } proc CreateInInitialStateFromRef {domns class ref} { set initstate [relvar restrictone ${domns}::__Arch_InitialState\ Class $class] if {[relation isnotempty $initstate]} { CreateStateInstanceFromRef $domns $class\ [relation extract $initstate State] $ref } return } proc SelfInstRef {{level 2}} { set foundRef false set ref [nilInstRef] for {set ns [uplevel $level namespace current]} {$ns ne "::"}\ {set ns [uplevel [incr level] namespace current]} { if {!$foundRef} { upvar $level self srcself if {[info exists srcself]} { set ref $srcself set foundRef true } } if {[string match {*__Activity*} $ns]} { return $ref ; # <1> } } return [nilInstRef] } namespace export DeclError proc DeclError {errcode args} { variable errFormats set errmsg [format [dict get $errFormats $errcode] {*}$args] tailcall throw [list ROSEA $errcode {*}$args $errmsg] $errmsg } proc SplitRelvarName {relvar {dvarname domain} {cvarname class}} { upvar 1 $dvarname domain $cvarname class set domain [namespace qualifiers $relvar] set class [namespace tail $relvar] } proc PropagatePolyEvents {super} { namespace upvar ::rosea::Config\ DeferredEvent DeferredEvent\ LocalEvent LocalEvent\ Superclass Superclass\ Subclass Subclass\ DeferralPath DeferralPath\ Generalization Generalization ; # <1> set supername [relation extract $super Class] set subs [pipe { relation semijoin $super\ $Generalization -using {Domain Domain Relationship Name}\ $Subclass -using {Domain Domain Name Relationship} }] relation foreach sub $subs { set defrdevents [pipe { relation semijoin $super $DeferralPath\ -using {Domain Domain Class Model Relationship Relationship}\ $DeferredEvent | relation update ~ deftup {1} { tuple update $deftup Model [relation extract $sub Class] } }] set multigens [relation semijoin $sub $Superclass\ -using {Domain Domain Class Class}] if {[relation isempty $multigens]} { relvar minus ::rosea::Config::LocalEvent $defrdevents relvar union ::rosea::Config::Event $defrdevents relvar union ::rosea::Config::EffectiveEvent $defrdevents relvar union ::rosea::Config::MappedEvent [relation extend\ $defrdevents metuple ParentModel string {$supername}] } else { set consumed [relation semijoin $defrdevents $LocalEvent] if {[relation isnotempty $consumed]} { relvar minus ::rosea::Config::LocalEvent $consumed ; # <1> relvar union ::rosea::Config::MappedEvent [relation extend\ $consumed ctup ParentModel string {$supername}] relvar union ::rosea::Config::NonLocalEvent [relation extend\ $consumed nletuple\ Relationship string {[relation extract $sub Relationship]}\ Role string {[relation extract $sub Role]}] set defrdevents [relation minus $defrdevents $consumed] ; # <2> set usedinsubs [pipe { FindSubclassesOf $multigens| relation tclose ~ | relation semijoin $consumed ~ -using {Model Super} | relation semijoin ~ $LocalEvent -using {Sub Model} | relation semijoin $consumed ~ -using {Domain Domain Event Event} }] relvar minus ::rosea::Config::LocalEvent $usedinsubs ; # <3> relvar minus ::rosea::Config::EffectiveEvent $usedinsubs relvar minus ::rosea::Config::Event $usedinsubs } relvar union ::rosea::Config::Event $defrdevents relvar union ::rosea::Config::DeferredEvent $defrdevents relvar union ::rosea::Config::InheritedEvent $defrdevents relvar union ::rosea::Config::DeferralPath [relation join\ $defrdevents $Superclass -using {Domain Domain Model Class}] } relvar union ::rosea::Config::NonLocalEvent [relation extend\ $defrdevents nletuple\ Relationship string {[relation extract $sub Relationship]}\ Role string {[relation extract $sub Role]}] relation foreach multigen $multigens { PropagatePolyEvents $multigen } } } proc FindSubclassesOf {supers} { namespace upvar ::rosea::Config\ Generalization Generalization\ Superclass Superclass\ Subclass Subclass if {[relation isempty $supers]} {# <1> return [relation create {Super string Sub string}] } set supnames [pipe { relation project $supers Class | relation rename ~ Class Super }] ; # <2> set subclasses [relation semijoin $supers\ $Generalization -using {Domain Domain Relationship Name}\ $Subclass -using {Domain Domain Name Relationship}] set subnames [pipe { relation project $subclasses Class | relation rename ~ Class Sub }] ; # <3> set uses [relation times $supnames $subnames] ; # <4> set nextsupers [relation semijoin $subclasses $Superclass\ -using {Domain Domain Class Class}] ; # <5> return [relation union $uses [FindSubclassesOf $nextsupers]] ; # <6> } proc UserDefaultTrace {defheading defvalues op relvar tuple} { tuple create\ [dict merge $defheading [tuple heading $tuple]]\ [dict merge $defvalues [tuple get $tuple]] } proc SupplyDefaultTrace {defheading op relvar tuple} { set attrs [tuple attributes $tuple] ; # <1> SplitRelvarName $relvar domain class ; # <2> foreach {attrname attrtype} $defheading { if {$attrname ni $attrs} { set value [set ${domain}::__Arch_SuppliedDefault($class,$attrname)] ; # <3> incr ${domain}::__Arch_SuppliedDefault($class,$attrname) set tuple [tuple extend $tuple $attrname $attrtype $value] ; # <4> } } return $tuple } proc GenerateDefaultTrace {defheading defcmds op relvar tuple} { set attrs [tuple attributes $tuple] foreach {attrname attrtype} $defheading { if {$attrname ni $attrs} { set value [eval [dict get $defcmds $attrname]] set tuple [tuple extend $tuple $attrname $attrtype $value] } } return $tuple } proc CheckValueTrace {attrchecks op relvar args} { if {$op eq "insert"} { set tuple [lindex $args 0] EvalAttrCheck $attrchecks $tuple return $tuple } elseif {$op eq "update"} { set tuple [lindex $args 1] EvalAttrCheck $attrchecks $tuple return $tuple } elseif {$op eq "set"} { set relvalue [lindex $args 0] relation foreach inst $relvalue { set tuple [relation tuple $inst] EvalAttrCheck $attrchecks $tuple } return $relvalue } else { tailcall DeclError RELVAR_TRACE_OP $op } } proc EvalAttrCheck {attrchecks tuple} { dict for {attrname checkexpr} $attrchecks { tuple assign $tuple set result [expr $checkexpr] if {!$result} { tailcall DeclError ATTR_CHECK_FAILED $attrname [tuple get $tuple]\ $checkexpr $result } } } proc QuerySystemOperations {which requiresSM} { return [pipe { relvar set ::rosea::Config::SuppliedOperation | relation restrictwith ~ {$RequiresStateModel == $requiresSM} | relation join [relvar set ::rosea::Config::$which] ~ }] } proc QuerySystemClassOperations {className requiresSM} { return [pipe { QuerySystemOperations SystemClassOperation $requiresSM | relation update ~ sco 1 { tuple update $sco Command\ [concat [tuple extract $sco Command]\ [list $className]] } | relation dict ~ Name Command }] } proc QuerySystemInstanceOperations {requiresSM} { return [pipe { QuerySystemOperations SystemInstanceOperation $requiresSM | relation dict ~ Name Command }] } proc Interleave {l1 l2} { set result [list] foreach a $l1 b $l2 { lappend result $a $b } return $result } proc MapCondMultToConstraint {cond mult} { if {$cond} { return [expr {$mult ? "*" : "?"}] } else { return [expr {$mult ? "+" : "1"}] } } } namespace eval ClassCmds { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path [namespace parent]::Helpers ; # <1> proc findAll {relvar} { tailcall ToRef $relvar [relvar set $relvar] } proc findById {relvar args} { tailcall ToRef $relvar [relvar restrictone $relvar {*}$args] } proc findWhere {relvar expr} { tailcall ToRef $relvar [uplevel 1 [list ::ral relation restrictwith\ [relvar set $relvar] $expr]] } proc create {relvar args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } set ref [ToRef $relvar [relvar insert $relvar $args]] ; # <1> SplitRelvarName $relvar domain class CreateInInitialStateFromRef $domain $class $ref return $ref } proc createin {relvar state args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } SplitRelvarName $relvar domain class set initstate [relvar restrictone ${domain}::__Arch_State\ Class $class State $state] if {[relation isempty $initstate]} { # <1> tailcall DeclError UNKNOWN_STATE $state $relvar } set ref [ToRef $relvar [relvar insert $relvar $args]] CreateStateInstanceFromRef $domain $class $state $ref return $ref } proc createasync {relvar event eventparams args} { SplitRelvarName $relvar domain class if {[relation isempty [relvar restrictone ${domain}::__Arch_Event\ Class $class Event $event]]} { tailcall DeclError UNKNOWN_EVENT $event $class } if {[relation isempty [relvar restrictone ${domain}::__Arch_State\ Class $class State @]]} { tailcall DeclError NO_CREATION_EVENTS $class } set srcref [SelfInstRef] set eventInfo [dict create\ type creation\ src $srcref\ dstClass $relvar\ dstAttrs $args\ event $event\ params $eventparams\ ] if {[::rosea::InstCmds::isRefEqual $srcref [nilInstRef]]} { lappend ::rosea::Dispatch::toc_queue $eventInfo } else { lappend ::rosea::Dispatch::event_queue $eventInfo } ::after 0 ::rosea::Dispatch::DispatchEvent return } proc update {relvar relvalue} { tailcall ToRef $relvar [relvar updateper $relvar $relvalue] } } namespace eval InstCmds { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace path [namespace parent]::Helpers pipe { relvar set ${domain}::$DstClass | relation $op $related ~ -using $Attrs } relatedQuery proc deRef {instref args} { lassign $instref relvar ref set inst [relation semijoin $ref [relvar set $relvar]] ; # <1> if {[llength $args] != 0} { set inst [relation project $inst\ {*}[relation attributes $ref] {*}$args] ; # <2> } return $inst } proc isEmptyRef {instref} { tailcall relation isempty [lindex $instref 1] } proc isNotEmptyRef {instref} { tailcall relation isnotempty [lindex $instref 1] } proc refMultiplicity {instref} { tailcall relation cardinality [lindex $instref 1] } proc isRefSingular {instref} { expr {[refMultiplicity $instref] == 1} } proc limitRef {instref {count 1}} { lassign $instref relvar insts return [pipe { relation tag $insts __Tag | relation restrictwith ~ {$__Tag >= 0 && $__Tag < $count} | ToRef $relvar ~ }] } proc isRefEqual {instref1 instref2} { lassign $instref1 relvar1 inst1 lassign $instref2 relvar2 inst2 return [expr {$relvar1 eq $relvar2 && [relation is $inst1 equal $inst2]}] } proc RefSetCommand {op instref1 instref2} { lassign $instref1 relvar1 inst1 lassign $instref2 relvar2 inst2 if {$relvar1 ne $relvar2} { tailcall DeclError SAME_CLASS $relvar1 $relvar2 } return [list $relvar1 [relation $op $inst1 $inst2]] } proc refUnion {instref1 instref2} { tailcall RefSetCommand union $instref1 $instref2 } proc refIntersect {instref1 instref2} { tailcall RefSetCommand intersect $instref1 $instref2 } proc refMinus {instref1 instref2} { tailcall RefSetCommand minus $instref1 $instref2 } proc forAllRefs {varname instref body} { lassign $instref relvar refs upvar 1 $varname inst relation foreach ref $refs { set inst [list $relvar $ref] uplevel 1 $body } ; # <1> return } proc FindRelatedInsts {instref op args} { set srcrelvar [lindex $instref 0] SplitRelvarName $srcrelvar domain class # This procedure queries the architectural data about relationship linkage, # so we bring the relvar variables into scope. namespace upvar ${domain}\ __Arch_Link Link\ __Arch_AssociationLink AssociationLink\ __Arch_PartitionLink PartitionLink\ __Arch_PartitionDst PartitionDst variable relatedQuery ; # <1> # We start by dereferencing the instance reference. set related [deRef $instref] foreach linkage $args { lassign $linkage lname dst ; # split out the linkage spec set link [relvar restrictone ${domain}::__Arch_Link\ Name $lname SrcClass $class] if {[ral relation isempty $link]} { tailcall DeclError UNKNOWN_LINKAGE $lname $class } # First we determine if we are dealing with an associative link or a # partition link. set assoc [relation join $link $AssociationLink] if {[relation isnotempty $assoc]} { relation assign $assoc DstClass Attrs # Check if additional path information was provided. if {$dst eq {}} { # Find the set of instances related to the current set. set related [eval $relatedQuery] # We must see if this is a class-based association. If so, then the first # traversal was to the associator and we must traverse again to the other # class. set assoc [relation semijoin $assoc $AssociationLink\ -using {Name Name SrcClass PrevSrcClass}] if {[relation isnotempty $assoc]} { relation assign $assoc DstClass Attrs set related [pipe {# <1> relvar set ${domain}::$DstClass | relation semijoin $related ~ -using $Attrs }] } } else { # If a destination was specified in the linkage, then we need to verify # that it is actually part of the relationship. if {$dst ne $DstClass} { tailcall DeclError PATH_ERROR $lname $class $DstClass\ $dst } set related [eval $relatedQuery] } } else { set partdst [relvar restrictone ${domain}::__Arch_PartitionDst\ Name $lname SrcClass $class DstClass $dst] if {[relation isempty $partdst]} { tailcall DeclError GEN_PATH_ERROR $class $lname $dst } relation assign $partdst DstClass Attrs set related [eval $relatedQuery] } # Continue the iteration by setting the next source to the current # destination class. set class $DstClass set srcrelvar ${domain}::$class } # N.B. that we are not returning an instance reference but rather the # complete relation value of the related instances. This allows us # to further filter the result in the "findRelatedWhere" command. return [list $srcrelvar $related] } proc findRelated {instref args} { tailcall ToRef {*}[FindRelatedInsts $instref semijoin {*}$args] ; # <1> } proc findUnrelated {instref args} { tailcall ToRef {*}[FindRelatedInsts $instref semiminus {*}$args] ; # <1> } proc findRelatedWhere {instref rchain expr} { lassign [FindRelatedInsts $instref semijoin {*}$rchain] relvar insts tailcall ToRef $relvar [uplevel 1\ [list ::ral relation restrictwith $insts $expr]] ; # <1> } proc findUnrelatedWhere {instref rchain expr} { lassign [FindRelatedInsts $instref semiminus {*}$rchain] relvar insts tailcall ToRef $relvar [uplevel 1\ [list ::ral relation restrictwith $insts $expr]] } proc idInstance {instref} { lassign $instref relvar insts SplitRelvarName $relvar domain relationship set assignrelvar ${domain}::${relationship}__STATEINST if {![relvar exists $assignrelvar]} { tailcall DeclError NO_ASSIGNER $rname } set idclass [pipe { relvar restrictone [namespace parent]::Config::MultipleAssigner\ Domain [string trim $domain :] Relationship $relationship | relation extract ~ Class }] return [pipe { relvar set ${domain}::$idclass | relation semijoin $insts ~ | ToRef ${domain}::$idclass ~ }] } proc updateAttribute {instref args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_ERROR $args } lassign $instref relvar insts if {[relation cardinality $insts] != 1} { tailcall MUST_BE_SINGULAR $relvar [relation cardinality $insts] } set idattrs [list] foreach identifier [relvar identifiers $relvar] { ::struct::set add idattrs $identifier } set idupdates [::struct::set intersect $idattrs $args] if {![::struct::set empty $idupdates]} { tailcall DeclError ID_UPDATE [join $idupdates {, }] } set extcmd [list relation extend $insts exttuple] set heading [relation heading [relvar set $relvar]] foreach {attr value} $args { if {![dict exists $heading $attr]} { tailcall DeclError UNKNOWN_ATTRIBUTE $attr } lappend extcmd $attr [dict get $heading $attr] \{$value\} } relvar updateper $relvar [eval $extcmd] return } proc withAttribute {instref args} { if {[llength $args] < 2} { tailcall DeclError WITH_ATTR_USAGE } lassign $instref relvar insts if {[relation cardinality $insts] != 1} { tailcall MUST_BE_SINGULAR $relvar [relation cardinality $insts] } set body [lindex $args end] set attrspecs [lrange $args 0 end-1] set attrnames [list] set varnames [list] foreach attrspec $attrspecs { set speclen [llength $attrspec] if {$speclen == 1} { lappend attrnames [lindex $attrspec 0] lappend varnames [lindex $attrspec 0] } elseif {$speclen == 2} { lappend attrnames [lindex $attrspec 0] lappend varnames [lindex $attrspec 1] } else { tailcall DeclError ATTR_VAR_SPEC $attrspec } } set idattrs [list] foreach identifier [relvar identifiers $relvar] { ::struct::set add idattrs $identifier } set idupdates [::struct::set intersect $idattrs $attrnames] if {![::struct::set empty $idupdates]} { tailcall DeclError ID_UPDATE [join $idupdates {, }] } uplevel 1 [list ral relation assign [deRef $instref] {*}$attrspecs] uplevel 1 $body set extcmd [list relation extend $insts exttuple] set heading [relation heading [relvar set $relvar]] foreach attr $attrnames var $varnames { if {[uplevel 1 [list info exists $var]]} { upvar 1 $var varvalue lappend extcmd $attr [dict get $heading $attr] \{$varvalue\} } } relvar updateper $relvar [eval $extcmd] return } proc readAttribute {ref args} { # We insist upon a singular reference for reading attributes. Multiple # references can be handled by dereferences and using TclRAL "relation" # commands. if {![isRefSingular $ref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $ref] } return [expr {[llength $args] == 0 ? {} :\ [relation extract [deRef $ref {*}$args] {*}$args]}] ; # <1> } proc assignAttribute {ref args} { # We must insist upon a singular references, since assigning to scalar # variables from a relation value doesn't make a lot of sense. if {![isRefSingular $ref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $ref] } uplevel 1 [list ral relation assign [deRef $ref] {*}$args] ; # <1> return } proc delete {args} { foreach instref $args { lassign $instref relvar insts relvar minus $relvar [deRef $instref] SplitRelvarName $relvar domain class set instrelvar ${domain}::${class}__STATEINST if {[relvar exists $instrelvar]} { relvar minus $instrelvar [relation semijoin $insts\ [relvar set $instrelvar]] } } return } proc signal {dstset event args} { set srcref [SelfInstRef] if {![::rosea::Dispatch::MapPolymorphicEvent ::rosea::Dispatch::SignalEvent\ $srcref $dstset $event $args]} { ::rosea::Dispatch::SignalEvent $srcref $dstset $event $args } return } proc delaysignal {time dstset event args} { if {!([string is integer -strict $time] && $time >= 0)} { tailcall DeclError INVALID_TIME $time } set srcref [SelfInstRef] if {![::rosea::Dispatch::MapPolymorphicEvent\ [list ::rosea::Dispatch::SignalDelayedEvent $time]\ $srcref $dstset $event $args]} { ::rosea::Dispatch::SignalDelayedEvent $time $srcref $dstset $event $args } return } proc canceldelayed {srcref dstset event} { set srcmult [refMultiplicity $srcref] if {$srcmult > 1} { tailcall DeclError SINGLE_OR_EMPTY_REF_REQUIRED $srcmult } forAllRefs dstref $dstset { ::rosea::Dispatch::CancelDelayedSignal $srcref $event $dstref } return } proc delayremaining {srcref dstref event} { set srcmult [refMultiplicity $srcref] if {$srcmult > 1} { tailcall DeclError SINGLE_OR_EMPTY_REF_REQUIRED $srcmult } if {![isRefSingular $dstref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $dstref] } tailcall ::rosea::Dispatch::SignalTimeRemaining $srcref $event $dstref } proc instop {instref op args} { tailcall [lindex $instref 0]::Instance $instref $op {*}$args } } namespace eval RelCmds { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path [list\ [namespace parent]::Helpers\ [namespace parent]::InstCmds\ ] proc linkSimple {rname instref1 instref2} { lassign $instref1 relvar1 inst1 SplitRelvarName $relvar1 domain1 class1 lassign $instref2 relvar2 inst2 SplitRelvarName $relvar2 domain2 class2 if {$domain1 ne $domain2} { tailcall DeclError NO_CROSS_DOMAIN $domain1 $domain2 } set reflink [relvar restrictone ${domain1}::__Arch_RefLink Relationship $rname] if {[relation isempty $reflink]} { tailcall DeclError UNKNOWN_RELATIONSHIP $rname } relation assign $reflink\ {ReferringClass referringClass}\ {ReferencedClass referencedClass}\ {ReferringAttrs referringAttrs} ; # <1> if {$class1 eq $referringClass && $class2 eq $referencedClass} { set fromrelvar $relvar1 set frominsts $inst1 set torelvar $relvar2 set toinst $inst2 } elseif {$class2 eq $referringClass && $class1 eq $referencedClass} { set fromrelvar $relvar2 set frominsts $inst2 set torelvar $relvar1 set toinst $inst1 } else { tailcall DeclError NON_PARTICIPANTS $relvar1 $relvar2 $rname\ $referringClass $referencedClass } if {[relation cardinality $toinst] != 1} { tailcall MUST_BE_SINGULAR $torelvar [relation cardinality $toinst] } set refedvalue [relation semijoin $toinst [relvar set $torelvar]] set tovalues [pipe { relation extend $referringAttrs rfa RefValue string { [relation extract $refedvalue\ [tuple extract $rfa ReferencedAttribute]]} | relation dict ~ ReferringAttribute RefValue }] relation foreach frominst $frominsts { relvar updateone $fromrelvar fromtup\ [tuple get [relation tuple $frominst]] { # <1> tuple update $fromtup {*}$tovalues ; # <2> } } return } proc linkAssoc {rname instref1 instref2 args} { lassign $instref1 relvar1 inst1 SplitRelvarName $relvar1 domain1 class1 lassign $instref2 relvar2 inst2 SplitRelvarName $relvar2 domain2 class2 if {$domain1 ne $domain2} { tailcall DeclError NO_CROSS_DOMAIN $domain1 $domain2 } set assocref [relvar restrictone ${domain1}::__Arch_AssocRef\ Relationship $rname] if {[relation isempty $assocref]} { tailcall DeclError UNKNOWN_RELATIONSHIP $rname } relation assign $assocref\ {AssocClass assocClass}\ {References references} set ref1 [relation restrictwith $references {$Participant eq $class1}] if {[relation isempty $ref1]} { tailcall DeclError NOT_IN_ASSOCIATION $class1 $rname } if {[relation cardinality $ref1] > 1} { set ref2 [relation restrictwith $ref1 {$Role eq "target"}] set ref1 [relation minus $ref1 $ref2] ; # <1> } else { set ref2 [relation restrictwith $references {$Participant eq $class2}] if {[relation isempty $ref2]} { tailcall DeclError NOT_IN_ASSOCIATION $class2 $rname } } set rattr1 [relation extract $ref1 ReferringAttrs] set rattr2 [relation extract $ref2 ReferringAttrs] set values1 [relation semijoin $inst1 [relvar set $relvar1]] set values2 [relation semijoin $inst2 [relvar set $relvar2]] set assoctuples [list] relation foreach v1 $values1 { # <1> set refto1 [pipe { relation extend $rattr1 rfa RefValue string { [relation extract $v1 [tuple extract $rfa ReferencedAttribute]] } | relation dict ~ ReferringAttribute RefValue }] relation foreach v2 $values2 { set refto2 [pipe { relation extend $rattr2 rfa RefValue string { [relation extract $v2\ [tuple extract $rfa ReferencedAttribute]] } | relation dict ~ ReferringAttribute RefValue }] lappend assoctuples [dict merge $args $refto1 $refto2] ; # <2> } } set ref [ToRef ${domain1}::$assocClass\ [relvar insert ${domain1}::$assocClass {*}$assoctuples]] CreateInInitialStateFromRef $domain1 $assocClass $ref ; # <1> return $ref } proc referenceAssoc {rname assocref instref {dir {}}} { if {![isRefSingular $assocref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $assocref] } lassign $assocref assocrelvar associnst SplitRelvarName $assocrelvar assocdomain assocclass if {![isRefSingular $instref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $instref] } lassign $instref instrelvar inst SplitRelvarName $instrelvar instdomain instclass if {$assocdomain ne $instdomain} { tailcall DeclError NO_CROSS_DOMAIN $domain1 $domain2 } set assocref [relvar restrictone ${instdomain}::__Arch_AssocRef\ Relationship $rname] if {[relation isempty $assocref]} { tailcall DeclError UNKNOWN_RELATIONSHIP $rname } relation assign $assocref\ {AssocClass assocClass}\ {References references} if {$assocClass ne $assocclass} { tailcall DeclError NOT_IN_ASSOCIATION $assocclass $rname } set ref [relation restrictwith $references {$Participant eq $instclass}] set refcard [relation cardinality $ref] if {$refcard == 2} { switch -exact -- $dir { forward { set role target } backward { set role source } default { tailcall DeclError DIRECTION_REQUIRED $dir } } set ref [relation restrictwith $ref {$Role eq $role}] } elseif {$refcard == 0} { tailcall DeclError NOT_IN_ASSOCIATION $instclass $rname } set referringAttrs [relation extract $ref ReferringAttrs] set refedvalue [relation semijoin $inst [relvar set $instrelvar]] set tovalues [pipe { relation extend $referringAttrs rfa RefValue string { [relation extract $refedvalue\ [tuple extract $rfa ReferencedAttribute]]} | relation dict ~ ReferringAttribute RefValue }] relvar updateone $assocrelvar assoctup [tuple get [relation tuple $associnst]] { tuple update $assoctup {*}$tovalues } } proc unlinkSimple {rname instref} { lassign $instref relvar inst SplitRelvarName $relvar domain class set reflink [relvar restrictone ${domain}::__Arch_RefLink\ Relationship $rname] if {[relation isempty $reflink]} { tailcall DeclError UNKNOWN_RELATIONSHIP $rname } relation assign $reflink\ {ReferringClass referringClass}\ {ReferencedClass referencedClass}\ {ReferringAttrs referringAttrs} if {$class eq $referringClass} { set fromrelvar $relvar set frominsts $inst } elseif {$class eq $referencedClass} { lassign [::rosea::InstCmds::findRelated $instref ~$rname]\ fromrelvar frominsts } else { tailcall DeclError NOT_IN_ASSOCIATION $relvar $rname } set tovalues [pipe { relation extend $referringAttrs rfa RefValue string {{}} | relation dict ~ ReferringAttribute RefValue }] relation foreach frominst $frominsts { relvar updateone $fromrelvar fromtup\ [tuple get [relation tuple $frominst]] { tuple update $fromtup {*}$tovalues } } return } proc unlinkAssoc {rname instref} { lassign $instref relvar insts SplitRelvarName $relvar domain class set assocref [relvar restrictone ${domain}::__Arch_AssocRef\ Relationship $rname] if {[relation isempty $assocref]} { tailcall DeclError UNKNOWN_RELATIONSHIP $rname } relation assign $assocref\ {Relationship relationship}\ {AssocClass associator}\ {References references} # If we are given instances to the associator class, then there is no # more work to do. if {$class ne $associator} { # Otherwise, we have to find the associator class instances ourselves. set part [relation restrictwith $references {$Participant eq $class}] set partcard [relation cardinality $part] if {$partcard == 0} { tailcall DeclError NOT_IN_ASSOCIATION $class $rname } elseif {$partcard > 1} { tailcall DeclError AMBIGUOUS_UNLINK $rname $relvar ; # <1> } else { # Find associative class instances. We have to determine the # direction of the relationship traversal. set navdir [expr {[relation extract $part Role] eq "source" ?\ "$relationship" : "~$relationship"}] set instref [::rosea::InstCmds::findRelated $instref\ [list $navdir [namespace tail $associator]]] lassign $instref relvar insts SplitRelvarName $relvar domain class } } # We are going to delete tuples from the relvar that holds the class # instances. set delrelvars [list ${domain}::$class] # If the associative class also has a state model, then we need to also # delete the state instance tuples. if {[relvar exists ${domain}::${class}__STATEINST]} { lappend delrelvars ${domain}::${class}__STATEINST } # Now, we iterate across the associative class instances and delete all the # tuples in class relvar and, if necessary, the state instances. relation foreach inst $insts { set idattrs [tuple get [relation tuple $inst]] foreach rv $delrelvars { relvar deleteone $rv {*}$idattrs } } return $instref } proc migrate {rname instref subclass args} { if {![isRefSingular $instref]} { tailcall DeclError SINGLE_REF_REQUIRED [refMultiplicity $instref] } lassign $instref relvar inst SplitRelvarName $relvar domns class set link [relvar restrictone ${domns}::__Arch_AssociationLink Name $rname\ SrcClass $class] if {[relation isempty $link]} { tailcall DeclError NO_SUBCLASS $rname $relvar } # Traverse the relationship to the superclass. We need to get the values of # the referenced attributes to use in creating the new subclass instance. set superinst [pipe { relvar set ${domns}::[relation extract $link DstClass] | relation semijoin $inst ~ -using [relation extract $link Attrs] }] set sublink [relvar restrictone ${domns}::__Arch_SubLink\ Relationship $rname SubClass $subclass] if {[relation isempty $sublink]} { tailcall DeclError NO_SUBCLASS $rname $subclass } # Using the same relation extend strategy, we compute a dictionary of the # attribute names / values as they must appear in the subclass we are about # to create. set refedvalues [pipe { relation extract $sublink ReferringAttrs | relation extend ~ rval Value string { [relation extract $superinst\ [tuple extract $rval ReferencedAttribute]] } | relation dict ~ ReferringAttribute Value }] # We use the class commands to delete the old subclass instance and create # the new one. This will make sure that if the subclass has a state model # that the initial state is set correctly. # N.B. this is _not_ done in a relvar transaction. The transaction # boundaries should be set by the current thread of control or domain # operation. ::rosea::InstCmds::delete $instref return [::rosea::ClassCmds::create ${domns}::$subclass\ {*}[dict merge $args $refedvalues]] } proc signalAssigner {rname event args} { SplitRelvarName $rname domain relationship set assignrelvar ${domain}::${relationship}__STATEINST if {![relvar exists $assignrelvar]} { tailcall DeclError NO_ASSIGNER $rname } set dstref [pipe { relvar set $assignrelvar | relation project ~ {*}[lindex [relvar identifiers $assignrelvar] 0] | list $rname ~ }] ::rosea::Dispatch::SignalEvent [SelfInstRef] $dstref $event $args return } proc signalMultiAssigner {rname idvalues event args} { SplitRelvarName $rname domain relationship set assignrelvar ${domain}::${relationship}__STATEINST if {![relvar exists $assignrelvar]} { tailcall DeclError NO_ASSIGNER $rname } set idattrs [lindex [relvar identifiers $assignrelvar] 0] # We will insist that the idvalues contain the necessary identifying # attributes. if {![struct::set equal [dict keys $idvalues] $idattrs]} { tailcall DeclError NO_IDENTIFIER [dict keys $idvalues] $idattrs } set assigninsts [relvar set $assignrelvar] set assignrefs [relation project $assigninsts {*}$idattrs] # We need to find the tuple in "assignrefs" that matches the attributes and # values in "idvalues". We will do this by creating a relation value from # the idvalues list and semijoining that to "assignrefs". If we come up # non-empty, then we have found our multi-assigner instance. set heading [relation heading $assignrefs] set dstinst [pipe { tuple create $heading $idvalues | tuple relation ~ | relation semijoin ~ $assignrefs }] if {[relation isempty $dstinst]} { tailcall DeclError UNKNOWN_ASSIGNER $idvalues $rname } set dstref [list $rname $dstinst] ::rosea::Dispatch::SignalEvent [SelfInstRef] $dstref $event $args ; # <1> return } proc createMultiAssigner {rname args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } SplitRelvarName $rname domain relationship set assignrelvar ${domain}::${relationship}__STATEINST if {![relvar exists $assignrelvar]} { tailcall DeclError NO_ASSIGNER $rname } set idattrs [lindex [relvar identifiers $assignrelvar] 0] if {![struct::set equal [dict keys $args] $idattrs]} { tailcall DeclError NO_IDENTIFIER [dict keys $args] $idattrs } CreateInInitialState $domain $relationship $args } } namespace eval Dispatch { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path [list\ [namespace parent]::Helpers\ [namespace parent]::InstCmds\ ] variable toc_queue [list] variable event_queue [list] pipe { relvar restrictone ${domain}::__Arch_Transition\ Class $class State $currstate Event $event | relation extract ~ NewState } transitionQuery relvar create DelayedSignal { RefId int SrcInstRef list Event string DstInstRef list TimerId string Expire bignum } RefId {SrcInstRef Event DstInstRef} TimerId variable DelayedSignalId 0 pipe { relvar set ${domain}::__Arch_PartitionDst | relation restrictwith ~ {$SrcClass eq $dstclass} | relation group ~ DstLinks DstClass Attrs } polymapQuery proc SignalEvent {srcref dstset event arglist} { lassign $dstset relvar insts SplitRelvarName $relvar domain class if {[relation isempty [relvar restrictone ${domain}::__Arch_Event\ Class $class Event $event]]} { tailcall DeclError UNKNOWN_EVENT $event $class } set callback [namespace code DispatchEvent] set eventInfo [dict create\ type ordinary\ src $srcref\ event $event\ params $arglist\ ] if {[isRefEqual $srcref [nilInstRef]]} { variable toc_queue forAllRefs dstref $dstset { # Queue the thread of control events. dict set eventInfo dst $dstref lappend toc_queue $eventInfo ::after 0 $callback } } else { variable event_queue forAllRefs dstref $dstset { dict set eventInfo dst $dstref if {[isRefEqual $srcref $dstref]} { # <1> for {set eqindex 0} {$eqindex < [llength $event_queue]} {incr eqindex} { set cmpevent [lindex $event_queue $eqindex] if {![isRefEqual [dict get $cmpevent src] [dict get $cmpevent dst]]} { break } } set event_queue [linsert [K $event_queue [set event_queue {}]]\ $eqindex $eventInfo] ; # <1> } else { # Non-self directed events are always simply appended to the # event queue. lappend event_queue $eventInfo } ::after 0 $callback } } } proc DispatchEvent {} { variable event_queue variable toc_queue if {[llength $event_queue] != 0} { set eventInfo [lindex $event_queue 0] set event_queue [lrange [K $event_queue [set event_queue {}]] 1 end] ; # <1> } elseif {[llength $toc_queue] != 0} { set eventInfo [lindex $toc_queue 0] set toc_queue [lrange [K $toc_queue [set toc_queue {}]] 1 end] relvar transaction begin ; # <2> } else { return } if {[dict get $eventInfo type] eq "creation"} { try { set dstref [::rosea::ClassCmds::createin\ [dict get $eventInfo dstClass] @\ {*}[dict get $eventInfo dstAttrs]] ; # <1> } on error {result} { catch { if {[llength $event_queue] == 0} { relvar transaction end } } tailcall DeclError ASYNC_CREATION_FAILED [dict get $eventInfo dstClass]\ [dict get $eventInfo dstAttrs] $result } dict set eventInfo dst $dstref ; # <2> ::rosea::Trace::TraceCreation [dict get $eventInfo src]\ [dict get $eventInfo event] $dstref [dict get $eventInfo params] } set dstref [dict get $eventInfo dst] lassign $dstref relvar ref SplitRelvarName $relvar domain class set instrelvar ${domain}::${class}__STATEINST set state [relation semijoin $ref [relvar set $instrelvar]] if {[relation isempty $state]} { tailcall DeclError EVENT_IN_FLIGHT [dict get $eventInfo event] $ref } set currstate [relation extract $state __State] set event [dict get $eventInfo event] variable transitionQuery set newState [eval $transitionQuery] ::rosea::Trace::TraceTransition [dict get $eventInfo src]\ $event $dstref $currstate $newState [dict get $eventInfo params] ; # <1> try { if {$newState eq "CH"} { TransitionError [dict get $eventInfo src] $event $dstref $currstate } elseif {$newState ne "IG"} { set idattrs [tuple get [relation tuple $ref]] relvar updateone $instrelvar is $idattrs { tuple update $is __State $newState } try { ${relvar}::__Activity::$newState $dstref\ {*}[dict get $eventInfo params] ; # <1> } on error {result opts} { return -options $opts $result } finally { set term [relvar restrictone ${domain}::__Arch_TerminalState\ Class $class State $newState] if {[relation isnotempty $term]} { relvar deleteone $relvar {*}$idattrs relvar deleteone $instrelvar {*}$idattrs } } } } on error {result opts} { catch { if {[llength $event_queue] == 0} { relvar transaction end } } ; # <1> return -options $opts $result } if {[llength $event_queue] == 0} { relvar transaction end } return } proc TransitionError {src event dst currstate} { tailcall DeclError CANT_HAPPEN_EVENT $src $event $dst $currstate } proc FindDelayedSignal {srcref event dstref} { variable DelayedSignal return [relation restrictwith $DelayedSignal { [isRefEqual $SrcInstRef $srcref] && $Event eq $event &&\ [isRefEqual $DstInstRef $dstref]}] } proc DeleteDelayedSignal {srcref event dstref} { relvar delete DelayedSignal dsig { [isRefEqual [tuple extract $dsig SrcInstRef] $srcref] &&\ [tuple extract $dsig Event] eq $event &&\ [isRefEqual [tuple extract $dsig DstInstRef] $dstref] } } proc SignalDelayedEvent {time srcref dstset event arglist} { lassign $dstset relvar insts SplitRelvarName $relvar domain class if {[relation isempty [relvar restrictone ${domain}::__Arch_Event\ Class $class Event $event]]} { tailcall DeclError UNKNOWN_EVENT $event $class } variable DelayedSignalId set eventInfo [dict create\ id [incr DelayedSignalId]\ type ordinary\ src $srcref\ event $event\ params $arglist\ ] forAllRefs dstref $dstset { dict set eventInfo dst $dstref DeleteDelayedSignal $srcref $event $dstref ; # <1> relvar insert DelayedSignal [list\ RefId $DelayedSignalId\ SrcInstRef $srcref\ Event $event\ DstInstRef $dstref\ TimerId [::after $time [list\ ::rosea::Dispatch::DispatchDelayedEvent $eventInfo]]\ Expire [expr {entier([clock milliseconds]) + entier($time)}]\ ] } return } proc DispatchDelayedEvent {eventInfo} { relvar deleteone DelayedSignal RefId [dict get $eventInfo id] variable toc_queue lappend toc_queue $eventInfo tailcall DispatchEvent } proc CancelDelayedSignal {srcref event dstref} { variable DelayedSignal set sig [FindDelayedSignal $srcref $event $dstref] if {[relation isnotempty $sig]} { ::after cancel [relation extract $sig TimerId] DeleteDelayedSignal $srcref $event $dstref } else { # Search the toc_queue to see if the signal delay has already expired # and the event is awaiting dispatch. variable toc_queue for {set i 0} {$i < [llength $toc_queue]} {incr i} { set eventInfo [lindex $toc_queue $i] dict update eventInfo src evtsrc dst evtdst event evtevent { if {[isRefEqual $evtsrc $srcref] &&\ [isRefEqual $evtdst $dstref] &&\ $evtevent eq $event} { set toc_queue [lreplace\ [K $toc_queue [set toc_queue {}]] $i $i] break } } } } } proc SignalTimeRemaining {srcref event dstref} { set sig [FindDelayedSignal $srcref $event $dstref] return [expr {[relation isempty $sig] ? 0 :\ max([relation extract $sig Expire] - [clock milliseconds], 0)}] ; # <1> } proc MapPolymorphicEvent {frwdcmd srcref dstrefs event arglist} { lassign $dstrefs dstrelvar dstinsts SplitRelvarName $dstrelvar domain dstclass set polyevent [relvar restrictone ${domain}::__Arch_PolymorphicEvent\ Class $dstclass Event $event] if {[relation isempty $polyevent]} { return false } variable polymapQuery set partitions [eval $polymapQuery] relation foreach inst $dstinsts { relation foreach partition $partitions { relation assign $partition relation foreach dstlink $DstLinks { relation assign $dstlink set related [relation semijoin $inst\ [relvar set ${domain}::$DstClass] -using $Attrs] if {[relation isnotempty $related]} { set dstreference [ToRef ${domain}::${DstClass} $related] set target [ToRef $dstrelvar $inst] ::rosea::Trace::TracePolymorphic $srcref $event $target $dstreference $Name\ $arglist if {![MapPolymorphicEvent $frwdcmd $target $dstreference $event $arglist]} { {*}$frwdcmd $target $dstreference $event $arglist ; # <1> } break } } } } return true } } namespace eval Config { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path [namespace parent]::Helpers variable evalLambda {{body} { upvar #0 ::rosea::Config::errcount errcount ; # <1> upvar #0 ::rosea::Config::configlineno configlineno set lineno $configlineno set command {} foreach line [split $body \n] { # <2> append command $line \n incr lineno ; # <3> if {[info complete $command]} { try { eval $command } on error {result} { log::error "line $configlineno: \"$result\"" incr errcount } set command {} ; # <4> set configlineno $lineno } } return $errcount }} relvar create Domain { Name string Location string } Name relvar create DomainElement { Domain string Element string } {Domain Element} relvar association R1\ DomainElement Domain *\ Domain Name 1 relvar create Class { Domain string Name string } {Domain Name} relvar create Relationship { Domain string Name string } {Domain Name} relvar create DomainOperation { Domain string Name string Parameters list Body string } {Domain Name} relvar partition R2 DomainElement {Domain Element}\ Class {Domain Name}\ Relationship {Domain Name}\ DomainOperation {Domain Name} relvar create Attribute { Domain string Class string Name string Type string } {Domain Class Name} relvar association R3\ Attribute {Domain Class} +\ Class {Domain Name} 1 relvar create Identifier { Domain string Class string Number int } {Domain Class Number} relvar association R4\ Identifier {Domain Class} +\ Class {Domain Name} 1 relvar create IdentifyingAttribute { Domain string Class string Attribute string Number int } {Domain Class Attribute Number} relvar correlation R5 IdentifyingAttribute\ {Domain Class Number} + Identifier {Domain Class Number}\ {Domain Class Attribute} * Attribute {Domain Class Name} relvar create DefaultValue { Domain string Class string Attribute string } {Domain Class Attribute} relvar association R6\ DefaultValue {Domain Class Attribute} ?\ Attribute {Domain Class Name} 1 relvar create UserSuppliedValue { Domain string Class string Attribute string Value string } {Domain Class Attribute} relvar create SystemSuppliedValue { Domain string Class string Attribute string StartValue int } {Domain Class Attribute} relvar create GeneratedValue { Domain string Class string Attribute string Cmd string } {Domain Class Attribute} relvar partition R18 DefaultValue {Domain Class Attribute}\ UserSuppliedValue {Domain Class Attribute}\ SystemSuppliedValue {Domain Class Attribute}\ GeneratedValue {Domain Class Attribute} relvar create ValueCheck { Domain string Class string Attribute string Expression string } {Domain Class Attribute} relvar association R17\ ValueCheck {Domain Class Attribute} ?\ Attribute {Domain Class Name} 1 relvar create AttributeReference { Domain string ReferringClass string ReferringAttribute string ReferringRole string ReferencedClass string ReferencedAttribute string ReferencedRole string ReferencedIdNumber int Relationship string } {Domain ReferringClass ReferringAttribute ReferringRole\ ReferencedClass ReferencedAttribute ReferencedRole ReferencedIdNumber\ Relationship} relvar association R13\ AttributeReference {Domain ReferringClass ReferringAttribute} *\ Attribute {Domain Class Name} 1 relvar create ReferencedIdAttribute { Domain string Class string Relationship string Role string Attribute string Number int } {Domain Class Relationship Role Attribute Number} relvar create Operation { Domain string Class string Name string } {Domain Class Name} relvar association R8\ Operation {Domain Class} * Class {Domain Name} 1 relvar create InstanceOperation { Domain string Class string Name string } {Domain Class Name} relvar create ClassOperation { Domain string Class string Name string } {Domain Class Name} relvar partition R7 Operation {Domain Class Name}\ InstanceOperation {Domain Class Name}\ ClassOperation {Domain Class Name} relvar create UserInstanceOperation { Domain string Class string Name string Parameters string Body string } {Domain Class Name} relvar create SystemInstanceOperation { Domain string Class string Name string } {Domain Class Name} relvar partition R9 InstanceOperation {Domain Class Name}\ UserInstanceOperation {Domain Class Name}\ SystemInstanceOperation {Domain Class Name} relvar create UserClassOperation { Domain string Class string Name string Parameters string Body string } {Domain Class Name} relvar create SystemClassOperation { Domain string Class string Name string } {Domain Class Name} relvar partition R10 ClassOperation {Domain Class Name}\ UserClassOperation {Domain Class Name}\ SystemClassOperation {Domain Class Name} relvar create SuppliedOperation { Name string Command string RequiresStateModel boolean } Name relvar create SuppliedClassOperation { Name string } Name relvar create SuppliedInstanceOperation { Name string } Name relvar partition R14 SuppliedOperation Name\ SuppliedClassOperation Name\ SuppliedInstanceOperation Name relvar association R15\ SystemClassOperation Name *\ SuppliedClassOperation Name 1 relvar association R16\ SystemInstanceOperation Name *\ SuppliedInstanceOperation Name 1 relvar eval { relvar insert SuppliedOperation { Name findAll Command ::rosea::ClassCmds::findAll RequiresStateModel false } { Name findById Command ::rosea::ClassCmds::findById RequiresStateModel false } { Name findWhere Command ::rosea::ClassCmds::findWhere RequiresStateModel false } { Name create Command ::rosea::ClassCmds::create RequiresStateModel false } { Name createin Command ::rosea::ClassCmds::createin RequiresStateModel true } { Name createasync Command ::rosea::ClassCmds::createasync RequiresStateModel true } { Name update Command ::rosea::ClassCmds::update RequiresStateModel false } relvar insert SuppliedClassOperation { Name findAll } { Name findById } { Name findWhere } { Name create } { Name createin } { Name createasync } { Name update } } relvar eval { relvar insert SuppliedOperation { Name findRelated Command ::rosea::InstCmds::findRelated RequiresStateModel false } { Name findUnrelated Command ::rosea::InstCmds::findById RequiresStateModel false } { Name findRelatedWhere Command ::rosea::InstCmds::findRelatedWhere RequiresStateModel false } { Name findUnrelatedWhere Command ::rosea::InstCmds::findUnrelatedWhere RequiresStateModel false } { Name updateAttribute Command ::rosea::InstCmds::updateAttribute RequiresStateModel false } { Name withAttribute Command ::rosea::InstCmds::withAttribute RequiresStateModel false } { Name readAttribute Command ::rosea::InstCmds::readAttribute RequiresStateModel false } { Name assignAttribute Command ::rosea::InstCmds::assignAttribute RequiresStateModel false } { Name delete Command ::rosea::InstCmds::delete RequiresStateModel false } { Name signal Command ::rosea::InstCmds::signal RequiresStateModel true } { Name delaysignal Command ::rosea::InstCmds::delaysignal RequiresStateModel true } { Name canceldelayed Command ::rosea::InstCmds::canceldelayed RequiresStateModel true } { Name delayremaining Command ::rosea::InstCmds::delayremaining RequiresStateModel true } { Name instop Command ::rosea::InstCmds::instop RequiresStateModel false } { Name deRef Command ::rosea::InstCmds::deRef RequiresStateModel false } { Name isEmptyRef Command ::rosea::InstCmds::isEmptyRef RequiresStateModel false } { Name isNotEmptyRef Command ::rosea::InstCmds::isNotEmptyRef RequiresStateModel false } { Name refMultiplicity Command ::rosea::InstCmds::refMultiplicity RequiresStateModel false } { Name isRefSingular Command ::rosea::InstCmds::isRefSingular RequiresStateModel false } { Name limitRef Command ::rosea::InstCmds::limitRef RequiresStateModel false } { Name isRefEqual Command ::rosea::InstCmds::isRefEqual RequiresStateModel false } { Name forAllRefs Command ::rosea::InstCmds::forAllRefs RequiresStateModel false } relvar insert SuppliedInstanceOperation { Name findRelated } { Name findUnrelated } { Name findRelatedWhere } { Name findUnrelatedWhere } { Name updateAttribute } { Name withAttribute } { Name readAttribute } { Name assignAttribute } { Name delete } { Name signal } { Name delaysignal } { Name canceldelayed } { Name delayremaining } { Name instop } { Name deRef } { Name isEmptyRef } { Name isNotEmptyRef } { Name refMultiplicity } { Name isRefSingular } { Name limitRef } { Name isRefEqual } { Name forAllRefs } } relvar create Association { Domain string Name string } {Domain Name} relvar create Generalization { Domain string Name string } {Domain Name} relvar partition R30 Relationship {Domain Name}\ Association {Domain Name}\ Generalization {Domain Name} relvar create SimpleAssociation { Domain string Name string } {Domain Name} relvar create ClassBasedAssociation { Domain string Name string } {Domain Name} relvar partition R31 Association {Domain Name}\ SimpleAssociation {Domain Name}\ ClassBasedAssociation {Domain Name} relvar create SimpleReferringClass { Domain string Class string Relationship string Role string Conditionality boolean Multiplicity boolean } {Domain Class Relationship Role} relvar association R32\ SimpleReferringClass {Domain Relationship} 1\ SimpleAssociation {Domain Name} 1 relvar create SimpleReferencedClass { Domain string Class string Relationship string Role string Conditionality boolean } {Domain Class Relationship Role} relvar association R33\ SimpleReferencedClass {Domain Relationship} 1\ SimpleAssociation {Domain Name} 1 relvar create SourceClass { Domain string Class string Relationship string Role string Conditionality boolean Multiplicity boolean } {Domain Class Relationship Role} relvar association R34\ SourceClass {Domain Relationship} 1\ ClassBasedAssociation {Domain Name} 1 relvar create TargetClass { Domain string Class string Relationship string Role string Conditionality boolean Multiplicity boolean } {Domain Class Relationship Role} relvar association R35\ TargetClass {Domain Relationship} 1\ ClassBasedAssociation {Domain Name} 1 relvar create AssociatorClass { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar association R42\ AssociatorClass {Domain Relationship} 1\ ClassBasedAssociation {Domain Name} 1 relvar create Superclass { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar association R36\ Superclass {Domain Relationship} 1\ Generalization {Domain Name} 1 relvar create Subclass { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar association R37\ Subclass {Domain Relationship} +\ Generalization {Domain Name} 1 relvar create ReferringClass { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar partition R38 ReferringClass {Domain Class Relationship Role}\ SimpleReferringClass {Domain Class Relationship Role}\ AssociatorClass {Domain Class Relationship Role}\ Subclass {Domain Class Relationship Role} relvar create ReferencedClass { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar partition R39 ReferencedClass {Domain Class Relationship Role}\ SimpleReferencedClass {Domain Class Relationship Role}\ SourceClass {Domain Class Relationship Role}\ TargetClass {Domain Class Relationship Role}\ Superclass {Domain Class Relationship Role} relvar create ClassRole { Domain string Class string Relationship string Role string } {Domain Class Relationship Role} relvar partition R40 ClassRole {Domain Class Relationship Role}\ ReferringClass {Domain Class Relationship Role}\ ReferencedClass {Domain Class Relationship Role} relvar correlation R41 ClassRole\ {Domain Relationship} + Relationship {Domain Name}\ {Domain Class} * Class {Domain Name} relvar correlation R11 ReferencedIdAttribute\ {Domain Class Relationship Role} +\ ReferencedClass {Domain Class Relationship Role}\ {Domain Class Attribute Number} *\ IdentifyingAttribute {Domain Class Attribute Number} relvar correlation R12 AttributeReference\ {Domain ReferringClass Relationship ReferringRole} +\ ReferringClass {Domain Class Relationship Role}\ {Domain ReferencedClass Relationship ReferencedRole ReferencedAttribute\ ReferencedIdNumber} +\ ReferencedIdAttribute {Domain Class Relationship Role Attribute Number} relvar create Config_AssocSpec { Spec string NeedsAssociator boolean ReflexiveAllowed boolean ReferringCond boolean ReferringMult boolean ReferencedCond boolean ReferencedMult boolean } Spec relvar insert Config_AssocSpec { Spec 1--1 NeedsAssociator false ReflexiveAllowed true ReferringCond false ReferringMult false ReferencedCond false ReferencedMult false } { Spec 0..1--1 NeedsAssociator false ReflexiveAllowed false ReferringCond true ReferringMult false ReferencedCond false ReferencedMult false } { Spec 0..1--0..1 NeedsAssociator false ReflexiveAllowed true ReferringCond true ReferringMult false ReferencedCond true ReferencedMult false } { Spec 1..*--1 NeedsAssociator false ReflexiveAllowed true ReferringCond false ReferringMult true ReferencedCond false ReferencedMult false } { Spec 0..*--1 NeedsAssociator false ReflexiveAllowed false ReferringCond true ReferringMult true ReferencedCond false ReferencedMult false } { Spec 1..*--0..1 NeedsAssociator false ReflexiveAllowed false ReferringCond false ReferringMult true ReferencedCond true ReferencedMult false } { Spec 0..*--0..1 NeedsAssociator false ReflexiveAllowed true ReferringCond true ReferringMult true ReferencedCond true ReferencedMult false } { Spec 1..*--1..* NeedsAssociator true ReflexiveAllowed true ReferringCond false ReferringMult true ReferencedCond false ReferencedMult true } { Spec 0..*--1..* NeedsAssociator true ReflexiveAllowed false ReferringCond true ReferringMult true ReferencedCond false ReferencedMult true } { Spec 1..*--0..* NeedsAssociator true ReflexiveAllowed false ReferringCond false ReferringMult true ReferencedCond true ReferencedMult true } { Spec 0..*--0..* NeedsAssociator true ReflexiveAllowed true ReferringCond true ReferringMult true ReferencedCond true ReferencedMult true } { Spec ?--1 NeedsAssociator false ReflexiveAllowed false ReferringCond true ReferringMult false ReferencedCond false ReferencedMult false } { Spec ?--? NeedsAssociator false ReflexiveAllowed true ReferringCond true ReferringMult false ReferencedCond true ReferencedMult false } { Spec +--1 NeedsAssociator false ReflexiveAllowed true ReferringCond false ReferringMult true ReferencedCond false ReferencedMult false } { Spec *--1 NeedsAssociator false ReflexiveAllowed false ReferringCond true ReferringMult true ReferencedCond false ReferencedMult false } { Spec +--? NeedsAssociator false ReflexiveAllowed false ReferringCond false ReferringMult true ReferencedCond true ReferencedMult false } { Spec *--? NeedsAssociator false ReflexiveAllowed true ReferringCond true ReferringMult true ReferencedCond true ReferencedMult false } { Spec +--+ NeedsAssociator true ReflexiveAllowed true ReferringCond false ReferringMult true ReferencedCond false ReferencedMult true } { Spec *--+ NeedsAssociator true ReflexiveAllowed false ReferringCond true ReferringMult true ReferencedCond false ReferencedMult true } { Spec +--* NeedsAssociator true ReflexiveAllowed false ReferringCond false ReferringMult true ReferencedCond true ReferencedMult true } { Spec *--* NeedsAssociator true ReflexiveAllowed true ReferringCond true ReferringMult true ReferencedCond true ReferencedMult true } relvar create Config_ClassAssoc { Domain string Relationship string AssocClass string SourceClass string } {Domain Relationship AssocClass SourceClass} relvar create Config_NonReflexiveAssoc { Domain string Relationship string AssocClass string SourceClass string TargetClass string } {Domain Relationship AssocClass SourceClass} relvar create Config_ReflexiveAssoc { Domain string Relationship string AssocClass string SourceClass string } {Domain Relationship AssocClass SourceClass} relvar create Config_ReflexivePath { Domain string Relationship string AssocClass string SourceClass string SourceAttr string TargetAttr string } {Domain Relationship AssocClass SourceClass SourceAttr} relvar partition Config1\ Config_ClassAssoc\ {Domain Relationship AssocClass SourceClass}\ Config_NonReflexiveAssoc\ {Domain Relationship AssocClass SourceClass}\ Config_ReflexiveAssoc\ {Domain Relationship AssocClass SourceClass} relvar association Config2\ Config_ReflexivePath {Domain Relationship AssocClass SourceClass} +\ Config_ReflexiveAssoc {Domain Relationship AssocClass SourceClass} 1 pipe { relvar set ::rosea::Config::AttributeReference | relation project ~ Domain ReferencedClass Relationship ReferencedRole\ ReferencedAttribute ReferencedIdNumber | relation rename ~ ReferencedClass Class ReferencedRole Role\ ReferencedAttribute Attribute ReferencedIdNumber Number | relvar union ::rosea::Config::ReferencedIdAttribute } refIdQuery relvar create StateModel { Domain string Model string InitialState string DefaultTrans string } {Domain Model} relvar create InstanceStateModel { Domain string Class string } {Domain Class} relvar association R51\ InstanceStateModel {Domain Class} ?\ Class {Domain Name} 1 relvar create AssignerStateModel { Domain string Relationship string } {Domain Relationship} relvar association R52\ AssignerStateModel {Domain Relationship} ?\ Association {Domain Name} 1 relvar partition R50 StateModel {Domain Model}\ InstanceStateModel {Domain Class}\ AssignerStateModel {Domain Relationship} relvar create SingleAssigner { Domain string Relationship string } {Domain Relationship} relvar create MultipleAssigner { Domain string Relationship string Class string Number int } {Domain Relationship} relvar partition R53 AssignerStateModel {Domain Relationship}\ SingleAssigner {Domain Relationship}\ MultipleAssigner {Domain Relationship} relvar association R54\ MultipleAssigner {Domain Class Number} ?\ Identifier {Domain Class Number} 1 relvar create State { Domain string Model string Name string Parameters string Action string IsFinal boolean } {Domain Model Name} relvar association R55\ State {Domain Model} +\ StateModel {Domain Model} 1 relvar association R58\ StateModel {Domain Model InitialState} ?\ State {Domain Model Name} 1 relvar create TransitionRule { Name string } Name relvar insert TransitionRule {Name IG} {Name CH} relvar association R59\ StateModel DefaultTrans *\ TransitionRule Name 1 relvar create CreationState { Domain string Model string Name string } {Domain Model Name} relvar create StatePlace { Domain string Model string Name string } {Domain Model Name} relvar partition R57 StatePlace {Domain Model Name}\ State {Domain Model Name}\ CreationState {Domain Model Name} relvar create Event { Domain string Model string Event string } {Domain Model Event} relvar create DeferredEvent { Domain string Model string Event string } {Domain Model Event} relvar create EffectiveEvent { Domain string Model string Event string } {Domain Model Event} relvar partition R80 Event {Domain Model Event}\ DeferredEvent {Domain Model Event}\ EffectiveEvent {Domain Model Event} relvar create DeferralPath { Domain string Model string Event string Relationship string Role string } {Domain Model Event Relationship Role} relvar correlation R86 DeferralPath\ {Domain Model Event} + DeferredEvent {Domain Model Event}\ {Domain Model Relationship Role} * Superclass\ {Domain Class Relationship Role} relvar create PolymorphicEvent { Domain string Model string Event string } {Domain Model Event} relvar create InheritedEvent { Domain string Model string Event string } {Domain Model Event} relvar partition R81 DeferredEvent {Domain Model Event}\ PolymorphicEvent {Domain Model Event}\ InheritedEvent {Domain Model Event} relvar create MappedEvent { Domain string Model string Event string ParentModel string } {Domain Model Event} relvar association R84\ MappedEvent {Domain ParentModel Event} *\ DeferredEvent {Domain Model Event} 1 relvar create LocalEvent { Domain string Model string Event string } {Domain Model Event} relvar partition R82 EffectiveEvent {Domain Model Event}\ MappedEvent {Domain Model Event}\ LocalEvent {Domain Model Event} relvar create NonLocalEvent { Domain string Model string Event string Relationship string Role string } {Domain Model Event} relvar partition R83 NonLocalEvent {Domain Model Event}\ MappedEvent {Domain Model Event}\ InheritedEvent {Domain Model Event} relvar association R85\ NonLocalEvent {Domain Model Relationship Role} *\ Subclass {Domain Class Relationship Role} 1 relvar association R87\ EffectiveEvent {Domain Model} +\ StateModel {Domain Model} 1 relvar create TransitionPlace { Domain string Model string State string Event string } {Domain Model State Event} relvar correlation R70 TransitionPlace\ {Domain Model State} * StatePlace {Domain Model Name}\ {Domain Model Event} * EffectiveEvent {Domain Model Event} relvar create StateTransition { Domain string Model string State string Event string NewState string } {Domain Model State Event} relvar create NonStateTransition { Domain string Model string State string Event string TransRule string } {Domain Model State Event} relvar partition R71 TransitionPlace {Domain Model State Event}\ StateTransition {Domain Model State Event}\ NonStateTransition {Domain Model State Event} relvar association R72\ StateTransition {Domain Model NewState} *\ State {Domain Model Name} 1 relvar association R73\ NonStateTransition TransRule *\ TransitionRule Name 1 relvar create Config_DataError { Relationship string RefClass string RefType string Format string } {Relationship RefClass RefType} relvar insert Config_DataError { Relationship R3 RefClass Class RefType notrefed Format {in domain, \"$Domain\", class, \"$Name\",\ has no attributes} } { Relationship R4 RefClass Class RefType notrefed Format {in domain, \"$Domain\", class, \"$Name\",\ has no identifiers} } { Relationship R11 RefClass ReferencedClass RefType notrefed Format {in domain, \"$Domain\", for relationship,\ \"$Relationship\", no class has defined a reference\ to class, \"$Class\"} } { Relationship R11 RefClass ReferencedIdAttribute RefType refnone Format {in domain, \"$Domain\", relationship,\ \"$Relationship\", references attribute,\ \"$Attribute\", in class, \"$Class\", which is\ not an identifying attribute, does not exist\ or \"$Relationship\" does not exist} } { Relationship R12 RefClass AttributeReference RefType refnone Format {in domain, \"$Domain\", the attribute,\ \"$ReferringAttribute\", in class, \"$ReferringClass\",\ refers to, \"$ReferencedAttribute\", in class,\ \"$ReferencedClass\", but the class, attribute or\ relationship does not exist} } { Relationship R12 RefClass ReferringClass RefType notrefed Format {in domain, \"$Domain\", in class, \"$Class\",\ makes a reference along relationship,\ \"$Relationship\", but $Class does not pariticipate\ in $Relationship} } { Relationship R13 RefClass AttributeReference RefType refnone Format {in domain, \"$Domain\", the attribute,\ \"$ReferringAttribute\", in class, \"$ReferringClass\",\ does not exist, but is used as a referential attribute} } { Relationship R41 RefClass ClassRole RefType refnone Format {in domain, \"$Domain\", relationship,\ \"$Relationship\", references class, \"$Class\",\ which does not exist} } { Relationship R52 RefClass AssignerStateModel RefType refnone Format {in domain, \"$Domain\", an assigner state model is\ defined on relationship, \"$Relationship\", which is\ not an association type relationship} } { Relationship R70 RefClass TransitionPlace RefType refnone Format {in domain, \"$Domain\", the state model for,\ \"$Model\", contains a transition for event,\ \"$Event\", but $Event was a polymorphic event\ consumed by a superclass of $Model} } { Relationship R72 RefClass StateTransition RefType refnone Format {in domain, \"$Domain\", the state model for,\ \"$Model\", contains the transition,\ \"$State - $Event -> $NewState\",\ but state \"$NewState\" does not exist} } { Relationship R81 RefClass DeferredEvent RefType multrefed Format {in domain, \"$Domain\", in the state model for,\ \"$Model\", event, \"$Event\", is both an inherited\ polymorphic event and a locally defined one} } { Relationship R86 RefClass DeferredEvent RefType notrefed Format {in domain, \"$Domain\", in the state model for,\ \"$Model\", event, \"$Event\", is defined as\ polymorphic but \"$Model\" is not a superclass\ of a generalization} } { Relationship R87 RefClass EffectiveEvent RefType refnone Format {in domain, \"$Domain\", event, \"$Event\" has been\ inherited, but no state model exists for, \"$Model\"} } namespace export ConfigEvaluate proc ConfigEvaluate {ns body} { variable evalLambda tailcall ::apply [concat $evalLambda [list $ns]] $body ; # <1> } proc domain {name body} { namespace upvar DomainDef DomainName DomainName ; # <1> set DomainName $name relvar insert ::rosea::Config::Domain [list Name $name Location {}] try { if {$name eq {}} { tailcall DeclError EMPTY_NAME domain } relvar eval { # <2> ConfigEvaluate [namespace current]::DomainDef $body # At this point we have the definition of the domain and enough # information to tie together the referential attributes and # the association definitions. variable Config_NonReflexiveAssoc relation foreach nra $Config_NonReflexiveAssoc { relation assign $nra relvar update ::rosea::Config::AttributeReference ar { [tuple extract $ar Domain] eq $Domain && [tuple extract $ar Relationship] eq $Relationship && [tuple extract $ar ReferringClass] eq $AssocClass } {tuple update $ar ReferringRole associator} relvar update ::rosea::Config::AttributeReference ar { [tuple extract $ar Domain] eq $Domain && [tuple extract $ar Relationship] eq $Relationship && [tuple extract $ar ReferringClass] eq $AssocClass && [tuple extract $ar ReferencedClass] eq $SourceClass } {tuple update $ar ReferencedRole source} } variable Config_ReflexivePath relation foreach rp $Config_ReflexivePath { relation assign $rp relvar update ::rosea::Config::AttributeReference ar { [tuple extract $ar Domain] eq $Domain && [tuple extract $ar Relationship] eq $Relationship && [tuple extract $ar ReferringClass] eq $AssocClass } {tuple update $ar ReferringRole associator} relvar update ::rosea::Config::AttributeReference ar { [tuple extract $ar Domain] eq $Domain && [tuple extract $ar Relationship] eq $Relationship && [tuple extract $ar ReferringClass] eq $AssocClass && [tuple extract $ar ReferringAttribute] eq $SourceAttr } {tuple update $ar ReferencedRole source} } variable refIdQuery eval $refIdQuery # We must also compute how polymorphic events are inherited # down generalization hierarchies. # Create Deferral Path instances variable PolymorphicEvent variable DeferredEvent variable Superclass variable Subclass variable DeferralPath set dpaths [pipe { relation restrictwith $PolymorphicEvent {$Domain eq $name} | relation semijoin ~ $DeferredEvent | relation join ~ $Superclass -using {Domain Domain Model Class} }] relvar insert ::rosea::Config::DeferralPath {*}[relation body $dpaths] set supers [relation semiminus $Subclass $Superclass\ -using {Domain Domain Class Class}] relation foreach super $supers { PropagatePolyEvents $super } } } on error {result} { # puts $::errorInfo ::rosea::Config::HandleConfigError $result } } proc HandleConfigError {result} { set lines [split [string trimright $result] \n] set nlines [llength $lines] set lineno 0 upvar #0 ::rosea::Config::errcount errcount while {$lineno < $nlines} { set line [lindex $lines $lineno] incr lineno if {[regexp {^for[^:]+([^(]+)\(.+\), in relvar (.+)$} $line\ match rnum refclass]} { set rnum [namespace tail $rnum] set refclass [namespace tail $refclass] # Now iterate over the "tuple" lines that follow the constraint message. while {$lineno < $nlines} { set tupline [lindex $lines $lineno] if {[regexp {^tuple {(.+)} (.+)$} $tupline match tuple phrase]} { incr lineno incr errcount if {[string match {is not referenced*} $phrase]} { set reftype notrefed } elseif {[string match {references no*} $phrase]} { set reftype refnone } elseif {[string match {*to by multiple*} $phrase]} { set reftype multrefed } elseif {[string match {is not referred to*} $phrase]} { set reftype notrefto } else { log::error "unknown constraint phrasing, \"$phrase\"" continue } set cde [relvar restrictone Config_DataError Relationship $rnum RefClass\ $refclass RefType $reftype] if {[relation isnotempty $cde]} { dict with tuple { log::error [subst -nocommands [relation extract $cde Format]] } } else { log::error "$line\n$tupline" } } else { break } } } else { log::error "unknown configuration error, \"$result\"" } } return } namespace eval DomainDef { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Config::ConfigEvaluate namespace import ::rosea::Helpers::DeclError proc class {name body} { namespace upvar [namespace current] DomainName DomainName ; # <1> namespace upvar ClassDef ClassName ClassName set ClassName $name if {![regexp {\A[[:alnum:]].*} $name]} { tailcall DeclError BAD_CLASS_NAME $name } try { relvar insert ::rosea::Config::DomainElement [list\ Domain $DomainName\ Element $name\ ] } trap {RAL relvar insert DUPLICATE_TUPLE} {} { tailcall DeclError DUP_ELEMENT_NAME $name } ; # <2> relvar insert ::rosea::Config::Class [list\ Domain $DomainName\ Name $name\ ] set instops [pipe { relvar set ::rosea::Config::SuppliedInstanceOperation | relation extend ~ ioptuple\ Domain string {[set DomainName]}\ Class string {[set ClassName]} }] relvar union ::rosea::Config::SystemInstanceOperation $instops relvar union ::rosea::Config::InstanceOperation $instops relvar union ::rosea::Config::Operation $instops set classops [pipe { relvar set ::rosea::Config::SuppliedClassOperation | relation extend ~ coptuple\ Domain string {[set DomainName]}\ Class string {[set ClassName]} }] relvar union ::rosea::Config::SystemClassOperation $classops relvar union ::rosea::Config::ClassOperation $classops relvar union ::rosea::Config::Operation $classops ConfigEvaluate [namespace current]::ClassDef $body } proc association {name source spec target args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } if {$name eq {}} { tailcall DeclError EMPTY_NAME association } if {[string index $name 0] eq "~"} { tailcall DeclError TILDE_NAME $name } # Obtain references to the domain and class context. namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName set associator {} set path {} foreach {option value} $args { switch -exact -- $option { -associator { set associator $value } -path { set path $value if {[llength $path] % 2 != 0} { tailcall DeclError ARG_FORMAT $path } } default { tailcall DeclError UNKNOWN_OPTION association $option } } } set cas [relvar restrictone ::rosea::Config::Config_AssocSpec Spec $spec] if {[relation isempty $cas]} { tailcall DeclError BAD_RELATIONSHIP_SPEC $spec } set needsassoc [relation extract $cas NeedsAssociator] if {$needsassoc && $associator eq {}} { tailcall DeclError NEED_ASSOCIATOR $spec } if {$source eq $target} { if {![relation extract $cas ReflexiveAllowed]} { tailcall DeclError REFLEXIVE_NOT_ALLOWED $spec } if {$needsassoc && $path eq {}} { tailcall DeclError NEED_REFLEXIVE_PATH $name $source $spec $target } } try { relvar insert ::rosea::Config::DomainElement [list\ Domain $DomainName\ Element $name\ ] } trap {RAL relvar insert DUPLICATE_TUPLE} {result opts} { tailcall DeclError DUP_ELEMENT_NAME $name } # Many relvars have tuples with the same heading, so we construct it # once here. set reltuple [list\ Domain $DomainName\ Name $name\ ] # Populate the data for a Relationship and Association since that # is what this command defines. relvar insert ::rosea::Config::Relationship $reltuple relvar insert ::rosea::Config::Association $reltuple # Populate the type of association we are dealing with. if {$associator eq {}} { relvar insert ::rosea::Config::SimpleAssociation $reltuple relvar insert ::rosea::Config::SimpleReferringClass [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ Conditionality [relation extract $cas ReferringCond]\ Multiplicity [relation extract $cas ReferringMult]\ ] relvar insert ::rosea::Config::ReferringClass [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ ] relvar insert ::rosea::Config::ClassRole [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ ] relvar insert ::rosea::Config::SimpleReferencedClass [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ Conditionality [relation extract $cas ReferencedCond]\ ] relvar insert ::rosea::Config::ReferencedClass [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ ] relvar insert ::rosea::Config::ClassRole [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ ] } else { relvar insert ::rosea::Config::Config_ClassAssoc [list\ Domain $DomainName\ Relationship $name\ AssocClass $associator\ SourceClass $source\ ] if {[llength $path] == 0} { relvar insert ::rosea::Config::Config_NonReflexiveAssoc [list\ Domain $DomainName\ Relationship $name\ AssocClass $associator\ SourceClass $source\ TargetClass $target\ ] } else { relvar insert ::rosea::Config::Config_ReflexiveAssoc [list\ Domain $DomainName\ Relationship $name\ AssocClass $associator\ SourceClass $source\ ] foreach {sourceattr targetattr} $path { relvar insert ::rosea::Config::Config_ReflexivePath [list\ Domain $DomainName\ Relationship $name\ AssocClass $associator\ SourceClass $source\ SourceAttr $sourceattr\ TargetAttr $targetattr\ ] } } relvar insert ::rosea::Config::ClassBasedAssociation $reltuple relvar insert ::rosea::Config::SourceClass [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ Conditionality [relation extract $cas ReferringCond]\ Multiplicity [relation extract $cas ReferringMult]\ ] relvar insert ::rosea::Config::ReferencedClass [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ ] relvar insert ::rosea::Config::ClassRole [list\ Domain $DomainName\ Class $source\ Relationship $name\ Role source\ ] relvar insert ::rosea::Config::TargetClass [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ Conditionality [relation extract $cas ReferencedCond]\ Multiplicity [relation extract $cas ReferencedMult]\ ] relvar insert ::rosea::Config::ReferencedClass [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ ] relvar insert ::rosea::Config::ClassRole [list\ Domain $DomainName\ Class $target\ Relationship $name\ Role target\ ] relvar insert ::rosea::Config::AssociatorClass [list\ Domain $DomainName\ Class $associator\ Relationship $name\ Role associator\ ] relvar insert ::rosea::Config::ReferringClass [list\ Domain $DomainName\ Class $associator\ Relationship $name\ Role associator\ ] relvar insert ::rosea::Config::ClassRole [list\ Domain $DomainName\ Class $associator\ Relationship $name\ Role associator\ ] } } proc generalization {name super args} { if {[llength $args] < 2} { tailcall DeclError TOO_FEW_SUBCLASSES [llength $args] } if {$name eq {}} { tailcall DeclError EMPTY_NAME generalization } if {[string index $name 0] eq "~"} { tailcall DeclError TILDE_NAME $name } namespace upvar ::rosea::Config::DomainDef DomainName DomainName try { relvar insert ::rosea::Config::DomainElement [list\ Domain $DomainName\ Element $name\ ] } trap {RAL relvar insert DUPLICATE_TUPLE} {result opts} { tailcall DeclError DUP_ELEMENT_NAME $name } set reltuple [list\ Domain $DomainName\ Name $name\ ] relvar insert ::rosea::Config::Relationship $reltuple relvar insert ::rosea::Config::Generalization $reltuple set supertuple [list\ Domain $DomainName\ Class $super\ Relationship $name\ Role target\ ] relvar insert ::rosea::Config::Superclass $supertuple relvar insert ::rosea::Config::ReferencedClass $supertuple relvar insert ::rosea::Config::ClassRole $supertuple set subtuple [dict create\ Domain $DomainName\ Relationship $name\ Role source\ ] foreach sub $args { dict set subtuple Class $sub relvar insert ::rosea::Config::Subclass $subtuple relvar insert ::rosea::Config::ReferringClass $subtuple relvar insert ::rosea::Config::ClassRole $subtuple } } proc assigner {rname body} { namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar AssignerDef\ RelationshipName RelationshipName\ multiClass multiClass\ multiIdNum multiIdNum\ InitialState InitialState\ DefaultTrans DefaultTrans set RelationshipName $rname set multiClass {} set multiIdNum 1 set InitialState {} set DefaultTrans {} try { ConfigEvaluate [namespace current]::AssignerDef $body if {$DefaultTrans eq {}} { set DefaultTrans CH } relvar insert ::rosea::Config::StateModel [list\ Domain $DomainName\ Model $rname\ InitialState $InitialState\ DefaultTrans $DefaultTrans\ ] set assigntuple [list\ Domain $DomainName\ Relationship $rname\ ] relvar insert ::rosea::Config::AssignerStateModel $assigntuple if {$multiClass eq {}} { relvar insert ::rosea::Config::SingleAssigner $assigntuple } else { lappend assigntuple Class $multiClass Number $multiIdNum relvar insert ::rosea::Config::MultipleAssigner $assigntuple } } on error {result opts} { log::error $result upvar #0 ::rosea::Config::errcount errcount incr errcount } } proc operation {name params body} { if {$name eq {}} { tailcall DeclError EMPTY_NAME operation } namespace upvar ::rosea::Config::DomainDef DomainName DomainName try { relvar insert ::rosea::Config::DomainElement [list\ Domain $DomainName\ Element $name\ ] } trap {RAL relvar insert DUPLICATE_TUPLE} {result opts} { tailcall DeclError DUP_ELEMENT_NAME $name } relvar insert ::rosea::Config::DomainOperation [list\ Domain $DomainName\ Name $name\ Parameters $params\ Body $body\ ] } namespace eval ClassDef { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Config::ConfigEvaluate namespace import ::rosea::Helpers::DeclError proc attribute {name type args} { if {$name eq {}} { tailcall DeclError EMPTY_NAME attribute } if {[string range $name 0 1] eq "__"} { tailcall DeclError RESERVED_NAME $name } if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName relvar insert ::rosea::Config::Attribute [list\ Domain $DomainName\ Class $ClassName\ Name $name\ Type $type\ ] foreach {option value} $args { switch -exact -- $option { -default { relvar insert ::rosea::Config::DefaultValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ ] relvar insert ::rosea::Config::UserSuppliedValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ Value $value\ ] } -system { if {$type ne "int"} { tailcall DeclError INT_TYPE_REQUIRED $type } if {![string is integer -strict $value]} { tailcall DeclError INT_VALUE_REQUIRED $value } relvar insert ::rosea::Config::DefaultValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ ] relvar insert ::rosea::Config::SystemSuppliedValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ StartValue $value\ ] } -generate { relvar insert ::rosea::Config::DefaultValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ ] relvar insert ::rosea::Config::GeneratedValue [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ Cmd $value\ ] } -id { relvar uinsert ::rosea::Config::Identifier [list\ Domain $DomainName\ Class $ClassName\ Number $value\ ] ; # <1> relvar insert ::rosea::Config::IdentifyingAttribute [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ Number $value\ ] } -check { relvar insert ::rosea::Config::ValueCheck [list\ Domain $DomainName\ Class $ClassName\ Attribute $name\ Expression $value\ ] } default { tailcall DeclError UNKNOWN_OPTION attribute $option } } } } proc reference {relname rclass args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName set refnum 1 set linkopts [list] foreach {option value} $args { switch -exact -- $option { -refid { set refnum $value } -link { if {[llength $value] < 1 || [llength $value] > 2} { tailcall DeclError ARG_FORMAT $value } lappend linkopts $value } default { tailcall DeclError UNKNOWN_OPTION reference $option } } } # We defer processing the link options until the end so as not # to impose an order on the -refid option. foreach linkopt $linkopts { lassign $linkopt referring referenced if {$referenced eq {}} { set referenced $referring } relvar insert ::rosea::Config::AttributeReference [list\ Domain $DomainName\ ReferringClass $ClassName\ ReferringAttribute $referring\ ReferringRole source\ ReferencedClass $rclass\ ReferencedAttribute $referenced\ ReferencedRole target\ ReferencedIdNumber $refnum\ Relationship $relname ] ; # <1> } } proc classop {name params body} { if {$name eq {}} { tailcall DeclError EMPTY_NAME "class operation" } elseif {[string first :: $name] != -1} { tailcall DeclError NS_QUALIFIERS $name } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName set sysop [relvar restrictone ::rosea::Config::Operation\ Domain $DomainName Class $ClassName Name $name] if {[relation isnotempty $sysop]} { tailcall DeclError DUP_OP_NAME $name } set optuple [list Domain $DomainName Class $ClassName Name $name] relvar insert ::rosea::Config::Operation $optuple relvar insert ::rosea::Config::ClassOperation $optuple lappend optuple Parameters $params Body $body relvar insert ::rosea::Config::UserClassOperation $optuple } proc instop {name params body} { if {$name eq {}} { tailcall DeclError EMPTY_NAME "instance operation" } elseif {[string first :: $name] != -1} { tailcall DeclError NS_QUALIFIERS $name } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName set sysop [relvar restrictone ::rosea::Config::Operation\ Domain $DomainName Class $ClassName Name $name] if {[relation isnotempty $sysop]} { tailcall DeclError DUP_OP_NAME $name } set optuple [list Domain $DomainName Class $ClassName Name $name] relvar insert ::rosea::Config::Operation $optuple relvar insert ::rosea::Config::InstanceOperation $optuple lappend optuple Parameters $params Body $body relvar insert ::rosea::Config::UserInstanceOperation $optuple } proc statemodel {body} { namespace upvar ::rosea::Config::DomainDef DomainName DomainName variable ClassName namespace upvar StateModelDef\ InitialState InitialState\ DefaultTrans DefaultTrans\ Terminals Terminals set InitialState {} set DefaultTrans {} set Terminals [list] try { ConfigEvaluate [namespace current]::StateModelDef $body if {$DefaultTrans eq {}} { set DefaultTrans CH } relvar insert ::rosea::Config::StateModel [list\ Domain $DomainName\ Model $ClassName\ InitialState $InitialState\ DefaultTrans $DefaultTrans\ ] relvar insert ::rosea::Config::InstanceStateModel [list\ Domain $DomainName\ Class $ClassName\ ] foreach terminal $Terminals { relvar updateone ::rosea::Config::State stup [list\ Domain $DomainName Model $ClassName Name $terminal] { tuple update $stup IsFinal true } } } on error {result opts} { log::error $result upvar #0 ::rosea::Config::errcount errcount incr errcount } } proc polymorphic {args} { namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName foreach polyevent $args { set eventtuple [list\ Domain $DomainName\ Model $ClassName\ Event $polyevent\ ] relvar insert ::rosea::Config::PolymorphicEvent $eventtuple relvar insert ::rosea::Config::DeferredEvent $eventtuple relvar insert ::rosea::Config::Event $eventtuple } return } namespace eval StateModelDef { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Config::ConfigEvaluate namespace import ::rosea::Helpers::DeclError proc state {name params body} { if {$name eq {}} { tailcall DeclError EMPTY_NAME state } if {$name in {@ CH IG}} { tailcall DeclError PSEUDO_STATE $name state } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName variable InitialState if {$InitialState eq {}} { set InitialState $name } relvar insert ::rosea::Config::State [list\ Domain $DomainName\ Model $ClassName\ Name $name\ Parameters $params\ Action $body\ IsFinal false\ ] relvar insert ::rosea::Config::StatePlace [list\ Domain $DomainName\ Model $ClassName\ Name $name\ ] return } proc transition {source - event -> target} { if {$event eq {}} { tailcall DeclError EMPTY_NAME event } if {$source in {CH IG}} { tailcall DeclError PSEUDO_STATE $source "transition source state" } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::ClassDef ClassName ClassName if {$source eq "@"} { if {$target in {CH IG}} { tailcall DeclError BAD_CREATION_TARGET $target } set cstuple [list\ Domain $DomainName\ Model $ClassName\ Name @\ ] relvar uinsert ::rosea::Config::CreationState $cstuple relvar uinsert ::rosea::Config::StatePlace $cstuple } set eventtuple [list\ Domain $DomainName\ Model $ClassName\ Event $event\ ] relvar uinsert ::rosea::Config::Event $eventtuple ; # <1> relvar uinsert ::rosea::Config::EffectiveEvent $eventtuple relvar uinsert ::rosea::Config::LocalEvent $eventtuple set tranrule [relvar restrictone ::rosea::Config::TransitionRule\ Name $target] set transtuple [list\ Domain $DomainName\ Model $ClassName\ State $source\ Event $event\ ] relvar insert ::rosea::Config::TransitionPlace $transtuple if {[relation isnotempty $tranrule]} { lappend transtuple TransRule $target set tpsubtype NonStateTransition } else { lappend transtuple NewState $target set tpsubtype StateTransition } relvar insert ::rosea::Config::$tpsubtype $transtuple return } proc initialstate {name} { if {$name eq {}} { tailcall DeclError EMPTY_NAME initialstate } if {$name in {@ CH IG}} { tailcall DeclError PSEUDO_STATE $name initialstate } variable InitialState $name return } proc defaulttrans {name} { if {$name ni {CH IG}} { tailcall DeclError EXPECTED_PSEUDO_STATE $name } variable DefaultTrans $name return } proc terminal {args} { variable Terminals ::struct::set add Terminals $args return } } } namespace eval AssignerDef { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Config::ConfigEvaluate namespace import ::rosea::Helpers::DeclError proc state {name params body} { if {$name eq {}} { tailcall DeclError EMPTY_NAME state } if {$name in {CH IG}} { tailcall DeclError PSEUDO_STATE $name state } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::AssignerDef\ RelationshipName RelationshipName variable InitialState if {$InitialState eq {}} { set InitialState $name } relvar insert ::rosea::Config::State [list\ Domain $DomainName\ Model $RelationshipName\ Name $name\ Parameters $params\ Action $body\ IsFinal false\ ] relvar insert ::rosea::Config::StatePlace [list\ Domain $DomainName\ Model $RelationshipName\ Name $name\ ] return } proc transition {source - event -> target} { if {$event eq {}} { tailcall DeclError EMPTY_NAME event } if {$source in {CH IG}} { tailcall DeclError PSEUDO_STATE $name "transition source state" } namespace upvar ::rosea::Config::DomainDef DomainName DomainName namespace upvar ::rosea::Config::DomainDef::AssignerDef\ RelationshipName RelationshipName set eventtuple [list\ Domain $DomainName\ Model $RelationshipName\ Event $event\ ] relvar uinsert ::rosea::Config::Event $eventtuple relvar uinsert ::rosea::Config::EffectiveEvent $eventtuple relvar uinsert ::rosea::Config::LocalEvent $eventtuple set tranrule [relvar restrictone ::rosea::Config::TransitionRule\ Name $target] set transtuple [list\ Domain $DomainName\ Model $RelationshipName\ State $source\ Event $event\ ] relvar insert ::rosea::Config::TransitionPlace $transtuple if {[relation isnotempty $tranrule]} { lappend transtuple TransRule $target set tpsubtype NonStateTransition } else { lappend transtuple NewState $target set tpsubtype StateTransition } relvar insert ::rosea::Config::$tpsubtype $transtuple return } proc initialstate {name} { if {$name eq {}} { tailcall DeclError EMPTY_NAME initialstate } if {$name in {CH IG}} { tailcall DeclError PSEUDO_STATE $name initialstate } variable InitialState $name return } proc defaulttrans {name} { if {$name ni {CH IG}} { tailcall DeclError EXPECTED_PSEUDO_STATE $name } variable DefaultTrans $name return } proc identifyby {name args} { if {[llength $args] % 2 != 0} { tailcall DeclError ARG_FORMAT $args } variable multiClass $name foreach {option value} $args { switch -exact -- $option { -id { variable multiIdNum $value } default { tailcall DeclError UNKNOWN_OPTION identifyby $option } } } return } } } } namespace eval Populate { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Config::ConfigEvaluate namespace import ::rosea::Helpers::DeclError proc domain {name body} { set domain [relvar restrictone ::rosea::Config::Domain Name $name] if {[relation isempty $domain]} { tailcall DeclError UNKNOWN_DOMAIN $domain } namespace upvar DomainPop DomainName DomainName DomainLoc DomainLoc relation assign $domain {Name DomainName} {Location DomainLoc} try { relvar eval { ConfigEvaluate [namespace current]::DomainPop $body } } on error {result opts} { log::error $result upvar #0 ::rosea::Config::errcount errcount incr errcount } } namespace eval DomainPop { logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path ::rosea::Helpers proc class {class heading args} { # Determine if we have one big list or a bunch of values. set popvalues [expr {[llength $args] == 1 ? [lindex $args 0] : $args}] set headlen [llength $heading] if {[llength $popvalues] % $headlen != 0} { tailcall DeclError ARG_MISMATCH $headlen [llength $popvalues] } # Iterate over the attribute values taking them in chunks that are the same # size as the heading. set body [list] for {set vindex 0} {$vindex < [llength $popvalues]} {incr vindex $headlen} { set values [lrange $popvalues $vindex [expr {$vindex + $headlen - 1}]] # Create a tuple as a list of attribute name / value pairs. set tuple [list] foreach attr $heading value $values { # Check if we are skipping a value to use a default. We must also # allow some way to specify the value as "-". if {$value eq "-"} { continue } elseif {$value eq "\\-"} { set value - } lappend tuple $attr $value } # Accumulate the tuples as a list to form the body that will be # inserted into the relvar. lappend body $tuple } # Insert the body into the relvar. namespace upvar [namespace current]\ DomainName DomainName\ DomainLoc DomainLoc set domns ${DomainLoc}::${DomainName} set relvar ${domns}::$class set insts [relvar insert $relvar {*}$body] # Now we have to deal with any state model that might be present. We have # to set up the initial state properly if such a thing exists for this # class. set idattrs [lindex [relvar identifiers $relvar] 0] relation foreach inst $insts { CreateInInitialState $domns $class [pipe { relation project $inst {*}$idattrs | relation tuple ~ | tuple get ~ }] } return [relation body $insts] } proc assigner {rname heading args} { # Determine if we have one big list or a bunch of values. set popvalues [expr {[llength $args] == 1 ? [lindex $args 0] : $args}] set headlen [llength $heading] if {[llength $popvalues] % $headlen != 0} { tailcall DeclError ARG_MISMATCH $headlen [llength $popvalues] } namespace upvar [namespace current]\ DomainName DomainName\ DomainLoc DomainLoc set domns ${DomainLoc}::${DomainName} set relvar ${domns}::${rname}__STATEINST set idattrs [lindex [relvar identifiers $relvar] 0] if {![struct::set equal $heading $idattrs]} { tailcall DeclError NO_IDENTIFIER $heading $idattrs } # Iterate over the attribute values taking them in chunks that are the same # size as the heading. for {set vindex 0} {$vindex < [llength $popvalues]} {incr vindex $headlen} { set values [lrange $popvalues $vindex [expr {$vindex + $headlen - 1}]] # Create a tuple as a list of attribute name / value pairs. We assume # the values are in the same order as the heading -- that is the point. set tuple [list] foreach attr $heading value $values { lappend tuple $attr $value } CreateInInitialState $domns $rname $tuple } return } } } namespace eval Info { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace import ::rosea::Helpers::DeclError proc domain {arglist} { set arglist [lassign $arglist subcmd domainname] set dominst [relvar restrictone ::rosea::Config::Domain Name $domainname] if {[relation isempty $dominst]} { tailcall DeclError UNKNOWN_DOMAIN $domainname } switch -exact -- $subcmd { classes { return [pipe { relvar set ::rosea::Config::Class | relation semijoin $dominst ~ -using {Name Domain} | relation list ~ Name }] } relationships { return [pipe { relvar set ::rosea::Config::Relationship | relation semijoin $dominst ~ -using {Name Domain} | relation list ~ Name }] } operations { return [FormatOpsInfo [pipe { relvar set ::rosea::Config::DomainOperation | relation semijoin $dominst ~ -using {Name Domain} | relation project ~ Name Parameters Body }]] } default { tailcall DeclError UNKNOWN_INFO_CMD $subcmd } } } proc FormatOpsInfo {ops} { set result [list] relation foreach op $ops { relation assign $op lappend result $Name $Parameters $Body } return $result } proc class {arglist} { set arglist [lassign $arglist subcmd domainname classname] set dominst [relvar restrictone ::rosea::Config::Domain Name $domainname] if {[relation isempty $dominst]} { tailcall DeclError UNKNOWN_DOMAIN $domainname } set classinst [pipe { relvar set ::rosea::Config::Class | relation semijoin $dominst ~ -using {Name Domain} | relation restrictwith ~ {$Name eq $classname} }] if {[relation isempty $classinst]} { tailcall DeclError UNKNOWN_CLASS $classname $domainname } switch -exact -- $subcmd { attributes { return [pipe { relvar set ::rosea::Config::Attribute | relation semijoin $classinst ~ -using {Domain Domain Name Class} | relation dict ~ Name Type }] } classops { return [FormatOpsInfo [pipe { relvar set ::rosea::Config::UserClassOperation | relation semijoin $classinst ~ -using {Domain Domain Name Class} | relation project ~ Name Parameters Body }]] } instops { return [FormatOpsInfo [pipe { relvar set ::rosea::Config::UserInstanceOperation | relation semijoin $classinst ~ -using {Domain Domain Name Class} | relation project ~ Name Parameters Body }]] } default { tailcall DeclError UNKNOWN_INFO_CMD $subcmd } } } proc statemodel {arglist} { set arglist [lassign $arglist subcmd domainname classname statename] set dominst [relvar restrictone ::rosea::Config::Domain Name $domainname] if {[relation isempty $dominst]} { tailcall DeclError UNKNOWN_DOMAIN $domainname } set domns [string cat [relation extract $dominst Location] :: $domainname] set classinst [pipe { relvar set ::rosea::Config::Class | relation semijoin $dominst ~ -using {Name Domain} | relation restrictwith ~ {$Name eq $classname} }] if {[relation isempty $classinst]} { tailcall DeclError UNKNOWN_CLASS $classname $domainname } switch -exact -- $subcmd { states { set states [pipe { relvar set ::rosea::Config::State | relation restrictwith ~\ {$Domain eq $domainname && $Model eq $classname} | relation project ~ Name Parameters Action }] set result [list] relation foreach state $states { relation assign $state lappend result $Name $Parameters $Action } return $result } events { return [pipe { relvar set ::rosea::Config::EffectiveEvent | relation restrictwith ~\ {$Domain eq $domainname && $Model eq $classname} | relation list ~ Event }] } transitions { return [pipe { relvar set ${domns}::__Arch_Transition | relation restrictwith ~ {$Class eq $classname} | relation eliminate ~ Class | relation group ~ Transition Event NewState | relation extend ~ trtup TranCol dict { [relation dict [tuple extract $trtup Transition] Event NewState]} | relation dict ~ State TranCol }] ; # <1> } activityproc { return ${domns}::${classname}::__Activity::${statename} } } } } namespace eval Trace { namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ::ralutil::pipe namespace import ::ral::relvar namespace path [list\ [namespace parent]::Helpers\ [namespace parent]::InstCmds\ ] relvar create Trace { Trace_Id int Timestamp bignum Source list Event string Target list Params list } Trace_Id relvar create Creation { Trace_Id int } Trace_Id relvar create Polymorphic { Trace_Id int SubInst string Linkage string } Trace_Id relvar create Transition { Trace_Id int CurrState string NewState string } Trace_Id relvar partition R1 Trace Trace_Id\ Creation Trace_Id\ Polymorphic Trace_Id\ Transition Trace_Id variable targetCmpFunc [lambda {instrefs target} { lassign $target trelvar tinst foreach instref $instrefs { lassign $instref crelvar cinst if {$trelvar eq $crelvar && [ral relation is $tinst subsetof $cinst]} { return true } } return false }] variable traceState off variable traceNumber 0 variable traceLogState off variable traceLogLevel info variable traceLogCmd [::logger::init rosea] proc QueryClassTraces {classes} { variable Trace return [relation restrictwith $Trace { [lindex $Target 0] in $classes ||\ [namespace tail [lindex $Target 0]] in $classes }] ; # <1> } proc QueryTargetTraces {targets} { variable Trace variable targetCmpFunc return [relation restrictwith $Trace {[{*}$targetCmpFunc $targets $Target]}] } proc TraceCreation {source event target params} { variable traceState if {$traceState} { relvar eval { set trace [NewTrace $source $event $target $params] relvar insert Creation [list\ Trace_Id [relation extract $trace Trace_Id]\ ] } LogTrace $trace } } proc TracePolymorphic {source event target sub link params} { variable traceState if {$traceState} { relvar eval { set trace [NewTrace $source $event $target $params] relvar insert Polymorphic [list\ Trace_Id [relation extract $trace Trace_Id]\ SubInst $sub\ Linkage $link\ ] } LogTrace $trace } } proc TraceTransition {source event target curr new params} { variable traceState if {$traceState} { relvar eval { set trace [NewTrace $source $event $target $params] relvar insert Transition [list\ Trace_Id [relation extract $trace Trace_Id]\ CurrState $curr\ NewState $new\ ] } LogTrace $trace } } proc NewTrace {src event target params} { variable traceNumber return [relvar insert Trace [list\ Trace_Id [incr traceNumber]\ Timestamp [clock microseconds]\ Source $src\ Event $event\ Target $target\ Params $params\ ]] } proc LogTrace {trace} { variable traceLogState if {$traceLogState} { set rec [FormatTraceRec [lindex [TracesToRecords $trace] 0]] ; # <1> variable traceLogCmd variable traceLogLevel ${traceLogCmd}::${traceLogLevel} $rec } } proc TracesToRecords {traces} { foreach rvname {Creation Polymorphic Transition} { # <1> set traces [::ralutil::rvajoin $traces [relvar set $rvname] $rvname] } set result [list] relation foreach trace $traces -ascending Trace_Id { # <2> relation assign $trace set labeled [dict create\ id $Trace_Id\ time $Timestamp\ source $Source\ event $Event\ target $Target\ params $Params\ class [lindex $Target 0]\ ] ; # <3> if {[relation isnotempty $Transition]} { # <4> relation assign $Transition dict set labeled type transition dict set labeled current $CurrState dict set labeled new $NewState } elseif {[relation isnotempty $Polymorphic]} { relation assign $Polymorphic dict set labeled type polymorphic dict set labeled sub $SubInst dict set labeled link $Linkage } elseif {[relation isnotempty $Creation]} { dict set labeled type creation } lappend result $labeled } return $result } proc DecodeAllTraces {} { variable Trace tailcall TracesToRecords $Trace } proc DecodeClassTraces {args} { return [TracesToRecords [QueryClassTraces $args]] } proc DecodeTargetTraces {args} { tailcall TracesToRecords [QueryTargetTraces $args] } proc FormatTraceRec {rec} { dict with rec { switch -exact -- $type { transition { append result\ "Transition: "\ [FormatTransition $source $event $params $target]\ " ==> $current -> $new" } polymorphic { append result\ "Polymorphic : "\ [FormatTransition $source $event $params $target]\ " ==> $link -> [FormatInstRef $sub]" } creation { append result\ "Creation: "\ "[FormatInstRef $source] - "\ "[FormatEvent $event $params] -> $class\ " ==> [FormatInstRef $target]" } default { DeclError BAD_TRACETYPE $type } } } return $result } proc FormatTransition {source event params target} { return "[FormatInstRef $source] - [FormatEvent $event $params] ->\ [FormatInstRef $target]" } proc FormatEvent {event params} { return [string cat\ "$event"\ [expr {[llength $params] != 0 ? " \([join $params {, }]\)" : {}}]\ ] } proc FormatInstRef {instref} { lassign $instref relvar inst if {$relvar eq {}} { return {()} } else { return "$relvar \([tuple get [relation tuple $inst]]\)" } } proc FormatTimestamp {time} { set sec [clock format [expr {$time / 1000000}] -format %T] ; # <1> set time [expr {$time % 1000000}] set msec [expr {$time / 1000}] set usec [expr {$time % 1000}] return [format %s.%03ld.%03ld $sec $msec $usec] } proc FormatTimeAsSec {time} { set sec [expr {$time / 1000000}] set time [expr {$time % 1000000}] set msec [expr {$time / 1000}] set usec [expr {$time % 1000}] return [format %3ld.%03ld.%03ld $sec $msec $usec] } proc DiagTraces {traces args} { set result {} append result "seqdiag \{\n" append result " activation = none;\n" foreach {option value} $args { append result " $option = $value;\n" } foreach rvname {Creation Polymorphic Transition} { set traces [::ralutil::rvajoin $traces [relvar set $rvname] $rvname] } relation foreach trace $traces -ascending Trace_Id { relation assign $trace if {[isEmptyRef $Source]} { set Source EXTERNAL } else { set Source [namespace tail [lindex $Source 0]] } set Target [namespace tail [lindex $Target 0]] set evtlabel [FormatEvent $Event $Params] if {[relation isnotempty $Polymorphic]} { relation assign $Polymorphic Linkage append evtlabel " <<Polymorphic $Linkage>>" } elseif {[relation isnotempty $Creation]} { append evtlabel " <<Creation>>" } append result " $Source ->> $Target \[label=\"$evtlabel\"\];\n" } append result "\}\n" return $result } proc DiagAllTraces {filename args} { set chan [open $filename w] variable Trace try { chan puts $chan [DiagTraces $Trace {*}$args] } finally { chan close $chan } return } proc DiagClassTraces {filename classes args} { set chan [open $filename w] try { chan puts $chan [DiagTraces [QueryClassTraces $classes] {*}$args] } finally { chan close $chan } return } proc DiagTargetTraces {filename targets args} { set chan [open $filename w] try { chan puts $chan [DiagTraces [QueryTargetTraces $targets] {*}$args] } finally { chan close $chan } return } } namespace path ::rosea::Helpers namespace import ::rosea::Config::ConfigEvaluate } package provide rosea $::rosea::version |
Changes to rosea/doc/rosea.html.
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
...
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
<!-- Generated from file 'rosea.man' by tcllib/doctools with format 'html'
-->
<!-- Copyright &copy; 2014-2020 by G. Andrew Mangogna
-->
<!-- rosea.n
-->
<body><div class="doctools">
<h1 class="doctools_title">rosea(n) 1.9 rosea "XUML Data and Execution Architecture"</h1>
<div id="name" class="doctools_section"><h2><a name="name">Name</a></h2>
<p>rosea - Relation Oriented Software Execution Architecture</p>
</div>
<div id="toc" class="doctools_section"><h2><a name="toc">Table Of Contents</a></h2>
<ul class="doctools_toc">
<li class="doctools_section"><a href="#toc">Table Of Contents</a></li>
<li class="doctools_section"><a href="#synopsis">Synopsis</a></li>
................................................................................
</li>
<li class="doctools_section"><a href="#copyright">Copyright</a></li>
</ul>
</div>
<div id="synopsis" class="doctools_section"><h2><a name="synopsis">Synopsis</a></h2>
<div class="doctools_synopsis">
<ul class="doctools_requirements">
<li>package require <b class="pkgname">rosea <span class="opt">?1.9?</span></b></li>
</ul>
<ul class="doctools_syntax">
<li>Package Commands</li>
<li><a href="#1"><b class="cmd">::rosea configure</b> <i class="arg">script</i></a></li>
<li><a href="#2"><b class="cmd">::rosea configureFromChan</b> <i class="arg">channel</i></a></li>
<li><a href="#3"><b class="cmd">::rosea configureFromFile</b> <i class="arg">filename</i></a></li>
<li><a href="#4"><b class="cmd">::rosea generate</b> <span class="opt">?<i class="arg">pattern</i>?</span> <span class="opt">?<i class="arg">nsqual</i>?</span></a></li>
|
|
|
|
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
...
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
<!-- Generated from file 'rosea.man' by tcllib/doctools with format 'html' --> <!-- Copyright &copy; 2014-2020 by G. Andrew Mangogna --> <!-- rosea.n --> <body><div class="doctools"> <h1 class="doctools_title">rosea(n) 1.9.1 rosea "XUML Data and Execution Architecture"</h1> <div id="name" class="doctools_section"><h2><a name="name">Name</a></h2> <p>rosea - Relation Oriented Software Execution Architecture</p> </div> <div id="toc" class="doctools_section"><h2><a name="toc">Table Of Contents</a></h2> <ul class="doctools_toc"> <li class="doctools_section"><a href="#toc">Table Of Contents</a></li> <li class="doctools_section"><a href="#synopsis">Synopsis</a></li> ................................................................................ </li> <li class="doctools_section"><a href="#copyright">Copyright</a></li> </ul> </div> <div id="synopsis" class="doctools_section"><h2><a name="synopsis">Synopsis</a></h2> <div class="doctools_synopsis"> <ul class="doctools_requirements"> <li>package require <b class="pkgname">rosea <span class="opt">?1.9.1?</span></b></li> </ul> <ul class="doctools_syntax"> <li>Package Commands</li> <li><a href="#1"><b class="cmd">::rosea configure</b> <i class="arg">script</i></a></li> <li><a href="#2"><b class="cmd">::rosea configureFromChan</b> <i class="arg">channel</i></a></li> <li><a href="#3"><b class="cmd">::rosea configureFromFile</b> <i class="arg">filename</i></a></li> <li><a href="#4"><b class="cmd">::rosea generate</b> <span class="opt">?<i class="arg">pattern</i>?</span> <span class="opt">?<i class="arg">nsqual</i>?</span></a></li> |
Changes to rosea/doc/rosea.pdf.
cannot compute difference between binary files
Changes to rosea/src/Makefile.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
vpath %.pdf $(DOCDIR) vpath %.html $(DOCDIR) vpath %.test $(TESTDIR) vpath %.uxf $(IMAGEDIR) PROGNAME = rosea VERSION=1.9 DOCSRC =\ $(PROGNAME).aweb\ $(NULL) DIAGRAMS =\ assoc-link.uxf\ |
| |
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
vpath %.pdf $(DOCDIR)
vpath %.html $(DOCDIR)
vpath %.test $(TESTDIR)
vpath %.uxf $(IMAGEDIR)
PROGNAME = rosea
VERSION=1.9.1
DOCSRC =\
$(PROGNAME).aweb\
$(NULL)
DIAGRAMS =\
assoc-link.uxf\
|
Changes to rosea/src/rosea-docinfo.xml.
259 260 261 262 263 264 265 266 |
<revremark> Corrected a problem with polymorphic event dispatch across repeated generalizations. Dispatch only happened on the first level of a multi-level hierarchy. Corrected problems in formatting the polymorphic event traces. </revremark> </revision> </revhistory> |
> > > > > > > > > > > > > > > |
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
<revremark> Corrected a problem with polymorphic event dispatch across repeated generalizations. Dispatch only happened on the first level of a multi-level hierarchy. Corrected problems in formatting the polymorphic event traces. </revremark> </revision> <revision> <revnumber>1.9.1</revnumber> <date>May 6, 2020</date> <authorinitials>GAM</authorinitials> <revremark> Corrected a problem with generation of seqdiag output for polymorphic events. Minor changes in the formatting of event traces. Changed the tracing of a cascade of repeated polymorphic events so that the target of the previous event polymorphic event becomes the source for the next one. Previously, all polymorphic events appear to have originated from the source instance of the first one. </revremark> </revision> </revhistory> |
Changes to rosea/src/rosea.aweb.
7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 ..... 21315 21316 21317 21318 21319 21320 21321 21322 21323 21324 21325 21326 21327 21328 21329 21330 21331 21332 21333 21334 21335 21336 21337 21338 21339 21340 21341 21342 21343 21344 ..... 21415 21416 21417 21418 21419 21420 21421 21422 21423 21424 21425 21426 21427 21428 21429 ..... 23152 23153 23154 23155 23156 23157 23158 23159 23160 23161 23162 23163 23164 23165 23166 ..... 23176 23177 23178 23179 23180 23181 23182 23183 23184 23185 23186 23187 23188 23189 23190 ..... 23290 23291 23292 23293 23294 23295 23296 23297 23298 23299 23300 23301 23302 23303 23304 23305 23306 23307 23308 23309 23310 23311 |
set related [relation semijoin $inst\ [relvar set ${domain}::$DstClass] -using $Attrs] if {[relation isnotempty $related]} { set dstreference [ToRef ${domain}::${DstClass} $related] set target [ToRef $dstrelvar $inst] ::rosea::Trace::TracePolymorphic $srcref $event $target $dstreference $Name\ $arglist if {![MapPolymorphicEvent $frwdcmd $srcref $dstreference $event $arglist]} { {*}$frwdcmd $srcref $dstreference $event $arglist ; # <1> } break } ---- <1> The forward command prefix will either be +SignalEvent+ or +SignalDelayedEvent <time>+ depending whether we arrived here via the +signal+ instance command or the +delaysignal+ instance command. ................................................................................ (((rosea,Trace,FormatEvent))) [source,tcl] ---- <<trace commands>>= proc FormatEvent {event params} { return [string cat\ $event\ [expr {[llength $params] != 0 ? "\([join $params {, }]\)" : {}}]\ ] } ---- (((rosea,Trace,FormatInstRef))) [source,tcl] ---- <<trace commands>>= proc FormatInstRef {instref} { lassign $instref relvar inst if {$relvar eq {}} { return {{}} } else { return "$relvar\{[tuple get [relation tuple $inst]]\}" } } ---- (((error code,BAD_TRACETYPE))) [source,tcl] ---- ................................................................................ set Source EXTERNAL } else { set Source [namespace tail [lindex $Source 0]] } set Target [namespace tail [lindex $Target 0]] set evtlabel [FormatEvent $Event $Params] if {[relation isnotempty $Polymorphic]} { relation assign $Transition Linkage append evtlabel " <<Polymorphic $Linkage>>" } elseif {[relation isnotempty $Creation]} { append evtlabel " <<Creation>>" } append result " $Source ->> $Target \[label=\"$evtlabel\"\];\n" } ................................................................................ proc ::K {x y} {set x} namespace eval ::rosea { <<rosea exports>> namespace ensemble create variable version 1.9 logger::initNamespace [namespace current] <<tclral imports>> namespace import ::ral::relvar <<rosea data>> <<rosea commands>> ................................................................................ === Package Index We also provide a root chunk to extract a package index file. [source,tcl] ---- <<pkgIndex.tcl>>= package ifneeded rosea 1.9 [list source [file join $dir rosea.tcl]] ---- === Unit Tests [source,tcl] ---- <<rosea.test>>= ................................................................................ ---- === Reference Documentation [source,tcl] ---- <<rosea.man>>= [manpage_begin rosea n 1.9] [comment { <<copyright info>> }] [moddesc "XUML Data and Execution Architecture"] [titledesc "Relation Oriented Software Execution Architecture"] [copyright "2014-2020 by G. Andrew Mangogna"] [require rosea [opt 1.9]] [description] <<manual description>> [section "Package Commands"] The commands in this section are part of the ensemble command [cmd ::rosea]. Their use is to configure, generate and populate domains and to control state machine tracing during run time. [list_begin definitions] |
| | | | | | | | | | | |
7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 ..... 21315 21316 21317 21318 21319 21320 21321 21322 21323 21324 21325 21326 21327 21328 21329 21330 21331 21332 21333 21334 21335 21336 21337 21338 21339 21340 21341 21342 21343 21344 ..... 21415 21416 21417 21418 21419 21420 21421 21422 21423 21424 21425 21426 21427 21428 21429 ..... 23152 23153 23154 23155 23156 23157 23158 23159 23160 23161 23162 23163 23164 23165 23166 ..... 23176 23177 23178 23179 23180 23181 23182 23183 23184 23185 23186 23187 23188 23189 23190 ..... 23290 23291 23292 23293 23294 23295 23296 23297 23298 23299 23300 23301 23302 23303 23304 23305 23306 23307 23308 23309 23310 23311 |
set related [relation semijoin $inst\ [relvar set ${domain}::$DstClass] -using $Attrs] if {[relation isnotempty $related]} { set dstreference [ToRef ${domain}::${DstClass} $related] set target [ToRef $dstrelvar $inst] ::rosea::Trace::TracePolymorphic $srcref $event $target $dstreference $Name\ $arglist if {![MapPolymorphicEvent $frwdcmd $target $dstreference $event $arglist]} { {*}$frwdcmd $target $dstreference $event $arglist ; # <1> } break } ---- <1> The forward command prefix will either be +SignalEvent+ or +SignalDelayedEvent <time>+ depending whether we arrived here via the +signal+ instance command or the +delaysignal+ instance command. ................................................................................ (((rosea,Trace,FormatEvent))) [source,tcl] ---- <<trace commands>>= proc FormatEvent {event params} { return [string cat\ "$event"\ [expr {[llength $params] != 0 ? " \([join $params {, }]\)" : {}}]\ ] } ---- (((rosea,Trace,FormatInstRef))) [source,tcl] ---- <<trace commands>>= proc FormatInstRef {instref} { lassign $instref relvar inst if {$relvar eq {}} { return {()} } else { return "$relvar \([tuple get [relation tuple $inst]]\)" } } ---- (((error code,BAD_TRACETYPE))) [source,tcl] ---- ................................................................................ set Source EXTERNAL } else { set Source [namespace tail [lindex $Source 0]] } set Target [namespace tail [lindex $Target 0]] set evtlabel [FormatEvent $Event $Params] if {[relation isnotempty $Polymorphic]} { relation assign $Polymorphic Linkage append evtlabel " <<Polymorphic $Linkage>>" } elseif {[relation isnotempty $Creation]} { append evtlabel " <<Creation>>" } append result " $Source ->> $Target \[label=\"$evtlabel\"\];\n" } ................................................................................ proc ::K {x y} {set x} namespace eval ::rosea { <<rosea exports>> namespace ensemble create variable version 1.9.1 logger::initNamespace [namespace current] <<tclral imports>> namespace import ::ral::relvar <<rosea data>> <<rosea commands>> ................................................................................ === Package Index We also provide a root chunk to extract a package index file. [source,tcl] ---- <<pkgIndex.tcl>>= package ifneeded rosea 1.9.1 [list source [file join $dir rosea.tcl]] ---- === Unit Tests [source,tcl] ---- <<rosea.test>>= ................................................................................ ---- === Reference Documentation [source,tcl] ---- <<rosea.man>>= [manpage_begin rosea n 1.9.1] [comment { <<copyright info>> }] [moddesc "XUML Data and Execution Architecture"] [titledesc "Relation Oriented Software Execution Architecture"] [copyright "2014-2020 by G. Andrew Mangogna"] [require rosea [opt 1.9.1]] [description] <<manual description>> [section "Package Commands"] The commands in this section are part of the ensemble command [cmd ::rosea]. Their use is to configure, generate and populate domains and to control state machine tracing during run time. [list_begin definitions] |
Changes to rosea/src/rosea.tcl.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 .... 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 .... 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 .... 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 |
namespace export tunnel namespace export trace namespace ensemble create variable version 1.9 logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ................................................................................ set related [relation semijoin $inst\ [relvar set ${domain}::$DstClass] -using $Attrs] if {[relation isnotempty $related]} { set dstreference [ToRef ${domain}::${DstClass} $related] set target [ToRef $dstrelvar $inst] ::rosea::Trace::TracePolymorphic $srcref $event $target $dstreference $Name\ $arglist if {![MapPolymorphicEvent $frwdcmd $srcref $dstreference $event $arglist]} { {*}$frwdcmd $srcref $dstreference $event $arglist ; # <1> } break } } } } ................................................................................ } proc FormatTransition {source event params target} { return "[FormatInstRef $source] - [FormatEvent $event $params] ->\ [FormatInstRef $target]" } proc FormatEvent {event params} { return [string cat\ $event\ [expr {[llength $params] != 0 ? "\([join $params {, }]\)" : {}}]\ ] } proc FormatInstRef {instref} { lassign $instref relvar inst if {$relvar eq {}} { return {{}} } else { return "$relvar\{[tuple get [relation tuple $inst]]\}" } } proc FormatTimestamp {time} { set sec [clock format [expr {$time / 1000000}] -format %T] ; # <1> set time [expr {$time % 1000000}] set msec [expr {$time / 1000}] set usec [expr {$time % 1000}] ................................................................................ set Source EXTERNAL } else { set Source [namespace tail [lindex $Source 0]] } set Target [namespace tail [lindex $Target 0]] set evtlabel [FormatEvent $Event $Params] if {[relation isnotempty $Polymorphic]} { relation assign $Transition Linkage append evtlabel " <<Polymorphic $Linkage>>" } elseif {[relation isnotempty $Creation]} { append evtlabel " <<Creation>>" } append result " $Source ->> $Target \[label=\"$evtlabel\"\];\n" } |
| | | | | | | | |
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 .... 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 .... 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 .... 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 |
namespace export tunnel namespace export trace namespace ensemble create variable version 1.9.1 logger::initNamespace [namespace current] namespace import\ ::ral::relation\ ::ral::tuple\ ::ral::relformat\ ................................................................................ set related [relation semijoin $inst\ [relvar set ${domain}::$DstClass] -using $Attrs] if {[relation isnotempty $related]} { set dstreference [ToRef ${domain}::${DstClass} $related] set target [ToRef $dstrelvar $inst] ::rosea::Trace::TracePolymorphic $srcref $event $target $dstreference $Name\ $arglist if {![MapPolymorphicEvent $frwdcmd $target $dstreference $event $arglist]} { {*}$frwdcmd $target $dstreference $event $arglist ; # <1> } break } } } } ................................................................................ } proc FormatTransition {source event params target} { return "[FormatInstRef $source] - [FormatEvent $event $params] ->\ [FormatInstRef $target]" } proc FormatEvent {event params} { return [string cat\ "$event"\ [expr {[llength $params] != 0 ? " \([join $params {, }]\)" : {}}]\ ] } proc FormatInstRef {instref} { lassign $instref relvar inst if {$relvar eq {}} { return {()} } else { return "$relvar \([tuple get [relation tuple $inst]]\)" } } proc FormatTimestamp {time} { set sec [clock format [expr {$time / 1000000}] -format %T] ; # <1> set time [expr {$time % 1000000}] set msec [expr {$time / 1000}] set usec [expr {$time % 1000}] ................................................................................ set Source EXTERNAL } else { set Source [namespace tail [lindex $Source 0]] } set Target [namespace tail [lindex $Target 0]] set evtlabel [FormatEvent $Event $Params] if {[relation isnotempty $Polymorphic]} { relation assign $Polymorphic Linkage append evtlabel " <<Polymorphic $Linkage>>" } elseif {[relation isnotempty $Creation]} { append evtlabel " <<Creation>>" } append result " $Source ->> $Target \[label=\"$evtlabel\"\];\n" } |
Changes to rosea/src/teapot.txt.
1 2 3 4 5 6 7 8 |
Package rosea 1.9 Meta description Rosea is a data and execution architecture for Meta description translating XUML models using Tcl as the implementation Meta description language. Meta entrysource rosea.tcl Meta included rosea.tcl Meta platform tcl Meta require {Tcl 8.6} |
| |
1 2 3 4 5 6 7 8 |
Package rosea 1.9.1
Meta description Rosea is a data and execution architecture for
Meta description translating XUML models using Tcl as the implementation
Meta description language.
Meta entrysource rosea.tcl
Meta included rosea.tcl
Meta platform tcl
Meta require {Tcl 8.6}
|