LCOV - code coverage report
Current view: directory - ogr/ogrsf_frmts/vfk - vfkreader.h (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 16 15 93.8 %
Date: 2010-01-09 Functions: 16 15 93.8 %

       1                 : /******************************************************************************
       2                 :  * $Id: vfkreader.h 18488 2010-01-09 03:27:14Z mloskot $
       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             158 :     bool                    IsNull() const    { return m_bIsNull; }
      70             444 :     int                     GetValueI() const { return m_nValue; }
      71              52 :     double                  GetValueD() const { return m_dValue; }
      72               3 :     const char             *GetValueS() const { return m_strValue.c_str(); }
      73                 : };
      74                 : 
      75                 : /************************************************************************/
      76                 : /*                              VFKFeature                              */
      77                 : /************************************************************************/
      78                 : class CPL_DLL VFKFeature
      79                 : {
      80                 : private:
      81                 :     VFKDataBlock             *m_poDataBlock;
      82                 :     
      83                 :     long                      m_nFID;
      84                 :     VFKProperty             **m_papszProperty;
      85                 :     
      86                 :     bool                      m_bAlive;
      87                 :     
      88                 :     OGRwkbGeometryType        m_nGeometryType;
      89                 :     bool                      m_bGeometry;
      90                 :     OGRGeometry              *m_paGeom;
      91                 :     
      92                 : public:
      93                 :     VFKFeature(VFKDataBlock *);
      94                 :     ~VFKFeature();
      95                 :     
      96              67 :     long                 GetFID() const { return m_nFID; }
      97                 :     void                 SetFID(long);
      98                 : 
      99                 :     VFKDataBlock        *GetDataBlock() const { return m_poDataBlock; }
     100                 :     
     101                 :     void                 SetProperty(int, const char *);
     102                 :     const VFKProperty   *GetProperty(int) const;
     103                 :     const VFKProperty   *GetProperty(const char *) const;
     104                 : 
     105                 :     bool                 LoadGeometry();
     106              28 :     OGRwkbGeometryType   GetGeometryType() const { return m_nGeometryType; }
     107                 :     OGRGeometry         *GetGeometry();
     108                 :     void                 SetGeometry(OGRGeometry *);
     109                 : 
     110                 :     bool                 AppendLineToRing(int, const OGRLineString *);
     111                 : };
     112                 : 
     113                 : /************************************************************************/
     114                 : /*                              VFKPropertyDefn                         */
     115                 : /************************************************************************/
     116                 : class CPL_DLL VFKPropertyDefn
     117                 : {
     118                 : private:
     119                 :     char             *m_pszName;
     120                 : 
     121                 :     char             *m_pszType;
     122                 :     OGRFieldType      m_eFType;
     123                 : 
     124                 :     int               m_nWidth;
     125                 :     int               m_nPrecision;
     126                 : 
     127                 : public:
     128                 :     VFKPropertyDefn(const char*, const char *);
     129                 :     ~VFKPropertyDefn();
     130                 : 
     131             885 :     const char       *GetName() const  { return m_pszName; }
     132            1051 :     int               GetWidth() const { return m_nWidth;  }
     133             605 :     int               GetPrecision() const { return m_nPrecision;  }
     134            1047 :     OGRFieldType      GetType() const  { return m_eFType;  }
     135                 : };
     136                 : 
     137                 : /************************************************************************/
     138                 : /*                              VFKDataBlock                            */
     139                 : /************************************************************************/
     140                 : class CPL_DLL VFKDataBlock
     141                 : {
     142                 : private:
     143                 :     typedef std::vector<OGRPoint>  PointList;
     144                 :     typedef std::vector<PointList *> PointListArray;
     145                 :     
     146                 :     char              *m_pszName;
     147                 :     
     148                 :     int                m_nPropertyCount;
     149                 :     VFKPropertyDefn  **m_papoProperty;
     150                 : 
     151                 :     int                m_nFeatureCount;
     152                 :     VFKFeature       **m_papoFeature;
     153                 :     
     154                 :     int                AddProperty(const char *, const char *);
     155                 :     
     156                 :     int                m_iNextFeature;
     157                 :     long               m_nFID;
     158                 :     
     159                 :     OGRwkbGeometryType m_nGeometryType;
     160                 :     bool               m_bGeometry;
     161                 :     bool               m_bGeometryPerBlock;
     162                 : 
     163                 :     IVFKReader        *m_poReader;
     164                 : 
     165                 :     bool               AppendLineToRing(PointListArray *, const OGRLineString *, bool);
     166                 : 
     167                 : public:
     168                 :     VFKDataBlock(const char *, const IVFKReader *);
     169                 :     ~VFKDataBlock();
     170                 : 
     171            4470 :     const char        *GetName() const { return m_pszName; }
     172                 : 
     173            3580 :     int                GetPropertyCount() const { return m_nPropertyCount; }
     174                 :     VFKPropertyDefn   *GetProperty(int) const;
     175                 :     int                SetProperties(char *);
     176                 :     int                GetPropertyIndex(const char *) const;
     177                 : 
     178              57 :     int                GetFeatureCount() const  { return m_nFeatureCount;  }
     179                 :     int                GetFeatureCount(const char *, const char *);
     180                 :     void               SetFeatureCount(int, int = FALSE);
     181                 :     VFKFeature        *GetFeatureByIndex(int) const;
     182                 :     VFKFeature        *GetFeature(int, int, VFKFeatureList* = NULL);
     183                 :     VFKFeatureList     GetFeatures(int, int);
     184                 :     VFKFeatureList     GetFeatures(int, int, int);
     185                 :     VFKFeature        *GetFeature(long);
     186                 :     int                AddFeature(const char *);
     187                 : 
     188                 :     void               ResetReading(int iIdx = -1);
     189                 :     VFKFeature        *GetNextFeature();
     190                 :     VFKFeature        *GetPreviousFeature();
     191                 :     VFKFeature        *GetFirstFeature();
     192                 :     VFKFeature        *GetLastFeature();
     193                 :     int                SetNextFeature(const VFKFeature *);
     194                 :     
     195                 :     OGRwkbGeometryType SetGeometryType();
     196                 :     OGRwkbGeometryType GetGeometryType() const;
     197                 : 
     198              54 :     long               GetMaxFID() const { return m_nFID; }
     199                 :     long               SetMaxFID(long);
     200                 : 
     201                 :     long               LoadGeometry();
     202                 : 
     203               0 :     IVFKReader        *GetReader() const { return m_poReader; }
     204                 : };
     205                 : 
     206                 : /************************************************************************/
     207                 : /*                              IVFKReader                              */
     208                 : /************************************************************************/
     209                 : class CPL_DLL IVFKReader
     210               1 : {
     211                 : private:
     212                 :     virtual int  AddDataBlock(VFKDataBlock * = NULL) = 0;
     213                 :     virtual void AddInfo(const char *) = 0;
     214                 : 
     215                 : public:
     216                 :     virtual ~IVFKReader();
     217                 : 
     218                 :     virtual void          SetSourceFile(const char *) = 0;
     219                 : 
     220                 :     virtual int           LoadData() = 0;
     221                 :     virtual int           LoadDataBlocks() = 0;
     222                 :     virtual long          LoadGeometry() = 0;
     223                 :     
     224                 :     virtual int           GetDataBlockCount() const = 0;
     225                 :     virtual VFKDataBlock *GetDataBlock(int) const = 0;
     226                 :     virtual VFKDataBlock *GetDataBlock(const char *) const = 0;
     227                 : 
     228                 :     virtual const char   *GetInfo(const char *) = 0;
     229                 : };
     230                 : 
     231                 : IVFKReader *CreateVFKReader();
     232                 : 
     233                 : #endif // GDAL_OGR_VFK_VFKREADER_H_INCLUDED

Generated by: LCOV version 1.7