00001
00002
00003
00004
00005
00006
00007
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
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
00050
00051
00052
00053
00054
00055
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
00066
00067 FuncDefineStreamer::~FuncDefineStreamer()
00068 {
00069 DEBUG_DEL(FuncDefineStreamer)
00070 }
00071
00072
00073
00074
00075
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
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
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
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