OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
ossimKakaduReaderFactory Class Reference

Factory for J2K image reader. More...

#include <ossimKakaduReaderFactory.h>

Inheritance diagram for ossimKakaduReaderFactory:
ossimImageHandlerFactoryBase ossimObjectFactory ossimObject ossimReferenced

Public Member Functions

virtual ~ossimKakaduReaderFactory ()
 virtual destructor More...
 
virtual ossimImageHandleropen (const ossimFilename &fileName, bool openOverview=true) const
 open that takes a file name. More...
 
virtual ossimImageHandleropen (const ossimKeywordlist &kwl, const char *prefix=0) const
 Open overview that takes a file name. More...
 
virtual ossimRefPtr< ossimImageHandleropen (std::shared_ptr< ossim::istream > &str, const std::string &connectionString, bool openOverview) const
 Open method that takes a stream. More...
 
virtual ossimRefPtr< ossimImageHandleropenOverview (const ossimFilename &file) const
 Open overview that takes a file name. More...
 
virtual ossimRefPtr< ossimImageHandleropenOverview (std::shared_ptr< ossim::istream > &str, const ossimString &connectionString) const
 Open method that takes a stream. More...
 
virtual ossimObjectcreateObject (const ossimString &typeName) const
 createObject that takes a class name (ossimKakaduReader) More...
 
virtual ossimObjectcreateObject (const ossimKeywordlist &kwl, const char *prefix=0) const
 Creates and object given a keyword list and prefix. More...
 
virtual void getTypeNameList (std::vector< ossimString > &typeList) const
 Adds ossimKakaduWriter to the typeList. More...
 
virtual void getSupportedExtensions (ossimImageHandlerFactoryBase::UniqueStringList &extensionList) const
 Method to add supported extension to the list, like "jp2". More...
 
virtual void getImageHandlersBySuffix (ossimImageHandlerFactoryBase::ImageHandlerList &result, const ossimString &ext) const
 Will add to the result list any handler that supports the passed in extensions. More...
 
virtual void getImageHandlersByMimeType (ossimImageHandlerFactoryBase::ImageHandlerList &result, const ossimString &mimeType) const
 Will add to the result list and handler that supports the passed in mime type. More...
 
- Public Member Functions inherited from ossimImageHandlerFactoryBase
virtual ossimRefPtr< ossimImageHandleropen (std::shared_ptr< ossim::ImageHandlerState > state) const
 
- Public Member Functions inherited from ossimObjectFactory
virtual ~ossimObjectFactory ()
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimObjectdup () const
 
virtual ossimString getShortName () const
 
virtual ossimString getLongName () const
 
virtual ossimString getDescription () const
 
virtual ossimString getClassName () const
 
virtual RTTItypeid getType () const
 
virtual bool canCastTo (ossimObject *obj) const
 
virtual bool canCastTo (const RTTItypeid &id) const
 
virtual bool canCastTo (const ossimString &parentClassName) const
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 
virtual std::ostream & print (std::ostream &out) const
 Generic print method. More...
 
virtual bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
virtual void accept (ossimVisitor &visitor)
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 

Static Public Member Functions

static ossimKakaduReaderFactoryinstance ()
 static method to return instance (the only one) of this class. More...
 

Protected Member Functions

bool hasExcludedExtension (const ossimFilename &file) const
 Method to weed out extensions that this plugin knows it does not support. More...
 
 ossimKakaduReaderFactory ()
 hidden from use default constructor More...
 
 ossimKakaduReaderFactory (const ossimKakaduReaderFactory &)
 hidden from use copy constructor More...
 
void operator= (const ossimKakaduReaderFactory &)
 hidden from use copy constructor More...
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Additional Inherited Members

- Public Types inherited from ossimImageHandlerFactoryBase
typedef UniqueList< ossimStringUniqueStringList
 
typedef std::vector< ossimRefPtr< ossimImageHandler > > ImageHandlerList
 

Detailed Description

Factory for J2K image reader.

Definition at line 21 of file ossimKakaduReaderFactory.h.

Constructor & Destructor Documentation

◆ ~ossimKakaduReaderFactory()

ossimKakaduReaderFactory::~ossimKakaduReaderFactory ( )
virtual

virtual destructor

