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

cachescriptstreamer.cpp

Go to the documentation of this file.
00001 //============================================================================= 
00002 //
00003 // XDFLengine library
00004 //
00005 //-----------------------------------------------------------------------------
00006 //  CACHESCRIPTSTREAMER.CPP
00007 //-----------------------------------------------------------------------------
00013 //_____________________________________________________________________________
00014 //
00015 //  Copyright (C) 2003 Guillaume Baurand. All Rights Reserved.
00016 //
00017 //  This file is part of the XDFLengine project.
00018 //
00019 //  The XDFLengine is free software; you can redistribute it and/or modify
00020 //  it under the terms of the GNU General Public License as published by
00021 //  the Free Software Foundation; either version 2 of the License, or
00022 //  (at your option) any later version.
00023 //
00024 //  This program is distributed in the hope that it will be useful,
00025 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00026 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00027 //  GNU General Public License for more details.
00028 //
00029 //  You should have received a copy of the GNU General Public License
00030 //  along with this program; if not, write to the Free Software
00031 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
00032 //  USA.
00033 //
00034 //  For more information, 
00035 //      contact  : guillaume@baurand.net 
00036 //      or visit : http://xdflengine.sourceforge.net
00037 //
00038 //=============================================================================
00039 
00040 #   include "cachescriptstreamer.hpp"
00041 #   include "processor/xmlprocessor.hpp"
00042 #   include "processor/xmlflowcontext.hpp"
00043 
00044 
00045 BEGIN_XDFLENGINE_NS
00046 
00047 //=============================================================================
00048 //  CLASS CACHESCRIPTSTREAMER
00049 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00050 
00051 // CONSTRUCTOR & DESTRUCTOR
00052 
00053     //_____________________________________________________________________
00054     //  CACHESCRIPTSTREAMER
00055     //---------------------------------------------------------------------
00056     CacheScriptStreamer::CacheScriptStreamer( const XMLStreamerFactory* p_pParent, StreamerParams* p_pParameters, XMLFlowContext* p_pContext, XMLStreamConsumer* p_pOutput)
00057     :XMLStreamer( p_pParent, p_pParameters, p_pContext, p_pOutput)
00058     {
00059         DEBUG_CREATE(CacheScriptStreamer)
00060         m_pScriptBuffer = 0;
00061     }
00062     
00063     //_____________________________________________________________________
00064     //  ~CACHESCRIPTSTREAMER
00065     //---------------------------------------------------------------------     
00066     CacheScriptStreamer::~CacheScriptStreamer()
00067     {
00068         DEBUG_DEL(CacheScriptStreamer)
00069     }
00070     
00071 // STREAM   
00072 
00073     //_____________________________________________________________________
00074     //  INITSTREAM
00075     //---------------------------------------------------------------------
00076     bool CacheScriptStreamer::initStream()
00077     {
00078         DEBUG_IN(CacheScriptStreamer::initStream)
00079 
00080         m_pScriptBuffer = m_pContext->getProcessor() -> getNewBuffer();
00081 
00082         DEBUG_OUT(CacheScriptStreamer::initStream)
00083 
00084         return true;
00085     }
00086 
00087     //_____________________________________________________________________
00088     //  WRITEDATA
00089     //---------------------------------------------------------------------
00090     void CacheScriptStreamer::writeData( const char*    p_pszData, unsigned int p_uiDataLen)
00091     {
00092         DEBUG_IN(CacheScriptStreamer::writeData)
00093 
00094         m_pScriptBuffer -> writeData( p_pszData, p_uiDataLen);
00095 
00096         DEBUG_OUT(CacheScriptStreamer::writeData)
00097     }
00098 
00099     //_____________________________________________________________________
00100     //  COMMITSTREAM
00101     //---------------------------------------------------------------------
00102     bool CacheScriptStreamer::commitStream(bool p_fFinal)
00103     {
00104         //-----------------------------------------------------------------
00105         const char* l_pszScriptName;
00106         RootStreamNode* l_pScriptRoot;
00107         //-----------------------------------------------------------------
00108         PREP_CATCH_XML_FLOW_ERROR;
00109 
00110         if(p_fFinal)
00111         {
00112             l_pszScriptName = getParamValue( m_pParameters, CACHESCRIPTSTREAMER_NAME,"");
00113             logout << "\t" << CACHESCRIPTSTREAMER_TAGNAME<< "   :   " << "Caching script " << l_pszScriptName << "...\n";
00114             WATCH_XML_FLOW_ERROR
00115             {
00116                 l_pScriptRoot = m_pContext->getProcessor()->compile( m_pScriptBuffer, m_pContext->getThreadId());
00117                 ((XMLProcessor*) m_pContext->getProcessor())->cacheScript( l_pScriptRoot, l_pszScriptName);
00118             }
00119             CATCH_XML_FLOW_ERROR_RELEASE_AND_RETURN
00120 
00121         }
00122 
00123     RELEASE_AND_RETURN:
00124 
00125         if(p_fFinal)
00126         {
00127             delete m_pScriptBuffer;
00128         }
00129         ON_XML_FLOW_ERROR_DO
00130         {
00131             delete l_pScriptRoot;
00132         }
00133         ON_XML_FLOW_ERROR_THROW;
00134         return false;
00135     }
00136 
00137 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00138 //=============================================================================
00139 
00140 
00141 //=============================================================================
00142 //  CLASS CacheScriptStreamerFactory
00143 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00144 
00145     XMLStreamer* CacheScriptStreamerFactory::getStreamer(
00146         StreamerParams*         p_pParameters, 
00147         XMLFlowContext* p_pStreamContext, 
00148         XMLStreamConsumer*      p_pStreamConsumer) const
00149     {
00150         return (XMLStreamer*) new CacheScriptStreamer( this, p_pParameters, p_pStreamContext, p_pStreamConsumer);
00151     }
00152 
00153 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00154 //=============================================================================
00155 
00156 
00157 END_XDFLENGINE_NS
00158 
00159 
00160 
00161 
00162 
00163 
00164 
00165 

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