Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members | Related Pages

FloatFunHelpers.h

Go to the documentation of this file.
00001 
00009 #ifndef __FLOATFUNHELPERS_H
00010 #define __FLOATFUNHELPERS_H
00011 
00012 #include "jbltools/sfh/FloatFun.h"
00013 
00014 #ifndef __JBLMATH_H
00015 #include "jbltools/sfh/JBLMath.h"
00016 #endif /* #ifndef __JBLMATH_H */
00017 
00018 #include "jbltools/sfh/ROListPoR.h"
00019 #include "jbltools/sfh/CachedO.h"
00020 #include "jbltools/sfh/FloatFunPoR.h"
00021 
00022 #include <vector>
00023  
00024 
00025 //  Class OneFunCompound:
00026 // Helper class for unary functions of FloatFun objects
00027 /*
00028  * This Class holds a pointer pointers to one other FloatFun
00029  * The derived classes implement operator().
00030  */
00031 class OneFunCompound : public FloatFun {
00032   public:
00033     OneFunCompound (const std::string& funname_,             
00034                     const FloatFun& arg_                     
00035                    );
00036     OneFunCompound (const char * funname_,                   
00037                     const FloatFun& arg_                     
00038                    );
00039     OneFunCompound (const FloatFun& arg_,                    
00040                     const std::string& name_                 
00041                    );
00042                     
00043     virtual Float_FF operator() () const = 0;
00044     
00045     virtual const FillIterator *getIterator() const {  
00046       return arg.getIterator(); 
00047     }
00048     
00049   protected:
00051     virtual ~OneFunCompound() {} 
00052 
00053     // Data members
00054     const FloatFun& arg;       
00055 };
00056 
00057 template<Float_FF fun(Float_FF)> 
00058 class AnyFloatFun1: public OneFunCompound   {
00059   public:
00060     AnyFloatFun1 (const char *name_,      
00061                  const FloatFun& arg_    
00062                  )
00063     : OneFunCompound (name_, arg_){}
00065     virtual Float_FF operator() () const {
00066       return fun(arg());
00067     }
00068   protected:
00069     virtual ~AnyFloatFun1() {}
00070 };
00071 
00072 //  Class TwoFunCompound:
00073 // Helper class for binary arithmetic operations between FloatFun objects
00074 /*
00075  * This Class holds pointers to two other FloatFun objects.
00076  * The derived classes ProdOfTwoFuns and SumOfTwoFuns implement
00077  * operator().
00078  */
00079 class TwoFunCompound : public FloatFun {
00080   public:
00081     TwoFunCompound (const FloatFun& lhs_, 
00082                     const std::string opname_,
00083                     const FloatFun& rhs_
00084                    );
00085     TwoFunCompound (const std::string funname_,
00086                     const FloatFun& lhs_, 
00087                     const FloatFun& rhs_
00088                    );
00089     TwoFunCompound (const FloatFun& lhs_, 
00090                     const FloatFun& rhs_, 
00091                     const std::string name_
00092                    );
00093     
00094     virtual Float_FF operator() () const = 0;
00095     
00096     virtual const FillIterator *getIterator() const;
00097     
00098   protected:
00099     virtual ~TwoFunCompound() {} 
00100 
00101     const FloatFun& lhs;
00102     const FloatFun& rhs;
00103 };
00104 
00105 template<Float_FF fun(Float_FF, Float_FF)> 
00106 class AnyFloatFun2: public TwoFunCompound   {
00107   public:
00108     AnyFloatFun2 (const char *name_,      
00109                   const FloatFun& lhs_,  
00110                   const FloatFun& rhs_   
00111                  )
00112     : TwoFunCompound (name_, lhs_, rhs_){}
00113     AnyFloatFun2 (const FloatFun& lhs_,  
00114                   const char *opname_,    
00115                   const FloatFun& rhs_   
00116                  )
00117     : TwoFunCompound (lhs_, name_, rhs_){}
00119     virtual Float_FF operator() () const {
00120       return fun(lhs(), rhs());
00121     }
00122   protected:
00123     virtual ~AnyFloatFun2() {}
00124 };
00125 
00126 //  Class SumOfTwoFuns:
00127 // Helper class for the implementation of FloatFun + FloatFun
00128 /*
00129  * Returns the sum of two FloatFun objects.
00130  */
00131 class SumOfTwoFuns : public TwoFunCompound {
00132   public:
00133     SumOfTwoFuns (const FloatFun& lhs_,   
00134                   const FloatFun& rhs_    
00135                   )
00136     : TwoFunCompound (lhs_, "+", rhs_) {}
00137   
00138     virtual Float_FF operator() () const {
00139       return lhs() + rhs();
00140     }
00141     
00142   protected:
00144     ~SumOfTwoFuns() {} 
00145 };
00146  
00147 
00148 //  Class DiffOfTwoFuns:
00149 // Helper class for the implementation of FloatFun - FloatFun
00150 /*
00151  * Returns the differemce of two FloatFun objects.
00152  */
00153 class DiffOfTwoFuns : public TwoFunCompound {
00154   public:
00155     DiffOfTwoFuns (const FloatFun& lhs_,   
00156                    const FloatFun& rhs_    
00157                   )
00158     : TwoFunCompound (lhs_, "-", rhs_) {}
00159   
00160     virtual Float_FF operator() () const {
00161       return lhs() - rhs();
00162     };
00163     
00164   protected:
00166     ~DiffOfTwoFuns() {} 
00167 };
00168  
00169 
00170 //  Class ProdOfTwoFuns:
00171 // Helper class for the implementation of FloatFun * FloatFun
00172 /*
00173  * Returns the product of two FloatFun objects.
00174  */
00175 class ProdOfTwoFuns : public TwoFunCompound {
00176   public:
00177     ProdOfTwoFuns (const FloatFun& lhs_, const FloatFun& rhs_)
00178     : TwoFunCompound (lhs_, "*", rhs_) {}
00179   
00180     virtual Float_FF operator() () const {
00181       return lhs() * rhs();
00182     };
00183     
00184   protected:
00185     ~ProdOfTwoFuns() {}
00186     
00187 };
00188 
00189 //  Class DivOfTwoFuns:
00190 // Helper class for the implementation of FloatFun / FloatFun
00191 /*
00192  * Returns the quotient of two FloatFun objects.
00193  */
00194 class DivOfTwoFuns : public TwoFunCompound {
00195   public:
00196     DivOfTwoFuns (const FloatFun& lhs_, const FloatFun& rhs_)
00197     : TwoFunCompound (lhs_, "/", rhs_) {}
00198   
00199     virtual Float_FF operator() () const {
00200       Float_FF r = rhs();
00201       return (r) ? lhs() / r : 0;
00202     };
00203     
00204   protected:
00206     ~DivOfTwoFuns() {} 
00207 };
00208 
00209 //  Class ScalarSumFloatFun:
00210 // Helper class for sum of a FloatFun with a scalar value
00211 class ScalarSumFloatFun: public OneFunCompound   {
00212   public:
00213     ScalarSumFloatFun (Float_FF s_,                     
00214                        const FloatFun& arg_             
00215                        )
00216     : OneFunCompound (str(s_)+"+", arg_), s (s_), a(1) {}
00217     ScalarSumFloatFun (Float_FF s_,                     
00218                        const FloatFun& arg_,            
00219                        Float_FF a_,                     
00220                        const std::string& name_         
00221                        )
00222     : OneFunCompound (arg_, name_), s (s_), a(a_) {}
00223     
00224     virtual Float_FF operator() () const { return s + a*arg(); }
00225     
00226   protected:
00228     virtual ~ScalarSumFloatFun() {}
00229 
00230     Float_FF s;                                      
00231     Float_FF a;                                      
00232 };
00233 
00234 //  Class ScalarProductFloatFun:
00235 // Helper class for multiplication of a FloatFun with a scalar value
00236 class ScalarProductFloatFun: public OneFunCompound   {
00237   public:
00238     ScalarProductFloatFun (Float_FF s_,                     
00239                            const FloatFun& arg_             
00240                            )
00241     : OneFunCompound (str(s_)+"*", arg_), s (s_) {}
00242     ScalarProductFloatFun (const std::string& funname_,     
00243                            Float_FF s_,                     
00244                            const FloatFun& arg_             
00245                            )
00246     : OneFunCompound (funname_, arg_), s (s_) {}
00247     
00248     virtual Float_FF operator() () const { return s * arg(); }
00249     
00250   protected:
00252     virtual ~ScalarProductFloatFun() {} 
00253 
00254     Float_FF s;                                      
00255 };
00256 
00257 //  Class ScalarDivisionFloatFun:
00258 // Helper class for division of a scalar value by a FloatFun
00259 class ScalarDivisionFloatFun: public OneFunCompound   {
00260   public:
00261     ScalarDivisionFloatFun (Float_FF s_,            
00262                             const FloatFun& arg_    
00263                             )
00264     : OneFunCompound (str(s_)+'/', arg_), s (s_) {};
00265     
00266     virtual Float_FF operator() () const {
00267       Float_FF a = arg();
00268       return (a) ? s/a : 0;
00269     }
00270     
00271   protected:
00273     virtual ~ScalarDivisionFloatFun() {}; 
00274 
00275     Float_FF s;                                      
00276 };
00277 
00278 //  Class TwoFloatFunComp:
00279 // Helper class for comparisons between FloatFun objects
00280 /*
00281  * This cut holds pointers to two FloatFun objects.
00282  * The derived classes implement operator().
00283  */
00284 class  TwoFloatFunComp: public FloatFunComp {
00285   public:
00287     TwoFloatFunComp (const FloatFun& lhs_,        
00288                      const std::string& opname_,   
00289                      const FloatFun& rhs_         
00290                     );
00291     virtual Float_FF lhsValue() const {
00292       return lhs();
00293     }
00294     virtual Float_FF rhsValue() const {
00295       return rhs();
00296     }
00297     
00298     virtual const FillIterator *getIterator() const;
00299     
00300   protected:
00301     virtual ~TwoFloatFunComp() {} 
00302 
00303     const FloatFun& lhs;                     
00304     const FloatFun& rhs;                     
00305 };
00306 
00307 
00308 //  Class FloatFunLess:
00309 // Helper class for FloatFun < FloatFun
00310 class  FloatFunLess: public TwoFloatFunComp {
00311   public:
00313     FloatFunLess (const FloatFun&  lhs_,    
00314                   const FloatFun&  rhs_     
00315                   )
00316     : TwoFloatFunComp (lhs_, "<", rhs_) {}
00317     
00319     virtual bool operator() () const {
00320       return lhs() < rhs();
00321     }
00322   protected:
00324     virtual ~FloatFunLess() {}
00325 };
00326 
00327 //  Class FloatFunLessEqual:
00328 // Helper class for FloatFun <= FloatFun
00329 class  FloatFunLessEqual: public TwoFloatFunComp {
00330   public:
00332     FloatFunLessEqual (const FloatFun&  lhs_,    
00333                        const FloatFun&  rhs_     
00334                       )
00335     : TwoFloatFunComp (lhs_, "<=", rhs_) {}
00336     
00338     virtual bool operator() () const {
00339       return lhs() <= rhs();
00340     };
00341     
00342   protected:
00344     virtual ~FloatFunLessEqual() {}
00345 };
00346 
00347 //  Class FloatFunGreater:
00348 // Helper class for FloatFun > FloatFun
00349 class  FloatFunGreater: public TwoFloatFunComp {
00350   public:
00352     FloatFunGreater (const FloatFun&  lhs_,    
00353                      const FloatFun&  rhs_     
00354                      )
00355     : TwoFloatFunComp (lhs_, ">", rhs_) {}
00356     
00358     virtual bool operator() () const {
00359       return lhs() > rhs();
00360     };
00361     
00362   protected:
00364     virtual ~FloatFunGreater() {}
00365 };
00366 
00367 //  Class FloatFunGreaterEqual:
00368 // Helper class for FloatFun >= FloatFun
00369 class  FloatFunGreaterEqual: public TwoFloatFunComp {
00370   public:
00372     FloatFunGreaterEqual (const FloatFun&  lhs_,    
00373                           const FloatFun&  rhs_     
00374                           )
00375     : TwoFloatFunComp (lhs_, ">=", rhs_) {}
00376     
00378     virtual bool operator() () const {
00379       return lhs() >= rhs();
00380     };
00381     
00382   protected:
00384     virtual ~FloatFunGreaterEqual() {}
00385 };
00386 
00387 //  Class FloatFunEqual:
00388 // Helper class for FloatFun == FloatFun
00389 class  FloatFunEqual: public TwoFloatFunComp {
00390   public:
00392     FloatFunEqual (const FloatFun&  lhs_,    
00393                    const FloatFun&  rhs_     
00394                   )
00395     : TwoFloatFunComp (lhs_, "==", rhs_) {}
00396     
00398     virtual bool operator() () const {
00399       return lhs() == rhs();
00400     };
00401     
00402   protected:
00404     virtual ~FloatFunEqual() {}
00405 };
00406 
00407 //  Class FloatFunNotEqual:
00408 // Helper class for FloatFun != FloatFun
00409 class  FloatFunNotEqual: public TwoFloatFunComp {
00410   public:
00412     FloatFunNotEqual (const FloatFun&  lhs_,    
00413                       const FloatFun&  rhs_     
00414                      )
00415     : TwoFloatFunComp (lhs_, "!=", rhs_) {}
00416     
00418     virtual bool operator() () const {
00419       return lhs() != rhs();
00420     };
00421     
00422   protected:
00424     virtual ~FloatFunNotEqual() {}
00425 };
00426 
00427 
00428 //  Class ChainComparison:
00429 // Abstract base class for (FloatFun < FloatFun) < FloatFun
00430 class  ChainComparison: public FloatFunComp {
00431   public:
00433     ChainComparison (const FloatFunComp& lhs_,    
00434                      const std::string&  opname_, 
00435                      const FloatFun&     rhs_     
00436                      );
00438     virtual Float_FF lhsValue() const {
00439       return lhs.lhsValue();
00440     }
00442     virtual Float_FF rhsValue() const {
00443       return rhs();
00444     }
00445     
00446     virtual const FillIterator *getIterator() const;
00447     
00448   protected:
00450     virtual ~ChainComparison() {}
00451     
00452     // Data members
00453     const FloatFunComp& lhs;    
00454     const FloatFun&     rhs;    
00455 };
00456 
00457 //  Class ChainCompLess:
00458 // Helper class for (FloatFun < FloatFun) < FloatFun
00459 class  ChainCompLess: public ChainComparison {
00460   public:
00461     ChainCompLess (const FloatFunComp&  lhs_,    
00462                    const FloatFun&  rhs_         
00463                    )
00464     : ChainComparison (lhs_, "<", rhs_) {}
00465     
00467     virtual bool operator() () const {
00468       return lhs() && (lhs.rhsValue() < rhs());
00469     }
00470     
00471   protected:
00473     virtual ~ChainCompLess() {}
00474 };
00475 
00476 //  Class ChainCompLessEqual:
00477 // Helper class for (FloatFun < FloatFun) <= FloatFun
00478 class  ChainCompLessEqual: public ChainComparison {
00479   public:
00480     ChainCompLessEqual (const FloatFunComp&  lhs_,    
00481                         const FloatFun&  rhs_               
00482                        )
00483     : ChainComparison (lhs_, "<=", rhs_) {}
00484     
00486     virtual bool operator() () const {
00487       return lhs() && (lhs.rhsValue() <= rhs());
00488     }
00489     
00490   protected:
00492     virtual ~ChainCompLessEqual() {}
00493 };
00494 
00495 //  Class ChainCompGreater:
00496 // Helper class for (FloatFun > FloatFun) > FloatFun
00497 class  ChainCompGreater: public ChainComparison {
00498   public:
00499     ChainCompGreater (const FloatFunComp&  lhs_,    
00500                       const FloatFun&  rhs_               
00501                       )
00502     : ChainComparison (lhs_, ">", rhs_) {}
00503     
00505     virtual bool operator() () const {
00506       return lhs() && (lhs.rhsValue() > rhs());
00507     }
00508     
00509   protected:
00511     virtual ~ChainCompGreater() {}
00512 };
00513 
00514 //  Class ChainCompGreaterEqual:
00515 //  Helper class for (FloatFun > FloatFun) >= FloatFun
00516 class  ChainCompGreaterEqual: public ChainComparison {
00517   public:
00518     ChainCompGreaterEqual (const FloatFunComp&  lhs_,    
00519                            const FloatFun&  rhs_               
00520                           )
00521     : ChainComparison (lhs_, ">=", rhs_) {}
00522     
00524     virtual bool operator() () const {
00525       return lhs() && (lhs.rhsValue() >= rhs());
00526     }
00527     
00528   protected:
00530     virtual ~ChainCompGreaterEqual() {}
00531 };
00532 
00533 //  Class ChainCompEqual:
00534 //  Helper class for (FloatFun > FloatFun) == FloatFun
00535 class  ChainCompEqual: public ChainComparison {
00536   public:
00537     ChainCompEqual (const FloatFunComp&  lhs_,    
00538                     const FloatFun&  rhs_               
00539                    )
00540     : ChainComparison (lhs_, "==", rhs_) {}
00541     
00543     virtual bool operator() () const {
00544       return lhs() && (lhs.rhsValue() == rhs());
00545     }
00546     
00547   protected:
00549     virtual ~ChainCompEqual() {}
00550 };
00551 
00552 //  Class ChainCompNotEqual:
00553 //  Helper class for (FloatFun > FloatFun) != FloatFun
00554 class  ChainCompNotEqual: public ChainComparison {
00555   public:
00556     ChainCompNotEqual (const FloatFunComp&  lhs_,    
00557                        const FloatFun&  rhs_               
00558                       )
00559     : ChainComparison (lhs_, "!=", rhs_) {}
00560     
00562     virtual bool operator() () const {
00563       return lhs() && (lhs.rhsValue() != rhs());
00564     }
00565     
00566   protected:
00568     virtual ~ChainCompNotEqual() {}
00569 };
00570 
00571 
00572 //  Class ChainCompFloat:
00573 //  Abstract base class for (FloatFun < FloatFun) < Float_FF
00574 class  ChainCompFloat: public FloatFunComp {
00575   public:
00577     ChainCompFloat (const FloatFunComp& lhs_,    
00578                     const std::string&  opname_, 
00579                     Float_FF            rhs_     
00580                    );
00582     virtual Float_FF lhsValue() const {
00583       return lhs.lhsValue();
00584     }
00586     virtual Float_FF rhsValue() const {
00587       return rhs;
00588     }
00589     
00590     virtual const FillIterator *getIterator() const {  
00591       return lhs.getIterator(); 
00592     }
00593     
00594   protected:
00595     virtual ~ChainCompFloat() {} 
00596 
00597     // Data members
00598     const FloatFunComp& lhs;    
00599     Float_FF            rhs;    
00600 };
00601 
00602 //  Class ChainCompFloatLess:
00603 //  Helper class for (FloatFun < FloatFun) < Float_FF
00604 class  ChainCompFloatLess: public ChainCompFloat {
00605   public:
00607     ChainCompFloatLess (const FloatFunComp& lhs_,    
00608                         Float_FF            rhs_      
00609                         )
00610     : ChainCompFloat (lhs_, "<", rhs_) {}
00612     virtual bool operator() () const {
00613       return lhs() && (lhs.rhsValue() < rhs);
00614     }
00615     
00616   protected:
00618     virtual ~ChainCompFloatLess() {}
00619 };
00620 
00621 //  Class ChainCompFloatLessEqual:
00622 //  Helper class for (FloatFun < FloatFun) <= Float_FF
00623 class  ChainCompFloatLessEqual: public ChainCompFloat {
00624   public:
00626     ChainCompFloatLessEqual (const FloatFunComp& lhs_,    
00627                              Float_FF            rhs_     
00628                             )
00629     : ChainCompFloat (lhs_, "<=", rhs_) {}
00631     virtual bool operator() () const {
00632       return lhs() && (lhs.rhsValue() <= rhs);
00633     }
00634     
00635   protected:
00637     virtual ~ChainCompFloatLessEqual() {}
00638 };
00639 
00640 //  Class ChainCompFloatGreater:
00641 //  Helper class for (FloatFun < FloatFun) > Float_FF
00642 class  ChainCompFloatGreater: public ChainCompFloat {
00643   public:
00645     ChainCompFloatGreater (const FloatFunComp& lhs_,    
00646                            Float_FF            rhs_     
00647                            )
00648     : ChainCompFloat (lhs_, ">", rhs_) {}
00650     virtual bool operator() () const {
00651       return lhs() && (lhs.rhsValue() > rhs);
00652     }
00653     
00654   protected:
00656     virtual ~ChainCompFloatGreater() {}
00657 };
00658 
00659 //  Class ChainCompFloatGreaterEqual:
00660 //  Helper class for (FloatFun < FloatFun) >= Float_FF
00661 class  ChainCompFloatGreaterEqual: public ChainCompFloat {
00662   public:
00664     ChainCompFloatGreaterEqual (const FloatFunComp& lhs_,    
00665                                 Float_FF            rhs_     
00666                                )
00667     : ChainCompFloat (lhs_, ">=", rhs_) {}
00669     virtual bool operator() () const {
00670       return lhs() && (lhs.rhsValue() >= rhs);
00671     }
00672     
00673   protected:
00675     virtual ~ChainCompFloatGreaterEqual() {}
00676 };
00677 
00678 //  Class ChainCompFloatEqual:
00679 //  Helper class for (FloatFun < FloatFun) == Float_FF
00680 class  ChainCompFloatEqual: public ChainCompFloat {
00681   public:
00683     ChainCompFloatEqual (const FloatFunComp& lhs_,    
00684                          Float_FF            rhs_     
00685                         )
00686     : ChainCompFloat (lhs_, "==", rhs_) {}
00688     virtual bool operator() () const {
00689       return lhs() && (lhs.rhsValue() == rhs);
00690     }
00691     
00692   protected:
00694     virtual ~ChainCompFloatEqual() {}
00695 };
00696 
00697 //  Class ChainCompFloatNotEqual:
00698 //  Helper class for (FloatFun < FloatFun) != Float_FF
00699 class  ChainCompFloatNotEqual: public ChainCompFloat {
00700   public:
00702     ChainCompFloatNotEqual (const FloatFunComp& lhs_,    
00703                             Float_FF            rhs_     
00704                             )
00705     : ChainCompFloat (lhs_, "!=", rhs_) {}
00707     virtual bool operator() () const {
00708       return lhs() && (lhs.rhsValue() != rhs);
00709     }
00710     
00711   protected:
00713     virtual ~ChainCompFloatNotEqual() {}
00714 };
00715 
00716 //  Class FloatFloatFunComp:
00717 //  Helper class for comparisons between a Float_FF and a FloatFun 
00718 /*
00719  * This cut holds a Float_FF and a pointer to a FloatFun
00720  * The derived classes operator().
00721  */
00722 class  FloatFloatFunComp: public FloatFunComp {
00723   public:
00725     FloatFloatFunComp (Float_FF lhs_,              
00726                        const std::string& opname_, 
00727                        const FloatFun& rhs_        
00728                       );
00729     virtual Float_FF lhsValue() const {
00730       return lhs;
00731     }
00732     virtual Float_FF rhsValue() const {
00733       return rhs();
00734     }
00735     
00736     virtual const FillIterator *getIterator() const {  
00737       return rhs.getIterator(); 
00738     }
00739   protected:
00740     virtual ~FloatFloatFunComp() {} 
00741 
00742     // Data members
00743     Float_FF           lhs;     
00744     const FloatFun& rhs;     
00745 };
00746 
00747 //  Class FloatFloatFunLess:
00748 //  Helper class for Float_FF < FloatFun
00749 class  FloatFloatFunLess: public FloatFloatFunComp {
00750   public:
00751     FloatFloatFunLess (Float_FF        lhs_,    
00752                        const FloatFun& rhs_     
00753                       )
00754     : FloatFloatFunComp (lhs_, "<", rhs_) {}
00755     
00757     virtual bool operator() () const {
00758       return lhs < rhs();
00759     }
00760   protected:
00762     virtual ~FloatFloatFunLess() {}
00763 };
00764 
00765 //  Class FloatFloatFunLessEqual:
00766 //  Helper class for Float_FF <= FloatFun
00767 class  FloatFloatFunLessEqual: public FloatFloatFunComp {
00768   public:
00769     FloatFloatFunLessEqual (Float_FF        lhs_,    
00770                             const FloatFun& rhs_     
00771                            )
00772     : FloatFloatFunComp (lhs_, "<=", rhs_) {}
00773     
00775     virtual bool operator() () const {
00776       return lhs <= rhs();
00777     }
00778   protected:
00780     virtual ~FloatFloatFunLessEqual() {}
00781 };
00782 
00783 //  Class FloatFloatFunGreater:
00784 //  Helper class for Float_FF > FloatFun
00785 class  FloatFloatFunGreater: public FloatFloatFunComp {
00786   public:
00787     FloatFloatFunGreater (Float_FF        lhs_,    
00788                           const FloatFun& rhs_     
00789                          )
00790     : FloatFloatFunComp (lhs_,">",  rhs_) {}
00791     
00793     virtual bool operator() () const {
00794       return lhs > rhs();
00795     }
00796   protected:
00798     virtual ~FloatFloatFunGreater() {}
00799 };
00800 
00801 //  Class FloatFloatFunGreaterEqual:
00802 //  Helper class for Float_FF >= FloatFun
00803 class  FloatFloatFunGreaterEqual: public FloatFloatFunComp {
00804   public:
00805     FloatFloatFunGreaterEqual (Float_FF        lhs_,    
00806                                const FloatFun& rhs_     
00807                            )
00808     : FloatFloatFunComp (lhs_, ">=", rhs_) {}
00809     
00811     virtual bool operator() () const {
00812       return lhs >= rhs();
00813     }
00814   protected:
00816     virtual ~FloatFloatFunGreaterEqual() {}
00817 };
00818 
00819 //  Class FloatFloatFunEqual:
00820 //  Helper class for Float_FF == FloatFun
00821 class  FloatFloatFunEqual: public FloatFloatFunComp {
00822   public:
00823     FloatFloatFunEqual (Float_FF        lhs_,    
00824                         const FloatFun& rhs_     
00825                        )
00826     : FloatFloatFunComp (lhs_, "==", rhs_) {}
00827     
00829     virtual bool operator() () const {
00830       return lhs == rhs();
00831     }
00832   protected:
00834     virtual ~FloatFloatFunEqual() {}
00835 };
00836 
00837 //  Class FloatFloatFunEqual:
00838 //  Helper class for Float_FF != FloatFun
00839 class  FloatFloatFunNotEqual: public FloatFloatFunComp {
00840   public:
00841     FloatFloatFunNotEqual (Float_FF        lhs_,    
00842                            const FloatFun& rhs_     
00843                           )
00844     : FloatFloatFunComp (lhs_, "!=", rhs_) {}
00845     
00847     virtual bool operator() () const {
00848       return lhs != rhs();
00849     }
00850   protected:
00852     virtual ~FloatFloatFunNotEqual() {}
00853 };
00854 
00855 
00856 //  Class FloatFunFloatComp:
00857 //  Helper class for comparisons between a Float_FF and a FloatFun 
00858 /*
00859  * This cut holds a pointer to a FloatFun and a Float_FF 
00860  * The derived classes operator().
00861  */
00862 class  FloatFunFloatComp: public FloatFunComp {
00863   public:
00865     FloatFunFloatComp (const FloatFun&   lhs_,       
00866                        const std::string& opname_,   
00867                        Float_FF           rhs_       
00868                       );
00869     virtual Float_FF lhsValue() const {
00870       return lhs();
00871     }
00872     virtual Float_FF rhsValue() const {
00873       return rhs;
00874     }
00875     
00876     virtual const FillIterator *getIterator() const {  
00877       return lhs.getIterator(); 
00878     }
00879     
00880   protected:
00881     virtual ~FloatFunFloatComp() {} 
00882 
00883     // Data members
00884     const FloatFun& lhs;     
00885     Float_FF           rhs;     
00886 };
00887 
00888 //  Class FloatFunFloatLess:
00889 //  Helper class for FloatFun < Float_FF
00890 class  FloatFunFloatLess: public FloatFunFloatComp {
00891   public:
00892     FloatFunFloatLess (const FloatFun& lhs_,    
00893                        Float_FF        rhs_     
00894                       )
00895     : FloatFunFloatComp (lhs_, "<", rhs_) {}
00896     
00898     virtual bool operator() () const {
00899       return lhs() < rhs;
00900     }
00901   protected:
00903     virtual ~FloatFunFloatLess() {}
00904 };
00905 
00906 //  Class FloatFunFloatLessEqual:
00907 //  Helper class for FloatFun <= Float_FF
00908 class  FloatFunFloatLessEqual: public FloatFunFloatComp {
00909   public:
00910     FloatFunFloatLessEqual (const FloatFun& lhs_,    
00911                             Float_FF        rhs_     
00912                            )
00913     : FloatFunFloatComp (lhs_, "<=", rhs_) {}
00914     
00916     virtual bool operator() () const {
00917       return lhs() <= rhs;
00918     }
00919   protected:
00921     virtual ~FloatFunFloatLessEqual() {}
00922 };
00923 
00924 //  Class FloatFunFloatGreater:
00925 //  Helper class for FloatFun > Float_FF
00926 class  FloatFunFloatGreater: public FloatFunFloatComp {
00927   public:
00928     FloatFunFloatGreater (const FloatFun& lhs_,    
00929                           Float_FF        rhs_     
00930                          )
00931     : FloatFunFloatComp (lhs_, ">", rhs_) {}
00932     
00934     virtual bool operator() () const {
00935       return lhs() > rhs;
00936     }
00937   protected:
00939     virtual ~FloatFunFloatGreater() {}
00940 };
00941 
00942 //  Class FloatFunFloatGreaterEqual:
00943 //  Helper class for FloatFun >= Float_FF
00944 class  FloatFunFloatGreaterEqual: public FloatFunFloatComp {
00945   public:
00946     FloatFunFloatGreaterEqual (const FloatFun& lhs_,    
00947                                Float_FF        rhs_     
00948                               )
00949     : FloatFunFloatComp (lhs_, ">=", rhs_) {}
00950     
00952     virtual bool operator() () const {
00953       return lhs() >= rhs;
00954     }
00955   protected:
00957     virtual ~FloatFunFloatGreaterEqual() {}
00958 };
00959 
00960 //  Class FloatFunFloatEqual:
00961 //  Helper class for FloatFun == Float_FF
00962 class  FloatFunFloatEqual: public FloatFunFloatComp {
00963   public:
00964     FloatFunFloatEqual (const FloatFun& lhs_,    
00965                         Float_FF        rhs_     
00966                         )
00967     : FloatFunFloatComp (lhs_, "==", rhs_) {}
00968     
00970     virtual bool operator() () const {
00971       return lhs() == rhs;
00972     }
00973   protected:
00975     virtual ~FloatFunFloatEqual() {}
00976 };
00977 
00978 //  Class FloatFunFloatNotEqual:
00979 //  Helper class for FloatFun != Float_FF
00980 class  FloatFunFloatNotEqual: public FloatFunFloatComp {
00981   public:
00982     FloatFunFloatNotEqual (const FloatFun& lhs_,    
00983                            Float_FF        rhs_     
00984                            )
00985     : FloatFunFloatComp (lhs_, "!=", rhs_) {}
00986     
00988     virtual bool operator() () const {
00989       return lhs() != rhs;
00990     }
00991   protected:
00993     virtual ~FloatFunFloatNotEqual() {}
00994 };
00995 
00996 
00997 class CachedFloatFun: public FloatFun, public CachedO {
00998   public:
01000     CachedFloatFun (const ROListPoR& rol,  
01001                     const FloatFun&  arg_  
01002                    );
01003     
01005     virtual Float_FF operator() () const;
01006     
01008     virtual void invalidateCache() { cacheValid = false; }
01009     
01010   protected:
01012     virtual ~CachedFloatFun() {}
01013     
01014     // Data members
01015     const   FloatFun& arg;         
01016     mutable bool cacheValid;       
01017     mutable Float_FF cachedValue;     
01018 };
01019 
01020 class CachedFloatFunIt: public FloatFun, public CachedO {
01021   public:
01023     CachedFloatFunIt (const ROListPoR&     rol,  
01024                       const FloatFun&      arg_, 
01025                       const FillIterator&  iter_ 
01026                      );
01027     
01029     virtual Float_FF operator() () const;
01030     
01032     virtual const FillIterator *getIterator() const { 
01033       return &iter; 
01034     }
01035     
01037     virtual void invalidateCache() {   
01038       cacheValid.resize(0);
01039       cachedValues.resize(0);
01040     }
01041     
01042   protected:
01044     void growCache (unsigned int s) const;
01045   
01047     virtual ~CachedFloatFunIt() {}
01048     
01049     // Data members
01050     const   FloatFun& arg;                      
01051     const   FillIterator&  iter;                  
01052     mutable std::vector<bool>  cacheValid;      
01053     mutable std::vector<Float_FF> cachedValues;    
01054 };
01055 
01056 
01057 // Base class for "collective" FloatFun classes that determine minimum, maximum etc.
01058 class CollectiveFloatFun: public FloatFun {
01059   public:
01060     CollectiveFloatFun (const std::string&           funname_,    
01061                         const FloatFunPoRConst&      fun_=0,      
01062                         const BaseCutPoRConst&       cut_=0,      
01063                         const FillIteratorPoR&       intiter_=0,  
01064                         const FillIteratorPoRConst&  extiter_=0   
01065                        );           
01066     virtual const FillIterator *getIterator() const {  
01067       return extiter; 
01068     }
01069     
01070   protected:
01071     virtual ~CollectiveFloatFun() {}
01072     void checkIterators();
01073     static std::string makeName(const std::string&           funname_,     
01074                                 const FloatFunPoRConst&      fun_,        
01075                                 const BaseCutPoRConst&       cut_,         
01076                                 const FillIteratorPoR&       intiter_,     
01077                                 const FillIteratorPoRConst&  extiter_      
01078                                );
01079     // Data members
01080     const FloatFun      *fun;      
01081     const BaseCut       *cut;      
01082           FillIterator  *intiter;  
01083     const FillIterator  *extiter;  
01084 };
01085 
01086 // Returns maximum value of all fun objects that fulfill cut
01087 class MaxFloatFun: public CollectiveFloatFun {
01088   public: 
01089     MaxFloatFun (const FloatFunPoRConst&      fun_=0,      
01090                  const BaseCutPoRConst&       cut_=0,      
01091                  const FillIteratorPoR&       intiter_=0,  
01092                  const FillIteratorPoRConst&  extiter_=0   
01093                  )
01094      : CollectiveFloatFun  ("max", fun_, cut_, intiter_, extiter_)
01095      {}
01096      
01097    virtual Float_FF operator() () const;           
01098   protected:
01099     virtual ~MaxFloatFun() {}
01100 };
01101 
01102 // Returns maximum value of all fun objects that fulfill cut
01103 class MinFloatFun: public CollectiveFloatFun {
01104   public: 
01105     MinFloatFun (const FloatFunPoRConst&      fun_=0,      
01106                  const BaseCutPoRConst&       cut_=0,      
01107                  const FillIteratorPoR&       intiter_=0,  
01108                  const FillIteratorPoRConst&  extiter_=0   
01109                  )
01110      : CollectiveFloatFun  ("min", fun_, cut_, intiter_, extiter_)
01111      {}
01112      
01113    virtual Float_FF operator() () const;           
01114   protected:
01115     virtual ~MinFloatFun() {}
01116 };
01117 
01118 // Returns sum of all fun objects that fulfill cut
01119 class SumFloatFun: public CollectiveFloatFun {
01120   public: 
01121     SumFloatFun (const FloatFunPoRConst&      fun_=0,      
01122                  const BaseCutPoRConst&       cut_=0,      
01123                  const FillIteratorPoR&       intiter_=0,  
01124                  const FillIteratorPoRConst&  extiter_=0   
01125                  )
01126      : CollectiveFloatFun  ("sum", fun_, cut_, intiter_, extiter_)
01127      {}
01128      
01129    virtual Float_FF operator() () const;           
01130   protected:
01131     virtual ~SumFloatFun() {}
01132 };
01133 
01134 // Returns sum of all fun objects that fulfill cut
01135 class AverageFloatFun: public CollectiveFloatFun {
01136   public: 
01137     AverageFloatFun (const FloatFunPoRConst&      fun_=0,      
01138                      const BaseCutPoRConst&       cut_=0,      
01139                      const FillIteratorPoR&       intiter_=0,  
01140                      const FillIteratorPoRConst&  extiter_=0   
01141                      )
01142      : CollectiveFloatFun  ("average", fun_, cut_, intiter_, extiter_)
01143      {}
01144      
01145    virtual Float_FF operator() () const;           
01146   protected:
01147     virtual ~AverageFloatFun() {}
01148 };
01149  
01150 #endif /* #ifndef __FLOATFUNHELPERS_H */

Generated on Thu Oct 26 12:52:56 2006 for SFH by doxygen 1.3.2