Definition at line 30 of file ossimKakaduReaderFactory.cpp.

31 {
32 }

◆ ossimKakaduReaderFactory() [1/2]

ossimKakaduReaderFactory::ossimKakaduReaderFactory ( )
protected

hidden from use default constructor

Definition at line 309 of file ossimKakaduReaderFactory.cpp.

309 {}

◆ ossimKakaduReaderFactory() [2/2]

ossimKakaduReaderFactory::ossimKakaduReaderFactory ( const ossimKakaduReaderFactory )
protected

hidden from use copy constructor

Definition at line 311 of file ossimKakaduReaderFactory.cpp.

311 {}

Member Function Documentation

◆ createObject() [1/2]

ossimObject * ossimKakaduReaderFactory::createObject ( const ossimString typeName) const
virtual

createObject that takes a class name (ossimKakaduReader)

Parameters
typeNameShould be "ossimKakaduReader".
Returns
pointer to image writer on success, NULL on failure.

Implements ossimObjectFactory.

Definition at line 208 of file ossimKakaduReaderFactory.cpp.

References ossimRefPtr< T >::release().

209 {
210  ossimRefPtr<ossimObject> result = 0;
211  if(typeName == "ossimKakaduNitfReader")
212  {
213  result = new ossimKakaduNitfReader;
214  }
215  else if(typeName == "ossimKakaduJp2Reader")
216  {
217  result = new ossimKakaduJp2Reader;
218  }
219  else if(typeName == "ossimKakaduJ2kReader")
220  {
221  result = new ossimKakaduJ2kReader;
222  }
223  return result.release();
224 }
ossimKakaduJp2Reader class for reading images with JPEG2000 (J2K) compressed blocks using kakadu libr...
ossimKakaduJ2kReader class for reading images with JPEG2000 (J2K) compressed blocks using kakadu libr...
T * release()
Definition: ossimRefPtr.h:93
ossimKakaduNitfReader class for reading NITF images with JPEG2000 (J2K) compressed blocks using kakad...

◆ createObject() [2/2]

ossimObject * ossimKakaduReaderFactory::createObject ( const ossimKeywordlist kwl,
const char *  prefix = 0 
) const
virtual

Creates and object given a keyword list and prefix.

Parameters
kwlThe keyword list.
prefixthe keyword list prefix.
Returns
pointer to image handler on success, NULL on failure.

Implements ossimObjectFactory.

Definition at line 226 of file ossimKakaduReaderFactory.cpp.

References open().

229 {
230  return this->open(kwl, prefix);
231 }
virtual ossimImageHandler * open(const ossimFilename &fileName, bool openOverview=true) const
open that takes a file name.

◆ getImageHandlersByMimeType()

void ossimKakaduReaderFactory::getImageHandlersByMimeType ( ossimImageHandlerFactoryBase::ImageHandlerList result,
const ossimString mimeType 
) const
virtual

Will add to the result list and handler that supports the passed in mime type.

Reimplemented from ossimImageHandlerFactoryBase.

Definition at line 290 of file ossimKakaduReaderFactory.cpp.

References ossimString::begin(), ossimString::end(), and ossimString::push_back().

292 {
293  ossimString test(mimeType.begin(), mimeType.begin()+6);
294  if(test == "image/")
295  {
296  ossimString mimeTypeTest(mimeType.begin() + 6, mimeType.end());
297  if(mimeTypeTest == "jp2")
298  {
299  result.push_back(new ossimKakaduJp2Reader);
300  }
301  else if(mimeTypeTest == "nitf")
302  {
303  result.push_back(new ossimKakaduNitfReader);
304  }
305  }
306 }
ossimKakaduJp2Reader class for reading images with JPEG2000 (J2K) compressed blocks using kakadu libr...
std::string::iterator end()
Definition: ossimString.h:423
void push_back(char c)
Equivalent to insert(end(), c).
Definition: ossimString.h:905
std::string::iterator begin()
Definition: ossimString.h:420
ossimKakaduNitfReader class for reading NITF images with JPEG2000 (J2K) compressed blocks using kakad...

◆ getImageHandlersBySuffix()

void ossimKakaduReaderFactory::getImageHandlersBySuffix ( ossimImageHandlerFactoryBase::ImageHandlerList result,
const ossimString ext 
) const
virtual

