LCOV - code coverage report
Current view: directory - ogr/ogrsf_frmts/mdb - ogr_mdb.h (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 10 10 100.0 %
Date: 2012-12-26 Functions: 10 10 100.0 %

       1                 : /******************************************************************************
       2                 :  * $Id: ogr_mdb.h 21557 2011-01-22 23:42:14Z rouault $
       3                 :  *
       4                 :  * Project:  OpenGIS Simple Features Reference Implementation
       5                 :  * Purpose:  Private definitions for MDB driver.
       6                 :  * Author:   Even Rouault, <even dot rouault at mines dash paris dot org>
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 2011, Even Rouault, <even dot rouault at mines dash paris dot org>
      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
      22                 :  * OR 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                 : #ifndef _OGR_MDB_H_INCLUDED
      31                 : #define _OGR_MDB_H_INCLUDED
      32                 : 
      33                 : #include <jni.h>
      34                 : #include <vector>
      35                 : 
      36                 : #include "ogrsf_frmts.h"
      37                 : #include "cpl_error.h"
      38                 : #include "cpl_string.h"
      39                 : 
      40                 : /************************************************************************/
      41                 : /*                            OGRMDBJavaEnv                             */
      42                 : /************************************************************************/
      43                 : 
      44                 : class OGRMDBJavaEnv
      45                 : {
      46                 :     public:
      47                 :         OGRMDBJavaEnv();
      48                 :         ~OGRMDBJavaEnv();
      49                 : 
      50                 :         int Init();
      51                 : 
      52                 : 
      53                 :     JavaVM *jvm;
      54                 :     JNIEnv *env;
      55                 :     int bCalledFromJava;
      56                 : 
      57                 :     int ExceptionOccured();
      58                 : 
      59                 :     jclass byteArray_class;
      60                 : 
      61                 :     jclass file_class;
      62                 :     jmethodID file_constructor;
      63                 :     jclass database_class;
      64                 :     jmethodID database_open;
      65                 :     jmethodID database_close;
      66                 :     jmethodID database_getTableNames;
      67                 :     jmethodID database_getTable;
      68                 : 
      69                 :     jclass table_class;
      70                 :     jmethodID table_getColumns;
      71                 :     jmethodID table_iterator;
      72                 :     jmethodID table_getRowCount;
      73                 : 
      74                 :     jclass column_class;
      75                 :     jmethodID column_getName;
      76                 :     jmethodID column_getType;
      77                 :     jmethodID column_getLength;
      78                 :     jmethodID column_isVariableLength;
      79                 : 
      80                 :     jclass datatype_class;
      81                 :     jmethodID datatype_getValue;
      82                 : 
      83                 :     jclass list_class;
      84                 :     jmethodID list_iterator;
      85                 : 
      86                 :     jclass set_class;
      87                 :     jmethodID set_iterator;
      88                 : 
      89                 :     jclass map_class;
      90                 :     jmethodID map_get;
      91                 : 
      92                 :     jclass iterator_class;
      93                 :     jmethodID iterator_hasNext;
      94                 :     jmethodID iterator_next;
      95                 : 
      96                 :     jclass object_class;
      97                 :     jmethodID object_toString;
      98                 :     jmethodID object_getClass;
      99                 : 
     100                 :     jclass boolean_class;
     101                 :     jmethodID boolean_booleanValue;
     102                 : 
     103                 :     jclass byte_class;
     104                 :     jmethodID byte_byteValue;
     105                 : 
     106                 :     jclass short_class;
     107                 :     jmethodID short_shortValue;
     108                 :     
     109                 :     jclass integer_class;
     110                 :     jmethodID integer_intValue;
     111                 : 
     112                 :     jclass float_class;
     113                 :     jmethodID float_floatValue;
     114                 : 
     115                 :     jclass double_class;
     116                 :     jmethodID double_doubleValue;
     117                 : };
     118                 : 
     119                 : /************************************************************************/
     120                 : /*                           OGRMDBDatabase                             */
     121                 : /************************************************************************/
     122                 : 
     123                 : class OGRMDBTable;
     124                 : 
     125                 : class OGRMDBDatabase
     126                 : {
     127                 :     OGRMDBJavaEnv* env;
     128                 :     jobject database;
     129                 : 
     130                 :     OGRMDBDatabase();
     131                 : public:
     132                 :     static OGRMDBDatabase* Open(OGRMDBJavaEnv* env, const char* pszName);
     133                 :     ~OGRMDBDatabase();
     134                 : 
     135                 :     std::vector<CPLString>   apoTableNames;
     136                 :     int                FetchTableNames();
     137                 :     OGRMDBTable* GetTable(const char* pszTableName);
     138                 : };
     139                 : 
     140                 : /************************************************************************/
     141                 : /*                             OGRMDBTable                              */
     142                 : /************************************************************************/
     143                 : 
     144                 : class OGRMDBTable
     145                 : {
     146                 :     OGRMDBJavaEnv* env;
     147                 :     OGRMDBDatabase* poDB;
     148                 :     jobject table;
     149                 : 
     150                 :     jobject table_iterator_obj;
     151                 :     jobject row;
     152                 : 
     153                 :     jobject GetColumnVal(int iCol);
     154                 : 
     155                 :     CPLString osTableName;
     156                 : 
     157                 :     std::vector<CPLString> apoColumnNames;
     158                 :     std::vector<jstring>   apoColumnNameObjects;
     159                 :     std::vector<int>       apoColumnTypes;
     160                 :     std::vector<int>       apoColumnLengths;
     161                 : 
     162                 : public:
     163                 :     OGRMDBTable(OGRMDBJavaEnv* env, OGRMDBDatabase* poDB, jobject table, const char* pszTableName);
     164                 :     ~OGRMDBTable();
     165                 : 
     166              18 :     OGRMDBDatabase* GetDB() { return poDB; }
     167                 : 
     168              18 :     const char* GetName() { return osTableName.c_str(); }
     169                 : 
     170              18 :     int GetColumnCount() { return (int)apoColumnNames.size(); }
     171                 :     int GetColumnIndex(const char* pszColName, int bEmitErrorIfNotFound = FALSE);
     172             120 :     const char* GetColumnName(int iIndex) { return apoColumnNames[iIndex].c_str(); }
     173             102 :     int GetColumnType(int iIndex) { return apoColumnTypes[iIndex]; }
     174              48 :     int GetColumnLength(int iIndex) { return apoColumnLengths[iIndex]; }
     175                 : 
     176                 :     void DumpTable();
     177                 : 
     178                 :     int FetchColumns();
     179                 : 
     180                 :     int GetRowCount();
     181                 :     int GetNextRow();
     182                 :     void ResetReading();
     183                 : 
     184                 :     char* GetColumnAsString(int iCol);
     185                 :     int GetColumnAsInt(int iCol);
     186                 :     double GetColumnAsDouble(int iCol);
     187                 :     GByte* GetColumnAsBinary(int iCol, int* pnBytes);
     188                 : 
     189                 : };
     190                 : 
     191                 : typedef enum 
     192                 : {
     193                 :     MDB_Boolean = 0x01,
     194                 :     MDB_Byte = 0x02,
     195                 :     MDB_Short = 0x03,
     196                 :     MDB_Int = 0x04,
     197                 :     MDB_Money = 0x05,
     198                 :     MDB_Float = 0x06,
     199                 :     MDB_Double = 0x07,
     200                 :     MDB_ShortDateTime = 0x08,
     201                 :     MDB_Binary = 0x09,
     202                 :     MDB_Text = 0x0A,
     203                 :     MDB_OLE = 0x0B,
     204                 :     MDB_Memo = 0x0C,
     205                 :     MDB_Unknown = 0x0D,
     206                 :     MDB_GUID = 0x0F,
     207                 :     MDB_Numeric = 0x10
     208                 : } MDBType;
     209                 : 
     210                 : typedef enum
     211                 : {
     212                 :     MDB_GEOM_NONE,
     213                 :     MDB_GEOM_PGEO,
     214                 :     MDB_GEOM_GEOMEDIA
     215                 : } MDBGeometryType;
     216                 : 
     217                 : /************************************************************************/
     218                 : /*                            OGRMDBLayer                              */
     219                 : /************************************************************************/
     220                 : 
     221                 : class OGRMDBDataSource;
     222                 :     
     223                 : class OGRMDBLayer : public OGRLayer
     224                 : {
     225                 :   protected:
     226                 :     OGRMDBTable* poMDBTable;
     227                 : 
     228                 :     MDBGeometryType     eGeometryType;
     229                 : 
     230                 :     OGRFeatureDefn     *poFeatureDefn;
     231                 : 
     232                 :     // Layer spatial reference system, and srid.
     233                 :     OGRSpatialReference *poSRS;
     234                 :     int                 nSRSId;
     235                 : 
     236                 :     int                 iNextShapeId;
     237                 : 
     238                 :     OGRMDBDataSource    *poDS;
     239                 : 
     240                 :     int                 iGeomColumn;
     241                 :     char                *pszGeomColumn;
     242                 :     char                *pszFIDColumn;
     243                 : 
     244                 :     int                *panFieldOrdinals;
     245                 : 
     246                 :     int                 bHasExtent;
     247                 :     OGREnvelope         sExtent;
     248                 : 
     249                 :     void                LookupSRID( int );
     250                 : 
     251                 :   public:
     252                 :                         OGRMDBLayer(OGRMDBDataSource* poDS, OGRMDBTable* poMDBTable);
     253                 :     virtual             ~OGRMDBLayer();
     254                 : 
     255                 :     CPLErr              BuildFeatureDefn();
     256                 : 
     257                 :     CPLErr              Initialize( const char *pszTableName,
     258                 :                                     const char *pszGeomCol,
     259                 :                                     int nShapeType,
     260                 :                                     double dfExtentLeft,
     261                 :                                     double dfExtentRight,
     262                 :                                     double dfExtentBottom,
     263                 :                                     double dfExtentTop,
     264                 :                                     int nSRID,
     265                 :                                     int bHasZ );
     266                 : 
     267                 :     CPLErr              Initialize( const char *pszTableName,
     268                 :                                     const char *pszGeomCol,
     269                 :                                     OGRSpatialReference* poSRS );
     270                 : 
     271                 :     virtual void        ResetReading();
     272                 :     virtual int         GetFeatureCount( int bForce );
     273                 :     virtual OGRFeature *GetNextRawFeature();
     274                 :     virtual OGRFeature *GetNextFeature();
     275                 : 
     276                 :     virtual OGRFeature *GetFeature( long nFeatureId );
     277                 :     
     278             355 :     OGRFeatureDefn *    GetLayerDefn() { return poFeatureDefn; }
     279                 : 
     280                 :     virtual OGRSpatialReference *GetSpatialRef();
     281                 : 
     282                 :     virtual int         TestCapability( const char * );
     283                 : 
     284                 :     virtual const char *GetFIDColumn();
     285                 :     virtual const char *GetGeometryColumn();
     286                 : 
     287                 :     virtual OGRErr      GetExtent( OGREnvelope *psExtent, int bForce );
     288                 : };
     289                 : 
     290                 : /************************************************************************/
     291                 : /*                           OGRMDBDataSource                            */
     292                 : /************************************************************************/
     293                 : 
     294                 : class OGRMDBDataSource : public OGRDataSource
     295                 : {
     296                 :     OGRMDBLayer        **papoLayers;
     297                 :     int                 nLayers;
     298                 : 
     299                 :     OGRMDBLayer        **papoLayersInvisible;
     300                 :     int                 nLayersWithInvisible;
     301                 : 
     302                 :     char               *pszName;
     303                 : 
     304                 :     OGRMDBJavaEnv       env;
     305                 : 
     306                 :     OGRMDBDatabase*     poDB;
     307                 : 
     308                 :     int                 OpenGDB(OGRMDBTable* poGDB_GeomColumns);
     309                 :     int                 OpenGeomediaWarehouse(OGRMDBTable* poGAliasTable);
     310                 :     OGRSpatialReference* GetGeomediaSRS(const char* pszGCoordSystemTable,
     311                 :                                         const char* pszGCoordSystemGUID);
     312                 : 
     313                 :   public:
     314                 :                         OGRMDBDataSource();
     315                 :                         ~OGRMDBDataSource();
     316                 : 
     317                 :     int                 Open( const char *, int bUpdate, int bTestOpen );
     318                 :     int                 OpenTable( const char *pszTableName, 
     319                 :                                    const char *pszGeomCol,
     320                 :                                    int bUpdate );
     321                 : 
     322               3 :     const char          *GetName() { return pszName; }
     323              66 :     int                 GetLayerCount() { return nLayers; }
     324                 :     OGRLayer            *GetLayer( int );
     325                 :     OGRLayer            *GetLayerByName( const char* pszLayerName );
     326                 : 
     327                 :     int                 TestCapability( const char * );
     328                 : };
     329                 : 
     330                 : /************************************************************************/
     331                 : /*                             OGRMDBDriver                             */
     332                 : /************************************************************************/
     333                 : 
     334                 : class OGRMDBDriver : public OGRSFDriver
     335             226 : {
     336                 :   public:
     337                 :                 ~OGRMDBDriver();
     338                 : 
     339                 :     const char  *GetName();
     340                 :     OGRDataSource *Open( const char *, int );
     341                 : 
     342                 :     int          TestCapability( const char * );
     343                 : };
     344                 : 
     345                 : #endif /* ndef _OGR_MDB_H_INCLUDED */

Generated by: LCOV version 1.7