00001 #ifndef USERFUNCPTR_H
00002 #define USERFUNCPTR_H
00003
00004 #include "SundanceDefs.h"
00005
00006 #include "ListBatch.h"
00007
00008
00009 namespace Sundance
00010 {
00011
00012 using namespace TSF;
00013 using std::string;
00014
00015 using std::ostream;
00016
00017
00018
00019
00020
00021
00022
00023
00024 class FuncPtrBase
00025 {
00026 public:
00027
00028
00029
00030 virtual ~FuncPtrBase(){;}
00031
00032
00033 virtual ExprValue average(const Cell& cell) const = 0 ;
00034
00035 private:
00036 };
00037
00038
00039
00040
00041 class FuncOfX : public FuncPtrBase
00042 {
00043 public:
00044
00045
00046
00047 FuncOfX(funcOfX f) : f_(f){;}
00048
00049 virtual ~FuncOfX(){;}
00050
00051
00052 virtual ExprValue average(const Cell& cell) const ;
00053
00054 private:
00055 funcOfX f_;
00056 };
00057
00058
00059
00060
00061
00062
00063
00064 class UserFuncPtr
00065 {
00066 public:
00067
00068
00069
00070 UserFuncPtr(funcOfX f);
00071
00072
00073 ExprValue average(const Cell& cell) const ;
00074
00075
00076 private:
00077 TSFSmartPtr<FuncPtrBase> ptr_;
00078 mutable ListBatch cache_;
00079 };
00080
00081
00082 }
00083 #endif