00001
00010 #ifndef __INTFUNHELPERS_H
00011 #define __INTFUNHELPERS_H
00012
00013 #include "jbltools/sfh/IntFun.h"
00014 #include "jbltools/sfh/CachedO.h"
00015 #include "jbltools/sfh/ROListPoR.h"
00016 #include "jbltools/sfh/BaseCutBase.h"
00017 #include "jbltools/sfh/BaseCutPoR.h"
00018 #include "jbltools/sfh/IntFunPoR.h"
00019 #include "jbltools/sfh/FloatFunBase.h"
00020
00021
00022 #include <vector>
00023
00024
00025
00026
00027
00028
00029
00030 class OneIntFunCompound : public IntFun {
00031 public:
00033 OneIntFunCompound (const std::string& funname_,
00034 const IntFun& arg_
00035 );
00036
00037 virtual int operator() () const = 0;
00038
00039 virtual const FillIterator *getIterator() const {
00040 return arg.getIterator();
00041 }
00042
00043 protected:
00045 virtual ~OneIntFunCompound() {}
00046
00047 const IntFun& arg;
00048 };
00049
00050 template<int fun(int)>
00051 class AnyIntFun1: public OneIntFunCompound {
00052 public:
00053 AnyIntFun1 (const char *name_,
00054 const IntFun& arg_
00055 )
00056 : OneIntFunCompound (name_, arg_){}
00058 virtual int operator() () const {
00059 return fun(arg());
00060 }
00061 protected:
00062 virtual ~AnyIntFun1() {}
00063 };
00064
00065
00066
00067
00068
00069
00070
00071
00072 class TwoIntFunCompound : public IntFun {
00073 public:
00074 TwoIntFunCompound (const IntFun& lhs_,
00075 const std::string& opname_,
00076 const IntFun& rhs_
00077 );
00078
00079 virtual int operator() () const = 0;
00080
00081 virtual const FillIterator *getIterator() const;
00082
00083 protected:
00084 virtual ~TwoIntFunCompound() {}
00085
00086 const IntFun& lhs;
00087 const IntFun& rhs;
00088 };
00089
00090 template<int fun(int, int)>
00091 class AnyIntFun2: public TwoIntFunCompound {
00092 public:
00093 AnyIntFun2 (const char *name_,
00094 const IntFun& lhs_,
00095 const IntFun& rhs_
00096 )
00097 : TwoIntFunCompound (name_, lhs_, rhs_){}
00098 AnyIntFun2 (const IntFun& lhs_,
00099 const char *opname_,
00100 const IntFun& rhs_
00101 )
00102 : TwoIntFunCompound (lhs_, name_, rhs_){}
00104 virtual int operator() () const {
00105 return fun(lhs(), rhs());
00106 }
00107 protected:
00108 virtual ~AnyIntFun2() {}
00109 };
00110
00111
00112 class IntFunComplement: public OneIntFunCompound {
00113 public:
00115 IntFunComplement (const IntFun& arg_
00116 )
00117 : OneIntFunCompound ("~", arg_) { }
00118
00119 virtual int operator() () const { return ~(arg()); }
00120
00121 protected:
00123 virtual ~IntFunComplement() {};
00124 };
00125
00126
00127
00128
00129
00130
00131 class SumOfTwoIntFuns : public TwoIntFunCompound {
00132 public:
00133 SumOfTwoIntFuns (const IntFun& lhs_,
00134 const IntFun& rhs_
00135 )
00136 : TwoIntFunCompound (lhs_, "+", rhs_) {}
00137
00138 virtual int operator() () const {
00139 return lhs() + rhs();
00140 }
00141
00142 protected:
00144 ~SumOfTwoIntFuns() {}
00145 };
00146
00147
00148
00149
00150
00151
00152 class DiffOfTwoIntFuns : public TwoIntFunCompound {
00153 public:
00154 DiffOfTwoIntFuns (const IntFun& lhs_,
00155 const IntFun& rhs_
00156 )
00157 : TwoIntFunCompound (lhs_, "-", rhs_) {}
00158
00159 virtual int operator() () const {
00160 return lhs() - rhs();
00161 };
00162
00163 protected:
00165 ~DiffOfTwoIntFuns() {}
00166 };
00167
00168
00169
00170
00171
00172
00173 class ProdOfTwoIntFuns : public TwoIntFunCompound {
00174 public:
00175 ProdOfTwoIntFuns (const IntFun& lhs_, const IntFun& rhs_)
00176 : TwoIntFunCompound (lhs_, "*", rhs_) {}
00177
00178 virtual int operator() () const {
00179 return lhs() * rhs();
00180 }
00181
00182 protected:
00184 ~ProdOfTwoIntFuns() {}
00185 };
00186
00187
00188
00189
00190
00191
00192 class DivOfTwoIntFuns : public TwoIntFunCompound {
00193 public:
00194 DivOfTwoIntFuns (const IntFun& lhs_, const IntFun& rhs_)
00195 : TwoIntFunCompound (lhs_, "/", rhs_) {}
00196
00197 virtual int operator() () const {
00198 int r = rhs();
00199 return r ? lhs() / r : 0;
00200 }
00201
00202 protected:
00204 ~DivOfTwoIntFuns() {}
00205 };
00206
00207
00208
00209
00210
00211
00212 class AndOfTwoIntFuns : public TwoIntFunCompound {
00213 public:
00214 AndOfTwoIntFuns (const IntFun& lhs_,
00215 const IntFun& rhs_
00216 )
00217 : TwoIntFunCompound (lhs_, "&", rhs_) {}
00218
00219 virtual int operator() () const {
00220 return lhs() & rhs();
00221 }
00222
00223 protected:
00225 ~AndOfTwoIntFuns() {}
00226 };
00227
00228
00229
00230
00231
00232
00233
00234 class OrOfTwoIntFuns : public TwoIntFunCompound {
00235 public:
00236 OrOfTwoIntFuns (const IntFun& lhs_,
00237 const IntFun& rhs_
00238 )
00239 : TwoIntFunCompound (lhs_, "|", rhs_) { };
00240
00241 virtual int operator() () const {
00242 return lhs() | rhs();
00243 }
00244
00245 protected:
00247 ~OrOfTwoIntFuns() {}
00248 };
00249
00250
00251
00252
00253
00254
00255 class XorOfTwoIntFuns : public TwoIntFunCompound {
00256 public:
00257 XorOfTwoIntFuns (const IntFun& lhs_,
00258 const IntFun& rhs_
00259 )
00260 : TwoIntFunCompound (lhs_, "^", rhs_) { }
00261
00262 virtual int operator() () const {
00263 return lhs() & rhs();
00264 }
00265
00266 protected:
00268 ~XorOfTwoIntFuns() {}
00269 };
00270
00271
00272
00273 class ScalarIntFunCompound: public IntFun {
00274 public:
00275 ScalarIntFunCompound (int s_,
00276 const std::string& opname_,
00277 const IntFun& fun_
00278 );
00279
00280 ScalarIntFunCompound (int s_,
00281 const IntFun& fun_,
00282 const std::string& name_
00283 );
00284
00285 virtual const FillIterator *getIterator() const {
00286 return fun.getIterator();
00287 }
00288
00289 protected:
00291 virtual ~ScalarIntFunCompound() {}
00292
00293 const IntFun& fun;
00294 int s;
00295 };
00296
00297
00298
00299 class ScalarProductIntFun: public ScalarIntFunCompound {
00300 public:
00301 ScalarProductIntFun (int s_,
00302 const IntFun& fun_
00303 )
00304 : ScalarIntFunCompound (s_, "*", fun_) {}
00305 ScalarProductIntFun (int s_,
00306 const IntFun& fun_,
00307 const std::string& name_
00308 )
00309 : ScalarIntFunCompound (s_, fun_, name_) {}
00310
00311 virtual int operator() () const { return s * fun() ; }
00312 protected:
00314 virtual ~ScalarProductIntFun() {}
00315 };
00316
00317
00318
00319 class ScalarDivisionIntFun: public ScalarIntFunCompound {
00320 public:
00321 ScalarDivisionIntFun (int s_,
00322 const IntFun& fun_
00323 )
00324 : ScalarIntFunCompound (s_, "/", fun_) {}
00325 virtual int operator() () const {
00326 int f = fun();
00327 return f ? s / f : 0 ;
00328 }
00329 protected:
00331 virtual ~ScalarDivisionIntFun() {}
00332 };
00333
00334
00335
00336 class ScalarDivisionIntFun2: public ScalarIntFunCompound {
00337 public:
00338 ScalarDivisionIntFun2 (const IntFun& fun_,
00339 int s_
00340 );
00341 virtual int operator() () const { return s ? fun()/s : 0 ; }
00342 protected:
00344 virtual ~ScalarDivisionIntFun2() {}
00345 };
00346
00347
00348
00349 class ScalarSumIntFun: public ScalarIntFunCompound {
00350 public:
00351 ScalarSumIntFun (int s_,
00352 const IntFun& fun_
00353 )
00354 : ScalarIntFunCompound (s_, "+", fun_) {}
00355 virtual int operator() () const { return s + fun() ; }
00356 protected:
00358 virtual ~ScalarSumIntFun() {}
00359 };
00360
00361
00362
00363 class ScalarDiffIntFun: public ScalarIntFunCompound {
00364 public:
00365 ScalarDiffIntFun (int s_,
00366 const IntFun& fun_
00367 )
00368 : ScalarIntFunCompound (s_, "-", fun_) {}
00369 virtual int operator() () const { return s - fun() ; }
00370 protected:
00372 virtual ~ScalarDiffIntFun() {}
00373 };
00374
00375
00376
00377 class ScalarAndIntFun: public ScalarIntFunCompound {
00378 public:
00379 ScalarAndIntFun (int s_,
00380 const IntFun& fun_
00381 )
00382 : ScalarIntFunCompound (s_, fun_, "c&(%s)") {}
00383 virtual int operator() () const { return s & fun() ; }
00384 protected:
00386 virtual ~ScalarAndIntFun() {}
00387 };
00388
00389
00390
00391 class ScalarOrIntFun: public ScalarIntFunCompound {
00392 public:
00393 ScalarOrIntFun (int s_,
00394 const IntFun& fun_
00395 )
00396 : ScalarIntFunCompound (s_, fun_, "c|(%s)") {}
00397 virtual int operator() () const { return s | fun() ; }
00398 protected:
00400 virtual ~ScalarOrIntFun() {}
00401 };
00402
00403
00404
00405 class ScalarXorIntFun: public ScalarIntFunCompound {
00406 public:
00407 ScalarXorIntFun (int s_,
00408 const IntFun& fun_
00409 )
00410 : ScalarIntFunCompound (s_, fun_, "c^(%s)") {}
00411 virtual int operator() () const { return s ^ fun() ; }
00412 protected:
00414 virtual ~ScalarXorIntFun() {}
00415 };
00416
00417
00418
00419 class FloatIntFun: public FloatFun {
00420 public:
00422 explicit FloatIntFun (const IntFun& theIntFun_,
00423 const char *name_ = 0
00424 );
00426 virtual Float_FF operator() () const { return theIntFun();}
00428 virtual const FillIterator *getIterator() const {
00429 return theIntFun.getIterator();
00430 }
00431
00432 protected:
00434 virtual ~FloatIntFun() {}
00435 const IntFun& theIntFun;
00436 };
00437
00438
00439
00440
00441
00442
00443
00444 class TwoIntFunComp: public IntFunComp {
00445 public:
00447 TwoIntFunComp (const IntFun& lhs_,
00448 const std::string& opname_,
00449 const IntFun& rhs_
00450 );
00452 virtual const FillIterator *getIterator() const {
00453 assert (!lhs.getIterator() || !rhs.getIterator() || lhs.getIterator()==rhs.getIterator());
00454 return (lhs.getIterator()) ? lhs.getIterator() : rhs.getIterator();
00455 }
00456
00457 virtual int lhsValue() const {
00458 return lhs();
00459 }
00460 virtual int rhsValue() const {
00461 return rhs();
00462 }
00463
00464 protected:
00465 virtual ~TwoIntFunComp() {}
00466
00467 const IntFun& lhs;
00468 const IntFun& rhs;
00469 };
00470
00471
00472
00473
00474 class IntFunLess: public TwoIntFunComp {
00475 public:
00477 IntFunLess (const IntFun& lhs_,
00478 const IntFun& rhs_
00479 )
00480 : TwoIntFunComp (lhs_, "<", rhs_) {}
00481
00483 virtual bool operator() () const {
00484 return lhs() < rhs();
00485 }
00486 protected:
00488 virtual ~IntFunLess() {}
00489 };
00490
00491
00492
00493 class IntFunLessEqual: public TwoIntFunComp {
00494 public:
00496 IntFunLessEqual (const IntFun& lhs_,
00497 const IntFun& rhs_
00498 )
00499 : TwoIntFunComp (lhs_, "<=", rhs_) {}
00500
00502 virtual bool operator() () const {
00503 return lhs() <= rhs();
00504 };
00505
00506 protected:
00508 virtual ~IntFunLessEqual() {}
00509 };
00510
00511
00512
00513 class IntFunGreater: public TwoIntFunComp {
00514 public:
00516 IntFunGreater (const IntFun& lhs_,
00517 const IntFun& rhs_
00518 )
00519 : TwoIntFunComp (lhs_, ">", rhs_) {}
00520
00522 virtual bool operator() () const {
00523 return lhs() > rhs();
00524 };
00525
00526 protected:
00528 virtual ~IntFunGreater() {}
00529 };
00530
00531
00532
00533 class IntFunGreaterEqual: public TwoIntFunComp {
00534 public:
00536 IntFunGreaterEqual (const IntFun& lhs_,
00537 const IntFun& rhs_
00538 )
00539 : TwoIntFunComp (lhs_, ">=", rhs_) {}
00540
00542 virtual bool operator() () const {
00543 return lhs() >= rhs();
00544 };
00545
00546 protected:
00548 virtual ~IntFunGreaterEqual() {}
00549 };
00550
00551
00552
00553 class IntFunEqual: public TwoIntFunComp {
00554 public:
00556 IntFunEqual (const IntFun& lhs_,
00557 const IntFun& rhs_
00558 )
00559 : TwoIntFunComp (lhs_, "==", rhs_) {}
00560
00562 virtual bool operator() () const {
00563 return lhs() == rhs();
00564 };
00565
00566 protected:
00568 virtual ~IntFunEqual() {}
00569 };
00570
00571
00572
00573 class IntFunNotEqual: public TwoIntFunComp {
00574 public:
00576 IntFunNotEqual (const IntFun& lhs_,
00577 const IntFun& rhs_
00578 )
00579 : TwoIntFunComp (lhs_, "!=", rhs_) {}
00580
00582 virtual bool operator() () const {
00583 return lhs() != rhs();
00584 };
00585
00586 protected:
00588 virtual ~IntFunNotEqual() {}
00589 };
00590
00591
00592
00593
00594 class IntChainComparison: public IntFunComp {
00595 public:
00597 IntChainComparison (const IntFunComp& lhs_,
00598 const std::string& opname_,
00599 const IntFun& rhs_
00600 );
00602 virtual const FillIterator *getIterator() const {
00603 assert (!lhs.getIterator() || !rhs.getIterator() || lhs.getIterator()==rhs.getIterator());
00604 return (lhs.getIterator()) ? lhs.getIterator() : rhs.getIterator();
00605 }
00606
00608 virtual int lhsValue() const {
00609 return lhs.lhsValue();
00610 }
00612 virtual int rhsValue() const {
00613 return rhs();
00614 }
00615
00616 protected:
00618 virtual ~IntChainComparison() {}
00619
00620
00621 const IntFunComp& lhs;
00622 const IntFun& rhs;
00623 };
00624
00625
00626
00627 class IntChainCompLess: public IntChainComparison {
00628 public:
00629 IntChainCompLess (const IntFunComp& lhs_,
00630 const IntFun& rhs_
00631 )
00632 : IntChainComparison (lhs_, "<", rhs_) {}
00633
00635 virtual bool operator() () const {
00636 return lhs() && (lhs.rhsValue() < rhs());
00637 }
00638
00639 protected:
00641 virtual ~IntChainCompLess() {}
00642 };
00643
00644
00645
00646 class IntChainCompLessEqual: public IntChainComparison {
00647 public:
00648 IntChainCompLessEqual (const IntFunComp& lhs_,
00649 const IntFun& rhs_
00650 )
00651 : IntChainComparison (lhs_, "<=", rhs_) {}
00652
00654 virtual bool operator() () const {
00655 return lhs() && (lhs.rhsValue() <= rhs());
00656 }
00657
00658 protected:
00660 virtual ~IntChainCompLessEqual() {}
00661 };
00662
00663
00664
00665 class IntChainCompGreater: public IntChainComparison {
00666 public:
00667 IntChainCompGreater (const IntFunComp& lhs_,
00668 const IntFun& rhs_
00669 )
00670 : IntChainComparison (lhs_, ">", rhs_) {}
00671
00673 virtual bool operator() () const {
00674 return lhs() && (lhs.rhsValue() > rhs());
00675 }
00676
00677 protected:
00679 virtual ~IntChainCompGreater() {}
00680 };
00681
00682
00683
00684 class IntChainCompGreaterEqual: public IntChainComparison {
00685 public:
00686 IntChainCompGreaterEqual (const IntFunComp& lhs_,
00687 const IntFun& rhs_
00688 )
00689 : IntChainComparison (lhs_, ">=", rhs_) {}
00690
00692 virtual bool operator() () const {
00693 return lhs() && (lhs.rhsValue() >= rhs());
00694 }
00695
00696 protected:
00698 virtual ~IntChainCompGreaterEqual() {}
00699 };
00700
00701
00702
00703 class IntChainCompEqual: public IntChainComparison {
00704 public:
00705 IntChainCompEqual (const IntFunComp& lhs_,
00706 const IntFun& rhs_
00707 )
00708 : IntChainComparison (lhs_, "==", rhs_) {}
00709
00711 virtual bool operator() () const {
00712 return lhs() && (lhs.rhsValue() == rhs());
00713 }
00714
00715 protected:
00717 virtual ~IntChainCompEqual() {}
00718 };
00719
00720
00721
00722 class IntChainCompNotEqual: public IntChainComparison {
00723 public:
00724 IntChainCompNotEqual (const IntFunComp& lhs_,
00725 const IntFun& rhs_
00726 )
00727 : IntChainComparison (lhs_, "!=", rhs_) {}
00728
00730 virtual bool operator() () const {
00731 return lhs() && (lhs.rhsValue() != rhs());
00732 }
00733
00734 protected:
00736 virtual ~IntChainCompNotEqual() {}
00737 };
00738
00739
00740
00741
00742 class IntChainCompInt: public IntFunComp {
00743 public:
00745 IntChainCompInt (const IntFunComp& lhs_,
00746 const std::string& opname_,
00747 int rhs_
00748 );
00750 virtual const FillIterator *getIterator() const {
00751 return lhs.getIterator();
00752 }
00753
00755 virtual int lhsValue() const {
00756 return lhs.lhsValue();
00757 }
00759 virtual int rhsValue() const {
00760 return rhs;
00761 }
00762
00763 protected:
00764 virtual ~IntChainCompInt() {}
00765
00766
00767 const IntFunComp& lhs;
00768 int rhs;
00769 };
00770
00771
00772
00773 class IntChainCompIntLess: public IntChainCompInt {
00774 public:
00776 IntChainCompIntLess (const IntFunComp& lhs_,
00777 int rhs_
00778 )
00779 : IntChainCompInt (lhs_, "<", rhs_) {}
00781 virtual bool operator() () const {
00782 return lhs() && (lhs.rhsValue() < rhs);
00783 }
00784
00785 protected:
00787 virtual ~IntChainCompIntLess() {}
00788 };
00789
00790
00791
00792 class IntChainCompIntLessEqual: public IntChainCompInt {
00793 public:
00795 IntChainCompIntLessEqual (const IntFunComp& lhs_,
00796 int rhs_
00797 )
00798 : IntChainCompInt (lhs_, "<=", rhs_) {}
00800 virtual bool operator() () const {
00801 return lhs() && (lhs.rhsValue() <= rhs);
00802 }
00803
00804 protected:
00806 virtual ~IntChainCompIntLessEqual() {}
00807 };
00808
00809
00810
00811 class IntChainCompIntGreater: public IntChainCompInt {
00812 public:
00814 IntChainCompIntGreater (const IntFunComp& lhs_,
00815 int rhs_
00816 )
00817 : IntChainCompInt (lhs_, ">", rhs_) {}
00819 virtual bool operator() () const {
00820 return lhs() && (lhs.rhsValue() > rhs);
00821 }
00822
00823 protected:
00825 virtual ~IntChainCompIntGreater() {}
00826 };
00827
00828
00829
00830 class IntChainCompIntGreaterEqual: public IntChainCompInt {
00831 public:
00833 IntChainCompIntGreaterEqual (const IntFunComp& lhs_,
00834 int rhs_
00835 )
00836 : IntChainCompInt (lhs_, ">=", rhs_) {}
00838 virtual bool operator() () const {
00839 return lhs() && (lhs.rhsValue() >= rhs);
00840 }
00841
00842 protected:
00844 virtual ~IntChainCompIntGreaterEqual() {}
00845 };
00846
00847
00848
00849 class IntChainCompIntEqual: public IntChainCompInt {
00850 public:
00852 IntChainCompIntEqual (const IntFunComp& lhs_,
00853 int rhs_
00854 )
00855 : IntChainCompInt (lhs_, "==", rhs_) {}
00857 virtual bool operator() () const {
00858 return lhs() && (lhs.rhsValue() == rhs);
00859 }
00860
00861 protected:
00863 virtual ~IntChainCompIntEqual() {}
00864 };
00865
00866
00867
00868 class IntChainCompIntNotEqual: public IntChainCompInt {
00869 public:
00871 IntChainCompIntNotEqual (const IntFunComp& lhs_,
00872 int rhs_
00873 )
00874 : IntChainCompInt (lhs_, "!=", rhs_) {}
00876 virtual bool operator() () const {
00877 return lhs() && (lhs.rhsValue() != rhs);
00878 }
00879
00880 protected:
00882 virtual ~IntChainCompIntNotEqual() {}
00883 };
00884
00885
00886
00887
00888
00889
00890
00891 class IntIntFunComp: public IntFunComp {
00892 public:
00894 IntIntFunComp (int lhs_,
00895 const std::string& opname_,
00896 const IntFun& rhs_
00897 );
00899 virtual const FillIterator *getIterator() const {
00900 return rhs.getIterator();
00901 }
00902
00903 virtual int lhsValue() const {
00904 return lhs;
00905 }
00906 virtual int rhsValue() const {
00907 return rhs();
00908 }
00909 protected:
00910 virtual ~IntIntFunComp() {}
00911
00912 int lhs;
00913 const IntFun& rhs;
00914 };
00915
00916
00917
00918 class IntIntFunLess: public IntIntFunComp {
00919 public:
00920 IntIntFunLess (int lhs_,
00921 const IntFun& rhs_
00922 )
00923 : IntIntFunComp (lhs_, "<", rhs_) {}
00924
00926 virtual bool operator() () const {
00927 return lhs < rhs();
00928 }
00929 protected:
00931 virtual ~IntIntFunLess() {}
00932 };
00933
00934
00935
00936 class IntIntFunLessEqual: public IntIntFunComp {
00937 public:
00938 IntIntFunLessEqual (int lhs_,
00939 const IntFun& rhs_
00940 )
00941 : IntIntFunComp (lhs_, "<=", rhs_) {}
00942
00944 virtual bool operator() () const {
00945 return lhs <= rhs();
00946 }
00947 protected:
00949 virtual ~IntIntFunLessEqual() {}
00950 };
00951
00952
00953
00954 class IntIntFunGreater: public IntIntFunComp {
00955 public:
00956 IntIntFunGreater (int lhs_,
00957 const IntFun& rhs_
00958 )
00959 : IntIntFunComp (lhs_, ">", rhs_) {}
00960
00962 virtual bool operator() () const {
00963 return lhs > rhs();
00964 }
00965 protected:
00967 virtual ~IntIntFunGreater() {}
00968 };
00969
00970
00971
00972 class IntIntFunGreaterEqual: public IntIntFunComp {
00973 public:
00974 IntIntFunGreaterEqual (int lhs_,
00975 const IntFun& rhs_
00976 )
00977 : IntIntFunComp (lhs_, ">=", rhs_) {}
00978
00980 virtual bool operator() () const {
00981 return lhs >= rhs();
00982 }
00983 protected:
00985 virtual ~IntIntFunGreaterEqual() {}
00986 };
00987
00988
00989
00990 class IntIntFunEqual: public IntIntFunComp {
00991 public:
00992 IntIntFunEqual (int lhs_,
00993 const IntFun& rhs_
00994 )
00995 : IntIntFunComp (lhs_, "==", rhs_) {}
00996
00998 virtual bool operator() () const {
00999 return lhs == rhs();
01000 }
01001 protected:
01003 virtual ~IntIntFunEqual() {}
01004 };
01005
01006
01007
01008 class IntIntFunNotEqual: public IntIntFunComp {
01009 public:
01010 IntIntFunNotEqual (int lhs_,
01011 const IntFun& rhs_
01012 )
01013 : IntIntFunComp (lhs_, "!=", rhs_) {}
01014
01016 virtual bool operator() () const {
01017 return lhs != rhs();
01018 }
01019 protected:
01021 virtual ~IntIntFunNotEqual() {}
01022 };
01023
01024
01025
01026
01027
01028
01029
01030
01031 class IntFunIntComp: public IntFunComp {
01032 public:
01034 IntFunIntComp (const IntFun& lhs_,
01035 const std::string& opname_,
01036 int rhs_
01037 );
01039 virtual const FillIterator *getIterator() const {
01040 return lhs.getIterator();
01041 }
01042
01043 virtual int lhsValue() const {
01044 return lhs();
01045 }
01046 virtual int rhsValue() const {
01047 return rhs;
01048 }
01049
01050 protected:
01051 virtual ~IntFunIntComp() {}
01052
01053 const IntFun& lhs;
01054 int rhs;
01055 };
01056
01057
01058
01059 class IntFunIntLess: public IntFunIntComp {
01060 public:
01061 IntFunIntLess (const IntFun& lhs_,
01062 int rhs_
01063 )
01064 : IntFunIntComp (lhs_, "<", rhs_) {}
01065
01067 virtual bool operator() () const {
01068 return lhs() < rhs;
01069 }
01070 protected:
01072 virtual ~IntFunIntLess() {}
01073 };
01074
01075
01076
01077 class IntFunIntLessEqual: public IntFunIntComp {
01078 public:
01079 IntFunIntLessEqual (const IntFun& lhs_,
01080 int rhs_
01081 )
01082 : IntFunIntComp (lhs_, "<=", rhs_) {}
01083
01085 virtual bool operator() () const {
01086 return lhs() <= rhs;
01087 }
01088 protected:
01090 virtual ~IntFunIntLessEqual() {}
01091 };
01092
01093
01094
01095 class IntFunIntGreater: public IntFunIntComp {
01096 public:
01097 IntFunIntGreater (const IntFun& lhs_,
01098 int rhs_
01099 )
01100 : IntFunIntComp (lhs_, ">", rhs_) {}
01101
01103 virtual bool operator() () const {
01104 return lhs() > rhs;
01105 }
01106 protected:
01108 virtual ~IntFunIntGreater() {}
01109 };
01110
01111
01112
01113 class IntFunIntGreaterEqual: public IntFunIntComp {
01114 public:
01115 IntFunIntGreaterEqual (const IntFun& lhs_,
01116 int rhs_
01117 )
01118 : IntFunIntComp (lhs_, ">=", rhs_) {}
01119
01121 virtual bool operator() () const {
01122 return lhs() >= rhs;
01123 }
01124 protected:
01126 virtual ~IntFunIntGreaterEqual() {}
01127 };
01128
01129
01130
01131 class IntFunIntEqual: public IntFunIntComp {
01132 public:
01133 IntFunIntEqual (const IntFun& lhs_,
01134 int rhs_
01135 )
01136 : IntFunIntComp (lhs_, "==", rhs_) {}
01137
01139 virtual bool operator() () const {
01140 return lhs() == rhs;
01141 }
01142 protected:
01144 virtual ~IntFunIntEqual() {}
01145 };
01146
01147
01148
01149 class IntFunIntNotEqual: public IntFunIntComp {
01150 public:
01151 IntFunIntNotEqual (const IntFun& lhs_,
01152 int rhs_
01153 )
01154 : IntFunIntComp (lhs_, "!=", rhs_) {}
01155
01157 virtual bool operator() () const {
01158 return lhs() != rhs;
01159 }
01160 protected:
01162 virtual ~IntFunIntNotEqual() {}
01163 };
01164
01165 class CachedIntFun: public IntFun, public CachedO {
01166 public:
01168 CachedIntFun (const ROListPoR& rol,
01169 const IntFun& arg_
01170 );
01171
01173 virtual int operator() () const;
01174
01176 virtual void invalidateCache() { cacheValid = false; }
01177
01178 protected:
01180 virtual ~CachedIntFun() {}
01181
01182
01183 const IntFun& arg;
01184 mutable bool cacheValid;
01185 mutable int cachedValue;
01186 };
01187
01188 class CachedIntFunIt: public IntFun, public CachedO {
01189 public:
01191 CachedIntFunIt (const ROListPoR& rol,
01192 const IntFun& arg_,
01193 const FillIterator& iter_
01194 );
01195
01197 virtual int operator() () const;
01198
01200 virtual const FillIterator *getIterator() const {
01201 return &iter;
01202 }
01203
01205 virtual void invalidateCache() {
01206 cacheValid.resize(0);
01207 cachedValues.resize(0);
01208 }
01209
01210 protected:
01212 void growCache (unsigned int s) const;
01213
01215 virtual ~CachedIntFunIt() {}
01216
01217
01218 const IntFun& arg;
01219 const FillIterator& iter;
01220 mutable std::vector<bool> cacheValid;
01221 mutable std::vector<int> cachedValues;
01222 };
01223
01224
01225
01226
01227
01228 class CollectiveIntFun: public IntFun {
01229 public:
01230 CollectiveIntFun (const std::string& funname_,
01231 const IntFunPoRConst& fun_=0,
01232 const BaseCutPoRConst& cut_=0,
01233 const FillIteratorPoR& intiter_=0,
01234 const FillIteratorPoRConst& extiter_=0
01235 );
01236 virtual const FillIterator *getIterator() const {
01237 return extiter;
01238 }
01239
01240 protected:
01241 virtual ~CollectiveIntFun() {}
01242 void checkIterators();
01243 static std::string makeName(const std::string& funname_,
01244 const IntFunPoRConst& fun_,
01245 const BaseCutPoRConst& cut_,
01246 const FillIteratorPoR& intiter_,
01247 const FillIteratorPoRConst& extiter_
01248 );
01249
01250 const IntFun *fun;
01251 const BaseCut *cut;
01252 FillIterator *intiter;
01253 const FillIterator *extiter;
01254 };
01255
01256
01257 class MaxIntFun: public CollectiveIntFun {
01258 public:
01259 MaxIntFun (const IntFunPoRConst& fun_=0,
01260 const BaseCutPoRConst& cut_=0,
01261 const FillIteratorPoR& intiter_=0,
01262 const FillIteratorPoRConst& extiter_=0
01263 )
01264 : CollectiveIntFun ("max", fun_, cut_, intiter_, extiter_)
01265 {}
01266
01267 virtual int operator() () const;
01268 protected:
01269 virtual ~MaxIntFun() {}
01270 };
01271
01272
01273 class MinIntFun: public CollectiveIntFun {
01274 public:
01275 MinIntFun (const IntFunPoRConst& fun_=0,
01276 const BaseCutPoRConst& cut_=0,
01277 const FillIteratorPoR& intiter_=0,
01278 const FillIteratorPoRConst& extiter_=0
01279 )
01280 : CollectiveIntFun ("min", fun_, cut_, intiter_, extiter_)
01281 {}
01282
01283 virtual int operator() () const;
01284 protected:
01285 virtual ~MinIntFun() {}
01286 };
01287
01288
01289 class SumIntFun: public CollectiveIntFun {
01290 public:
01291 SumIntFun (const IntFunPoRConst& fun_=0,
01292 const BaseCutPoRConst& cut_=0,
01293 const FillIteratorPoR& intiter_=0,
01294 const FillIteratorPoRConst& extiter_=0
01295 )
01296 : CollectiveIntFun ("sum", fun_, cut_, intiter_, extiter_)
01297 {}
01298
01299 virtual int operator() () const;
01300 protected:
01301 virtual ~SumIntFun() {}
01302 };
01303
01304 #endif