00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _XVFEATURE_H_
00014 #define _XVFEATURE_H_
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 template <class ST, class ER>
00028 class XVStatePair {
00029
00030 typedef ST STATE;
00031 typedef ER ERROR;
00032
00033 public:
00034
00035 STATE state;
00036 ERROR error;
00037
00038 XVStatePair(STATE s, ERROR e) : state(s), error(e) {}
00039 XVStatePair() {}
00040 };
00041
00042 #define _XVSTATEPAIR_BIN_OP_(_OP_) \
00043 template <class ST, class ER> \
00044 XVStatePair<ST, ER> operator _OP_ (const XVStatePair<ST, ER> & s1, const XVStatePair<ST, ER> & s2){ \
00045 XVStatePair<ST, ER> newS; \
00046 newS.state = s1.state _OP_ s2.state; \
00047 newS.error = s1.error && s2.error; \
00048 return newS; \
00049 }
00050
00051 _XVSTATEPAIR_BIN_OP_(+);
00052 _XVSTATEPAIR_BIN_OP_(-);
00053
00054 #include <XVInteractive.h>
00055
00056 template <class IMTYPE, class STATETYPE>
00057 class XVFeature {
00058
00059 protected:
00060
00061 STATETYPE currentState;
00062 bool view;
00063
00064 public:
00065
00066 typedef STATETYPE STATE;
00067 typedef IMTYPE IMAGE;
00068
00069 XVFeature() {}
00070 XVFeature(STATE init) : currentState(init) {}
00071
00072 virtual void initState(STATE init) { currentState = init; view = true; }
00073
00074 virtual STATE step(const IMTYPE &) = 0;
00075
00076
00077 virtual STATE step(const IMTYPE & im, const STATE & st){
00078
00079 currentState = st;
00080 return this->step(im);
00081 };
00082
00083 virtual STATE getState(){ return currentState; }
00084 virtual void setState(STATE & s){ currentState = s; };
00085
00086 virtual bool inView(){ return view; }
00087
00088 virtual STATE interactiveInit(XVInteractive &, const IMTYPE &) = 0;
00089 virtual void show(XVDrawable &) = 0;
00090 };
00091
00092 #define _REGISTER_XVFEATURE_(_IM_TYPE_, _STATE_TYPE_) \
00093 template class XVFeature<_IM_TYPE_, _STATE_TYPE_ >;
00094
00095 #endif