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

ossimImageHandlerRegistry supports the new state cache. More...

#include <ossimImageHandlerRegistry.h>

Inheritance diagram for ossimImageHandlerRegistry:
ossimObjectFactory ossimFactoryListInterface< ossimImageHandlerFactoryBase, ossimImageHandler > ossimObject ossimReferenced

Public Member Functions

virtual ~ossimImageHandlerRegistry ()
 
std::shared_ptr< ossim::ImageHandlerState > getState (const ossimString &connectionString, ossim_uint32 entry) const
 
std::shared_ptr< ossim::ImageHandlerState > getState (const ossimString &id) const
 
ossimRefPtr< ossimImageHandleropenConnection (const ossimString &connectionString, bool openOverview=true) const
 
virtual ossimImageHandleropen (const ossimFilename &fileName, bool trySuffixFirst=true, bool openOverview=true) const
 open that takes a filename. More...
 
virtual ossimImageHandleropen (const ossimKeywordlist &kwl, const char *prefix=0) const
 Given a keyword list return a pointer to an ImageHandler. More...
 
virtual ossimRefPtr< ossimImageHandleropen (std::shared_ptr< ossim::ImageHandlerState > state) const
 
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 ossimObjectcreateObject (const ossimString &typeName) const
 
virtual ossimObjectcreateObject (const ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual ossimRefPtr< ossimImageHandleropenBySuffix (const ossimFilename &file, bool openOverview=true) const
 openBySuffix will call the mthod getImageHandlersBySuffix and go through each handler to try and open the file. 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...
 
virtual void getTypeNameList (std::vector< ossimString > &typeList) const
 
virtual void getSupportedExtensions (ossimImageHandlerFactoryBase::UniqueStringList &extensionList) const
 
std::ostream & printReaderProps (std::ostream &out) const
 Prints list of readers and properties. 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
 
- Public Member Functions inherited from ossimFactoryListInterface< ossimImageHandlerFactoryBase, ossimImageHandler >
 ossimFactoryListInterface ()
 
void addFactory (ossimImageHandlerFactoryBase *factory)
 This is for backward compatability and calls registerFactory for simple adds. More...
 
bool isFactoryRegistered (ossimImageHandlerFactoryBase *factory) const
 Public access method to determine if a factory is already registered to this list. More...
 
void registerFactory (ossimImageHandlerFactoryBase *factory, bool pushToFrontFlag=false)
 Will register a factory to the factory list. More...
 
void unregisterFactory (ossimImageHandlerFactoryBase *factory)
 Will remove the factory from the registry. More...
 
void unregisterFactory (const ossimString &factoryTypeName)
 Will remove the factory from the registry by name. More...
 
void unregisterAllFactories ()
 Will remove all factories from the registry. More...
 
void registerFactoryToFront (ossimImageHandlerFactoryBase *factory)
 Inserts the factory to the front of the list. More...
 
void registerFactoryBefore (ossimImageHandlerFactoryBase *factory, ossimImageHandlerFactoryBase *beforeThisFactory)
 Will insert the factory before the beforeThisFactory. More...
 
void getAllTypeNamesFromRegistry (std::vector< ossimString > &typeList) const
 Will add all object types the factories can allocate. More...
 
ossimObjectcreateObjectFromRegistry (const ossimString &typeName) const
 This is the base object return for all objects in the system. More...
 
ossimObjectcreateObjectFromRegistry (const ossimKeywordlist &kwl, const char *prefix=0) const
 This is the base object return for all objects in the system. More...
 
ossimImageHandlercreateNativeObjectFromRegistry (const ossimString &typeName) const
 This is a helper method that calls the createObject and makes sure that the returned object is of the NativeType base type this registry supports. More...
 
ossimImageHandlercreateNativeObjectFromRegistry (const ossimKeywordlist &kwl, const char *prefix=0) const
 This is a helper method that calls the createObject and makes sure that the returned object is of the NativeType base type this registry supports. More...
 

Static Public Member Functions

static ossimImageHandlerRegistryinstance ()
 

Protected Member Functions

 ossimImageHandlerRegistry ()
 
 ossimImageHandlerRegistry (const ossimImageHandlerRegistry &rhs)
 
const ossimImageHandlerRegistryoperator= (const ossimImageHandlerRegistry &rhs)
 
void initializeStateCache () const
 
void addToStateCache (ossimImageHandler *handler) const
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 
- Protected Member Functions inherited from ossimFactoryListInterface< ossimImageHandlerFactoryBase, ossimImageHandler >
bool findFactory (ossimImageHandlerFactoryBase *factory) const
 Utility to find a factory in the list. More...
 

Protected Attributes

std::shared_ptr< ossim::ItemCache< ossim::ImageHandlerState > > m_stateCache
 
- Protected Attributes inherited from ossimFactoryListInterface< ossimImageHandlerFactoryBase, ossimImageHandler >
std::mutex m_factoryListMutex
 
FactoryListType m_factoryList
 

Additional Inherited Members

- Public Types inherited from ossimFactoryListInterface< ossimImageHandlerFactoryBase, ossimImageHandler >
typedef std::vector< ossimImageHandlerFactoryBase *> FactoryListType
 
typedef ossimImageHandlerFactoryBase FactoryType
 
typedef ossimImageHandler NativeReturnType
 

Detailed Description

ossimImageHandlerRegistry supports the new state cache.

During initialization the properties are read from the global preferences. The keywords are:

ossim.imaging.handler.registry.state_cache.enabled: true or false ossim.imaging.handler.registry.state_cache.min_size: min number of items ossim.imaging.handler.registry.state_cache.max_size: max number of items

On open if the state cache is enabled it will determine if a state exists when a file is passed in to be open and if a state exists it will try to open the handler based on the state.

Definition at line 41 of file ossimImageHandlerRegistry.h.

Constructor & Destructor Documentation

◆ ~ossimImageHandlerRegistry()

ossimImageHandlerRegistry::~ossimImageHandlerRegistry ( )
virtual

◆ ossimImageHandlerRegistry() [1/2]

ossimImageHandlerRegistry::ossimImageHandlerRegistry ( )
protected

◆ ossimImageHandlerRegistry() [2/2]

ossimImageHandlerRegistry::ossimImageHandlerRegistry ( const ossimImageHandlerRegistry rhs)
protected

Definition at line 542 of file ossimImageHandlerRegistry.cpp.

Member Function Documentation

◆ addToStateCache()

void ossimImageHandlerRegistry::addToStateCache ( ossimImageHandler handler) const
protected

Definition at line 583 of file ossimImageHandlerRegistry.cpp.

References ossimImageHandler::getFilename(), ossimImageHandler::getState(), m_stateCache, and ossimString::toString().

Referenced by open().

584 {
585  if(handler)
586  {
587  std::shared_ptr<ossim::ImageHandlerState> state = handler->getState();
588  if(state&&m_stateCache)
589  {
590  ossimString id = handler->getFilename()+"_e"+ossimString::toString(state->getCurrentEntry());
591  if(traceDebug())
592  {
593  ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::addToStateCache: " << id << std::endl;
594  }
595  m_stateCache->addItem(id, state);
596  }
597  }
598 }
static ossimString toString(bool aValue)
Numeric to string methods.
std::shared_ptr< ossim::ImageHandlerState > getState()
virtual const ossimFilename & getFilename() const
Returns the filename.
std::shared_ptr< ossim::ItemCache< ossim::ImageHandlerState > > m_stateCache
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ createObject() [1/2]

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

Creates an object given a type name.

Implements ossimObjectFactory.

Definition at line 471 of file ossimImageHandlerRegistry.cpp.

References ossimFactoryListInterface< ossimImageHandlerFactoryBase, ossimImageHandler >::createObjectFromRegistry().

472 {
473  return createObjectFromRegistry(typeName);
474 }
ossimObject * createObjectFromRegistry(const ossimString &typeName) const
This is the base object return for all objects in the system.

◆ createObject() [2/2]

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

Creates and object given a keyword list.

Implements ossimObjectFactory.

Definition at line 54 of file ossimImageHandlerRegistry.cpp.

References ossimFactoryListInterface< ossimImageHandlerFactoryBase, ossimImageHandler >::createObjectFromRegistry(), and open().

56 {
57  ossimObject* result = createObjectFromRegistry(kwl, prefix);
58  if(!result)
59  {
60  result = open(kwl, prefix);
61  }
62  return result;
63 }
virtual ossimImageHandler * open(const ossimFilename &fileName, bool trySuffixFirst=true, bool openOverview=true) const
open that takes a filename.
ossimObject * createObjectFromRegistry(const ossimString &typeName) const
This is the base object return for all objects in the system.

◆ getImageHandlersByMimeType()

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

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

Definition at line 108 of file ossimImageHandlerRegistry.cpp.

References ossimFactoryListInterface< ossimImageHandlerFactoryBase, ossimImageHandler >::m_factoryList.

110 {
111  vector<ossimImageHandlerFactoryBase*>::const_iterator iter = m_factoryList.begin();
113  while(iter != m_factoryList.end())
114  {
115  temp.clear();
116  (*iter)->getImageHandlersByMimeType(temp, mimeType);
117 
118  if(!temp.empty())
119  {
120 
121  // now append to the end of the typeList.
122  result.insert(result.end(),
123  temp.begin(),
124  temp.end());
125  }
126  ++iter;
127  }
128 }
std::vector< ossimRefPtr< ossimImageHandler > > ImageHandlerList

◆ getImageHandlersBySuffix()

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

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

Definition at line 86 of file ossimImageHandlerRegistry.cpp.

References ossimFactoryListInterface< ossimImageHandlerFactoryBase, ossimImageHandler >::m_factoryList.

Referenced by openBySuffix().

88 {
89  vector<ossimImageHandlerFactoryBase*>::const_iterator iter = m_factoryList.begin();
91  while(iter != m_factoryList.end())
92  {
93  temp.clear();
94  (*iter)->getImageHandlersBySuffix(temp, ext);
95 
96  if(!temp.empty())
97  {
98 
99  // now append to the end of the typeList.
100  result.insert(result.end(),
101  temp.begin(),
102  temp.end());
103  }
104  ++iter;
105  }
106 }
std::vector< ossimRefPtr< ossimImageHandler > > ImageHandlerList

◆ getState() [1/2]

std::shared_ptr< ossim::ImageHandlerState > ossimImageHandlerRegistry::getState ( const ossimString connectionString,
ossim_uint32  entry 
) const

Definition at line 151 of file ossimImageHandlerRegistry.cpp.

References ossimString::toString().

153 {
154  return getState(connectionString + "_e" + ossimString::toString(entry));
155 }
static ossimString toString(bool aValue)
Numeric to string methods.
std::shared_ptr< ossim::ImageHandlerState > getState(const ossimString &connectionString, ossim_uint32 entry) const

◆ getState() [2/2]

std::shared_ptr< ossim::ImageHandlerState > ossimImageHandlerRegistry::getState ( const ossimString id) const

Definition at line 157 of file ossimImageHandlerRegistry.cpp.

References m_stateCache.

158 {
159  std::shared_ptr<ossim::ImageHandlerState> result;
160 
161  if(m_stateCache)
162  {
163  result = m_stateCache->getItem(id);
164  }
165 
166  return result;
167 }
std::shared_ptr< ossim::ItemCache< ossim::ImageHandlerState > > m_stateCache

◆ getSupportedExtensions()

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

Definition at line 135 of file ossimImageHandlerRegistry.cpp.

References ossimFactoryListInterface< ossimImageHandlerFactoryBase, ossimImageHandler >::m_factoryList.

Referenced by ossimInfo::printExtensions().

137 {
138  vector<ossimString> result;
139  vector<ossimImageHandlerFactoryBase*>::const_iterator iter = m_factoryList.begin();
140 
141  while(iter != m_factoryList.end())
142  {
143  (*iter)->getSupportedExtensions(extensionList);
144 
145  ++iter;
146  }
147 
148 }

◆ getTypeNameList()

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

This should return the type name of all objects in all factories. This is the name used to construct the objects dynamially and this name must be unique.

Implements ossimObjectFactory.

Definition at line 130 of file ossimImageHandlerRegistry.cpp.

References ossimFactoryListInterface< ossimImageHandlerFactoryBase, ossimImageHandler >::getAllTypeNamesFromRegistry().

131 {
132  getAllTypeNamesFromRegistry(typeList);
133 }
void getAllTypeNamesFromRegistry(std::vector< ossimString > &typeList) const
Will add all object types the factories can allocate.

◆ initializeStateCache()

void ossimImageHandlerRegistry::initializeStateCache ( ) const
protected

Definition at line 546 of file ossimImageHandlerRegistry.cpp.

References ossimString::empty(), ossimPreferences::findPreference(), ossimPreferences::instance(), m_stateCache, ossimString::toBool(), and ossimString::toUInt32().

Referenced by ossimImageHandlerRegistry().

547 {
548  m_stateCache = 0;
549  ossimString enabledString = ossimPreferences::instance()->findPreference("ossim.imaging.handler.registry.state_cache.enabled");
550  ossimString minSizeString = ossimPreferences::instance()->findPreference("ossim.imaging.handler.registry.state_cache.min_size");
551  ossimString maxSizeString = ossimPreferences::instance()->findPreference("ossim.imaging.handler.registry.state_cache.max_size");
552 
553  ossim_uint32 maxSize = 0;
554  ossim_uint32 minSize = 0;
555 
556  if(!enabledString.empty())
557  {
558  if(enabledString.toBool())
559  {
560  m_stateCache = std::make_shared<ossim::ItemCache<ossim::ImageHandlerState> >();
561  if(!maxSizeString.empty())
562  {
563  maxSize = maxSizeString.toUInt32();
564  }
565  if(!minSizeString.empty())
566  {
567  minSize = minSizeString.toUInt32();
568  }
569  else if(maxSize)
570  {
571  minSize = ossim::round<ossim_uint32, ossim_float32>(maxSize*.8);
572  }
573 
574  if(minSize < maxSize)
575  {
576  m_stateCache->setMinAndMaxItemsToCache(minSize, maxSize);
577  }
578  }
579 
580  }
581 }
ossim_uint32 toUInt32() const
const char * findPreference(const char *key) const
bool toBool() const
String to numeric methods.
unsigned int ossim_uint32
std::shared_ptr< ossim::ItemCache< ossim::ImageHandlerState > > m_stateCache
static ossimPreferences * instance()
bool empty() const
Definition: ossimString.h:411

◆ instance()

ossimImageHandlerRegistry * ossimImageHandlerRegistry::instance ( )
static

◆ open() [1/4]

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

open that takes a filename.

Parameters
fileNameFile to open.
trySuffixFirstIf true calls code to try to open by suffix first, then goes through the list of available handlers. default=true.
openOverviewIf true image handler will attempt to open overview. default = true
Returns
Pointer to image handler or null if cannot open.

Definition at line 231 of file ossimImageHandlerRegistry.cpp.

Referenced by ossimSingleImageChain::addImageHandler(), ossimPointObservation::addMeasurement(), ATP::AtpGenerator::constructChain(), createObject(), demo1(), demo2(), demo3(), ossimShorelineTool::doThreshold(), ossimVerticesFinderTool::execute(), ossimImageCacheTileSource::fillTile(), ossimSubImageTool::initialize(), ossimEquationUtil::initInputSources(), ossimHdf5Tool::loadImageFiles(), main(), ossimBandSeparateHandler::open(), ossimGdalDataset::open(), ossimGeoidImage::open(), ossimImageElevationHandler::open(), ossimImageGeometry::open(), openBySuffix(), ossimInfo::openImageFromState(), ossimInfo::openImageHandler(), ossimTilingPoly::parseShpFile(), ossimRpcSolver::solve(), ossimGpkgReader::uncompressPngTile(), and ossimImageFileWriter::writeOverviewFile().

234 {
235  if(traceDebug())
236  {
237  ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::open(file, trySuffix,openOverview): entered.........." << std::endl;
238  }
239  std::shared_ptr<ossim::ImageHandlerState> state = getState(filename, 0);
240 
241  if(state)
242  {
244  if(h)
245  {
246  if(traceDebug())
247  {
248  ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::open(file, trySuffix,openOverview): returning with state open.........." << std::endl;;
249  }
250  return h.release();
251  }
252  }
253 
254  if(trySuffixFirst)
255  {
257  if(h.valid())
258  {
259  addToStateCache(h.get());
260  if(traceDebug())
261  {
262  ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::open(file, trySuffix,openOverview): leaving.........." << std::endl;
263  }
264  return h.release();
265  }
266  }
267 
268  // now try magic number opens
269  //
270  ossimImageHandler* result = NULL;
271  vector<ossimImageHandlerFactoryBase*>::const_iterator factory = m_factoryList.begin();
272  while((factory != m_factoryList.end()) && !result)
273  {
274  result = (*factory)->open(filename, openOverview);
275  ++factory;
276  }
277 
278  if(result)
279  {
280  addToStateCache(result);
281  }
282  if(traceDebug())
283  {
284  ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::open(file, trySuffix,openOverview): leaving.........." << std::endl;
285  }
286  return result;
287 }
virtual bool open()=0
Pure virtual open.
virtual ossimRefPtr< ossimImageHandler > openOverview(const ossimFilename &file) const
Open overview that takes a file name.
virtual ossimImageHandler * open(const ossimFilename &fileName, bool trySuffixFirst=true, bool openOverview=true) const
open that takes a filename.
bool valid() const
Definition: ossimRefPtr.h:75
void addToStateCache(ossimImageHandler *handler) const
std::shared_ptr< ossim::ImageHandlerState > getState(const ossimString &connectionString, ossim_uint32 entry) const
T * release()
Definition: ossimRefPtr.h:93
virtual ossimRefPtr< ossimImageHandler > openBySuffix(const ossimFilename &file, bool openOverview=true) const
openBySuffix will call the mthod getImageHandlersBySuffix and go through each handler to try and open...
This class defines an abstract Handler which all image handlers(loaders) should derive from...
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ open() [2/4]

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

Given a keyword list return a pointer to an ImageHandler.

Returns null if a valid handler cannot be found.

Definition at line 289 of file ossimImageHandlerRegistry.cpp.

References addToStateCache(), ossimFactoryListInterface< ossimImageHandlerFactoryBase, ossimImageHandler >::m_factoryList, and ossimImageHandler::open().

291 {
292  ossimImageHandler* result = NULL;
293  vector<ossimImageHandlerFactoryBase*>::const_iterator factory;
294 
295  factory = m_factoryList.begin();
296  while((factory != m_factoryList.end()) && !result)
297  {
298  result = (*factory)->open(kwl, prefix);
299  ++factory;
300  }
301 
302  if(result)
303  {
304  addToStateCache(result);
305  }
306 
307  return result;
308 }
virtual bool open()=0
Pure virtual open.
void addToStateCache(ossimImageHandler *handler) const
This class defines an abstract Handler which all image handlers(loaders) should derive from...

◆ open() [3/4]

ossimRefPtr< ossimImageHandler > ossimImageHandlerRegistry::open ( std::shared_ptr< ossim::ImageHandlerState >  state) const
virtual

Definition at line 360 of file ossimImageHandlerRegistry.cpp.

References ossimFactoryListInterface< ossimImageHandlerFactoryBase, ossimImageHandler >::m_factoryList.

361 {
363  vector<ossimImageHandlerFactoryBase*>::const_iterator factory = m_factoryList.begin();
364  if(traceDebug())
365  {
366  ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::open(state): Entered......." << std::endl;
367  }
368  while( (!result)&&(factory != m_factoryList.end()) )
369  {
370  result = (*factory)->open( state );
371  if ( result )
372  {
373  break;
374  }
375  ++factory;
376  }
377  if(traceDebug())
378  {
379  ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::open(state): Leaving.......valid?" << result.valid()<<std::endl;
380  }
381  return result;
382 }
virtual bool open()=0
Pure virtual open.
bool valid() const
Definition: ossimRefPtr.h:75
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ open() [4/4]

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

Open method that takes a stream.

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

Definition at line 310 of file ossimImageHandlerRegistry.cpp.

314 {
315  if(traceDebug())
316  {
317  ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::open(stream,connectionString,openOverview): entered.........." << std::endl;
318  }
320  std::shared_ptr<ossim::ImageHandlerState> state = getState(connectionString, 0);
321 
322  if(state)
323  {
324  result = open(state);
325  if(result)
326  {
327  if(traceDebug())
328  {
329  ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::open(stream,connectionString,openOverview): leaving with state open..........Valid? "
330  << result.valid() <<std::endl;
331  }
332  return result;
333  }
334  }
335  if ( str )
336  {
337  vector<ossimImageHandlerFactoryBase*>::const_iterator factory = m_factoryList.begin();
338  while( factory != m_factoryList.end() )
339  {
340  result = (*factory)->open( str, connectionString, openOverview );
341  if ( result.valid() )
342  {
343  break;
344  }
345  ++factory;
346  }
347  }
348  if(result)
349  {
350  addToStateCache(result.get());
351  }
352  if(traceDebug())
353  {
354  ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::open(stream,connectionString,openOverview): leaving..........Valid? "
355  << result.valid()<<std::endl;
356  }
357  return result;
358 }
virtual bool open()=0
Pure virtual open.
virtual ossimRefPtr< ossimImageHandler > openOverview(const ossimFilename &file) const
Open overview that takes a file name.
virtual ossimImageHandler * open(const ossimFilename &fileName, bool trySuffixFirst=true, bool openOverview=true) const
open that takes a filename.
bool valid() const
Definition: ossimRefPtr.h:75
void addToStateCache(ossimImageHandler *handler) const
std::shared_ptr< ossim::ImageHandlerState > getState(const ossimString &connectionString, ossim_uint32 entry) const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ openBySuffix()

ossimRefPtr< ossimImageHandler > ossimImageHandlerRegistry::openBySuffix ( const ossimFilename file,
bool  openOverview = true 
) const
virtual

openBySuffix will call the mthod getImageHandlersBySuffix and go through each handler to try and open the file.

This should be a faster open for we do not have to do a magic number compare on all prior files and keep opening and closing files.

Parameters
openOverviewIf true image handler will attempt to open overview. default = true

Definition at line 65 of file ossimImageHandlerRegistry.cpp.

References ossimFilename::ext(), getImageHandlersBySuffix(), open(), openOverview(), and size.

67 {
68  std::vector<ossimRefPtr<ossimImageHandler> > handlers;
69 
70  getImageHandlersBySuffix(handlers, file.ext());
71  ossim_uint32 idx = 0;
72  ossim_uint32 size = (ossim_uint32) handlers.size();
73 
74  for(idx = 0; idx < size; ++idx)
75  {
76  handlers[idx]->setOpenOverviewFlag(openOverview);
77  if(handlers[idx]->open(file))
78  {
79  return handlers[idx];
80  }
81  }
82 
84 }
virtual ossimRefPtr< ossimImageHandler > openOverview(const ossimFilename &file) const
Open overview that takes a file name.
virtual ossimImageHandler * open(const ossimFilename &fileName, bool trySuffixFirst=true, bool openOverview=true) const
open that takes a filename.
yy_size_t size
unsigned int ossim_uint32
ossimString ext() const
virtual void getImageHandlersBySuffix(ossimImageHandlerFactoryBase::ImageHandlerList &result, const ossimString &ext) const
Will add to the result list any handler that supports the passed in extensions.

◆ openConnection()

ossimRefPtr< ossimImageHandler > ossimImageHandlerRegistry::openConnection ( const ossimString connectionString,
bool  openOverview = true 
) const

Definition at line 170 of file ossimImageHandlerRegistry.cpp.

Referenced by ossimSingleImageChain::addImageHandler().

172 {
173  if(traceDebug())
174  {
175  ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::openConnection: entered.........." << std::endl;
176  }
178 
179  std::string myConnectionString = connectionString.downcase().string();
180  std::string fileStr = "file://";
181  std::size_t found = myConnectionString.find( fileStr );
182  if ( found == 0 )
183  {
184  myConnectionString = connectionString.string().substr( fileStr.size() );
185  }
186  else
187  {
188  myConnectionString = connectionString.string();
189  }
190 
191  // add entry 0
192  std::shared_ptr<ossim::ImageHandlerState> state = getState(myConnectionString, 0);
193  if(state)
194  {
195  if(traceDebug())
196  {
197  ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::openConnection: leaving with open(state).........." << std::endl;;
198  }
199  return open(state);
200  }
201 
202  std::shared_ptr<ossim::istream> str = ossim::StreamFactoryRegistry::instance()->
203  createIstream( myConnectionString, std::ios_base::in|std::ios_base::binary);
204 
205  if ( str )
206  {
207  result = open( str, myConnectionString, openOverview );
208  }
209 
210  if ( !result.valid() )
211  {
212  ossimFilename f = myConnectionString;
213  if ( f.exists() )
214  {
215  result = open( f, true, openOverview );
216  }
217  }
218 
219  if(result)
220  {
221  addToStateCache(result.get());
222  }
223  if(traceDebug())
224  {
225  ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::openConnection: leaving.........." << std::endl;
226  }
227 
228  return result;
229 }
virtual ossimRefPtr< ossimImageHandler > openOverview(const ossimFilename &file) const
Open overview that takes a file name.
virtual ossimImageHandler * open(const ossimFilename &fileName, bool trySuffixFirst=true, bool openOverview=true) const
open that takes a filename.
static StreamFactoryRegistry * instance()
void addToStateCache(ossimImageHandler *handler) const
std::shared_ptr< ossim::ImageHandlerState > getState(const ossimString &connectionString, ossim_uint32 entry) const
bool exists() const
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
const std::string & string() const
Definition: ossimString.h:414

◆ openOverview()

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

Open overview that takes a file name.

This will only check readers that can be overview handlers.

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

Definition at line 404 of file ossimImageHandlerRegistry.cpp.

Referenced by openBySuffix().

406 {
408 
409  if(traceDebug())
410  {
411  ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::openOverview: Entered......." << std::endl;
412  }
413 
414  std::shared_ptr<ossim::ImageHandlerState> state = getState(file, 0);
415 
416  if(state)
417  {
418  result = open(state);
419 
420  }
421 
422  if(!result)
423  {
424  // See if we can open via the stream interface:
425  std::shared_ptr<ossim::istream> str = ossim::StreamFactoryRegistry::instance()->
426  createIstream( file, std::ios_base::in|std::ios_base::binary);
427 
428  if ( str )
429  {
430  std::vector<ossimImageHandlerFactoryBase*>::const_iterator factory = m_factoryList.begin();
431  while( factory != m_factoryList.end() )
432  {
433  result = (*factory)->openOverview( str, file );
434  if ( result.valid() )
435  {
436  break;
437  }
438  ++factory;
439  }
440 
441  str = 0;
442  }
443 
444  if ( (result.valid() == false) && file.exists() )
445  {
446  vector<ossimImageHandlerFactoryBase*>::const_iterator factory = m_factoryList.begin();
447  while( factory != m_factoryList.end() )
448  {
449  result = (*factory)->openOverview( file );
450  if ( result.valid() )
451  {
452  break;
453  }
454  ++factory;
455  }
456  }
457 
458  if(result)
459  {
460  addToStateCache(result.get());
461  }
462  }
463  if(traceDebug())
464  {
465  ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::openOverview: Leaving.......Valid? "
466  << result.valid() << std::endl;
467  }
468  return result;
469 }
virtual ossimImageHandler * open(const ossimFilename &fileName, bool trySuffixFirst=true, bool openOverview=true) const
open that takes a filename.
bool valid() const
Definition: ossimRefPtr.h:75
static StreamFactoryRegistry * instance()
void addToStateCache(ossimImageHandler *handler) const
virtual bool openOverview()
Searches for an overview.
std::shared_ptr< ossim::ImageHandlerState > getState(const ossimString &connectionString, ossim_uint32 entry) const
bool exists() const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ operator=()

const ossimImageHandlerRegistry & ossimImageHandlerRegistry::operator= ( const ossimImageHandlerRegistry rhs)
protected

Definition at line 603 of file ossimImageHandlerRegistry.cpp.

604 { return rhs; }

◆ printReaderProps()

std::ostream & ossimImageHandlerRegistry::printReaderProps ( std::ostream &  out) const

Prints list of readers and properties.

Parameters
outStream to print to.
Returns
std::ostream&

Definition at line 476 of file ossimImageHandlerRegistry.cpp.

References ossimRefPtr< T >::get(), ossimObject::getClassName(), ossimStringProperty::getConstraints(), ossimImageHandler::getProperty(), ossimImageHandler::getPropertyNames(), ossimFactoryListInterface< ossimImageHandlerFactoryBase, ossimImageHandler >::m_factoryList, and ossimRefPtr< T >::valid().

Referenced by ossimInfo::printReaderProps().

477 {
478  // Loop through factories:
479  vector<ossimImageHandlerFactoryBase*>::const_iterator factory = m_factoryList.begin();
480  while( factory != m_factoryList.end() )
481  {
482  out << "factory: " << (*factory)->getClassName() << "\n";
483 
484  // Loop through factory image handlers:
485  std::vector<ossimString> readerList;
486  (*factory)->getTypeNameList(readerList);
487 
488  std::vector<ossimString>::const_iterator i = readerList.begin();
489  while ( i != readerList.end() )
490  {
492  dynamic_cast<ossimImageHandler*>( (*factory)->createObject( (*i) ) );
493  if ( ih.valid() )
494  {
495  out << "reader: " << ih->getClassName() << "\n";
496 
497  // Loop through image handler properties:
498  std::vector<ossimString> propNames;
499  ih->getPropertyNames(propNames);
500  if ( propNames.size() )
501  {
502  out << "\nproperties:\n";
504  std::vector<ossimString>::const_iterator p = propNames.begin();
505  while ( p != propNames.end() )
506  {
507  out << " " << (*p) << "\n";
508  prop = ih->getProperty( *p );
509  if ( prop.valid() )
510  {
511  ossimStringProperty* stringProp =
512  dynamic_cast<ossimStringProperty*>(prop.get());
513  if ( stringProp )
514  {
515  if ( stringProp->getConstraints().size() )
516  {
517  out << " constraints:\n";
518  std::vector<ossimString>::const_iterator strPropIter =
519  stringProp->getConstraints().begin();
520  while( strPropIter != stringProp->getConstraints().end() )
521  {
522  out << " " << (*strPropIter) << "\n";
523  ++strPropIter;
524  }
525  }
526  }
527  }
528 
529  ++p;
530  }
531  out << "\n";
532  }
533  }
534  ++i;
535  }
536  ++factory;
537  }
538  out << std::endl;
539  return out;
540 }
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossimString getClassName() const
Definition: ossimObject.cpp:64
const std::vector< ossimString > & getConstraints() const
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
This class defines an abstract Handler which all image handlers(loaders) should derive from...

Member Data Documentation

◆ m_stateCache

std::shared_ptr<ossim::ItemCache<ossim::ImageHandlerState> > ossimImageHandlerRegistry::m_stateCache
mutableprotected

Definition at line 187 of file ossimImageHandlerRegistry.h.

Referenced by addToStateCache(), getState(), and initializeStateCache().


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