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

StepScheme.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_VideoJob_StepScheme_h
00002 #define Impala_Core_VideoJob_StepScheme_h
00003 
00004 #include "Basis/ILog.h"
00005 
00006 namespace Impala
00007 {
00008 namespace Core
00009 {
00010 namespace VideoJob
00011 {
00012 
00013 /***********************************************************************
00014 An instance of this class represents a scheme of processing steps
00015 for the processing of video collections. A processing step is considered
00016 to be the smallest unit of work and applies to either an individual
00017 video or to the video set as a whole. Each step may depend on one or more 
00018 other steps. 
00019 ************************************************************************/
00020 
00021 class StepScheme
00022 {
00023 
00024 public:
00025 
00026     typedef struct Step
00027     {
00028         int stepNr;
00029         String text;
00030         String cmdLineTemplate[3];
00031         bool isIndiv;
00032         bool vidSetArgBeforeVidNrArg;
00033     } Step;
00034 
00035     StepScheme(const std::vector<String>& stepStrings)
00036     {
00037         int nrOfSteps = stepStrings.size();
00038         for (int i = 0; i < nrOfSteps; i++)
00039         {
00040             CString stepStr = stepStrings[i];
00041             Step step;
00042             step.stepNr = i;
00043             step.text = stepStr;
00044 
00045             int setPos = stepStr.find("%VIDEO_SET%");
00046             if (setPos < 0)
00047             {
00048                 // a collective step! 
00049                 step.isIndiv = false;
00050                 step.cmdLineTemplate[0] = "";
00051                 step.cmdLineTemplate[1] = "";
00052                 step.cmdLineTemplate[2] = "";
00053             }
00054             else
00055             {
00056                 int nrPos = stepStr.find("%VIDEO_NR%");
00057                 if (nrPos < 0)
00058                 {
00059                     // a collective step
00060                     step.isIndiv = false;
00061                     step.cmdLineTemplate[0] = stepStr.substr(0, setPos);
00062                     step.cmdLineTemplate[1] = stepStr.substr(setPos + 11);
00063                     step.cmdLineTemplate[2] = "";
00064                 }
00065                 else
00066                 {
00067                     // an individual step
00068                     step.isIndiv = true;
00069                     if (setPos < nrPos)
00070                     {
00071                         step.vidSetArgBeforeVidNrArg = true;
00072                         step.cmdLineTemplate[0] = stepStr.substr(0, setPos);
00073                         step.cmdLineTemplate[1] =
00074                             stepStr.substr(setPos + 11, nrPos - (setPos + 11));
00075                         step.cmdLineTemplate[2] = stepStr.substr(nrPos + 10);
00076                     }
00077                     else
00078                     {
00079                         step.vidSetArgBeforeVidNrArg = false;
00080                         step.cmdLineTemplate[0] = stepStr.substr(0, nrPos);
00081                         step.cmdLineTemplate[1] =
00082                             stepStr.substr(nrPos + 10, setPos - (nrPos + 10));
00083                         step.cmdLineTemplate[2] = stepStr.substr(setPos + 11);
00084                     }
00085                 }
00086             }
00087 
00088             mSteps.push_back(step);
00089         }
00090     }
00091 
00092     int 
00093     Size() const
00094     {
00095         return mSteps.size();
00096     }
00097 
00098     const Step&
00099     GetStep(int stepNr) const
00100     {
00101         return mSteps[stepNr];
00102     }
00103 
00104     String
00105     GetCmdLine(int stepNr, String videoSet, int videoNr = -1) const
00106     {
00107         const Step& step = mSteps.at(stepNr);
00108         if (step.isIndiv)
00109         {
00110             if (videoNr < 0)
00111             {
00112                 ILOG_ERROR("Need a valid video number (" << videoNr << ")");
00113             }
00114             if (step.vidSetArgBeforeVidNrArg)
00115                 return step.cmdLineTemplate[0] + videoSet +
00116                     step.cmdLineTemplate[1] + MakeString(videoNr) +
00117                     step.cmdLineTemplate[2];
00118             else
00119                 return step.cmdLineTemplate[0] + MakeString(videoNr) +
00120                     step.cmdLineTemplate[1] + videoSet + step.cmdLineTemplate[2];
00121         }
00122         else if (step.cmdLineTemplate[0].empty())
00123         {
00124             return step.text;
00125         }
00126         else
00127         {
00128             return step.cmdLineTemplate[0] + videoSet + step.cmdLineTemplate[1];
00129         }
00130     }
00131 
00132 
00133 private:
00134 
00135     ILOG_VAR_DECL;
00136 
00137     std::vector<Step> mSteps;
00138 
00139 }; // class
00140 
00141 ILOG_VAR_INIT(StepScheme, Impala.Core.VideoJob);
00142 
00143 } // namespace 
00144 } // namespace 
00145 } // namespace 
00146 
00147 #endif

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