OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimPngReaderFactory.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 Portable Network Graphics (PNG) reader
8 // (tile source).
9 //----------------------------------------------------------------------------
10 // $Id: ossimPngReaderFactory.cpp 22633 2014-02-20 00:57:42Z dburken $
11 
12 #include "ossimPngReaderFactory.h"
13 #include "ossimPngReader.h"
15 #include <ossim/base/ossimRefPtr.h>
16 #include <ossim/base/ossimString.h>
18 #include <ossim/base/ossimTrace.h>
20 
21 static const ossimTrace traceDebug("ossimPngReaderFactory:debug");
22 
24  "ossimPngReaderFactory",
26 
28 
30 {
31  theInstance = 0;
32 }
33 
35 {
36  if(!theInstance)
37  {
39  }
40  return theInstance;
41 }
42 
44  bool openOverview)const
45 {
46  if(traceDebug())
47  {
49  << "ossimPngReaderFactory::open(filename) DEBUG: entered..."
50  << "\ntrying ossimPngReader"
51  << std::endl;
52  }
53 
56  if(reader->open(fileName) == false)
57  {
58  reader = 0;
59  }
60 
61  if(traceDebug())
62  {
64  << "ossimPngReaderFactory::open(filename) DEBUG: leaving..."
65  << std::endl;
66  }
67 
68  return reader.release();
69 }
70 
72  const char* prefix)const
73 {
74  if(traceDebug())
75  {
77  << "ossimPngReaderFactory::open(kwl, prefix) DEBUG: entered..."
78  << "Trying ossimPngReader"
79  << std::endl;
80  }
81 
83  if(reader->loadState(kwl, prefix) == false)
84  {
85  reader = 0;
86  }
87 
88  if(traceDebug())
89  {
91  << "ossimPngReaderFactory::open(kwl, prefix) DEBUG: leaving..."
92  << std::endl;
93  }
94 
95  return reader.release();
96 }
97 
99  std::shared_ptr<ossim::istream>& str,
100  const ossimString& connectionString,
101  bool openOverview ) const
102 {
104 
105  // PNG:
108  if ( ih->open( str, connectionString ) )
109  {
110  result = ih.get();
111  }
112  else
113  {
114  // Reset the stream for downstream code.
115  str->seekg(0, std::ios_base::beg);
116  str->clear();
117  }
118 
119  return result;
120 }
121 
122 #if 0
124  std::istream* str, std::streamoff restartPosition, bool youOwnIt ) const
125 {
127 
129  if ( reader->open( str, restartPosition, youOwnIt ) )
130  {
131  result = reader.get();
132  }
133 
134  return result;
135 }
136 #endif
137 
138 
139 
141  const ossimString& typeName)const
142 {
143  ossimRefPtr<ossimObject> result = 0;
144  if(typeName == "ossimPngReader")
145  {
146  result = new ossimPngReader;
147  }
148  return result.release();
149 }
150 
152  const char* prefix)const
153 {
154  return this->open(kwl, prefix);
155 }
156 
157 void ossimPngReaderFactory::getTypeNameList(std::vector<ossimString>& typeList)const
158 {
159  typeList.push_back(ossimString("ossimPngReader"));
160 }
161 
164 {
165  extensionList.push_back(ossimString("png"));
166 }
167 
169  const ossimString& ext)const
170 {
171  ossimString testExt = ext.downcase();
172  if(ext == "png")
173  {
174  result.push_back(new ossimPngReader);
175  }
176 }
177 
179  const ossimString& mimeType)const
180 {
181  ossimString testExt = mimeType.downcase();
182  if(testExt == "image/png")
183  {
184  result.push_back(new ossimPngReader);
185  }
186 }
187 
189 
191 
Factory for PNG image reader.
virtual bool open()=0
Pure virtual open.
virtual void getSupportedExtensions(ossimImageHandlerFactoryBase::UniqueStringList &extensionList) const
Method to add supported extension to the list, like "png".
void setOpenOverviewFlag(bool flag)
Sets theOpenOverviewFlag.
virtual ~ossimPngReaderFactory()
virtual destructor
virtual bool open(std::shared_ptr< ossim::istream > &str, const std::string &connectionString)
This open takes a stream and stores/captures the shared pointer on success.
Represents serializable keyword/value map.
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 getImageHandlersByMimeType(ImageHandlerList &result, const ossimString &mimeType) const
virtual ossimRefPtr< ossimImageHandler > openOverview(const ossimFilename &file) const
Open overview that takes a file name.
virtual void getTypeNameList(std::vector< ossimString > &typeList) const
Adds ossimPngWriter to the typeList.
virtual ossimObject * createObject(const ossimString &typeName) const
createObject that takes a class name (ossimPngReader)
void push_back(char c)
Equivalent to insert(end(), c).
Definition: ossimString.h:905
T * release()
Definition: ossimRefPtr.h:93
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
static ossimPngReaderFactory * instance()
static method to return instance (the only one) of this class.
void operator=(const ossimPngReaderFactory &)
hidden from use copy constructor
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
This class defines an abstract Handler which all image handlers(loaders) should derive from...
virtual ossimImageHandler * open(const ossimFilename &fileName, bool openOverview=true) const
open that takes a file name.
RTTI_DEF1(ossimPngReaderFactory, "ossimPngReaderFactory", ossimImageHandlerFactoryBase)
std::vector< ossimRefPtr< ossimImageHandler > > ImageHandlerList
virtual void getImageHandlersBySuffix(ImageHandlerList &result, const ossimString &ext) const
static ossimPngReaderFactory * theInstance
static instance of this class
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
ossimPngReaderFactory()
hidden from use default constructor