OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimMrSidReaderFactory.cpp
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 //
3 // License: See top level LICENSE.txt file
4 //
5 // Author: Mingjie Su
6 //
7 // Description: Factory for OSSIM MrSID reader using kakadu library.
8 //----------------------------------------------------------------------------
9 // $Id: ossimMrSidReaderFactory.cpp 469 2009-12-23 18:52:47Z ming.su $
10 
12 #include <ossim/base/ossimRefPtr.h>
13 #include <ossim/base/ossimString.h>
14 #include <ossim/base/ossimTrace.h>
16 
18 #include "ossimMrSidReader.h"
19 #include "ossimMG4LidarReader.h"
20 
21 static const ossimTrace traceDebug("ossimMrSidReaderFactory:debug");
22 
23 class ossimImageHandler;
24 
26  "ossimMrSidReaderFactory",
28 
30 
32 {
33  theInstance = 0;
34 }
35 
37 {
38  if(!theInstance)
39  {
41  }
42  return theInstance;
43 }
44 
46  const ossimFilename& fileName, bool openOverview)const
47 {
48  if(traceDebug())
49  {
51  << "ossimMrSidReaderFactory::open(filename) DEBUG: entered...\n";
52  }
53 
55 
56  if ( hasExcludedExtension(fileName) == false )
57  {
58  if(traceDebug())
59  {
60  ossimNotify(ossimNotifyLevel_DEBUG) << "\nTrying ossimMrSidReader\n";
61  }
62  reader = new ossimMrSidReader;
64  if(reader->open(fileName) == false)
65  {
66  reader = 0;
67  }
68 
69  if (!reader.valid())
70  {
71  reader = new ossimMG4LidarReader;
73  if(reader->open(fileName) == false)
74  {
75  reader = 0;
76  }
77  }
78  }
79 
80  if(traceDebug())
81  {
83  << "ossimMrSidReaderFactory::open(filename) DEBUG: leaving...\n";
84  }
85 
86  return reader.release();
87 }
88 
90  const char* prefix)const
91 {
92  if(traceDebug())
93  {
95  << "ossimMrSidReaderFactory::open(kwl, prefix) DEBUG: entered..."
96  << "Trying ossimMrSidReader..."
97  << std::endl;
98  }
99 
101  if(reader->loadState(kwl, prefix) == false)
102  {
103  reader = 0;
104  }
105 
106  if(traceDebug())
107  {
109  << "ossimMrSidReaderFactory::open(kwl, prefix) DEBUG: leaving..."
110  << std::endl;
111  }
112 
113  return reader.release();
114 }
115 
117  const ossimString& typeName)const
118 {
119  ossimRefPtr<ossimObject> result = 0;
120  if(typeName == "ossimMrSidReader")
121  {
122  result = new ossimMrSidReader;
123  }
124  else if(typeName == "ossimMG4LidarReader")
125  {
126  result = new ossimMrSidReader;
127  }
128 
129  return result.release();
130 }
131 
133  const ossimKeywordlist& kwl,
134  const char* prefix)const
135 {
136  return this->open(kwl, prefix);
137 }
138 
140  std::vector<ossimString>& typeList)const
141 {
142  typeList.push_back(ossimString("ossimMrSidReader"));
143 }
144 
147 {
148  extensionList.push_back(ossimString("sid"));
149 }
150 
153 {
154  ossimString testExt = ext.downcase();
155  if(ext == "sid")
156  {
157  result.push_back(new ossimMrSidReader);
158  }
159 }
160 
162  ossimImageHandlerFactoryBase::ImageHandlerList& result, const ossimString& mimeType)const
163 {
164  ossimString testExt = mimeType.downcase();
165  if(testExt == "image/sid")
166  {
167  result.push_back(new ossimMrSidReader);
168  }
169 }
170 
172  const ossimFilename& file) const
173 {
174  bool result = true;
175  ossimString ext = file.ext().downcase();
176  if (ext == "sid") //only include the file with .sid extension and exclude any other files
177  {
178  result = false;
179  }
180  return result;
181 }
182 
184 
186 
virtual bool open()=0
Pure virtual open.
bool hasExcludedExtension(const ossimFilename &file) const
Method to weed out extensions that this plugin knows it does not support.
void setOpenOverviewFlag(bool flag)
Sets theOpenOverviewFlag.
static ossimMrSidReaderFactory * theInstance
static instance of this class
Factory for MrSid image reader.
void operator=(const ossimMrSidReaderFactory &)
hidden from use copy constructor
Represents serializable keyword/value map.
bool valid() const
Definition: ossimRefPtr.h:75
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 ossimRefPtr< ossimImageHandler > openOverview(const ossimFilename &file) const
Open overview that takes a file name.
virtual bool openOverview()
Searches for an overview.
void push_back(char c)
Equivalent to insert(end(), c).
Definition: ossimString.h:905
virtual void getSupportedExtensions(ossimImageHandlerFactoryBase::UniqueStringList &extensionList) const
Method to add supported extension to the list, like "sid".
T * release()
Definition: ossimRefPtr.h:93
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
ossimMrSidReaderFactory()
hidden from use default constructor
This class defines an abstract Handler which all image handlers(loaders) should derive from...
virtual void getTypeNameList(std::vector< ossimString > &typeList) const
Adds ossimMrSidWriter to the typeList.
virtual void getImageHandlersByMimeType(ImageHandlerList &result, const ossimString &mimeType) const
virtual ossimObject * createObject(const ossimString &typeName) const
createObject that takes a class name (ossimMrSidReader)
ossimString ext() const
virtual void getImageHandlersBySuffix(ImageHandlerList &result, const ossimString &ext) const
virtual ~ossimMrSidReaderFactory()
virtual destructor
std::vector< ossimRefPtr< ossimImageHandler > > ImageHandlerList
static ossimMrSidReaderFactory * instance()
static method to return instance (the only one) of this class.
virtual ossimImageHandler * open(const ossimFilename &fileName, bool openOverview=true) const
open that takes a file name.
RTTI_DEF1(ossimMrSidReaderFactory, "ossimMrSidReaderFactory", ossimImageHandlerFactoryBase)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)