Will add to the result list any handler that supports the passed in extensions.

Reimplemented from ossimImageHandlerFactoryBase.

Definition at line 268 of file ossimKakaduReaderFactory.cpp.

References ossimString::downcase(), and ossimString::push_back().

270 {
271  ossimString testExt = ext.downcase();
272  if(testExt == "jp2")
273  {
274  result.push_back(new ossimKakaduJp2Reader);
275  }
276  else if(testExt == "ntf")
277  {
278  result.push_back(new ossimKakaduNitfReader);
279  }
280  else if(testExt == "nitf")
281  {
282  result.push_back(new ossimKakaduNitfReader);
283  }
284 }
ossimKakaduJp2Reader class for reading images with JPEG2000 (J2K) compressed blocks using kakadu libr...
void push_back(char c)
Equivalent to insert(end(), c).
Definition: ossimString.h:905
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
ossimKakaduNitfReader class for reading NITF images with JPEG2000 (J2K) compressed blocks using kakad...

◆ getSupportedExtensions()

void ossimKakaduReaderFactory::getSupportedExtensions ( ossimImageHandlerFactoryBase::UniqueStringList extensionList) const
virtual

Method to add supported extension to the list, like "jp2".

Parameters
extensionListThe list to add to.

Implements ossimImageHandlerFactoryBase.

Definition at line 241 of file ossimKakaduReaderFactory.cpp.

References ossimImageHandlerFactoryBase::UniqueList< T >::push_back().

243 {
244  extensionList.push_back(ossimString("j2k"));
245  extensionList.push_back(ossimString("jp2"));
246 }

◆ getTypeNameList()

void ossimKakaduReaderFactory::getTypeNameList ( std::vector< ossimString > &  typeList) const
virtual

Adds ossimKakaduWriter to the typeList.

Parameters
typeListList to add to.

Implements ossimObjectFactory.

Definition at line 233 of file ossimKakaduReaderFactory.cpp.

235 {
236  typeList.push_back(ossimString("ossimKakaduNitfReader"));
237  typeList.push_back(ossimString("ossimKakaduJp2Reader"));
238  typeList.push_back(ossimString("ossimKakaduJ2kReader"));
239 }

◆ hasExcludedExtension()

bool ossimKakaduReaderFactory::hasExcludedExtension ( const ossimFilename file) const
protected

Method to weed out extensions that this plugin knows it does not support.

This is to avoid a costly open on say a tiff or jpeg that is not handled by this plugin.

Returns
true if extension, false if not.

Definition at line 248 of file ossimKakaduReaderFactory.cpp.

References ossimString::downcase(), and ossimFilename::ext().

250 {
251  bool result = false;
252  ossimString ext = file.ext().downcase();
253  if ( (ext == "tif") ||
254  (ext == "tiff") ||
255  (ext == "jpg") ||
256  (ext == "jpeg") ||
257  (ext == "png") )
258  {
259  result = true;
260  }
261  return result;
262 }
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
ossimString ext() const

◆ instance()

ossimKakaduReaderFactory * ossimKakaduReaderFactory::instance ( )
static

static method to return instance (the only one) of this class.

Returns
pointer to instance of this class.

Definition at line 34 of file ossimKakaduReaderFactory.cpp.

Referenced by ossimSharedLibraryFinalize(), and ossimSharedLibraryInitialize().

35 {
36  static ossimKakaduReaderFactory inst;
37  return &inst;
38 }
Factory for J2K image reader.

◆ open() [1/3]

ossimImageHandler * ossimKakaduReaderFactory::open ( const ossimFilename fileName,
bool  openOverview = true 
) const
virtual

open that takes a file name.

Parameters
fileThe file to open.
openOverviewIf true image handler will attempt to open overview. default = true
Returns
pointer to image handler on success, NULL on failure.

Implements ossimImageHandlerFactoryBase.

Definition at line 40 of file ossimKakaduReaderFactory.cpp.

Referenced by createObject().

