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

funcdefinestreamer.cpp

Go to the documentation of this file.
00001 //============================================================================= 
00002 //
00003 // XDFLengine library
00004 //
00005 //-----------------------------------------------------------------------------
00006 //  FUNCDEFINESTREAMER.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 "funcdefinestreamer.hpp"
00041 #   include "processor/xmlprocessor.hpp"
00042 #   include "processor/xmlflowcontext.hpp"
00043 #   include "streamers/func/funccallstreamer.hpp"
00044 
00045 
00046 BEGIN_XDFLENGINE_NS
00047 
00048 //=============================================================================
00049 //  CLASS FUNCDEFINESTREAMER
00050 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00051 
00052 // CONSTRUCTOR & DESTRUCTOR
00053 
00054     //_____________________________________________________________________
00055     //  FUNCDEFINESTREAMER
00056     //---------------------------------------------------------------------
00057     FuncDefineStreamer::FuncDefineStreamer( const XMLStreamerFactory* p_pParent, StreamerParams* p_pParameters, XMLFlowContext* p_pContext, XMLStreamConsumer* p_pOutput)
00058     :XMLStreamer( p_pParent, p_pParameters, p_pContext, p_pOutput)
00059     {
00060         DEBUG_CREATE(FuncDefineStreamer)
00061         m_pScriptBuffer = 0;
00062     }
00063     
00064     //_____________________________________________________________________
00065     //  ~FUNCDEFINESTREAMER
00066     //---------------------------------------------------------------------     
00067     FuncDefineStreamer::~FuncDefineStreamer()
00068     {
00069         DEBUG_DEL(FuncDefineStreamer)
00070     }
00071     
00072 // STREAM   
00073 
00074     //_____________________________________________________________________
00075     //  INITSTREAM
00076     //---------------------------------------------------------------------
00077     bool FuncDefineStreamer::initStream()
00078     {
00079         DEBUG_IN(FuncDefineStreamer::initStream)
00080 
00081         m_pScriptBuffer = m_pContext->getProcessor() -> getNewBuffer();
00082 
00083         DEBUG_OUT(FuncDefineStreamer::initStream)
00084 
00085         return true;
00086     }
00087 
00088     //_____________________________________________________________________
00089     //  WRITEDATA
00090     //---------------------------------------------------------------------
00091     void FuncDefineStreamer::writeData( const char* p_pszData, unsigned int p_uiDataLen)
00092     {
00093         DEBUG_IN(FuncDefineStreamer::writeData)
00094 
00095         m_pScriptBuffer -> writeData( p_pszData, p_uiDataLen);
00096 
00097         DEBUG_OUT(FuncDefineStreamer::writeData)
00098     }
00099 
00100     //_____________________________________________________________________
00101     //  COMMITSTREAM
00102     //---------------------------------------------------------------------
00103     bool FuncDefineStreamer::commitStream(bool p_fFinal)
00104     {
00105         //-----------------------------------------------------------------
00106         const char* l_pszScriptName;
00107         RootStreamNode* l_pScriptRoot;
00108         FuncCallStreamerFactory* l_pFuncCallSF;
00109         //-----------------------------------------------------------------
00110         PREP_CATCH_XML_FLOW_ERROR;
00111 
00112         if(p_fFinal)
00113         {
00114             l_pszScriptName = getParamValue( m_pParameters, FUNCDEFINESTREAMER_NAME,"");
00115             l_pFuncCallSF = (FuncCallStreamerFactory*) m_pContext->getProcessor()->getStreamerFactory(FUNCCALLSTREAMER_TAGNAME);
00116             if(!l_pFuncCallSF) THROW_XMLFLOW_EXCEPTION( ERRCODE_LOC_FUNCDEFINESTREAMER + ERRCODE_CAUSE_MISSINGREF , "Function Call Streamer not found." , "", "FuncDefineStreamer::commitStream", "", false );
00117 
00118             WATCH_XML_FLOW_ERROR
00119             {
00120                 logout << "\t" << FUNCDEFINESTREAMER_TAGNAME<< "   :   " << "Compile function " << l_pszScriptName << "...\n";
00121                 l_pScriptRoot = m_pContext->getProcessor()->compile( m_pScriptBuffer, m_pContext->getThreadId());
00122                 l_pFuncCallSF->cacheScript( l_pScriptRoot, l_pszScriptName);
00123             }
00124             CATCH_XML_FLOW_ERROR_RELEASE_AND_RETURN
00125 
00126         }
00127 
00128     RELEASE_AND_RETURN:
00129 
00130         if(p_fFinal)
00131         {
00132             delete m_pScriptBuffer;
00133         }
00134         ON_XML_FLOW_ERROR_DO
00135         {
00136             delete l_pScriptRoot;
00137         }
00138         ON_XML_FLOW_ERROR_THROW;
00139         return false;
00140     }
00141 
00142 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00143 //=============================================================================
00144 
00145 
00146 //=============================================================================
00147 //  CLASS FuncDefineStreamerFactory
00148 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00149 
00150     XMLStreamer* FuncDefineStreamerFactory::getStreamer(
00151         StreamerParams*         p_pParameters, 
00152         XMLFlowContext* p_pStreamContext, 
00153         XMLStreamConsumer*      p_pStreamConsumer) const
00154     {
00155         return (XMLStreamer*) new FuncDefineStreamer( this, p_pParameters, p_pStreamContext, p_pStreamConsumer);
00156     }
00157 
00158 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00159 //=============================================================================
00160 
00161 
00162 END_XDFLENGINE_NS
00163 
00164 
00165 
00166 
00167 
00168 
00169 
00170 

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