00001 #ifndef Impala_Core_VideoJob_ProcessDefinition_h 00002 #define Impala_Core_VideoJob_ProcessDefinition_h 00003 00004 #include "Basis/ILog.h" 00005 #include "Basis/File.h" 00006 #include "Util/IOBuffer.h" 00007 #include "Core/VideoJob/StepScheme.h" 00008 #include "Core/VideoJob/StageScheme.h" 00009 00010 namespace Impala 00011 { 00012 namespace Core 00013 { 00014 namespace VideoJob 00015 { 00016 00017 /*********************************************************************** 00018 Instances of this class define steps and stages for the processing of 00019 video collections. 00020 ************************************************************************/ 00021 00022 class ProcessDefinition 00023 { 00024 typedef StepScheme::Step Step; 00025 00026 public: 00027 00028 ProcessDefinition(CString fileName) : mFileName(fileName) 00029 { 00030 std::vector<String> stepDefinitions; 00031 00032 File procDefFile(fileName, "r"); 00033 if (! procDefFile.Valid()) 00034 { 00035 ILOG_ERROR("Failed to open file: " << fileName); 00036 return; 00037 } 00038 00039 while (! procDefFile.Eof()) 00040 { 00041 String line = procDefFile.ReadLine(true); 00042 if (! line.empty()) 00043 stepDefinitions.push_back(line); 00044 } 00045 procDefFile.Close(); 00046 00047 mSteps = new StepScheme(stepDefinitions); 00048 mStages = new StageScheme(*mSteps); 00049 ILOG_INFO("Process definition consists of " 00050 << StepCount() << " steps, to be grouped into " 00051 << StageCount() << " stage(s)"); 00052 } 00053 00054 virtual 00055 ~ProcessDefinition() 00056 { 00057 delete mStages; 00058 delete mSteps; 00059 } 00060 00061 CString 00062 GetFileName() 00063 { 00064 return mFileName; 00065 } 00066 00067 int 00068 StepCount() 00069 { 00070 return mSteps->Size(); 00071 } 00072 00073 int 00074 StageCount() 00075 { 00076 return mStages->Size(); 00077 } 00078 00079 int 00080 FirstStageNr() 00081 { 00082 return mStages->FirstStageNr(); 00083 } 00084 00085 bool 00086 IsIndividualStage(int stageNr) const 00087 { 00088 return mStages->IsIndivStage(stageNr); 00089 } 00090 00091 int 00092 FirstStepOfStage(int stageNr) 00093 { 00094 return mStages->FirstStepOfStage(stageNr); 00095 } 00096 00097 bool 00098 IsLastStepOfStage(int stepNr, int stageNr) 00099 { 00100 return mStages->IsLastStepOfStage(stepNr, stageNr); 00101 } 00102 00103 String 00104 GetCmdLine(int stepNr, CString videoSet, int videoNr = -1) 00105 { 00106 return mSteps->GetCmdLine(stepNr, videoSet, videoNr); 00107 } 00108 00109 CString 00110 GetStep(int stepNr) const 00111 { 00112 return mSteps->GetStep(stepNr).text; 00113 } 00114 00115 00116 private: 00117 00118 ILOG_VAR_DECL; 00119 00120 String mFileName; 00121 00122 StepScheme* mSteps; 00123 StageScheme* mStages; 00124 00125 }; // class 00126 00127 ILOG_VAR_INIT(ProcessDefinition, Impala.Core.VideoJob); 00128 00129 } // namespace 00130 } // namespace 00131 } // namespace 00132 00133 #endif