00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef VBVISITOR_HPP_
00012 #define VBVISITOR_HPP_
00013
00014 #include <iostream>
00015 #include <cv.h>
00016 #include <cxcore.h>
00017 #include <highgui.h>
00018 #include <vector>
00019 #include <string>
00020 #include <boost/variant.hpp>
00021 #include "visionbehavior.hpp"
00022
00027 enum VBEnum {COMPUTE, WRITEON};
00028
00035 typedef boost::variant<IplImage> VariantImgArg;
00036
00040 template<enum VBEnum e>
00041 class VBVisitor : public boost::static_visitor<> {
00042 public:
00043 template <class T>
00044 void operator()(VisionBehavior<T>* vb,
00045 IplImage& src) const {
00046 std::cerr << "Error: VBVisitor(IplImage) called " <<
00047 "with unknown enum" << std::endl;
00048 }
00049 };
00050
00056 template<>
00057 class VBVisitor<COMPUTE> : public boost::static_visitor<> {
00058 public:
00059 template <class T>
00060 void operator()(VisionBehavior<T>* vb,
00061 IplImage& src) const {
00062 vb->doComputations(src);
00063 }
00064 };
00065
00071 template<>
00072 class VBVisitor<WRITEON> : public boost::static_visitor<> {
00073 public:
00074 template <class T>
00075 void operator()(VisionBehavior<T>* vb,
00076 IplImage& src) const {
00077 vb->writeOn(src);
00078 }
00079 };
00080
00081 #endif