Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

xmlprocessor.hpp

Go to the documentation of this file.
00001 #if !defined(_XMLPROCESSOR_HPP)
00002 #define _XMLPROCESSOR_HPP
00003 //============================================================================= 
00004 //
00005 // XDFLengine library
00006 //
00007 //-----------------------------------------------------------------------------
00008 //  XMLPROCESSOR.HPP
00009 //----------------------------------------------------------------------------- 
00015 //_____________________________________________________________________________
00016 //
00017 //  Copyright (C) 2003 Guillaume Baurand. All Rights Reserved.
00018 //
00019 //  This file is part of the XDFLengine project.
00020 //
00021 //  The XDFLengine is free software; you can redistribute it and/or modify
00022 //  it under the terms of the GNU General Public License as published by
00023 //  the Free Software Foundation; either version 2 of the License, or
00024 //  (at your option) any later version.
00025 //
00026 //  This program is distributed in the hope that it will be useful,
00027 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00028 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00029 //  GNU General Public License for more details.
00030 //
00031 //  You should have received a copy of the GNU General Public License
00032 //  along with this program; if not, write to the Free Software
00033 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
00034 //  USA.
00035 //
00036 //  For more information, 
00037 //      contact  : guillaume@baurand.net 
00038 //      or visit : http://xdflengine.sourceforge.net
00039 //
00040 //=============================================================================  
00041 
00042 #   include "config/commonincs.hpp"
00043 #   include "processor/xmlflowbuilder.hpp"
00044 #   include "processor/xmlflowcontext.hpp"
00045 #   include "processor/xmlstreamerfactory.hpp"
00046 #   include "flow/xmlstreamconsumer.hpp"
00047 #   include "flow/buffers/xmlbuffers.hpp"
00048 
00049 BEGIN_XDFLENGINE_NS;
00050 
00051 static unsigned int     g_uiMaxThreads;         
00052 
00053 class XMLFlowContext;
00054 
00055 //============================================================================= 
00056 //  CLASS XMLPROCESSOR
00057 //----------------------------------------------------------------------------- 
00065 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00066 class XDFLENGINE_EXPORT XMLProcessor
00067 {
00068 public:
00069             
00070     protected: 
00071     
00072         char*                                   m_pszActiveURI ;        
00073         VAarray< XMLStreamerFactory*>           m_vaStreamerFactories;  
00074         VAarray< RootStreamNode*>               m_pvaScriptCache;               
00075         XMLFlowContext*                         m_pContext;                             
00076         bool                                    m_fOwnContext;                  
00077 
00078     public: 
00079 
00080     // STATICS
00081 
00082         //_____________________________________________________________________
00083         //  INIT
00084         //---------------------------------------------------------------------`
00087         //_____________________________________________________________________
00088         static void init ();
00089         
00090         //_____________________________________________________________________
00091         //  TERMINATE
00092         //---------------------------------------------------------------------
00095         //_____________________________________________________________________
00096         static void terminate ();
00097 
00098         //_____________________________________________________________________
00099         //  GETNEWBUFFER
00100         //---------------------------------------------------------------------
00107         //_____________________________________________________________________
00108         static XMLStreamBuffer* getNewBuffer(const char* p_pszBufferType = 0,const char* p_pszFileName = 0, bool p_fReadOnly=false, unsigned int p_uiBufferSize = 0);
00109 
00110 
00111         //_____________________________________________________________________
00112         //  SETTHREADCOUNT
00113         //---------------------------------------------------------------------
00116         //---------------------------------------------------------------------
00117         static void setThreadCount( unsigned int p_uiThreadCount);
00118 
00119         //_____________________________________________________________________
00120         //  GETTHREADCOUNT
00121         //---------------------------------------------------------------------
00124         //---------------------------------------------------------------------
00125         static unsigned int getThreadCount();
00126 
00127     // CONSTRUCTOR & DESTRUCTOR 
00128 
00129         //_____________________________________________________________________
00130         //  XMLPROCESSOR
00131         //---------------------------------------------------------------------
00134         //_____________________________________________________________________
00135         XMLProcessor ();
00136 
00137 
00138         //_____________________________________________________________________
00139         //  ~XMLPROCESSOR
00140         //---------------------------------------------------------------------
00143         //_____________________________________________________________________
00144         ~XMLProcessor ();
00145 
00146     // ACTIVE URI
00147 
00148         //_____________________________________________________________________
00149         //  SETACTIVEURI
00150         //---------------------------------------------------------------------
00154         //_____________________________________________________________________
00155         void setActiveURI ( const char* p_pszActiveURI);
00156 
00157         //_____________________________________________________________________
00158         //  GETACTIVEURI
00159         //---------------------------------------------------------------------
00162         //_____________________________________________________________________
00163         const char* getActiveURI();
00164 
00165     // STREAMERS
00166 
00167         //_____________________________________________________________________
00168         //  LOADSTREAMERFACTORIES
00169         //---------------------------------------------------------------------
00171         //_____________________________________________________________________     
00172         void loadStreamerFactories();
00173 
00174         //_____________________________________________________________________
00175         //  LOADVALUERS
00176                 //---------------------------------------------------------------------
00178                 //_____________________________________________________________________        
00179         void loadValuers( XMLFlowContext* p_pContext) const;
00180 
00181         //_____________________________________________________________________
00182         //  ADDSTREAMERFACTORY
00183         //---------------------------------------------------------------------
00188         //_____________________________________________________________________
00189         void addStreamerFactory ( XMLStreamerFactory* p_pXMLHandler, const char* p_pszName);
00190 
00191         //_____________________________________________________________________
00192         //  GETSTREAMERFACTORY
00193         //---------------------------------------------------------------------
00198         //_____________________________________________________________________
00199         XMLStreamerFactory* getStreamerFactory ( const char* p_pszName) const;        
00200 
00201     // CONTEXT
00202 
00203         //_____________________________________________________________________
00204         //  SETCONTEXT
00205         //---------------------------------------------------------------------
00206                 // @brief                                       Forces a context object for the XMLProcessor.
00207                 // @param               p_pContext      The context object to attribite to the XMLProcessor.
00208                 //_____________________________________________________________________
00209         void setContext(XMLFlowContext* p_pContext);
00210 
00211         //_____________________________________________________________________
00212         //  GETCONTEXT
00213         //---------------------------------------------------------------------
00214                 // @brief               Retrieve the static context from the Processor.
00215                 // @return              The context object of the XMlProcessor.
00216                 //_____________________________________________________________________
00217         XMLFlowContext* getContext() const;     
00218     
00219     // CACHE METHODS
00220 
00221         //_____________________________________________________________________
00222         //  CACHESCRIPT
00223         //---------------------------------------------------------------------
00224                 // @brief                                               Insert a compiled XDFL script in cache to fasten further execution.
00225                 // @param               p_pRootNode             The root node of the script to cache.
00226                 // @param               p_pszCacheName  The calling name for the cache.
00227                 // @param               p_uiThreadId    The number of the thread which performs the insertion.
00228                 //_____________________________________________________________________
00229         void cacheScript( RootStreamNode* p_pRootNode, const char* p_pszCacheName, unsigned int p_uiThreadId = 0);
00230 
00231         //_____________________________________________________________________
00232         //  GETCACHEDSCRIPT
00233         //---------------------------------------------------------------------
00234                 // @brief                                       Retrieves a compiled XDFL script from the cache.
00235                 // @param p_pszCacheName        The calling name for the cache.
00236                 // @param p_uiThreadId          The number of the thread which is calling the cache.
00237                 // @return                                      The cached script root node.
00238                 //_____________________________________________________________________
00239         const RootStreamNode*   getCachedScript( const char* p_pszCacheName, unsigned int p_uiThreadId = 0);
00240 
00241     // COMPILE & EXEC METHODS
00242 
00243         //_____________________________________________________________________
00244         //  COMPILE
00245         //---------------------------------------------------------------------
00246                 // @brief                                       Compiles a XDFL script as a tree of StreamNode objects.
00247                 // @param       p_pInput                The input XML stream containing the script to compile.
00248                 // @param       p_uiThreadId    The calling thread number.
00249                 // @return                                      The root node of the compiled script.
00250                 //_____________________________________________________________________
00251         RootStreamNode* compile( XMLStreamProvider* p_pInput, unsigned int p_uiThreadId = 0) const;
00252         
00253         //_____________________________________________________________________
00254         //  EXECUTE
00255         //---------------------------------------------------------------------
00256                 // @brief                                       Executes a compiles XDFL script.
00257                 // @param       p_pRootNode             The root node of the compiled script.
00258                 // @param       p_pOutput               The XMLStreamConsumer object which is to receive script's output.
00259                 // @param       p_pContext              The context object to use for the execution of the script.
00260                 // @return                                      The error code. 0 if no error.
00261                 //_____________________________________________________________________
00262         int execute( const RootStreamNode* p_pRootNode, XMLStreamConsumer* p_pOutput, XMLFlowContext* p_pContext=0) const;
00263 
00264         //_____________________________________________________________________
00265         //  PROCESS
00266         //---------------------------------------------------------------------
00267                 // @brief                                       Processes (ie compile + execute) a XDFL script.
00268                 // @param       p_pInput                The input XML stream containing the script to compile.
00269                 // @param       p_pOutput               The XMLStreamConsumer object which is to receive script's output.
00270                 // @param       p_pContext              The context object to use for the execution of the script.
00271                 // @return                                      The error code. 0 if no error.
00272                 //_____________________________________________________________________
00273         int process( XMLStreamProvider* p_pInput , XMLStreamConsumer* p_pOutput, XMLFlowContext* p_pContext=0) const;
00274         
00275     // TICKER
00276 
00277         //_____________________________________________________________________
00278         //  TICK
00279         //---------------------------------------------------------------------
00283         //_____________________________________________________________________
00284         void tick(unsigned long  p_ulClock);
00285 
00286 };
00287 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00288 //=============================================================================
00289 
00290 END_XDFLENGINE_NS;
00291 
00292 #endif
00293 

Generated on Sat Oct 4 13:20:04 2003 for XDFLengine by doxygen1.3-rc2