LTP GCOV extension - code coverage report
Current view: directory - ogr/ogrsf_frmts/vfk - vfkreader.h
Test: gdal_filtered.info
Date: 2010-07-12 Instrumented lines: 16
Code covered: 93.8 % Executed lines: 15

       1                 : /******************************************************************************
       2                 :  * $Id: vfkreader.h 18566 2010-01-16 16:36:45Z martinl $
       3                 :  *
       4                 :  * Project:  VFK Reader
       5                 :  * Purpose:  Public Declarations for OGR free VFK Reader code.
       6                 :  * Author:   Martin Landa, landa.martin gmail.com
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 2009-2010, Martin Landa <landa.martin gmail.com>
      10                 :  *
      11                 :  * Permission is hereby granted, free of charge, to any person
      12                 :  * obtaining a copy of this software and associated documentation
      13                 :  * files (the "Software"), to deal in the Software without
      14                 :  * restriction, including without limitation the rights to use, copy,
      15                 :  * modify, merge, publish, distribute, sublicense, and/or sell copies
      16                 :  * of the Software, and to permit persons to whom the Software is
      17                 :  * furnished to do so, subject to the following conditions:
      18                 :  *
      19                 :  * The above copyright notice and this permission notice shall be
      20                 :  * included in all copies or substantial portions of the Software.
      21                 :  *
      22                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
      23                 :  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
      24                 :  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
      25                 :  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
      26                 :  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
      27                 :  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
      28                 :  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
      29                 :  * SOFTWARE.
      30                 :  ****************************************************************************/
      31                 : 
      32                 : #ifndef GDAL_OGR_VFK_VFKREADER_H_INCLUDED
      33                 : #define GDAL_OGR_VFK_VFKREADER_H_INCLUDED
      34                 : 
      35                 : #include <vector>
      36                 : #include <string>
      37                 : 
      38                 : #include "ogrsf_frmts.h"
      39                 : 
      40                 : #include "cpl_port.h"
      41                 : #include "cpl_minixml.h"
      42                 : 
      43                 : class IVFKReader;
      44                 : class VFKDataBlock;
      45                 : class VFKFeature;
      46                 : 
      47                 : typedef std::vector<VFKFeature *> VFKFeatureList;
      48                 : 
      49                 : /************************************************************************/
      50                 : /*                              VFKProperty                             */
      51                 : /************************************************************************/
      52                 : class CPL_DLL VFKProperty
      53                 : {
      54                 : private:
      55                 :     bool                    m_bIsNull;
      56                 :     
      57                 :     int                     m_nValue;
      58                 :     double                  m_dValue;
      59                 :     std::string             m_strValue;
      60                 : 
      61                 : public:
      62                 :     VFKProperty();
      63                 :     explicit VFKProperty(int);
      64                 :     explicit VFKProperty(double);
      65                 :     explicit VFKProperty(const char*);
      66                 :     explicit VFKProperty(std::string const&);
      67                 :     ~VFKProperty();
      68                 :     
      69                 :     VFKProperty(VFKProperty const& other);
      70                 :     VFKProperty& operator=(VFKProperty const& other);
      71                 : 
      72             158 :     bool                    IsNull() const    { return m_bIsNull; }
      73             444 :     int                     GetValueI() const { return m_nValue; }
      74              52 :     double                  GetValueD() const { return m_dValue; }
      75               3 :     const char             *GetValueS() const { return m_strValue.c_str(); }
      76                 : };
      77                 : 
      78                 : /************************************************************************/
      79                 : /*                              VFKFeature                              */
      80                 : /************************************************************************/
      81                 : class CPL_DLL VFKFeature
      82                 : {
      83                 : private:
      84                 :     typedef std::vector<VFKProperty> VFKPropertyList;
      85                 :     
      86                 :     VFKDataBlock             *m_poDataBlock;
      87                 :  
      88                 :     VFKPropertyList           m_propertyList;
      89                 :     
      90                 :     long                      m_nFID;
      91                 :     
      92                 :     OGRwkbGeometryType        m_nGeometryType;
      93                 :     bool                      m_bGeometry;
      94                 :     OGRGeometry              *m_paGeom;
      95                 :     
      96                 : public:
      97                 :     VFKFeature(VFKDataBlock *);
      98                 :     ~VFKFeature();
      99                 :     
     100              67 :     long                 GetFID() const { return m_nFID; }
     101                 :     void                 SetFID(long);
     102                 : 
     103                 :     VFKDataBlock        *GetDataBlock() const { return m_poDataBlock; }
     104                 :     
     105                 :     void                 SetProperty(int, const char *);
     106                 :     const VFKProperty   *GetProperty(int) const;
     107                 :     const VFKProperty   *GetProperty(const char *) const;
     108                 : 
     109                 :     bool                 LoadGeometry();
     110              28 :     OGRwkbGeometryType   GetGeometryType() const { return m_nGeometryType; }
     111                 :     OGRGeometry         *GetGeometry();
     112                 :     void                 SetGeometry(OGRGeometry *);
     113                 : 
     114                 :     bool                 AppendLineToRing(int, const OGRLineString *);
     115                 : };
     116                 : 
     117                 : /************************************************************************/
     118                 : /*                              VFKPropertyDefn                         */
     119                 : /************************************************************************/
     120                 : class CPL_DLL VFKPropertyDefn
     121                 : {
     122                 : private:
     123                 :     char             *m_pszName;
     124                 : 
     125                 :     char             *m_pszType;
     126                 :     OGRFieldType      m_eFType;
     127                 : 
     128                 :     int               m_nWidth;
     129                 :     int               m_nPrecision;
     130                 : 
     131                 : public:
     132                 :     VFKPropertyDefn(const char*, const char *);
     133                 :     ~VFKPropertyDefn();
     134                 : 
     135             885 :     const char       *GetName() const  { return m_pszName; }
     136            1051 :     int               GetWidth() const { return m_nWidth;  }
     137             605 :     int               GetPrecision() const { return m_nPrecision;  }
     138            1047 :     OGRFieldType      GetType() const  { return m_eFType;  }
     139                 : };
     140                 : 
     141                 : /************************************************************************/
     142                 : /*                              VFKDataBlock                            */
     143                 : /************************************************************************/
     144                 : class CPL_DLL VFKDataBlock
     145                 : {
     146                 : private:
     147                 :     typedef std::vector<OGRPoint>  PointList;
     148                 :     typedef std::vector<PointList *> PointListArray;
     149                 :     
     150                 :     char              *m_pszName;
     151                 :     
     152                 :     int                m_nPropertyCount;
     153                 :     VFKPropertyDefn  **m_papoProperty;
     154                 : 
     155                 :     int                m_nFeatureCount;
     156                 :     VFKFeature       **m_papoFeature;
     157                 :     
     158                 :     int                AddProperty(const char *, const char *);
     159                 :     
     160                 :     int                m_iNextFeature;
     161                 :     long               m_nFID;
     162                 :     
     163                 :     OGRwkbGeometryType m_nGeometryType;
     164                 :     bool               m_bGeometry;
     165                 :     bool               m_bGeometryPerBlock;
     166                 : 
     167                 :     IVFKReader        *m_poReader;
     168                 : 
     169                 :     bool               AppendLineToRing(PointListArray *, const OGRLineString *, bool);
     170                 : 
     171                 : public:
     172                 :     VFKDataBlock(const char *, const IVFKReader *);
     173                 :     ~VFKDataBlock();
     174                 : 
     175            4470 :     const char        *GetName() const { return m_pszName; }
     176                 : 
     177            2223 :     int                GetPropertyCount() const { return m_nPropertyCount; }
     178                 :     VFKPropertyDefn   *GetProperty(int) const;
     179                 :     int                SetProperties(char *);
     180                 :     int                GetPropertyIndex(const char *) const;
     181                 : 
     182              57 :     int                GetFeatureCount() const  { return m_nFeatureCount;  }
     183                 :     int                GetFeatureCount(const char *, const char *);
     184                 :     void               SetFeatureCount(int, int = FALSE);
     185                 :     VFKFeature        *GetFeatureByIndex(int) const;
     186                 :     VFKFeature        *GetFeature(int, int, VFKFeatureList* = NULL);
     187                 :     VFKFeatureList     GetFeatures(int, int);
     188                 :     VFKFeatureList     GetFeatures(int, int, int);
     189                 :     VFKFeature        *GetFeature(long);
     190                 :     int                AddFeature(const char *);
     191                 : 
     192                 :     void               ResetReading(int iIdx = -1);
     193                 :     VFKFeature        *GetNextFeature();
     194                 :     VFKFeature        *GetPreviousFeature();
     195                 :     VFKFeature        *GetFirstFeature();
     196                 :     VFKFeature        *GetLastFeature();
     197                 :     int                SetNextFeature(const VFKFeature *);
     198                 :     
     199                 :     OGRwkbGeometryType SetGeometryType();
     200                 :     OGRwkbGeometryType GetGeometryType() const;
     201                 : 
     202              54 :     long               GetMaxFID() const { return m_nFID; }
     203                 :     long               SetMaxFID(long);
     204                 : 
     205                 :     long               LoadGeometry();
     206                 : 
     207               0 :     IVFKReader        *GetReader() const { return m_poReader; }
     208                 : };
     209                 : 
     210                 : /************************************************************************/
     211                 : /*                              IVFKReader                              */
     212                 : /************************************************************************/
     213                 : class CPL_DLL IVFKReader
     214               1 : {
     215                 : private:
     216                 :     virtual int  AddDataBlock(VFKDataBlock * = NULL) = 0;
     217                 :     virtual void AddInfo(const char *) = 0;
     218                 : 
     219                 : public:
     220                 :     virtual ~IVFKReader();
     221                 : 
     222                 :     virtual void          SetSourceFile(const char *) = 0;
     223                 : 
     224                 :     virtual int           LoadData() = 0;
     225                 :     virtual int           LoadDataBlocks() = 0;
     226                 :     virtual long          LoadGeometry() = 0;
     227                 :     
     228                 :     virtual int           GetDataBlockCount() const = 0;
     229                 :     virtual VFKDataBlock *GetDataBlock(int) const = 0;
     230                 :     virtual VFKDataBlock *GetDataBlock(const char *) const = 0;
     231                 : 
     232                 :     virtual const char   *GetInfo(const char *) = 0;
     233                 : };
     234                 : 
     235                 : IVFKReader *CreateVFKReader();
     236                 : 
     237                 : #endif // GDAL_OGR_VFK_VFKREADER_H_INCLUDED

Generated by: LTP GCOV extension version 1.5