00001 /******************************************************************************* 00002 * Copyright (c) 2006 International Business Machines Corporation 00003 * All rights reserved. This program and the accompanying materials 00004 * are made available under the terms of the Common Public License v1.0 00005 * which accompanies this distribution, and is available at 00006 * http://www.opensource.org/licenses/cpl1.0.php 00007 * 00008 * Contributors: 00009 * Douglas Sprague, Joel Wheeler - initial API and implementation 00010 * 00011 *****************************************************************************/ 00012 00013 #ifndef STILPATTERNEVAL_H 00014 #define STILPATTERNEVAL_H 00015 00016 #include <string> 00017 #include <vector> 00018 00019 #include "stil.h" 00020 00021 //--------------------------------------------------------------------------- 00034 //--------------------------------------------------------------------------- 00035 00036 class STILPatternEval 00037 { 00038 00039 public: 00040 00041 // - Virtual dtor 00042 virtual ~STILPatternEval(); 00043 00044 // - Open/Close a STIL file to be processed 00045 void open(const std::string & filename); 00046 void close(); 00047 00048 // - Load up the Pattern to be processed 00049 //loadpattern(by #) 00050 bool loadPattern(LONG patNum); 00051 //loadpattern(by name) 00052 00053 // - Return the number of the environment currently being processed 00054 LONG getEnvIdx() { return m_currEnvIdx; } 00055 00056 // - Start evaluating the Pattern block 00057 void evaluate(); 00058 00059 // Sometimes we'll need access directly to the STIL object, or even at 00060 // the evalengine level. I dont think theres any way to completely hide 00061 // these... 00062 // - Get the STIL block 00063 const STIL* getSTIL() { return ((const STIL*)(&m_stilobj)); } 00064 // - Get the currently loaded eval engine 00065 STILEvalEngine * getCurrEvalEngine() { return m_pCurrEvalEng; } 00066 00067 // Maybe return some context about where the current block is found?? 00068 // const STILEntity* getParentBlock() 00069 00070 00071 // Overloadable functions: 00072 // Through these virtual functions, a user can re-implement just those functions 00073 // for which he needs processing capability. By re-implementing these 00074 // member functions in a derived class, the user says that they dont care 00075 // about iterating thru pattern statments or eval engines- all they want 00076 // to do is have a certain function called when a certain type of data 00077 // is encountered. They'll take care of the details of what happens when 00078 // that data type is encountered. And leave all of the evalengine switching 00079 // and iterating up to this parent class... 00080 00081 // - Call this once for each eval engine, before processing any data 00082 virtual void init(); 00083 00084 // Every type of entity in a Pattern block should eventually have a 00085 // 'process<EntityType>' function. When that type is encountered, it's 00086 // derived implementation will be called. 00087 // Any 'block' object (one that may be iterated over) will have a 00088 // 'process<EntityType>' and 'process<EntityType>End' pair of functions. 00089 // If the object is a simple entity (no iteration), then there will only 00090 // be a 'process<EntityType>' member function. 00091 // Block entity (may be iterated over): 00092 virtual void processVector(const STILVector*); 00093 virtual void processVectorEnd(const STILVector*); 00094 00095 virtual void processCondition(const STILCondition*); 00096 virtual void processConditionEnd(const STILCondition*); 00097 00098 virtual void processShift(const STILShift*); 00099 virtual void processShiftEnd(const STILShift*); 00100 00101 // Base entity (no iteration): 00102 virtual void processVectorItem(const STILVectorItem*); 00103 virtual void processWaveformTableRef(const std::string &); 00104 00105 00106 private: 00107 00108 // Dont allow protected access here for any derived classes. 00109 // The implementation is to stay hidden. 00110 STILPattern* getPattern(LONG patNum); 00111 00112 // Iterate thru the various blocks 00113 void iterPatternBlock(); 00114 void iterSubPatternBlock(const STILPatternBlock *); 00115 void iterPatternBlockStatements(const STILEntity &); 00116 void iterVectorBlock(const STILVectorBlock*); 00117 00118 00119 STIL m_stilobj; // base STIL object 00120 STILPattern * m_pPattern; // ptr to desired Pattern block 00121 00122 STILEvalEngine* m_pCurrEvalEng; // the active EE 00123 std::vector<STILEvalEngine*> m_pEvalEngs; // array of EE's- one per env 00124 LONG m_currEnvIdx; // index of active EE 00125 00126 }; 00127 00128 00129 #endif