00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef UTILITIES_H
00012 #define UTILITIES_H
00013
00014 #include <stdio.h>
00015 #include "yapi.h"
00016 #include "vya.h"
00017
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 template<class FORK2>
00035
00036 class fork2: public Process
00037 {
00038 public:
00039
00040 fork2 (
00041 Id n,
00042 In<FORK2>& inF,
00043 Out<FORK2>& out1F,
00044 Out<FORK2>& out2F
00045 )
00046 :
00047
00048
00049 Process(n),
00050
00051
00052 inP(id("in"), inF),
00053 out1P(id("out1"), out1F),
00054 out2P(id("out2"), out2F)
00055 { }
00056
00057 const char* type() const { return "fork2"; }
00058 void main() {
00059 while(true) {
00060 read(inP, in);
00061 write(out1P, in);
00062 write(out2P, in);
00063 }
00064 }
00065
00066 private:
00067
00068 InPort<FORK2> inP;
00069 OutPort<FORK2> out1P;
00070 OutPort<FORK2> out2P;
00071
00072
00073 FORK2 in;
00074 };
00075
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 template<class FORK3>
00094
00095 class fork3: public Process
00096 {
00097 public:
00098
00099 fork3 (
00100 Id n,
00101 In<FORK3>& inF,
00102 Out<FORK3>& out1F,
00103 Out<FORK3>& out2F,
00104 Out<FORK3>& out3F
00105 )
00106 :
00107
00108
00109 Process(n),
00110
00111
00112 inP(id("in"), inF),
00113 out1P(id("out1"), out1F),
00114 out2P(id("out2"), out2F),
00115 out3P(id("out3"), out3F)
00116 { }
00117
00118 const char* type() const { return "fork3"; }
00119 void main() {
00120 while(true) {
00121 read(inP, in);
00122 write(out1P, in);
00123 write(out2P, in);
00124 write(out3P, in);
00125 }
00126 }
00127
00128 private:
00129
00130 InPort<FORK3> inP;
00131 OutPort<FORK3> out1P;
00132 OutPort<FORK3> out2P;
00133 OutPort<FORK3> out3P;
00134
00135
00136 FORK3 in;
00137 };
00138
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157 template<class FORK4>
00158
00159 class fork4: public Process
00160 {
00161 public:
00162
00163 fork4 (
00164 Id n,
00165 In<FORK4>& inF,
00166 Out<FORK4>& out1F,
00167 Out<FORK4>& out2F,
00168 Out<FORK4>& out3F,
00169 Out<FORK4>& out4F
00170 )
00171 :
00172
00173
00174 Process(n),
00175
00176
00177 inP(id("in"), inF),
00178 out1P(id("out1"), out1F),
00179 out2P(id("out2"), out2F),
00180 out3P(id("out3"), out3F),
00181 out4P(id("out4"), out4F)
00182 { }
00183
00184
00185 const char* type() const { return "fork4"; }
00186 void main() {
00187 while(true) {
00188 read(inP, in);
00189 write(out1P, in);
00190 write(out2P, in);
00191 write(out3P, in);
00192 write(out4P, in);
00193 }
00194 }
00195
00196 private:
00197
00198 InPort<FORK4> inP;
00199 OutPort<FORK4> out1P;
00200 OutPort<FORK4> out2P;
00201 OutPort<FORK4> out3P;
00202 OutPort<FORK4> out4P;
00203
00204
00205 FORK4 in;
00206 };
00207
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227 template<class FORK5>
00228
00229 class fork5: public Process
00230 {
00231 public:
00232
00233 fork5 (
00234 Id n,
00235 In<FORK5>& inF,
00236 Out<FORK5>& out1F,
00237 Out<FORK5>& out2F,
00238 Out<FORK5>& out3F,
00239 Out<FORK5>& out4F,
00240 Out<FORK5>& out5F
00241 )
00242 :
00243
00244
00245 Process(n),
00246
00247
00248 inP(id("in"), inF),
00249 out1P(id("out1"), out1F),
00250 out2P(id("out2"), out2F),
00251 out3P(id("out3"), out3F),
00252 out4P(id("out4"), out4F),
00253 out5P(id("out5"), out5F)
00254 { }
00255
00256
00257 const char* type() const { return "fork5"; }
00258 void main() {
00259 while(true) {
00260 read(inP, in);
00261 write(out1P, in);
00262 write(out2P, in);
00263 write(out3P, in);
00264 write(out4P, in);
00265 write(out5P, in);
00266 }
00267 }
00268
00269 private:
00270
00271 InPort<FORK5> inP;
00272 OutPort<FORK5> out1P;
00273 OutPort<FORK5> out2P;
00274 OutPort<FORK5> out3P;
00275 OutPort<FORK5> out4P;
00276 OutPort<FORK5> out5P;
00277
00278
00279 FORK5 in;
00280 };
00281
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299 template<class FORK6>
00300
00301 class fork6: public Process
00302 {
00303 public:
00304
00305 fork6 (
00306 Id n,
00307 In<FORK6>& inF,
00308 Out<FORK6>& out1F,
00309 Out<FORK6>& out2F,
00310 Out<FORK6>& out3F,
00311 Out<FORK6>& out4F,
00312 Out<FORK6>& out5F,
00313 Out<FORK6>& out6F
00314 )
00315 :
00316
00317
00318 Process(n),
00319
00320
00321 inP(id("in"), inF),
00322 out1P(id("out1"), out1F),
00323 out2P(id("out2"), out2F),
00324 out3P(id("out3"), out3F),
00325 out4P(id("out4"), out4F),
00326 out5P(id("out5"), out5F),
00327 out6P(id("out6"), out6F)
00328 { }
00329
00330
00331 const char* type() const { return "fork6"; }
00332 void main() {
00333 while(true) {
00334 read(inP, in);
00335 write(out1P, in);
00336 write(out2P, in);
00337 write(out3P, in);
00338 write(out4P, in);
00339 write(out5P, in);
00340 write(out6P, in);
00341 }
00342 }
00343
00344 private:
00345
00346 InPort<FORK6> inP;
00347 OutPort<FORK6> out1P;
00348 OutPort<FORK6> out2P;
00349 OutPort<FORK6> out3P;
00350 OutPort<FORK6> out4P;
00351 OutPort<FORK6> out5P;
00352 OutPort<FORK6> out6P;
00353
00354
00355 FORK6 in;
00356 };
00357
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376 template<class FORK7>
00377
00378 class fork7: public Process
00379 {
00380 public:
00381
00382 fork7 (
00383 Id n,
00384 In<FORK7>& inF,
00385 Out<FORK7>& out1F,
00386 Out<FORK7>& out2F,
00387 Out<FORK7>& out3F,
00388 Out<FORK7>& out4F,
00389 Out<FORK7>& out5F,
00390 Out<FORK7>& out6F,
00391 Out<FORK7>& out7F
00392 )
00393 :
00394
00395
00396 Process(n),
00397
00398
00399 inP(id("in"), inF),
00400 out1P(id("out1"), out1F),
00401 out2P(id("out2"), out2F),
00402 out3P(id("out3"), out3F),
00403 out4P(id("out4"), out4F),
00404 out5P(id("out5"), out5F),
00405 out6P(id("out6"), out6F),
00406 out7P(id("out7"), out7F)
00407 { }
00408
00409
00410 const char* type() const { return "fork7"; }
00411 void main() {
00412 while(true) {
00413 read(inP, in);
00414 write(out1P, in);
00415 write(out2P, in);
00416 write(out3P, in);
00417 write(out4P, in);
00418 write(out5P, in);
00419 write(out6P, in);
00420 write(out7P, in);
00421 }
00422 }
00423
00424 private:
00425
00426 InPort<FORK7> inP;
00427 OutPort<FORK7> out1P;
00428 OutPort<FORK7> out2P;
00429 OutPort<FORK7> out3P;
00430 OutPort<FORK7> out4P;
00431 OutPort<FORK7> out5P;
00432 OutPort<FORK7> out6P;
00433 OutPort<FORK7> out7P;
00434
00435
00436 FORK7 in;
00437 };
00438
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458 template<class FORK8>
00459
00460 class fork8: public Process
00461 {
00462 public:
00463
00464 fork8 (
00465 Id n,
00466 In<FORK8>& inF,
00467 Out<FORK8>& out1F,
00468 Out<FORK8>& out2F,
00469 Out<FORK8>& out3F,
00470 Out<FORK8>& out4F,
00471 Out<FORK8>& out5F,
00472 Out<FORK8>& out6F,
00473 Out<FORK8>& out7F,
00474 Out<FORK8>& out8F
00475 )
00476 :
00477
00478
00479 Process(n),
00480
00481
00482 inP(id("in"), inF),
00483 out1P(id("out1"), out1F),
00484 out2P(id("out2"), out2F),
00485 out3P(id("out3"), out3F),
00486 out4P(id("out4"), out4F),
00487 out5P(id("out5"), out5F),
00488 out6P(id("out6"), out6F),
00489 out7P(id("out7"), out7F),
00490 out8P(id("out8"), out8F)
00491 { }
00492
00493
00494 const char* type() const { return "fork8"; }
00495 void main() {
00496 while(true) {
00497 read(inP, in);
00498 write(out1P, in);
00499 write(out2P, in);
00500 write(out3P, in);
00501 write(out4P, in);
00502 write(out5P, in);
00503 write(out6P, in);
00504 write(out7P, in);
00505 write(out8P, in);
00506 }
00507 }
00508
00509 private:
00510
00511 InPort<FORK8> inP;
00512 OutPort<FORK8> out1P;
00513 OutPort<FORK8> out2P;
00514 OutPort<FORK8> out3P;
00515 OutPort<FORK8> out4P;
00516 OutPort<FORK8> out5P;
00517 OutPort<FORK8> out6P;
00518 OutPort<FORK8> out7P;
00519 OutPort<FORK8> out8P;
00520
00521
00522 FORK8 in;
00523 };
00524
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545 template<class FORK9>
00546
00547 class fork9: public Process
00548 {
00549 public:
00550
00551 fork9 (
00552 Id n,
00553 In<FORK9>& inF,
00554 Out<FORK9>& out1F,
00555 Out<FORK9>& out2F,
00556 Out<FORK9>& out3F,
00557 Out<FORK9>& out4F,
00558 Out<FORK9>& out5F,
00559 Out<FORK9>& out6F,
00560 Out<FORK9>& out7F,
00561 Out<FORK9>& out8F,
00562 Out<FORK9>& out9F
00563 )
00564 :
00565
00566
00567 Process(n),
00568
00569
00570 inP(id("in"), inF),
00571 out1P(id("out1"), out1F),
00572 out2P(id("out2"), out2F),
00573 out3P(id("out3"), out3F),
00574 out4P(id("out4"), out4F),
00575 out5P(id("out5"), out5F),
00576 out6P(id("out6"), out6F),
00577 out7P(id("out7"), out7F),
00578 out8P(id("out8"), out8F),
00579 out9P(id("out9"), out9F)
00580 { }
00581
00582
00583 const char* type() const { return "fork9"; }
00584 void main() {
00585 while(true) {
00586 read(inP, in);
00587 write(out1P, in);
00588 write(out2P, in);
00589 write(out3P, in);
00590 write(out4P, in);
00591 write(out5P, in);
00592 write(out6P, in);
00593 write(out7P, in);
00594 write(out8P, in);
00595 write(out9P, in);
00596 }
00597 }
00598
00599 private:
00600
00601 InPort<FORK9> inP;
00602 OutPort<FORK9> out1P;
00603 OutPort<FORK9> out2P;
00604 OutPort<FORK9> out3P;
00605 OutPort<FORK9> out4P;
00606 OutPort<FORK9> out5P;
00607 OutPort<FORK9> out6P;
00608 OutPort<FORK9> out7P;
00609 OutPort<FORK9> out8P;
00610 OutPort<FORK9> out9P;
00611
00612
00613 FORK9 in;
00614 };
00615
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637 template<class FORK10>
00638
00639 class fork10: public Process
00640 {
00641 public:
00642
00643 fork10 (
00644 Id n,
00645 In<FORK10>& inF,
00646 Out<FORK10>& out1F,
00647 Out<FORK10>& out2F,
00648 Out<FORK10>& out3F,
00649 Out<FORK10>& out4F,
00650 Out<FORK10>& out5F,
00651 Out<FORK10>& out6F,
00652 Out<FORK10>& out7F,
00653 Out<FORK10>& out8F,
00654 Out<FORK10>& out9F,
00655 Out<FORK10>& out10F
00656 )
00657 :
00658
00659
00660 Process(n),
00661
00662
00663 inP(id("in"), inF),
00664 out1P(id("out1"), out1F),
00665 out2P(id("out2"), out2F),
00666 out3P(id("out3"), out3F),
00667 out4P(id("out4"), out4F),
00668 out5P(id("out5"), out5F),
00669 out6P(id("out6"), out6F),
00670 out7P(id("out7"), out7F),
00671 out8P(id("out8"), out8F),
00672 out9P(id("out9"), out9F),
00673 out10P(id("out10"), out10F)
00674 { }
00675
00676
00677 const char* type() const { return "fork10"; }
00678 void main() {
00679 while(true) {
00680 read(inP, in);
00681 write(out1P, in);
00682 write(out2P, in);
00683 write(out3P, in);
00684 write(out4P, in);
00685 write(out5P, in);
00686 write(out6P, in);
00687 write(out7P, in);
00688 write(out8P, in);
00689 write(out9P, in);
00690 write(out10P, in);
00691 }
00692 }
00693
00694 private:
00695
00696 InPort<FORK10> inP;
00697 OutPort<FORK10> out1P;
00698 OutPort<FORK10> out2P;
00699 OutPort<FORK10> out3P;
00700 OutPort<FORK10> out4P;
00701 OutPort<FORK10> out5P;
00702 OutPort<FORK10> out6P;
00703 OutPort<FORK10> out7P;
00704 OutPort<FORK10> out8P;
00705 OutPort<FORK10> out9P;
00706 OutPort<FORK10> out10P;
00707
00708
00709 FORK10 in;
00710 };
00711
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727 template<class SINK>
00728
00729 class sink : public Process
00730 {
00731 public:
00732
00733 sink (
00734 Id n,
00735 In<SINK>& InF
00736 )
00737 :
00738
00739
00740 Process(n),
00741
00742
00743 InP(id("InP"), InF)
00744 { }
00745
00746 const char* type() const { return "sink"; }
00747 void main() {
00748 while(true) {
00749 read(InP, in);
00750 }
00751 }
00752
00753 private:
00754
00755 InPort<SINK> InP;
00756
00757
00758 SINK in;
00759 };
00760
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772 template<class SOURCE>
00773
00774 class source : public Process
00775 {
00776 public:
00777
00778 source (
00779 Id n,
00780 Out<SOURCE>& OutF
00781 )
00782 :
00783
00784
00785 Process(n),
00786
00787
00788 OutP(id("OutP"), OutF)
00789 { }
00790
00791 const char* type() const { return "source"; }
00792 void main() { }
00793
00794 private:
00795
00796 OutPort<SOURCE> OutP;
00797 };
00798
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810 template<class PASS>
00811
00812 class pass : public Process
00813 {
00814 public:
00815
00816 pass (
00817 Id n,
00818 In<PASS>& InF,
00819 Out<PASS>& OutF
00820 )
00821 :
00822
00823
00824 Process(n),
00825
00826
00827 InP(id("InP"), InF),
00828 OutP(id("OutP"), OutF)
00829 { }
00830
00831 const char* type() const { return "pass"; }
00832 void main() {
00833 while(true) {
00834 read(InP, in);
00835 write(OutP, in);
00836 }
00837 }
00838
00839 private:
00840
00841 InPort<PASS> InP;
00842 OutPort<PASS> OutP;
00843
00844
00845 PASS in;
00846 };
00847
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862 class i2l : public Process
00863 {
00864 public:
00865
00866 i2l(
00867 Id n,
00868 In<VYAimageWidth>& imgWinF,
00869 In<VYAimageHeight>& imgHinF,
00870 Out<VYAlineLength>& lineLoutF
00871 )
00872 :
00873
00874
00875 Process(n),
00876
00877
00878 imgWinP(id("imgWin"), imgWinF),
00879 imgHinP(id("imgHin"), imgHinF),
00880 lineLoutP(id("lineLout"), lineLoutF)
00881 { }
00882
00883
00884 const char* type() const { return "i2l"; }
00885 void main() {
00886 while (true) {
00887 read(imgWinP, imgWin);
00888 read(imgHinP, imgHin);
00889 lineLout = imgWin;
00890 for (int i=0; i < (int)imgHin; i++)
00891 write(lineLoutP, lineLout);
00892 }
00893 }
00894
00895 private:
00896
00897 InPort<VYAimageWidth> imgWinP;
00898 InPort<VYAimageHeight> imgHinP;
00899 OutPort<VYAlineLength> lineLoutP;
00900
00901
00902 VYAimageWidth imgWin;
00903 VYAimageHeight imgHin;
00904 VYAlineLength lineLout;
00905 };
00906
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921 class l2i : public Process
00922 {
00923 public:
00924
00925 l2i(
00926 Id n,
00927 In<VYAlineLength>& lineLinF,
00928 In<VYAimageHeight>& imgHinF,
00929 Out<VYAimageWidth>& imgWoutF
00930 )
00931 :
00932
00933
00934 Process(n),
00935
00936
00937 lineLinP(id("lineLin"), lineLinF),
00938 imgHinP(id("imgHin"), imgHinF),
00939 imgWoutP(id("imgWout"), imgWoutF)
00940 { }
00941
00942
00943 const char* type() const { return "l2i"; }
00944 void main() {
00945 while (true) {
00946 read(imgHinP, imgHin);
00947 read(lineLinP, lineLin);
00948 imgWout = lineLin;
00949 write(imgWoutP, imgWout);
00950
00951 for (int i=1; i < (int)imgHin; i++)
00952 read(lineLinP, lineLin);
00953 }
00954 }
00955
00956 private:
00957
00958 InPort<VYAlineLength> lineLinP;
00959 InPort<VYAimageHeight> imgHinP;
00960 OutPort<VYAimageWidth> imgWoutP;
00961
00962
00963 VYAimageWidth imgWout;
00964 VYAimageHeight imgHin;
00965 VYAlineLength lineLin;
00966 };
00967
00968
00969 #endif // UTILITIES_H
00970
00971