LCOV - code coverage report
Current view: directory - ogr/ogrsf_frmts/ili/iom - iom_iterator.cpp (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 40 27 67.5 %
Date: 2012-12-26 Functions: 19 10 52.6 %

       1                 : /**********************************************************************
       2                 :  * $Id: iom_iterator.cpp 12582 2007-10-29 09:38:21Z pka $
       3                 :  *
       4                 :  * Project:  iom - The INTERLIS Object Model
       5                 :  * Purpose:  For more information, please see <http://iom.sourceforge.net>
       6                 :  * Author:   Claude Eisenhut
       7                 :  *
       8                 :  **********************************************************************
       9                 :  * Copyright (c) 2007, Claude Eisenhut
      10                 :  *
      11                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      12                 :  * copy of this software and associated documentation files (the "Software"),
      13                 :  * to deal in the Software without restriction, including without limitation
      14                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      15                 :  * and/or sell copies of the Software, and to permit persons to whom the
      16                 :  * Software is furnished to do so, subject to the following conditions:
      17                 :  * 
      18                 :  * The above copyright notice and this permission notice shall be included
      19                 :  * in all copies or substantial portions of the Software.
      20                 :  * 
      21                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      22                 :  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      23                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
      24                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      25                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      26                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
      27                 :  * DEALINGS IN THE SOFTWARE.
      28                 :  ****************************************************************************/
      29                 : 
      30                 : 
      31                 : /** @file
      32                 :  * implementation of object iterator
      33                 :  * @defgroup iterator iterator functions
      34                 :  * @{
      35                 :  */
      36                 : 
      37                 : #include <iom/iom_p.h>
      38                 : 
      39                 : 
      40                 : /**
      41                 :  * release handle
      42                 :  */
      43              51 : extern "C" int iom_releaseiterator(IOM_ITERATOR iterator)
      44                 : {
      45              51 :   if(!iterator->freeRef()){
      46              51 :     delete iterator;
      47                 :   }
      48              51 :   return 0;
      49                 : }
      50                 : 
      51                 : /** @}
      52                 :  */
      53                 : 
      54              12 : iom_iterator::iom_iterator(IomFile file1)
      55                 : : type(iom_iterator::eBASKET)
      56                 : , useCount(0)
      57                 : , basketv(file1)
      58              12 : , basketi(0)
      59                 : {
      60              12 : }
      61                 : 
      62              12 : IomBasket iom_iterator::next_basket()
      63                 : {
      64              12 :   if(basketi==basketv->basketv.size()){
      65                 :     // file completly read?
      66               0 :     if(!basketv->parser){
      67               0 :       return IomBasket();
      68                 :     }
      69                 :     // read next basket
      70               0 :     basketv->readBasket(basketv);
      71                 :   }
      72              12 :   if(basketi==basketv->basketv.size()){
      73                 :     // file completly read
      74               0 :     return IomBasket();
      75                 :   }
      76              12 :   return basketv->basketv.at(basketi++);
      77                 : }
      78                 : 
      79              51 : iom_iterator::iom_iterator(IomBasket basket1)
      80                 : : type(iom_iterator::eOBJECT)
      81                 : , useCount(0)
      82                 : , objectv(basket1)
      83              51 : , objecti(0)
      84                 : {
      85              51 : }
      86                 : 
      87           13710 : IomObject iom_iterator::next_object()
      88                 : {
      89           13710 :   if(objecti==objectv->objectv.size()){
      90                 :     // basket completly read
      91              49 :     return IomObject();
      92                 :   }
      93           13661 :   return objectv->objectv.at(objecti++);
      94                 : }
      95                 : 
      96                 : 
      97              63 : iom_iterator::~iom_iterator()
      98                 : {
      99              63 : }
     100                 : 
     101                 : 
     102              12 : IomIterator::IomIterator(struct iom_iterator *pointee1) 
     103              12 : : pointee(pointee1 ? pointee1->getRef() : 0){
     104              12 : }
     105               0 : IomIterator::IomIterator(const IomIterator& src) 
     106               0 : : pointee(src.pointee ? src.pointee->getRef() : 0){
     107               0 : }
     108               0 : IomIterator& IomIterator::operator=(const IomIterator& src){
     109               0 :   if(this!=&src){
     110               0 :     if(pointee && !pointee->freeRef()){
     111               0 :       delete pointee;
     112                 :     }
     113               0 :     pointee=src.pointee ? src.pointee->getRef() : 0;
     114                 :   }
     115               0 :   return *this;
     116                 : }
     117              12 : IomIterator::~IomIterator(){
     118              12 :   if(pointee && !pointee->freeRef()){
     119              12 :     delete pointee;
     120                 :   }
     121            2151 : }
     122                 : 

Generated by: LCOV version 1.7