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

dbobjsetstreamer.hpp

Go to the documentation of this file.
00001 #if !defined(_DBOBJSETREQUEST_HPP)
00002 #define _DBOBJSETREQUEST_HPP
00003 //============================================================================= 
00004 //
00005 // XDFLengine library
00006 //
00007 //-----------------------------------------------------------------------------
00008 //  DBOBJGETHANDLER.HPP
00009 //----------------------------------------------------------------------------- 
00015 //_____________________________________________________________________________
00016 //
00017 //  Copyright (C) 2003 Guillaume Baurand. All Rights Reserved.
00018 //
00019 //  This file is part of the XDFLengine project.
00020 //
00021 //  The XDFLengine is free software; you can redistribute it and/or modify
00022 //  it under the terms of the GNU General Public License as published by
00023 //  the Free Software Foundation; either version 2 of the License, or
00024 //  (at your option) any later version.
00025 //
00026 //  This program is distributed in the hope that it will be useful,
00027 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00028 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00029 //  GNU General Public License for more details.
00030 //
00031 //  You should have received a copy of the GNU General Public License
00032 //  along with this program; if not, write to the Free Software
00033 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
00034 //  USA.
00035 //
00036 //  For more information, 
00037 //      contact  : guillaume@baurand.net 
00038 //      or visit : http://xdflengine.sourceforge.net
00039 //
00040 //=============================================================================
00041 
00042 #   include "config/commonincs.hpp"
00043 #   include "streamers/db/dbobject/dbobjstreamerfactory.hpp"
00044 #   include "streamers/db/dbobject/dbset/dbobject.hpp"
00045 
00046 
00047 BEGIN_XDFLENGINE_NS
00048 
00049 class DBObjectSAXBuilder;
00050 class DBOBJSetHandler;
00051 
00052 //============================================================================= 
00053 //  STRUCT STREAM_CACHE
00054 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00055 typedef struct _stream_cache
00056 {
00057         otl_stream*             otlStream;   
00058         otl_var_desc*           varDesc;        
00059         int                     descLen;            
00060         char*                   fieldList;      
00061 } stream_cache;
00062 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00063 //=============================================================================
00064 
00065 
00066 
00067 //============================================================================= 
00068 
00069 //============================================================================= 
00070 //  CLASS DBOBJSETREQUEST
00071 //----------------------------------------------------------------------------- 
00073 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00074 class XDFLENGINE_EXPORT DBOBJSetStreamer : public XMLStreamer /*, public XMLValuable*/
00075 {
00076 
00077     private: //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00078         char*                   m_pszConnName;
00079         DBOBJSetAction          m_intAction;        
00080         char*                   m_pszAction;        
00081         bool                    m_fErrorFatal;      
00082         bool                    m_fCount;           
00083         bool                    m_fError;           
00084         unsigned int            m_uiBufferSize;
00085         unsigned int            m_uiCommitPacks;    
00086         unsigned int            m_uiCommitted;
00087         unsigned int            m_uiCommittedRecs;
00088         unsigned int            m_uiStreamObjects;
00089         unsigned int            m_uiToStream;
00090         const char*             m_pszEnclose;
00091 
00092         const DBOBJDefinitionNode*  m_pDBOBJDefinitionRoot;
00093         DBOBJDefinitionNode*    m_pDBOBJOwnedDefinitionRoot;
00094 
00095         VAarray< DBObjectNode* > m_vaObjects;       
00096         VAarray<int>            m_vaNodesCounts;    
00097 
00098         otl_connect*            m_pConnection;
00099         VAarray<stream_cache*>  m_vaOTLStreams;     
00100 
00101         XMLStreamProvider*      m_pBufferInput;     
00102         XMLStreamConsumer*      m_pBufferReject;    
00103         XMLStreamConsumer*      m_pBufferError;     
00104         XMLStreamConsumer*      m_pBufferReport;    
00105         XMLFlowContext*         m_pContext; // Parsing context
00106 
00107     protected :
00108 
00109         StreamSAX2Parser*           m_pStreamParser;
00110         XDFLSaxErrorReporter*   m_pErrorReporter;
00111         DBStreamerFactory*          m_pParent;
00112         DBObjectSAXBuilder*         m_pHandler;
00113 
00114     public: //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00115 
00116     // CONSTRUCTOR & DESTRUCTOR
00117         //_____________________________________________________________________
00118         //  DBOBJGetStreamer
00119         //---------------------------------------------------------------------
00120         DBOBJSetStreamer(const XMLStreamerFactory* p_pParent, StreamerParams* p_pParameters, XMLFlowContext* p_pContext, XMLStreamConsumer* p_pOutput);
00121         
00122         //_____________________________________________________________________
00123         //  ~DBOBJSETREQUEST
00124         //---------------------------------------------------------------------
00127         //_____________________________________________________________________
00128         ~DBOBJSetStreamer();
00129 
00130     
00131     // STREAMER
00132         
00133         //_____________________________________________________________________
00134         //  INITSTREAM
00135         //---------------------------------------------------------------------
00136         bool initStream();
00137 
00138         //_____________________________________________________________________
00139         //  WRITEDATA
00140         //---------------------------------------------------------------------
00141         void writeData( const char* p_pszData, unsigned int p_uiDataLen);
00142 
00143         //_____________________________________________________________________
00144         //  COMMITSTREAM
00145         //---------------------------------------------------------------------
00146         bool commitStream(bool p_fFinal=false);
00147 
00148 
00149         //_____________________________________________________________________
00150         //  makeReport
00151         //---------------------------------------------------------------------
00153         //_____________________________________________________________________     
00154         virtual void makeReport();
00155 
00156     // OBJECT PROCESSING
00157 
00158         //_____________________________________________________________________
00159         //  TRANSFORMOBJECT
00160         //---------------------------------------------------------------------
00164         //_____________________________________________________________________
00165         virtual bool transformObject( DBObjectNode* p_pDBObjectNode);
00166 
00167         //_____________________________________________________________________
00168         //  PROCESSOBJECT
00169         //---------------------------------------------------------------------
00174         //_____________________________________________________________________
00175         virtual void processObject( DBObjectNode* p_pDBObjectNode);
00176 
00177         //_________________________________________________________________________
00178         //  commitObjects
00179         //-------------------------------------------------------------------------
00180         virtual void commitObjects();
00181 
00182         //_________________________________________________________________________
00183         //  rollBackObjects
00184         //-------------------------------------------------------------------------
00185         void rollBackObjects();
00186     
00187     protected: //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
00188         
00189 
00190     // NODES PROCESSING
00191 
00192         //_________________________________________________________________________
00193         //  PROCESSNODE
00194         //-------------------------------------------------------------------------
00195         void processNode(   DBObjectNode* p_pDBObjectNode, DBOBJSetAction p_intParentAction);
00196 
00197     
00198         //_________________________________________________________________________
00199         //  SENDNODETODB
00200         //-------------------------------------------------------------------------
00201         void sendNodeToDB( DBObjectNode* p_pDBObjectNode, DBOBJSetAction    l_iCurAction);
00202 
00203 
00204         //_________________________________________________________________________
00205         //  SENDNODETODB
00206         //-------------------------------------------------------------------------
00207         void sendRecordToDB( DBObjectNode* p_pDBObjectNode, otl_stream* p_pOTLStream, const char* p_pszFieldList, int p_iDescLen, otl_var_desc* p_varsDesc);
00208 
00209     
00210 
00211     // SQL STATEMENT BUILD
00212 
00213         //_____________________________________________________________________
00214         //  BUILDINSERTSTATEMENT
00215         //---------------------------------------------------------------------
00219         //_____________________________________________________________________
00220         bool  buildINSERTStatement( DBObjectNode* p_pDBObjectNode, char** l_ppszStatement, char** l_ppszFields);
00221 
00222 
00223         //_____________________________________________________________________
00224         //  BUILDUPDATESTATEMENT
00225         //---------------------------------------------------------------------
00229         //_____________________________________________________________________
00230         bool buildUPDATEStatement( DBObjectNode* p_pDBObjectNode, char** l_ppszStatement, char** l_ppszFields);
00231 
00232 
00233         //_____________________________________________________________________
00234         //  BUILDDELETESTATEMENT
00235         //---------------------------------------------------------------------
00239         //_____________________________________________________________________
00240         bool buildDELETEStatement( DBObjectNode* p_pDBObjectNode, char** l_ppszStatement, char** l_ppszFields);
00241 
00242 
00243         //_____________________________________________________________________
00244         //  BUILDWHERECLAUSE
00245         //---------------------------------------------------------------------
00249         //_____________________________________________________________________
00250         bool buildWHEREclause( DBObjectNode* p_pDBObjectNode, char** l_ppszStatement, char** l_ppszFields);
00251 
00252 
00253         //_____________________________________________________________________
00254         //  BUILDCHECKSTATEMENT
00255         //---------------------------------------------------------------------
00260         //_____________________________________________________________________
00261         bool buildCHECKStatement( DBObjectNode* p_pDBObjectNode, char** l_ppszStatement, char** l_ppszFields, bool p_boolPre);
00262 
00263 
00264         //_____________________________________________________________________
00265         //  BUILDEVENTSTATEMENT
00266         //---------------------------------------------------------------------
00267         bool buildEventStatement( DBObjectNode* p_pDBObjectNode, const char* l_pszEnventString, char** l_ppszStatement, char** l_ppszFields);
00268 
00269         //_____________________________________________________________________
00270         //  GETSQLINSERT
00271         //---------------------------------------------------------------------
00272         char* getSQLInsert(DBObjectField* l_pDBObjectField, bool* p_pfCachable, char** p_ppszFields);
00273 
00274         //_____________________________________________________________________
00275         //  GETFIELDVALUE
00276         //---------------------------------------------------------------------
00279         //_____________________________________________________________________
00280         char* getFieldValue ( DBObjectField* p_pDBObjectField);
00281 
00282         //_________________________________________________________________________
00283         //  getFieldBindVar
00284         //-------------------------------------------------------------------------
00285         char* getFieldBindVar(DBObjectField* l_pDBObjectField);
00286 
00287         //_____________________________________________________________________
00288         //  STACKOBJECT
00289         //---------------------------------------------------------------------
00292         //_____________________________________________________________________
00293         void stackObject ( DBObjectNode* p_pDBObjectNode);
00294 
00295         //_____________________________________________________________________
00296         //  deStackObjects
00297         //---------------------------------------------------------------------
00300         //_____________________________________________________________________
00301         void deStackObjects ( XMLStreamConsumer*  p_pBufferXML, bool l_fCount);
00302 
00303         //_____________________________________________________________________
00304         //  countObjectNodes
00305         //---------------------------------------------------------------------
00308         //_____________________________________________________________________
00309         void countObjectNodes(DBObjectNode * p_pDBObjectNode);
00310 
00311 };
00312 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00313 //=============================================================================
00314 
00315 
00316 //============================================================================= 
00317 //  CLASS DBOBJSetStreamerFACTORY
00318 //----------------------------------------------------------------------------- 
00320 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00321 class XDFLENGINE_EXPORT DBOBJSetStreamerFactory:public DBOBJStreamerFactory
00322 {
00323 
00324     public: //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00325 
00326         //_____________________________________________________________________
00327         //  GETSTREAMER
00328         //---------------------------------------------------------------------
00329         XMLStreamer* getStreamer(StreamerParams* p_pParameters, XMLFlowContext* p_pStreamContext, XMLStreamConsumer* p_pStreamConsumer) const;
00330 };
00331 
00332 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00333 //=============================================================================
00334 
00335 
00336 
00337 END_XDFLENGINE_NS
00338 
00339 #endif
00340 

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