OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimH5ReaderFactory.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 // Copied from Mingjie Su's ossimHdfReaderFactory.
8 //
9 // Description: Factory for OSSIM HDF5 reader using HDF5 libraries.
10 //----------------------------------------------------------------------------
11 // $Id: ossimH5ReaderFactory.cpp 2645 2011-05-26 15:21:34Z oscar.kramer $
12 
13 #include "ossimH5ReaderFactory.h"
15 #include <ossim/base/ossimRefPtr.h>
16 #include <ossim/base/ossimString.h>
17 #include <ossim/base/ossimTrace.h>
19 #include "ossimH5Reader.h"
20 
21 static const ossimTrace traceDebug("ossimH5ReaderFactory:debug");
22 
23 class ossimImageHandler;
24 
26  "ossimH5ReaderFactory",
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  << "ossimH5ReaderFactory::open(filename) DEBUG: entered..."
52  << "\ntrying ossimH5Reader"
53  << std::endl;
54  }
55 
57 
58  if ( hasExcludedExtension(fileName) == false )
59  {
60  if (reader == 0) //try hdf5 reader
61  {
62  // cout << "Calling ossimH5Reader ***********************" << endl;
63  reader = new ossimHdf5ImageHandler;
65  if(reader->open(fileName) == false)
66  {
67  reader = 0;
68  }
69  }
70  }
71 
72  if(traceDebug())
73  {
75  << "ossimH5ReaderFactory::open(filename) DEBUG: leaving..."
76  << std::endl;
77  }
78 
79  return reader.release();
80 }
81 
83  const char* prefix)const
84 {
85  if(traceDebug())
86  {
88  << "ossimH5ReaderFactory::open(kwl, prefix) DEBUG: entered..."
89  << "Trying ossimKakaduNitfReader"
90  << std::endl;
91  }
92 
94  if(reader->loadState(kwl, prefix) == false)
95  {
96  reader = 0;
97  }
98 
99  if(traceDebug())
100  {
102  << "ossimH5ReaderFactory::open(kwl, prefix) DEBUG: leaving..."
103  << std::endl;
104  }
105 
106  return reader.release();
107 }
108 
110  const ossimString& typeName)const
111 {
112  ossimRefPtr<ossimObject> result = 0;
113  if(typeName == "ossimH5Reader")
114  {
115  result = new ossimHdf5ImageHandler;
116  }
117 
118  return result.release();
119 }
120 
122  const ossimKeywordlist& kwl,
123  const char* prefix)const
124 {
125  return this->open(kwl, prefix);
126 }
127 
129  std::vector<ossimString>& typeList)const
130 {
131  typeList.push_back(ossimString("ossimH5Reader"));
132 }
133 
136 {
137  extensionList.push_back(ossimString("h5"));
138  extensionList.push_back(ossimString("he5"));
139  extensionList.push_back(ossimString("hdf5"));
140 }
141 
143  const ossimFilename& file) const
144 {
145  bool result = true;
146  ossimString ext = file.ext().downcase();
147  //only include the file with those extension and exclude any other files
148  if ( (ext == "h5") || (ext == "hdf5") || (ext == "he5") )
149  {
150  result = false;
151  }
152  return result;
153 }
154 
156 
158 
160 
virtual bool open()=0
Pure virtual open.
void setOpenOverviewFlag(bool flag)
Sets theOpenOverviewFlag.
virtual ossimObject * createObject(const ossimString &typeName) const
createObject that takes a class name (ossimH5Reader)
virtual void getSupportedExtensions(ossimImageHandlerFactoryBase::UniqueStringList &extensionList) const
Method to add supported extension to the list, like "hdf".
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 getTypeNameList(std::vector< ossimString > &typeList) const
Adds ossimH5Reader to the typeList.
This is the base class for all imagery using HDF5 as the file format.
virtual ~ossimH5ReaderFactory()
virtual destructor
void operator=(const ossimH5ReaderFactory &)
hidden from use copy constructor
virtual ossimRefPtr< ossimImageHandler > openOverview(const ossimFilename &file) const
Open overview that takes a file name.
static ossimH5ReaderFactory * instance()
static method to return instance (the only one) of this class.
bool hasExcludedExtension(const ossimFilename &file) const
Method to weed out extensions that this plugin knows it does not support.
virtual bool openOverview()
Searches for an overview.
RTTI_DEF1(ossimH5ReaderFactory, "ossimH5ReaderFactory", ossimImageHandlerFactoryBase)
T * release()
Definition: ossimRefPtr.h:93
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
ossimH5ReaderFactory()
hidden from use default constructor
This class defines an abstract Handler which all image handlers(loaders) should derive from...
Factory for Hdf image reader.
static ossimH5ReaderFactory * theInstance
static instance of this class
virtual ossimImageHandler * open(const ossimFilename &fileName, bool openOverview=true) const
open that takes a file name.
ossimString ext() const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)