Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

stil.h

Go to the documentation of this file.
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 STIL_H
00014 #define STIL_H
00015 
00016 #include <pthread.h>       // POSIX thread lib, run parser in separate thread
00017 
00018 //#ifdef __xxx__
00019 #ifdef __xlC__
00020   // nothing
00021 #else
00022   #include <semaphore.h>     // Semaphore library
00023   #undef open
00024   #define open open
00025 #endif
00026 
00027 
00028 
00029 #include "stilcom.h"               // Common library
00030 
00031 #include "stilblock.h"         // STIL Block class interface
00032 #include "stilheader.h"        // STIL Header class interface
00033 #include "stilsignals.h"       // STIL Signals class interface
00034 #include "stilsignalgroups.h"  // STIL Signals class interface
00035 #include "stilpattern.h"       // STIL Pattern class interface
00036 #include "stilpatternburst.h"  // STIL PatternBurst class interface
00037 #include "stilpatternexec.h"   // STIL PatternExec class interface
00038 #include "stilcategory.h"      // STIL Category class interface
00039 #include "stilselector.h"      // STIL Selector class interface
00040 #include "stiltiming.h"        // STIL Timing class interface
00041 #include "stilscanstructures.h"// STIL ScanStructures class interface
00042 #include "stilspec.h"          // STIL Spec class interface
00043 #include "stilloop.h"          // STIL Loop class interface
00044 #include "stilshift.h"         // STIL Shift class interface
00045 #include "stilprocedures.h"    // STIL Procedures class interface
00046 #include "stilmacrodefs.h"     // STIL Macrodefs class interface
00047 #include "stilevalengine.h"    // STIL pattern environment interface
00048 #include "stilscanchain.h"
00049 #include "stilextension.h"
00050 
00051 #include <list>
00052 #include <vector>
00053 
00054 // The default # of buffered pattern statements (0 = no buffer)
00055 //   NOTE: For STIL objects opened in READ mode then specifying a non-zero
00056 //         buffer size also  implies threads will be used in the parser
00057 #define  STIL_DEFAULT_PAT_BUF_SIZE   20   // default thread size of 20
00058 
00059 //---------------------------------------------------------------------------
00071 //---------------------------------------------------------------------------
00072 class STIL : public STILBlock {
00073 
00074   // - Make a friend of the STILEvalEngine so that the lists of blocks may be accessed
00075   friend class STILEvalEngine;
00076 
00077   // - Public members
00078   public:
00079 
00080     // - Type of STIL open mode
00081     enum OPENMODE { OPEN_READ = 1,
00082                     OPEN_WRITE = 2,
00083                     OPEN_NONE = 0};
00084 
00085     // - Default Constructor
00086     STIL();
00087 
00088     // - Copy Constructor
00089     STIL(const STIL &);
00090 
00091     // - Constructor a STIL object given a starting STIL filename
00092     STIL(const sstring &fname,
00093          OPENMODE openmode  = OPEN_READ,
00094          ULONG pat_buf_size = STIL_DEFAULT_PAT_BUF_SIZE);
00095          // optionally specify # of pattern statements to
00096          // buffer up in a sliding window
00097          // 0 - implies no buffering
00098 
00099 
00100     // - Destructor
00101     ~STIL();
00102 
00103     // - Assignment Operator
00104     STIL & operator=(const STIL &);
00105 
00106     // - Initialize this STIL object.
00107     void                init();
00108 
00109     // - Open a STIL file for either READ or WRITE
00110     void                open(const sstring &,
00111                              OPENMODE openmode = OPEN_READ,
00112                              ULONG pat_buf_size = STIL_DEFAULT_PAT_BUF_SIZE);
00113                              // optionally specify # of pattern statements to
00114                              // buffer up in a sliding window
00115                              // 0 - implies no buffering
00116 
00117     // - Close a STIL file (if opened for WRITE then complete write to file)
00118     void                close();
00119 
00120     // - Verify STIL file's syntax/semantics. (Only for files opened for READ)
00121     void                verify();
00122 
00123     // - Get the pattern buffer size this STIL file was opened with (0=no buffer)
00124     ULONG               getPatternBufferSize() const;
00125 
00126     // - Get/Set the current STIL Version
00127     const sstring &      getVersion() const;
00128     void                setVersion(const sstring &);
00129 
00130     // - Get number of STIL extensions
00131     LONG                getNumExtensions() const;
00132     // - Query whether a certain extension exists
00133     BOOLEAN             hasExtension(const sstring &);
00134     // - Add/Get a STIL language extension specifier
00135     const STILExtension &  getExtension(LONG) const;
00136     void                   addExtension(const STILExtension &);
00137 
00138     // - Get/Set the current STIL Filename
00139 //    const sstring &      getFileName() const;
00140 //    void                setFileName(const sstring &);
00141 
00142     // - Get/Set the Header block (new used for writing)
00143     const STILHeader *  getHeader() const;
00144     void                setHeader(const STILHeader &) ;
00145 
00146     // - Get/Set the Signals block
00147     const STILSignals * getSignals() const;
00148     void                setSignals(const STILSignals &) ;
00149 
00150     // - Audit and add a new SignalGroups block
00151     void                addSignalGroups(const STILSignalGroups &);
00152 
00153     // - Audit and add a new PatternBurst block
00154     void                addPatternBurst(const STILPatternBurst &);
00155 
00156     // - Audit and add a new PatternExec block
00157     void                addPatternExec(const STILPatternExec &);
00158 
00159     // - Audit and add a new Spec block
00160     void                addSpec(const STILSpec &);
00161 
00162     // - Audit and add a new Category block
00163     void                addCategory(const STILCategory &);
00164 
00165     // - Audit and add a new Selector block
00166     void                addSelector(const STILSelector &);
00167 
00168     // - Audit and add a new Timing block
00169     void                addTiming(const STILTiming &);
00170 
00171     // - Audit and add a new ScanStructures block
00172     void                addScanStructures(const STILScanStructures &);
00173 
00174     // - Audit and add a new Procedures block
00175     void                addProcedures(const STILProcedures &);
00176 
00177     // - Audit and add a new MacroDefs block
00178     void                addMacroDefs(const STILMacroDefs &);
00179 
00180     // - Allocate a new Pattern block
00181     STILPattern *       newPattern();
00182 
00183     // - Get a Pattern's reference count. This is how many times the
00184     //   given pattern is uniquely referenced for this STIL object within
00185     //   a PatList or PatternBurst
00186     LONG               getPatternRefCount(const sstring& pat);
00187 
00188     // - Get an Evaluation Engine for a given Pattern and it's n'th reference
00189     //   If n'th reference not specified then use first reference.
00190     //   This Evaluation Engine will be properly setup to evaluate signals
00191     //   and WFCS's for the Pattern given it's presence within the PatternExec,
00192     //   PatternBurst, & PatList where it was referenced.
00193     STILEvalEngine*    getEvalEngine(const sstring& pat, LONG nth_reference=1);
00194     void                destroyEvalEngine(const STILEvalEngine *);
00195 
00196   // Private members
00197   private:
00198 
00199     //----------------------- private member functions -----------------------
00200 
00201     // - Determine all of the setup paths possible for a single Pattern based
00202     //    on the combinations of PatternExecs and PatternBursts. Be able to
00203     //    print all possible paths, and to setup for a specific path.
00204     void                buildPatternPaths(const sstring& patname);
00205     void                printPatternPaths(FILE * pOutFile);
00206 
00207     // - Verify the references inside a PatternBurst block (for the block and
00208     //    its patlist_items)
00209     // Was validatePatternBurst_ref, still refers to PatternBurstRef
00210     bool                validatePatternBurst(const STILEntity &) const;
00211 
00212     // - Write out the STIL object to the specified file
00213     void                write(FILE *) const;
00214 
00215     // - Update all complex entries in a newly copied object
00216     void                updateEntityList();
00217 
00218     //----------------------- private members --------------------------------
00219 
00220     // duplicate of stilentity value:
00221     //sstring                 m_filename;          // Name of STIL file
00222     OPENMODE               m_openmode;          // Open mode for the fstream
00223     FILE                  *m_pFile;            // File stream ptr for STIL file.
00224     static bool            m_openedThreaded;   // Have we already opened as threaded
00225     ULONG                  m_patternBufferSize;  // Pattern block buffer size
00226 
00227     sstring            m_version;           // STIL Version (from STIL <version>)
00228 
00229     STILHeader             m_header;            // STIL Header
00230     STILSignals            m_signals;           // STIL Signals block
00231 
00232     std::list<STILSignalGroups> m_signalGroupsList; // STIL List of SignalGroups blocks
00233     std::list<STILPattern>      m_patternList;      // STIL List of Pattern blocks
00234     std::list<STILPatternBurst> m_patternBurstList; // STIL List of PatternBurst blocks
00235     std::list<STILPatternExec>  m_patternExecList;  // STIL List of PatternExec blocks
00236     std::list<STILSpec>         m_specList;         // STIL List of Spec blocks
00237     std::list<STILCategory>     m_categoryList;     // STIL List of Category blocks
00238     std::list<STILSelector>     m_selectorList;     // STIL List of Selector blocks
00239     std::list<STILTiming>       m_timingList;       // STIL List of Timing blocks
00240     std::list<STILScanStructures> m_scanStructuresList;  // STIL List of ScanStructures blocks
00241     std::list<STILProcedures>   m_proceduresList;   // STIL List of Procedures blocks
00242     std::list<STILMacroDefs>    m_macroDefsList;    // STIL List of Macrodefs blocks
00243 
00244     // - A Linked list of all of the PatternBurst/Pattern paths
00245     std::list< std::list<STILEntity*> >  m_paths;
00246 
00247     std::vector<STILExtension>  m_stilExts;
00248 
00249 }; // end STIL class
00250 
00251 // Inline functions
00252 //--------------------------------------------------------------------------
00260 //--------------------------------------------------------------------------
00261 inline ULONG STIL::getPatternBufferSize() const { return m_patternBufferSize; }
00262 
00263 //--------------------------------------------------------------------------
00271 //--------------------------------------------------------------------------
00272 inline const sstring & STIL::getVersion() const { return m_version; }
00273 
00274 //--------------------------------------------------------------------------
00282 //--------------------------------------------------------------------------
00283 inline void STIL::setVersion(const sstring & v) { m_version = v; }
00284 
00285 //--------------------------------------------------------------------------
00293 //--------------------------------------------------------------------------
00294 inline const STILHeader * STIL::getHeader() const { return &m_header; }
00295 
00296 //--------------------------------------------------------------------------
00304 //--------------------------------------------------------------------------
00305 inline const STILSignals * STIL::getSignals() const { return &m_signals; }
00306 
00307 
00308 //inline const sstring & STIL::getFileName() const { return m_filename; }
00309 //inline void STIL::setFileName(const sstring & f) { m_filename = f; }
00310 
00311 #endif

This page last updated on 6 Jul 2007

SourceForge.net Logo