LTP GCOV extension - code coverage report
Current view: directory - ogr/ogrsf_frmts/odbc - ogrodbcselectlayer.cpp
Test: gdal_filtered.info
Date: 2010-07-12 Instrumented lines: 45
Code covered: 0.0 % Executed lines: 0

       1                 : /******************************************************************************
       2                 :  * $Id: ogrodbcselectlayer.cpp 10645 2007-01-18 02:22:39Z warmerdam $
       3                 :  *
       4                 :  * Project:  OpenGIS Simple Features Reference Implementation
       5                 :  * Purpose:  Implements OGRODBCSelectLayer class, layer access to the results
       6                 :  *           of a SELECT statement executed via ExecuteSQL().
       7                 :  * Author:   Frank Warmerdam, warmerdam@pobox.com
       8                 :  *
       9                 :  ******************************************************************************
      10                 :  * Copyright (c) 2004, Frank Warmerdam
      11                 :  *
      12                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      13                 :  * copy of this software and associated documentation files (the "Software"),
      14                 :  * to deal in the Software without restriction, including without limitation
      15                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      16                 :  * and/or sell copies of the Software, and to permit persons to whom the
      17                 :  * Software is furnished to do so, subject to the following conditions:
      18                 :  *
      19                 :  * The above copyright notice and this permission notice shall be included
      20                 :  * in all copies or substantial portions of the Software.
      21                 :  *
      22                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      23                 :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      24                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      25                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      26                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      27                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      28                 :  * DEALINGS IN THE SOFTWARE.
      29                 :  ****************************************************************************/
      30                 : 
      31                 : #include "cpl_conv.h"
      32                 : #include "ogr_odbc.h"
      33                 : 
      34                 : CPL_CVSID("$Id: ogrodbcselectlayer.cpp 10645 2007-01-18 02:22:39Z warmerdam $");
      35                 : /************************************************************************/
      36                 : /*                          OGRODBCSelectLayer()                         */
      37                 : /************************************************************************/
      38                 : 
      39                 : OGRODBCSelectLayer::OGRODBCSelectLayer( OGRODBCDataSource *poDSIn,
      40               0 :                                         CPLODBCStatement * poStmtIn )
      41                 : 
      42                 : {
      43               0 :     poDS = poDSIn;
      44                 : 
      45               0 :     iNextShapeId = 0;
      46               0 :     nSRSId = -1;
      47               0 :     poFeatureDefn = NULL;
      48                 : 
      49               0 :     poStmt = poStmtIn;
      50               0 :     pszBaseStatement = CPLStrdup( poStmtIn->GetCommand() );
      51                 : 
      52               0 :     BuildFeatureDefn( "SELECT", poStmt );
      53               0 : }
      54                 : 
      55                 : /************************************************************************/
      56                 : /*                          ~OGRODBCSelectLayer()                          */
      57                 : /************************************************************************/
      58                 : 
      59               0 : OGRODBCSelectLayer::~OGRODBCSelectLayer()
      60                 : 
      61                 : {
      62               0 :     ClearStatement();
      63               0 : }
      64                 : 
      65                 : /************************************************************************/
      66                 : /*                           ClearStatement()                           */
      67                 : /************************************************************************/
      68                 : 
      69               0 : void OGRODBCSelectLayer::ClearStatement()
      70                 : 
      71                 : {
      72               0 :     if( poStmt != NULL )
      73                 :     {
      74               0 :         delete poStmt;
      75               0 :         poStmt = NULL;
      76                 :     }
      77               0 : }
      78                 : 
      79                 : /************************************************************************/
      80                 : /*                            GetStatement()                            */
      81                 : /************************************************************************/
      82                 : 
      83               0 : CPLODBCStatement *OGRODBCSelectLayer::GetStatement()
      84                 : 
      85                 : {
      86               0 :     if( poStmt == NULL )
      87               0 :         ResetStatement();
      88                 : 
      89               0 :     return poStmt;
      90                 : }
      91                 : 
      92                 : /************************************************************************/
      93                 : /*                           ResetStatement()                           */
      94                 : /************************************************************************/
      95                 : 
      96               0 : OGRErr OGRODBCSelectLayer::ResetStatement()
      97                 : 
      98                 : {
      99               0 :     ClearStatement();
     100                 : 
     101               0 :     iNextShapeId = 0;
     102                 : 
     103               0 :     CPLDebug( "OGR_ODBC", "Recreating statement." );
     104               0 :     poStmt = new CPLODBCStatement( poDS->GetSession() );
     105               0 :     poStmt->Append( pszBaseStatement );
     106                 : 
     107               0 :     if( poStmt->ExecuteSQL() )
     108               0 :         return OGRERR_NONE;
     109                 :     else
     110                 :     {
     111               0 :         delete poStmt;
     112               0 :         poStmt = NULL;
     113               0 :         return OGRERR_FAILURE;
     114                 :     }
     115                 : }
     116                 : 
     117                 : /************************************************************************/
     118                 : /*                            ResetReading()                            */
     119                 : /************************************************************************/
     120                 : 
     121               0 : void OGRODBCSelectLayer::ResetReading()
     122                 : 
     123                 : {
     124               0 :     if( iNextShapeId != 0 )
     125               0 :         ClearStatement();
     126                 : 
     127               0 :     OGRODBCLayer::ResetReading();
     128               0 : }
     129                 : 
     130                 : /************************************************************************/
     131                 : /*                             GetFeature()                             */
     132                 : /************************************************************************/
     133                 : 
     134               0 : OGRFeature *OGRODBCSelectLayer::GetFeature( long nFeatureId )
     135                 : 
     136                 : {
     137               0 :     return OGRODBCLayer::GetFeature( nFeatureId );
     138                 : }
     139                 : 
     140                 : /************************************************************************/
     141                 : /*                           TestCapability()                           */
     142                 : /************************************************************************/
     143                 : 
     144               0 : int OGRODBCSelectLayer::TestCapability( const char * pszCap )
     145                 : 
     146                 : {
     147               0 :     return OGRODBCLayer::TestCapability( pszCap );
     148                 : }
     149                 : 
     150                 : /************************************************************************/
     151                 : /*                             GetExtent()                              */
     152                 : /*                                                                      */
     153                 : /*      Since SELECT layers currently cannot ever have geometry, we     */
     154                 : /*      can optimize the GetExtent() method!                            */
     155                 : /************************************************************************/
     156                 : 
     157               0 : OGRErr OGRODBCSelectLayer::GetExtent(OGREnvelope *, int )
     158                 : 
     159                 : {
     160               0 :     return OGRERR_FAILURE;
     161                 : }
     162                 : 
     163                 : /************************************************************************/
     164                 : /*                          GetFeatureCount()                           */
     165                 : /*                                                                      */
     166                 : /*      If a spatial filter is in effect, we turn control over to       */
     167                 : /*      the generic counter.  Otherwise we return the total count.      */
     168                 : /*      Eventually we should consider implementing a more efficient     */
     169                 : /*      way of counting features matching a spatial query.              */
     170                 : /************************************************************************/
     171                 : 
     172               0 : int OGRODBCSelectLayer::GetFeatureCount( int bForce )
     173                 : 
     174                 : {
     175               0 :     return OGRODBCLayer::GetFeatureCount( bForce );
     176                 : }

Generated by: LTP GCOV extension version 1.5