00001 //============================================================================= 00002 // 00003 // XDFLengine library 00004 // 00005 //----------------------------------------------------------------------------- 00006 // NamedBufferGetStreamer.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 # include "namedbuffergetstreamer.hpp" 00040 # include "processor/xmlflowcontext.hpp" 00041 00042 BEGIN_XDFLENGINE_NS 00043 00044 //============================================================================= 00045 // CLASS NamedBufferGetStreamer 00046 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00047 00048 //_____________________________________________________________________ 00049 // NamedBufferGetStreamer 00050 //--------------------------------------------------------------------- 00051 NamedBufferGetStreamer::NamedBufferGetStreamer( const XMLStreamerFactory* p_pParent, StreamerParams* p_pParameters, XMLFlowContext* p_pContext, XMLStreamConsumer* p_pOutput) 00052 :XMLStreamer( p_pParent, p_pParameters, p_pContext, p_pOutput) 00053 { 00054 DEBUG_CREATE(NamedBufferGetStreamer) 00055 } 00056 00057 //_____________________________________________________________________ 00058 // ~NamedBufferGetStreamer 00059 //--------------------------------------------------------------------- 00060 NamedBufferGetStreamer::~NamedBufferGetStreamer() 00061 { 00062 DEBUG_DEL(NamedBufferGetStreamer) 00063 } 00064 00065 //_____________________________________________________________________ 00066 // INITSTREAM 00067 //--------------------------------------------------------------------- 00068 bool NamedBufferGetStreamer::initStream() 00069 { 00070 DEBUG_FUNC(NamedBufferGetStreamer::initStream) 00071 return true; 00072 } 00073 00074 //_____________________________________________________________________ 00075 // WRITEDATA 00076 //--------------------------------------------------------------------- 00077 void NamedBufferGetStreamer::writeData( const char* p_pszData, unsigned int p_uiDataLen) 00078 { 00079 DEBUG_FUNC(NamedBufferGetStreamer::writeData) 00080 } 00081 00082 //_____________________________________________________________________ 00083 // COMMITSTREAM 00084 //--------------------------------------------------------------------- 00085 bool NamedBufferGetStreamer::commitStream(bool p_fFinal) 00086 { 00087 //----------------------------------------------------------------- 00088 const char* l_pszBufferName; 00089 XMLStreamBuffer* l_pNamedBuffer; 00090 //----------------------------------------------------------------- 00091 00092 DEBUG_FUNC(NamedBufferGetStreamer::commitStream) 00093 //logout << "buf get...\n"; 00094 if(p_fFinal) 00095 { 00096 l_pszBufferName = getParamValue( m_pParameters, NAMEDBUFGETSTREAMER_NAME, ""); 00097 if(strlen(l_pszBufferName)>0) 00098 { 00099 //logout << "buffer is " << l_pszBufferName << "\n"; 00100 l_pNamedBuffer = m_pContext -> getNamedBuffer( l_pszBufferName); 00101 00102 if( !l_pNamedBuffer) THROW_XMLFLOW_EXCEPTION ( ERRCODE_LOC_NAMEDBUFFERGETSTREAMER + ERRCODE_CAUSE_MISSINGREF , "Named buffer not found.", l_pszBufferName, "NamedBufferGetStreamer::initStream", "", false ); 00103 //logout << "output data... \n"; 00104 00105 (*m_pOutput) << (* l_pNamedBuffer); 00106 //logout << "commit data... \n"; 00107 m_pOutput->commitStream(false); 00108 } 00109 } 00110 00111 //logout << "buf get OK\n"; 00112 00113 return true; 00114 } 00115 00116 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00117 //============================================================================= 00118 00119 00120 //============================================================================= 00121 // CLASS NamedBufferGetStreamerFactory 00122 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00123 00124 XMLStreamer* NamedBufferGetStreamerFactory::getStreamer( 00125 StreamerParams* p_pParameters, 00126 XMLFlowContext* p_pStreamContext, 00127 XMLStreamConsumer* p_pStreamConsumer) const 00128 { 00129 return (XMLStreamer*) new NamedBufferGetStreamer( this, p_pParameters, p_pStreamContext, p_pStreamConsumer); 00130 } 00131 00132 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00133 //============================================================================= 00134 00135 00136 END_XDFLENGINE_NS 00137