00001 //============================================================================= 00002 // 00003 // XDFLengine library 00004 // 00005 //----------------------------------------------------------------------------- 00006 // dbobjtreamerFactory.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 "dbobjstreamerfactory.hpp" 00041 # include "processor/xmlprocessor.hpp" 00042 # include "streamers/db/dbobject/dbobjdefinition.hpp" 00043 00044 BEGIN_XDFLENGINE_NS 00045 00046 //============================================================================= 00047 // CLASS DBOBJStreamerFactory 00048 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00049 00050 //_____________________________________________________________________ 00051 // DBOBJSTREAMERFACTORY 00052 //--------------------------------------------------------------------- 00053 DBOBJStreamerFactory::~DBOBJStreamerFactory() 00054 { 00055 while(! g_pvaDefinitionsCache.empty()) delete g_pvaDefinitionsCache.pop(); 00056 } 00057 00058 //_____________________________________________________________________ 00059 // CACHEDEFINITION 00060 //--------------------------------------------------------------------- 00061 void DBOBJStreamerFactory::cacheDefinition( const char* p_pszName, DBOBJDefinitionNode* p_pDefinitionRoot) 00062 { 00063 logout << "\tDEF CACHE : " << "Add cached definition " << p_pszName << "...\n"; 00064 g_pvaDefinitionsCache.add(p_pDefinitionRoot, p_pszName); 00065 } 00066 00067 //_____________________________________________________________________ 00068 // GETCACHEDDEFINITION 00069 //--------------------------------------------------------------------- 00070 const DBOBJDefinitionNode* DBOBJStreamerFactory::getCachedDefinition( const char* p_pszName, XMLFlowContext* p_pStreamContext) const 00071 { 00072 // try to get from cache 00073 logout << "\tDEF CACHE : " << "Get cached definition " << p_pszName << "...\n"; 00074 return g_pvaDefinitionsCache.get(p_pszName); 00075 } 00076 00077 //_____________________________________________________________________ 00078 // BUILDCACHEDDEFINITION 00079 //--------------------------------------------------------------------- 00080 DBOBJDefinitionNode* DBOBJStreamerFactory::buildDefinition( const char* p_pszName, XMLFlowContext* p_pStreamContext) const 00081 { 00082 DBOBJDefinitionNode* l_pDefinitionRoot=0; 00083 XMLStreamBuffer* l_pszDefinitionBuffer; 00084 00085 00086 logout << "\tDEF CACHE : " << "Build definition " << p_pszName << "...\n"; 00087 l_pszDefinitionBuffer = p_pStreamContext -> getNamedBuffer( p_pszName); 00088 if (l_pszDefinitionBuffer) l_pDefinitionRoot = SAXDBOBJDefinitionBuilder::buildDBOBJDefinition(p_pStreamContext, l_pszDefinitionBuffer); 00089 00090 00091 return l_pDefinitionRoot; 00092 } 00093 00094 00095 00096 //============================================================================= 00097 00098 END_XDFLENGINE_NS 00099