42 {
43  static const char* M = "ossimKakaduReaderFactory::open(filename) -- ";
44  if(traceDebug())
45  ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Entered with filename <"<<fileName<<">" ;
46 
48  while (true)
49  {
50  if (hasExcludedExtension(fileName)) break;
51 
52  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying ossimKakaduNitfReader...";
53  reader = new ossimKakaduNitfReader;
55  if(reader->open(fileName)) break;
56 
57  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying ossimKakaduJp2Reader...";
58  reader = new ossimKakaduJp2Reader;
60  if(reader->open(fileName)) break;
61 
62  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying ossimKakaduJ2kReader...";
63  reader = new ossimKakaduJ2kReader;
65  if(reader->open(fileName)) break;
66 
67  reader = 0;
68  break;
69  }
70 
71  if (traceDebug())
72  {
73  if (reader.valid())
74  ossimNotify(ossimNotifyLevel_DEBUG)<<M<< " SUCCESS" << std::endl;
75  else
76  ossimNotify(ossimNotifyLevel_DEBUG)<<M<< " Open FAILED" << std::endl;
77  }
78 
79  return reader.release();
80 }
virtual bool open()=0
Pure virtual open.
void setOpenOverviewFlag(bool flag)
Sets theOpenOverviewFlag.
ossimKakaduJp2Reader class for reading images with JPEG2000 (J2K) compressed blocks using kakadu libr...
bool valid() const
Definition: ossimRefPtr.h:75
ossimKakaduJ2kReader class for reading images with JPEG2000 (J2K) compressed blocks using kakadu libr...
virtual ossimRefPtr< ossimImageHandler > openOverview(const ossimFilename &file) const
Open overview that takes a file name.
T * release()
Definition: ossimRefPtr.h:93
bool hasExcludedExtension(const ossimFilename &file) const
Method to weed out extensions that this plugin knows it does not support.
ossimKakaduNitfReader class for reading NITF images with JPEG2000 (J2K) compressed blocks using kakad...
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ open() [2/3]

ossimImageHandler * ossimKakaduReaderFactory::open ( const ossimKeywordlist kwl,
const char *  prefix = 0 
) const
virtual

Open overview that takes a file name.

Parameters
fileFile to open.
Returns
ossimRefPtr to image handler on success or null on failure.

Implements ossimImageHandlerFactoryBase.

Definition at line 82 of file ossimKakaduReaderFactory.cpp.

84 {
85  if(traceDebug())
86  {
88  << "ossimKakaduReaderFactory::open(kwl, prefix) DEBUG: entered..."
89  << std::endl;
90  }
91 
93 
94  // To save time check the file name first.
95  const char* lookup = kwl.find(prefix, ossimKeywordNames::FILENAME_KW);
96  if (!lookup)
97  {
98  // Deprecated...
99  lookup = kwl.find(prefix, ossimKeywordNames::IMAGE_FILE_KW);
100  }
101 
102  if (lookup)
103  {
104  ossimFilename f = lookup;
105  if ( hasExcludedExtension(f) == false )
106  {
107  reader = new ossimKakaduNitfReader;
108  if(reader->loadState(kwl, prefix) == false)
109  {
110  reader = 0;
111  }
112 
113  if (!reader)
114  {
115  reader = new ossimKakaduJp2Reader;
116  if(reader->loadState(kwl, prefix) == false)
117  {
118  reader = 0;
119  }
120  }
121 
122  if (!reader)
123  {
124  reader = new ossimKakaduJ2kReader;
125  if(reader->loadState(kwl, prefix) == false)
126  {
127  reader = 0;
128  }
129  }
130  }
131  }
132 
133  if(traceDebug())
134  {
136  << "ossimKakaduReaderFactory::open(kwl, prefix) DEBUG: leaving..."
137  << std::endl;
138  }
139 
140  return reader.release();
141 }
ossimKakaduJp2Reader class for reading images with JPEG2000 (J2K) compressed blocks using kakadu libr...
const char * find(const char *key) const
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
ossimKakaduJ2kReader class for reading images with JPEG2000 (J2K) compressed blocks using kakadu libr...
T * release()
Definition: ossimRefPtr.h:93
bool hasExcludedExtension(const ossimFilename &file) const
Method to weed out extensions that this plugin knows it does not support.
ossimKakaduNitfReader class for reading NITF images with JPEG2000 (J2K) compressed blocks using kakad...
static const char * IMAGE_FILE_KW
static const char * FILENAME_KW
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ open() [3/3]

