Add shared ptr
[trackerpp.git] / src / VideoReader.h
index 340b548..79d39d0 100644 (file)
@@ -1,65 +1,66 @@
 #ifndef _IVIDEO_READER_H_
 #define _IVIDEO_READER_H_
 
+#include "SharedPtr.h"
 #include <string>
 #include <opencv2/opencv.hpp>
 
 namespace suanzi {
 
-typedef enum {
-    URL,
-    File,
-    USB
-} VideoSrcType;
-
-class VideoReader;
-
-class VideoReaderFactory
-{
-public:
-    static VideoReader* createVideoReader(VideoSrcType type, const std::string& url);
-};
-
-class VideoReader
-{
-public:
-    VideoReader(VideoSrcType type, const std::string& url) : type(type), url(url){}
-
-    virtual ~VideoReader();
-    virtual bool read(cv::Mat& mat){return true;}
-
-private:
-    VideoSrcType type;
-
-protected:
-    std::string url;
-};
-
-
-class UrlReader  : public VideoReader
-{
-public:
-    UrlReader(VideoSrcType type, const std::string& url);
-    virtual ~UrlReader();
-    bool read(cv::Mat& mat);
-private:
-    cv::VideoCapture vcap;
-};
-
-class FileReader : public VideoReader
-{
-public:
-    FileReader(VideoSrcType type, const std::string& url):VideoReader(type, url){}
-//    void read(){};
-};
-
-class UsbReader : public VideoReader
-{
-public:
-    UsbReader(VideoSrcType type, const std::string& url):VideoReader(type, url){}
-//    void read(){};
-};
-
+    typedef enum {
+        URL,
+        File,
+        USB
+    } VideoSrcType;
+
+    TK_DECLARE_PTR(VideoReaderFactory);
+    TK_DECLARE_PTR(VideoReader);
+    TK_DECLARE_PTR(URLReader);
+
+    class VideoReaderFactory
+    {
+        public:
+            static VideoReaderPtr createVideoReader(VideoSrcType type, const std::string& url);
+    };
+
+    class VideoReader
+    {
+        public:
+            VideoReader(VideoSrcType type, const std::string& url) : type(type), url(url){}
+
+            virtual ~VideoReader();
+            virtual bool read(cv::Mat& mat){return true;}
+
+        private:
+            VideoSrcType type;
+
+        protected:
+            std::string url;
+    };
+
+    class UrlReader  : public VideoReader
+    {
+        public:
+            UrlReader(VideoSrcType type, const std::string& url);
+            virtual ~UrlReader();
+            bool read(cv::Mat& mat);
+        private:
+            cv::VideoCapture vcap;
+    };
+
+    class FileReader : public VideoReader
+    {
+        public:
+            FileReader(VideoSrcType type, const std::string& url):VideoReader(type, url){}
+        //    void read(){};
+    };
+
+    class UsbReader : public VideoReader
+    {
+        public:
+            UsbReader(VideoSrcType type, const std::string& url):VideoReader(type, url){}
+        //    void read(){};
+    };
 
 }