OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimSqliteReaderFactory.cpp
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 //
3 // License: See top level LICENSE.txt file
4 //
5 // Author: David Burken
6 //
7 // Description: Factory for OSSIM SQLite reader factory.
8 //
9 //----------------------------------------------------------------------------
10 // $Id$
11 
13 #include "ossimGpkgReader.h"
15 #include <ossim/base/ossimRefPtr.h>
16 #include <ossim/base/ossimString.h>
18 #include <ossim/base/ossimTrace.h>
20 
21 #include <sqlite3.h>
22 
23 static const ossimTrace traceDebug("ossimSqliteReaderFactory:debug");
24 
26  "ossimSqliteReaderFactory",
28 
30 
32 {
33  theInstance = 0;
34 }
35 
37 {
38  if(!theInstance)
39  {
41  }
42  return theInstance;
43 }
44 
46  bool openOverview)const
47 {
48  if(traceDebug())
49  {
51  << "ossimSqliteReaderFactory::open(filename) DEBUG: entered..."
52  << "\ntrying ossimGpkgReader"
53  << std::endl;
54  }
56 
57  std::string ext = file.ext().downcase().string();
58  if ( ext == "gpkg" )
59  {
60  reader = new ossimGpkgReader;
62  if(reader->open(file) == false)
63  {
64  reader = 0;
65  }
66  }
67 
68  if(traceDebug())
69  {
71  << "ossimSqliteReaderFactory::open(filename) DEBUG: leaving..."
72  << std::endl;
73  }
74 
75  return reader.release();
76 }
77 
79  const char* prefix)const
80 {
81  if(traceDebug())
82  {
84  << "ossimSqliteReaderFactory::open(kwl, prefix) DEBUG: entered..."
85  << "Trying ossimGpkgReader"
86  << std::endl;
87  }
88 
90  if(reader->loadState(kwl, prefix) == false)
91  {
92  reader = 0;
93  }
94 
95  if(traceDebug())
96  {
98  << "ossimSqliteReaderFactory::open(kwl, prefix) DEBUG: leaving..."
99  << std::endl;
100  }
101 
102  return reader.release();
103 }
104 
106  const ossimString& typeName)const
107 {
108  ossimRefPtr<ossimObject> result = 0;
109  if(typeName == "ossimGpkgReader")
110  {
111  result = new ossimGpkgReader;
112  }
113  return result.release();
114 }
115 
117  const char* prefix)const
118 {
119  return this->open(kwl, prefix);
120 }
121 
122 void ossimSqliteReaderFactory::getTypeNameList(std::vector<ossimString>& typeList)const
123 {
124  typeList.push_back(ossimString("ossimGpkgReader"));
125 }
126 
129 {
130  extensionList.push_back(ossimString("gpkg"));
131 }
132 
134  const ossimString& ext)const
135 {
136  ossimString testExt = ext.downcase();
137  if(ext == "gpkg")
138  {
139  result.push_back(new ossimGpkgReader);
140  }
141 }
142 
144  const ossimString& mimeType)const
145 {
146  ossimString testExt = mimeType.downcase();
147  if(testExt == "image/gpkg")
148  {
149  result.push_back(new ossimGpkgReader);
150  }
151 }
152 
154 
156 
virtual bool open()=0
Pure virtual open.
virtual void getImageHandlersBySuffix(ImageHandlerList &result, const ossimString &ext) const
static ossimSqliteReaderFactory * theInstance
static instance of this class
void setOpenOverviewFlag(bool flag)
Sets theOpenOverviewFlag.
virtual void getImageHandlersByMimeType(ImageHandlerList &result, const ossimString &mimeType) const
ossimSqliteReaderFactory()
hidden from use default constructor
Represents serializable keyword/value map.
virtual ~ossimSqliteReaderFactory()
virtual destructor
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
virtual void getSupportedExtensions(ossimImageHandlerFactoryBase::UniqueStringList &extensionList) const
Method to add supported extension to the list, like "sqlite".
virtual ossimRefPtr< ossimImageHandler > openOverview(const ossimFilename &file) const
Open overview that takes a file name.
virtual void getTypeNameList(std::vector< ossimString > &typeList) const
Adds ossimSqliteWriter to the typeList.
static ossimSqliteReaderFactory * instance()
static method to return instance (the only one) of this class.
void push_back(char c)
Equivalent to insert(end(), c).
Definition: ossimString.h:905
virtual ossimImageHandler * open(const ossimFilename &file, bool openOverview=true) const
open that takes a file name.
virtual ossimObject * createObject(const ossimString &typeName) const
createObject that takes a class name (ossimSqliteReader)
T * release()
Definition: ossimRefPtr.h:93
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
RTTI_DEF1(ossimSqliteReaderFactory, "ossimSqliteReaderFactory", ossimImageHandlerFactoryBase)
This class defines an abstract Handler which all image handlers(loaders) should derive from...
ossimString ext() const
void operator=(const ossimSqliteReaderFactory &)
hidden from use copy constructor
std::vector< ossimRefPtr< ossimImageHandler > > ImageHandlerList
Factory for SQLITE image reader.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
const std::string & string() const
Definition: ossimString.h:414