00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef HxExportExtraWeightMaskSum_h
00011 #define HxExportExtraWeightMaskSum_h
00012
00013 #include "HxClassName.h"
00014 #include "HxSizes.h"
00015 #include "HxCategories.h"
00016 #include "HxTagList.h"
00017
00018
00022 template<class ResultT, class ImValT, class ExtraValT>
00023 class HxExportExtraWeightMaskSum
00024 {
00025 public:
00027 typedef HxTagTransInVar TransVarianceCategory;
00028
00030 typedef HxTag1Phase PhaseCategory;
00031
00032
00034 HxExportExtraWeightMaskSum(HxTagList& tags);
00035
00037 ~HxExportExtraWeightMaskSum();
00038
00040 void doIt(const ImValT& imV, const ExtraValT& extraV);
00041
00043 static HxString className();
00044
00045 private:
00046 HxTagList& _tags;
00047 ResultT _accum;
00048 ResultT _weight;
00049 };
00050
00051 template<class ResultT, class ImValT, class ExtraValT>
00052
00053 HxExportExtraWeightMaskSum<ResultT,ImValT,ExtraValT>::HxExportExtraWeightMaskSum(HxTagList& tags) : _tags(tags)
00054 {
00055 _accum = HxScalarInt(0);
00056 _weight = HxScalarInt(0);
00057 }
00058
00059 template<class ResultT, class ImValT, class ExtraValT>
00060 HxExportExtraWeightMaskSum<ResultT,ImValT,ExtraValT>::~HxExportExtraWeightMaskSum()
00061 {
00062 ResultT result = _accum / _weight;
00063 HX_COUT << "r: " << result;
00064 HxAddTag(_tags, "result", HxValue(result));
00065 }
00066
00067 template<class ResultT, class ImValT, class ExtraValT>
00068 inline void
00069 HxExportExtraWeightMaskSum<ResultT,ImValT,ExtraValT>::doIt(const ImValT& imV,
00070 const ExtraValT& extraV)
00071 {
00072 HX_COUT << "im : " << imV << ", extra: " << extraV;
00073 _accum += ResultT(imV) * ResultT(extraV);
00074 _weight += ResultT(extraV);
00075 HX_COUT << ", accum : " << _accum << ", weight : " << _weight << STD_ENDL;
00076 }
00077
00078 template<class ResultT, class ImValT, class ExtraValT>
00079 inline HxString
00080 HxExportExtraWeightMaskSum<ResultT,ImValT,ExtraValT>::className()
00081 {
00082 return HxString("weightMaskSum");
00083 }
00084
00085
00086 #endif