OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimPluginReaderFactory.cpp
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 //
3 // License: LGPL
4 //
5 // See LICENSE.txt file in the top level directory for more details.
6 //
7 // Author: David Burken
8 //
9 // Description: Image handler factory for ossim plugins plugin.
10 //
11 //----------------------------------------------------------------------------
12 // $Id$
13 
18 #include <ossim/base/ossimRefPtr.h>
19 #include <ossim/base/ossimString.h>
21 #include <ossim/base/ossimTrace.h>
23 
24 namespace ossimplugins
25 {
26 
27 
28  static const ossimTrace traceDebug("ossimPluginReaderFactory:debug");
29 
30  RTTI_DEF1(ossimPluginReaderFactory,
31  "ossimPluginReaderFactory",
33 
34  ossimPluginReaderFactory* ossimPluginReaderFactory::theInstance = 0;
35 
37  {
38  theInstance = 0;
39  }
40 
42  {
43  if(!theInstance)
44  {
46  }
47  return theInstance;
48  }
49 
51  const ossimFilename& fileName, bool openOverview)const
52  {
53  if(traceDebug())
54  {
56  << "ossimPluginReaderFactory::open(filename) DEBUG: entered..."
57  << "\ntrying ossimRadarSat2TiffReader"
58  << std::endl;
59  }
60 
63  if(reader->open(fileName) == false)
64  {
65  reader = 0;
66  }
67 
68  if ( !reader.valid() )
69  {
70  if(traceDebug())
71  {
73  << "\ntrying ossimTerraSarTiffReader"
74  << std::endl;
75  }
76 
77  reader = new ossimTerraSarTiffReader();
79  if(reader->open(fileName) == false)
80  {
81  reader = 0;
82  }
83  }
84 
85  if(traceDebug())
86  {
88  << "ossimPluginReaderFactory::open(filename) DEBUG: leaving..."
89  << std::endl;
90  }
91 
92  return reader.release();
93  }
94 
96  const char* prefix)const
97  {
98  if(traceDebug())
99  {
101  << "ossimPluginReaderFactory::open(kwl, prefix) DEBUG: entered..."
102  << "Trying ossimRadarSat2TiffReader"
103  << std::endl;
104  }
105 
107  if(reader->loadState(kwl, prefix) == false)
108  {
109  reader = 0;
110  }
111 
112  if ( !reader.valid() )
113  {
114  if(traceDebug())
115  {
117  << "ossimPluginReaderFactory::open(kwl, prefix) DEBUG: entered..."
118  << "Trying ossimTerraSarTiffReader"
119  << std::endl;
120  }
121  reader = new ossimTerraSarTiffReader;
122  if(reader->loadState(kwl, prefix) == false)
123  {
124  reader = 0;
125  }
126  }
127 
128  if(traceDebug())
129  {
131  << "ossimPluginReaderFactory::open(kwl, prefix) DEBUG: leaving..."
132  << std::endl;
133  }
134 
135  return reader.release();
136  }
137 
139  const ossimString& typeName)const
140  {
141  ossimRefPtr<ossimObject> result = 0;
142  if(typeName == "ossimRadarSat2TiffReader")
143  {
144  result = new ossimRadarSat2TiffReader;
145  }
146  else if(typeName == "ossimTerraSarTiffReader")
147  {
148  result = new ossimTerraSarTiffReader;
149  }
150 
151  return result.release();
152  }
153 
155  const ossimKeywordlist& kwl, const char* prefix)const
156  {
157  return this->open(kwl, prefix);
158  }
159 
161  std::vector<ossimString>& typeList)const
162  {
163  typeList.push_back(ossimString("ossimRadarSat2TiffReader"));
164  typeList.push_back(ossimString("ossimTerraSarTiffReader"));
165  }
166 
169  {
170  extensionList.push_back(ossimString("xml"));
171  }
172 
174 
176 
178 }
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.
RTTI_DEF1(ossimAlosPalsarModel, "ossimAlosPalsarModel", ossimGeometricSarSensorModel)
Represents serializable keyword/value map.
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossimObject * createObject(const ossimString &typeName) const
createObject that takes a class name.
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 getTypeNameList(std::vector< ossimString > &typeList) const
Adds ossimTerraSarTiffReader to the typeList.
Image handler factory for ossim plugins plugin.
void operator=(const ossimPluginReaderFactory &)
hidden from use copy constructor
virtual ossimRefPtr< ossimImageHandler > openOverview(const ossimFilename &file) const
Open overview that takes a file name.
static ossimPluginReaderFactory * theInstance
static instance of this class
ossimPluginReaderFactory()
hidden from use default constructor
T * release()
Definition: ossimRefPtr.h:93
This class defines an abstract Handler which all image handlers(loaders) should derive from...
virtual ~ossimPluginReaderFactory()
virtual destructor
static ossimPluginReaderFactory * 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.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)