ossimRefPtr< ossimImageHandler > ossimKakaduReaderFactory::open ( std::shared_ptr< ossim::istream > &  str,
const std::string &  connectionString,
bool  openOverview 
) const
virtual

Open method that takes a stream.

This implementation returns an ossimRefPtr with a null pointer.

Parameters
strOpen stream to image.
connectionString
openOverviewIf true attempt to open overview file.
Returns
ossimImageHandler

Reimplemented from ossimImageHandlerFactoryBase.

Definition at line 143 of file ossimKakaduReaderFactory.cpp.

References ossimRefPtr< T >::get(), ossimNitfTileSource::open(), openOverview(), and ossimImageHandler::setOpenOverviewFlag().

147 {
149 
150  // J2K NITF:
153  if ( ih->open( str, connectionString ) )
154  {
155  result = ih.get();
156  }
157  else
158  {
159  // Reset the stream for downstream code.
160  str->seekg(0, std::ios_base::beg);
161  str->clear();
162  }
163 
164  return result;
165 }
void setOpenOverviewFlag(bool flag)
Sets theOpenOverviewFlag.
virtual ossimRefPtr< ossimImageHandler > openOverview(const ossimFilename &file) const
Open overview that takes a file name.
virtual bool open()
Returns true if the image_file can be opened and is a valid nitf file.
ossimKakaduNitfReader class for reading NITF images with JPEG2000 (J2K) compressed blocks using kakad...

◆ openOverview() [1/2]

ossimRefPtr< ossimImageHandler > ossimKakaduReaderFactory::openOverview ( const ossimFilename file) const
virtual

Open overview that takes a file name.

Parameters
fileFile to open.
Returns
ossimRefPtr to image handler on success or null on failure.

Reimplemented from ossimImageHandlerFactoryBase.

Definition at line 168 of file ossimKakaduReaderFactory.cpp.

References ossimImageHandler::open(), ossimImageHandler::setOpenOverviewFlag(), and ossimString::size().

Referenced by open().

170 {
172  if ( file.size() )
173  {
174  result = new ossimKakaduNitfReader;
175 
176  result->setOpenOverviewFlag( false ); // Always false...
177 
178  if( result->open( file ) == false )
179  {
180  result = 0;
181  }
182  }
183  return result;
184 }
virtual bool open()=0
Pure virtual open.
void setOpenOverviewFlag(bool flag)
Sets theOpenOverviewFlag.
std::string::size_type size() const
Definition: ossimString.h:405
ossimKakaduNitfReader class for reading NITF images with JPEG2000 (J2K) compressed blocks using kakad...

◆ openOverview() [2/2]

ossimRefPtr< ossimImageHandler > ossimKakaduReaderFactory::openOverview ( std::shared_ptr< ossim::istream > &  str,
const ossimString connectionString 
) const
virtual

Open method that takes a stream.

Parameters
strOpen stream to image.
connectionString
Returns
ossimImageHandler

Reimplemented from ossimImageHandlerFactoryBase.

Definition at line 186 of file ossimKakaduReaderFactory.cpp.

References ossimRefPtr< T >::get(), ossimNitfTileSource::open(), and ossimImageHandler::setOpenOverviewFlag().

188 {
190 
191  // J2K NITF:
193  ih->setOpenOverviewFlag(false);
194  if ( ih->open( str, connectionString ) )
195  {
196  result = ih.get();
197  }
198  else
199  {
200  // Reset the stream for downstream code.
201  str->seekg(0, std::ios_base::beg);
202  str->clear();
203  }
204 
205  return result;
206 }
void setOpenOverviewFlag(bool flag)
Sets theOpenOverviewFlag.
virtual bool open()
Returns true if the image_file can be opened and is a valid nitf file.
ossimKakaduNitfReader class for reading NITF images with JPEG2000 (J2K) compressed blocks using kakad...

◆ operator=()

void ossimKakaduReaderFactory::operator= ( const ossimKakaduReaderFactory )
protected

hidden from use copy constructor

Definition at line 313 of file ossimKakaduReaderFactory.cpp.

313 {}

The documentation for this class was generated from the following files: