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

Factory for PNG image reader. More...

#include <ossimOpjReaderFactory.h>

Inheritance diagram for ossimOpjReaderFactory:
ossimImageHandlerFactoryBase ossimObjectFactory ossimObject ossimReferenced

Public Member Functions

virtual ~ossimOpjReaderFactory ()
 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 that takes a keyword list and prefix. More...
 
virtual ossimRefPtr< ossimImageHandleropenOverview (const ossimFilename &file) const
 Open overview that takes a file name. More...
 
virtual ossimObjectcreateObject (const ossimString &typeName) const
 createObject that takes a class name (ossimOpjReader) 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 ossimOpjWriter to the typeList. More...
 
virtual void getSupportedExtensions (ossimImageHandlerFactoryBase::UniqueStringList &extensionList) const
 Method to add supported extension to the list, like "png". 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::istream > &str, const std::string &connectionString, bool openOverview=true) const
 Open method that takes a stream. More...
 
virtual ossimRefPtr< ossimImageHandleropen (std::shared_ptr< ossim::ImageHandlerState > state) const
 
virtual ossimRefPtr< ossimImageHandleropenOverview (std::shared_ptr< ossim::istream > &str, const ossimString &connectionString) const
 Open method that takes a stream. More...
 
- 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 ossimOpjReaderFactoryinstance ()
 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...
 
 ossimOpjReaderFactory ()
 hidden from use default constructor More...
 
 ossimOpjReaderFactory (const ossimOpjReaderFactory &)
 hidden from use copy constructor More...
 
void operator= (const ossimOpjReaderFactory &)
 hidden from use copy constructor More...
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Static Protected Attributes

static ossimOpjReaderFactorytheInstance = 0
 static instance of this class More...
 

Additional Inherited Members

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

Detailed Description

Factory for PNG image reader.

Definition at line 20 of file ossimOpjReaderFactory.h.

Constructor & Destructor Documentation

◆ ~ossimOpjReaderFactory()

ossimOpjReaderFactory::~ossimOpjReaderFactory ( )
virtual

virtual destructor

Definition at line 28 of file ossimOpjReaderFactory.cpp.

References theInstance.

29 {
30  theInstance = 0;
31 }
static ossimOpjReaderFactory * theInstance
static instance of this class

◆ ossimOpjReaderFactory() [1/2]

ossimOpjReaderFactory::ossimOpjReaderFactory ( )
protected

hidden from use default constructor

Definition at line 240 of file ossimOpjReaderFactory.cpp.

Referenced by instance().

240 {}

◆ ossimOpjReaderFactory() [2/2]

ossimOpjReaderFactory::ossimOpjReaderFactory ( const ossimOpjReaderFactory )
protected

hidden from use copy constructor

Definition at line 242 of file ossimOpjReaderFactory.cpp.

242 {}

Member Function Documentation

◆ createObject() [1/2]

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

createObject that takes a class name (ossimOpjReader)

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

Implements ossimObjectFactory.

Definition at line 157 of file ossimOpjReaderFactory.cpp.

159 {
160  if(typeName == "ossimOpjJp2Reader")
161  {
162  return new ossimOpjJp2Reader;
163  }
164  else if(typeName == "ossimOpjNitfReader")
165  {
166  return new ossimOpjNitfReader;
167  }
168  return 0;
169 }

◆ createObject() [2/2]

ossimObject * ossimOpjReaderFactory::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 171 of file ossimOpjReaderFactory.cpp.

References open().

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

◆ getImageHandlersByMimeType()

void ossimOpjReaderFactory::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 206 of file ossimOpjReaderFactory.cpp.

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

209 {
210  ossimString test(mimeType.begin(), mimeType.begin()+6);
211  if(test == "image/")
212  {
213  ossimString mimeTypeTest(mimeType.begin() + 6, mimeType.end());
214  if( (mimeTypeTest == "jp2") || (mimeTypeTest == "j2k") )
215  {
216  result.push_back(new ossimOpjJp2Reader);
217  }
218  else if(mimeTypeTest == "nitf")
219  {
220  result.push_back(new ossimOpjNitfReader);
221  }
222  }
223 }
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

◆ getImageHandlersBySuffix()

void ossimOpjReaderFactory::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 191 of file ossimOpjReaderFactory.cpp.

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

194 {
195  ossimString testExt = ext.downcase();
196  if ( (testExt == "jp2") || (testExt == "j2k") )
197  {
198  result.push_back( new ossimOpjJp2Reader() );
199  }
200  else if( (testExt == "ntf") || (testExt == "nitf") )
201  {
202  result.push_back(new ossimOpjNitfReader() );
203  }
204 }
void push_back(char c)
Equivalent to insert(end(), c).
Definition: ossimString.h:905
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48

◆ getSupportedExtensions()

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

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

Parameters
extensionListThe list to add to.

Implements ossimImageHandlerFactoryBase.

Definition at line 185 of file ossimOpjReaderFactory.cpp.

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

187 {
188  extensionList.push_back(ossimString("jp2"));
189 }

◆ getTypeNameList()

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

Adds ossimOpjWriter to the typeList.

Parameters
typeListList to add to.

Implements ossimObjectFactory.

Definition at line 178 of file ossimOpjReaderFactory.cpp.

180 {
181  typeList.push_back(ossimString("ossimOpjJp2Reader"));
182  typeList.push_back(ossimString("ossimOpjNitfReader"));
183 }

◆ hasExcludedExtension()

bool ossimOpjReaderFactory::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 225 of file ossimOpjReaderFactory.cpp.

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

226 {
227  bool result = false;
228  ossimString ext = file.ext().downcase();
229  if ( (ext == "tif") ||
230  (ext == "tiff") ||
231  (ext == "jpg") ||
232  (ext == "jpeg") ||
233  (ext == "png") )
234  {
235  result = true;
236  }
237  return result;
238 }
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
ossimString ext() const

◆ instance()

ossimOpjReaderFactory * ossimOpjReaderFactory::instance ( )
static

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

Returns
pointer to instance of this class.

Definition at line 33 of file ossimOpjReaderFactory.cpp.

References ossimOpjReaderFactory(), and theInstance.

Referenced by ossimSharedLibraryFinalize(), and ossimSharedLibraryInitialize().

34 {
35  if(!theInstance)
36  {
38  }
39  return theInstance;
40 }
ossimOpjReaderFactory()
hidden from use default constructor
static ossimOpjReaderFactory * theInstance
static instance of this class

◆ open() [1/2]

ossimImageHandler * ossimOpjReaderFactory::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 42 of file ossimOpjReaderFactory.cpp.

Referenced by createObject().

44 {
45  static const char* M = "ossimOpjReaderFactory::open(filename)";
46 
47  if(traceDebug())
48  {
50  << M << " Entered with filename:" << fileName
51  << "\n";
52  }
53 
55  while (true)
56  {
57  if (hasExcludedExtension(fileName)) break;
58 
59  if (traceDebug())
60  {
61  ossimNotify(ossimNotifyLevel_DEBUG) << M << " Trying ossimOpjJp2Reader...";
62  }
63  reader = new ossimOpjJp2Reader();
65  if( reader->open(fileName) ) break;
66 
67  if (traceDebug())
68  {
69  ossimNotify(ossimNotifyLevel_DEBUG) << M << " Trying ossimOpjNitfReader...";
70  }
71  reader = new ossimOpjNitfReader();
72  if( reader->open(fileName) ) break;
73 
74  reader = 0;
75  break;
76  }
77 
78  if(traceDebug())
79  {
80  ossimNotify(ossimNotifyLevel_DEBUG) << M << " DEBUG: leaving..." << std::endl;
81  }
82 
83  return reader.release();
84 }
virtual bool open()=0
Pure virtual open.
void setOpenOverviewFlag(bool flag)
Sets theOpenOverviewFlag.
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.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ open() [2/2]

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

open that takes a keyword list and prefix.

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

Implements ossimImageHandlerFactoryBase.

Definition at line 86 of file ossimOpjReaderFactory.cpp.

88 {
89  if(traceDebug())
90  {
92  << "ossimOpjReaderFactory::open(kwl, prefix) DEBUG: entered..."
93  << "Trying ossimOpjReader"
94  << std::endl;
95  }
96 
98 
99  // To save time check the file name first.
100  const char* lookup = kwl.find(prefix, ossimKeywordNames::FILENAME_KW);
101  if (!lookup)
102  {
103  // Deprecated...
104  lookup = kwl.find(prefix, ossimKeywordNames::IMAGE_FILE_KW);
105  }
106 
107  if (lookup)
108  {
109  ossimFilename f = lookup;
110  if ( hasExcludedExtension(f) == false )
111  {
112  reader = new ossimOpjNitfReader;
113  if(reader->loadState(kwl, prefix) == false)
114  {
115  reader = 0;
116  }
117 
118  if (!reader)
119  {
120  reader = new ossimOpjJp2Reader;
121  if(reader->loadState(kwl, prefix) == false)
122  {
123  reader = 0;
124  }
125  }
126  }
127  }
128 
129  if(traceDebug())
130  {
132  << "ossimOpjReaderFactory::open(kwl, prefix) DEBUG: leaving..."
133  << std::endl;
134  }
135 
136  return reader.release();
137 }
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.
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.
static const char * IMAGE_FILE_KW
static const char * FILENAME_KW
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ openOverview()

ossimRefPtr< ossimImageHandler > ossimOpjReaderFactory::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 139 of file ossimOpjReaderFactory.cpp.

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

141 {
143  if ( file.size() )
144  {
145  result = new ossimOpjNitfReader();
146 
147  result->setOpenOverviewFlag( false ); // Always false...
148 
149  if( result->open( file ) == false )
150  {
151  result = 0;
152  }
153  }
154  return result;
155 }
virtual bool open()=0
Pure virtual open.
void setOpenOverviewFlag(bool flag)
Sets theOpenOverviewFlag.
std::string::size_type size() const
Definition: ossimString.h:405

◆ operator=()

void ossimOpjReaderFactory::operator= ( const ossimOpjReaderFactory )
protected

hidden from use copy constructor

Definition at line 244 of file ossimOpjReaderFactory.cpp.

244 {}

Member Data Documentation

◆ theInstance

ossimOpjReaderFactory * ossimOpjReaderFactory::theInstance = 0
staticprotected

static instance of this class

Definition at line 129 of file ossimOpjReaderFactory.h.

Referenced by instance(), and ~ossimOpjReaderFactory().


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