00001 //============================================================================= 00002 // 00003 // XDFLengine library 00004 // 00005 //----------------------------------------------------------------------------- 00006 // CacheDefinitionStreamer.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 "cachedefinitionstreamer.hpp" 00041 # include "processor/xmlflowcontext.hpp" 00042 # include "streamers/db/dbobject/dbobjdefinition.hpp" 00043 00044 BEGIN_XDFLENGINE_NS 00045 00046 //============================================================================= 00047 // CLASS CacheDefinitionStreamer 00048 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00049 00050 00051 //_____________________________________________________________________ 00052 // SaxStreamer 00053 //--------------------------------------------------------------------- 00054 CacheDefinitionStreamer::CacheDefinitionStreamer( const XMLStreamerFactory* p_pParent, StreamerParams* p_pParameters, XMLFlowContext* p_pContext, XMLStreamConsumer* p_pOutput, ContentHandler* p_pHandler, bool p_fCopyStreamToOutput) 00055 :SaxStreamer( p_pParent, p_pParameters, p_pContext, p_pOutput, p_pHandler, p_fCopyStreamToOutput) 00056 { 00057 DEBUG_CREATE(CacheDefinitionStreamer) 00058 } 00059 00060 //_____________________________________________________________________ 00061 // ~SaxStreamer 00062 //--------------------------------------------------------------------- 00063 CacheDefinitionStreamer::~CacheDefinitionStreamer() 00064 { 00065 DEBUG_DEL(CacheDefinitionStreamer) 00066 } 00067 00068 //_____________________________________________________________________ 00069 // COMMITSTREAM 00070 //--------------------------------------------------------------------- 00071 bool CacheDefinitionStreamer::commitStream(bool p_fFinal) 00072 { 00073 //--------------------------------------------------------------------- 00074 bool l_fOK; 00075 DBOBJDefinitionNode* l_pDefinitionRoot=0; 00076 const char* l_pszDefName=0; 00077 //--------------------------------------------------------------------- 00078 00079 PREP_CATCH_XML_FLOW_ERROR; 00080 00081 DEBUG_IN(CacheDefinitionStreamer::writeData) 00082 00083 l_fOK = SaxStreamer::commitStream( p_fFinal); 00084 00085 if(l_fOK && p_fFinal) 00086 { 00087 00088 l_pszDefName = getParamValue( m_pParameters, CACHEDEFINITIONSTREAMER_NAME,""); 00089 // get definition 00090 WATCH_XML_FLOW_ERROR 00091 { 00092 logout << "\t" << CACHEDEFINITIONSTREAMER_TAGNAME<< " : " << "Caching definition " << l_pszDefName << "...\n"; 00093 00094 // retrieve definition 00095 l_pDefinitionRoot = ((SAXDBOBJDefinitionBuilder*)m_pHandler)->getDefinition(); 00096 // process definition completion 00097 ( (CacheDefinitionStreamerFactory*) m_pParent)->cacheDefinition( l_pszDefName, l_pDefinitionRoot); 00098 } 00099 CATCH_XML_FLOW_ERROR_RELEASE_AND_RETURN ; 00100 } 00101 00102 RELEASE_AND_RETURN: 00103 00104 ON_XML_FLOW_ERROR_DO 00105 { 00106 l_fOK = false; 00107 delete l_pDefinitionRoot; 00108 } 00109 ON_XML_FLOW_ERROR_THROW; 00110 00111 DEBUG_OUT(CacheDefinitionStreamer::writeData) 00112 00113 return l_fOK; 00114 } 00115 00116 00117 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00118 //============================================================================= 00119 00120 00121 //============================================================================= 00122 // CLASS CacheDefinitionStreamerFactory 00123 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00124 00125 00126 00127 00128 00129 //_____________________________________________________________________ 00130 // GETSTREAMER 00131 //--------------------------------------------------------------------- 00132 XMLStreamer* CacheDefinitionStreamerFactory::getStreamer( 00133 StreamerParams* p_pParameters, 00134 XMLFlowContext* p_pStreamContext, 00135 XMLStreamConsumer* p_pStreamConsumer) const 00136 { 00137 SAXDBOBJDefinitionBuilder* l_pSAXDefinitionBuilder = 0; 00138 00139 l_pSAXDefinitionBuilder = new SAXDBOBJDefinitionBuilder( p_pStreamContext); 00140 return (XMLStreamer*) new CacheDefinitionStreamer( this, p_pParameters, p_pStreamContext, p_pStreamConsumer, l_pSAXDefinitionBuilder, false); 00141 } 00142 00143 00144 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00145 //============================================================================= 00146 00147 00148 END_XDFLENGINE_NS 00149 00150 00151