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

ThreadHistory.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Trec_ThreadHistory_h
00002 #define Impala_Core_Trec_ThreadHistory_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 {
00010 namespace Core
00011 {
00012 namespace Trec
00013 {
00014 
00015 
00016 class ThreadHistory : public Thread
00017 {
00018 public:
00019 
00020     ThreadHistory() :
00021         Thread("history")
00022     {
00023         mHistory = new std::vector<int>();
00024     }
00025 
00026     ~ThreadHistory()
00027     {
00028         delete mHistory;
00029     }
00030 
00031     virtual int
00032     GetShot(int position)
00033     {
00034         if ((position < 0) || (position >= mHistory->size()))
00035             return -1;
00036         return (*mHistory)[position];
00037     }
00038 
00039     virtual int
00040     GetLength()
00041     {
00042         return mHistory->size();
00043     }
00044 
00045     virtual int
00046     GetShotAt(int shot, int offset)
00047     {
00048         int r = GetShotPosition(shot);
00049         if (r == -1)
00050             return -1;
00051         int dst = r + offset;
00052         if ((dst < 0) || (dst >= mHistory->size()))
00053             return -1;
00054         return (*mHistory)[dst];
00055     }
00056 
00057     virtual int
00058     GetShotPosition(int shot)
00059     {
00060         for (int i = 0; i < mHistory->size(); i++)
00061         {
00062             if ( (*mHistory)[i] == shot)
00063                 return i;
00064         }
00065         return -1;
00066     }
00067 
00068     void
00069     Remove(int shot)
00070     {
00071         std::vector<int>::iterator i = mHistory->begin();
00072         while (i != mHistory->end())
00073         {
00074             if (*i == shot)
00075                 i = mHistory->erase(i);
00076             else
00077                 i++;
00078         }
00079     }
00080 
00081     void
00082     Push(int shot)
00083     {
00084         if (mHistory->size() > 0 && (*mHistory)[mHistory->size() - 1] == shot)
00085             return;
00086         ILOG_DEBUG("adding " << shot << " to history");
00087         mHistory->push_back(shot);
00088     }
00089 
00090     virtual int
00091     GetType()
00092     {
00093         return HISTORY;
00094     }
00095 
00096 private:
00097 
00098     std::vector<int> *mHistory;
00099 
00100     ILOG_VAR_DEC;
00101 
00102 };
00103 ILOG_VAR_INIT(ThreadHistory, Core.Trec);
00104 
00105 
00106 } // namespace Trec
00107 } // namespace Core
00108 } // namespace Impala
00109 
00110 #endif

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