Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

ThreadBookmarked.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Trec_ThreadBookmarked_h
00002 #define Impala_Core_Trec_ThreadBookmarked_h
00003 
00004 #include "Core/Trec/Thread.h"
00005 #include "Core/VideoSet/TableShots.h"
00006 #include "Core/Column/Find.h"
00007 
00008 namespace Impala {
00009 namespace Core {
00010 namespace Trec {
00011 
00012 class ThreadBookmarked : public Thread
00013 {
00014 public:
00015 
00016     ThreadBookmarked(VideoSet::TableShots* bookmarked,
00017                      String threadName = "bookmarked") :
00018         Thread(threadName)
00019     {
00020         mBookmarked = bookmarked;
00021 
00022         if (!mBookmarked)
00023         {
00024             ILOG_DEBUG("Using internal TableShots for " << mName);
00025             mBookmarked = new VideoSet::TableShots();
00026         }
00027     }
00028 
00029     virtual int
00030     GetShot(int position)
00031     {
00032         if ((position < 0) || (position >= mBookmarked->Size()))
00033             return -1;
00034         return mBookmarked->Get1(position);
00035     }
00036 
00037     virtual int
00038     GetLength()
00039     {
00040         return mBookmarked->Size();
00041     }
00042 
00043     virtual int
00044     GetShotAt(int shot, int offset)
00045     {
00046         int r = Column::Find(mBookmarked->GetColumn1(), shot, 0,
00047                                 mBookmarked->Size());
00048         int dst = r + offset;
00049         if ((dst < 0) || (dst >= mBookmarked->Size()))
00050             return -1;
00051         return mBookmarked->Get1(dst);
00052     }
00053 
00054     virtual int
00055     GetShotPosition(int shot)
00056     {
00057         int r = Column::Find(mBookmarked->GetColumn1(), shot, 0,
00058                                 mBookmarked->Size());
00059         if (r >= mBookmarked->Size())
00060             return -1;
00061         return r;
00062     }
00063 
00064     VideoSet::TableShots*
00065     GetBookmarkTable()
00066     {
00067         return mBookmarked;
00068     }
00069 
00070     virtual int
00071     GetType()
00072     {
00073         return BOOKMARK;
00074     }
00075 
00076     void
00077     Clear()
00078     {
00079         mBookmarked->SetEmpty();
00080     }
00081     
00082 
00083     void
00084     AddShot(int shotid, int keyframe)
00085     {
00086         Geometry::Rectangle r;
00087         if (GetShotPosition(shotid) >= 0) {
00088             ILOG_DEBUG(mName << ":AddShot(" << shotid << ", " << keyframe <<
00089                        ") already selected, skipping.");
00090             return;
00091         }
00092         //ILOG_DEBUG(mName << ":AddShot(" << shotid << ", " << keyframe <<")");
00093         mBookmarked->Add(shotid, keyframe, "", r);
00094     }
00095 
00096     void
00097     RemoveShot(int shotid)
00098     {
00099         int row = Core::Column::Find(mBookmarked->GetColumn1(), shotid,
00100                                      0, mBookmarked->Size());
00101         if (row >= 0)
00102         {
00103             Core::Table::RemoveRow(mBookmarked, row);
00104             //ILOG_DEBUG(mName << ":RemoveShot(" << shotid <<"): " <<
00105             //           "removing row " << row);
00106         }
00107     }
00108 
00109 private:
00110 
00111     VideoSet::TableShots* mBookmarked;
00112 
00113     ILOG_VAR_DEC;
00114 
00115 };
00116 
00117 ILOG_VAR_INIT(ThreadBookmarked, Core.Trec);
00118 
00119 } // namespace Trec
00120 } // namespace Core
00121 } // namespace Impala
00122 
00123 #endif

Generated on Fri Mar 19 09:31:26 2010 for ImpalaSrc by  doxygen 1.5.1