osgEarth 2.1.1
|
Public Member Functions | |
const Profile * | getNamedProfile (const std::string &name) const |
const Profile * | getGlobalGeodeticProfile () const |
const Profile * | getGlobalMercatorProfile () const |
const Profile * | getCubeProfile () const |
OpenThreads::ReentrantMutex & | getGDALMutex () |
Cache * | getCacheOverride () const |
void | setCacheOverride (Cache *cacheOverride) |
void | addMimeTypeExtensionMapping (const std::string fromMimeType, const std::string toExt) |
osgDB::ReaderWriter * | getReaderWriterForMimeType (const std::string &mimeType) |
bool | isBlacklisted (const std::string &filename) |
void | blacklist (const std::string &filename) |
unsigned int | getNumBlacklistedFilenames () |
void | clearBlacklist () |
const VerticalSpatialReference * | getDefaultVSRS () const |
const Capabilities & | getCapabilities () const |
ShaderFactory * | getShaderFactory () const |
void | setShaderFactory (ShaderFactory *lib) |
TaskServiceManager * | getTaskServiceManager () |
UID | createUID () |
void | setCacheDirectory (const std::string &dir) |
const std::string & | getCacheDirectory () const |
const osgDB::Options * | getDefaultOptions () const |
osgDB::Options * | cloneOrCreateOptions (const osgDB::Options *options=0L) const |
Static Public Member Functions | |
static Registry * | instance (bool erase=false) |
Protected Types | |
typedef std::map< std::string, std::string > | MimeTypeExtensionMap |
typedef std::set< std::string > | StringSet |
Protected Member Functions | |
virtual | ~Registry () |
Registry () | |
void | destruct () |
void | initCapabilities () |
Protected Attributes | |
OpenThreads::ReentrantMutex | _gdal_mutex |
bool | _gdal_registered |
osg::ref_ptr< const Profile > | _global_geodetic_profile |
osg::ref_ptr< const Profile > | _global_mercator_profile |
osg::ref_ptr< const Profile > | _cube_profile |
OpenThreads::Mutex | _regMutex |
int | _numGdalMutexGets |
MimeTypeExtensionMap | _mimeTypeExtMap |
osg::ref_ptr< Cache > | _cacheOverride |
StringSet | _blacklistedFilenames |
OpenThreads::Mutex | _blacklistMutex |
osg::ref_ptr< const VerticalSpatialReference > | _defaultVSRS |
osg::ref_ptr< ShaderFactory > | _shaderLib |
osg::ref_ptr< TaskServiceManager > | _taskServiceManager |
int | _uidGen |
osg::ref_ptr< Capabilities > | _caps |
osg::ref_ptr< osgDB::Options > | _defaultOptions |
typedef std::map< std::string, std::string> osgEarth::Registry::MimeTypeExtensionMap [protected] |
typedef std::set<std::string> osgEarth::Registry::StringSet [protected] |
Registry::~Registry | ( | ) | [protected, virtual] |
Definition at line 88 of file Registry.cpp.
{ }
Registry::Registry | ( | ) | [protected] |
Definition at line 42 of file Registry.cpp.
: osg::Referenced(true), _gdal_registered( false ), _numGdalMutexGets( 0 ), _uidGen( 0 ), _caps( 0L ) { OGRRegisterAll(); GDALAllRegister(); // add built-in mime-type extension mappings for( int i=0; ; i+=2 ) { std::string mimeType = builtinMimeTypeExtMappings[i]; if ( mimeType.length() == 0 ) break; addMimeTypeExtensionMapping( mimeType, builtinMimeTypeExtMappings[i+1] ); } _shaderLib = new ShaderFactory(); _taskServiceManager = new TaskServiceManager(); // activate KMZ support osgDB::Registry::instance()->addFileExtensionAlias( "kmz", "kml" ); osgDB::Registry::instance()->addArchiveExtension( "kmz" ); #if OSG_MIN_VERSION_REQUIRED(3,0,0) osgDB::Registry::instance()->addMimeTypeExtensionMapping( "application/vnd.google-earth.kml+xml", "kml" ); osgDB::Registry::instance()->addMimeTypeExtensionMapping( "application/vnd.google-earth.kmz", "kmz" ); #endif // set up our default r/w options to NOT cache archives! _defaultOptions = new osgDB::Options(); _defaultOptions->setObjectCacheHint( (osgDB::Options::CacheHintOptions) ((int)_defaultOptions->getObjectCacheHint() & ~osgDB::Options::CACHE_ARCHIVES) ); // see if there's a cache in the envvar const char* cachePath = ::getenv("OSGEARTH_CACHE_PATH"); if ( cachePath ) { TMSCacheOptions tmso; tmso.setPath( std::string(cachePath) ); setCacheOverride( new TMSCache(tmso) ); OE_INFO << LC << "Setting cache (from env.var.) to " << tmso.path() << std::endl; } }
void Registry::addMimeTypeExtensionMapping | ( | const std::string | fromMimeType, |
const std::string | toExt | ||
) |
Registers a mapping of a mime-type to an extension. A process fetching data over HTTP can use this facility to determine the proper ReaderWriter to use when there is no filename extension to rely upon.
Definition at line 210 of file Registry.cpp.
{ _mimeTypeExtMap[fromMimeType] = toExt; }
void Registry::blacklist | ( | const std::string & | filename | ) |
Blacklist the given filename
Definition at line 232 of file Registry.cpp.
{ OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_blacklistMutex); _blacklistedFilenames.insert( filename ); OE_DEBUG << "Blacklist size = " << _blacklistedFilenames.size() << std::endl; }
void Registry::clearBlacklist | ( | ) |
Clears the blacklist
Definition at line 240 of file Registry.cpp.
{ OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_blacklistMutex); _blacklistedFilenames.clear(); OE_DEBUG << "Blacklist size = " << _blacklistedFilenames.size() << std::endl; }
osgDB::Options * Registry::cloneOrCreateOptions | ( | const osgDB::Options * | options = 0L | ) | const |
Clones an options structure (fixing the archive caching), or creates a new one.
Definition at line 294 of file Registry.cpp.
{ osgDB::Options* newOptions = input ? static_cast<osgDB::Options*>(input->clone(osg::CopyOp::SHALLOW_COPY)) : new osgDB::Options(); // clear the CACHE_ARCHIVES flag because it is evil if ( ((int)newOptions->getObjectCacheHint() & osgDB::Options::CACHE_ARCHIVES) != 0 ) { newOptions->setObjectCacheHint( (osgDB::Options::CacheHintOptions) ((int)newOptions->getObjectCacheHint() & ~osgDB::Options::CACHE_ARCHIVES) ); } return newOptions; }
UID Registry::createUID | ( | ) |
Generates an instance-wide global unique ID.
Definition at line 286 of file Registry.cpp.
void Registry::destruct | ( | ) | [protected] |
Definition at line 105 of file Registry.cpp.
{ _cacheOverride = 0; }
const std::string& osgEarth::Registry::getCacheDirectory | ( | ) | const |
osgEarth::Cache * Registry::getCacheOverride | ( | ) | const |
Global override of map caching settings.
Definition at line 199 of file Registry.cpp.
{ return _cacheOverride.get(); }
const Capabilities & Registry::getCapabilities | ( | ) | const |
Gets the graphics hardware capabilities for this platform
Definition at line 255 of file Registry.cpp.
const Profile * Registry::getCubeProfile | ( | ) | const |
Gets the unified cube builtin profile
Definition at line 163 of file Registry.cpp.
{ if ( !_cube_profile.valid() ) { GDAL_SCOPED_LOCK; if ( !_cube_profile.valid() ) // double-check pattern { const_cast<Registry*>(this)->_cube_profile = new UnifiedCubeProfile(); } } return _cube_profile.get(); }
const osgDB::Options* osgEarth::Registry::getDefaultOptions | ( | ) | const [inline] |
Gets the default set of osgDB::Options to use.
Definition at line 138 of file Registry.
{ return _defaultOptions.get(); }
const VerticalSpatialReference * Registry::getDefaultVSRS | ( | ) | const |
The system wide default vertical spatial reference system.
Definition at line 191 of file Registry.cpp.
{ if ( !_defaultVSRS.valid() ) const_cast<Registry*>(this)->_defaultVSRS = new VerticalSpatialReference( Units::METERS ); return _defaultVSRS.get(); }
OpenThreads::ReentrantMutex & Registry::getGDALMutex | ( | ) |
Access to the application-wide GDAL serialization mutex. GDAL is not thread-safe.
Definition at line 112 of file Registry.cpp.
{ //_numGdalMutexGets++; //OE_NOTICE << "GDAL = " << _numGdalMutexGets << std::endl; return _gdal_mutex; }
const Profile * Registry::getGlobalGeodeticProfile | ( | ) | const |
Gets the global-geodetic builtin profile
Definition at line 121 of file Registry.cpp.
{ if ( !_global_geodetic_profile.valid() ) { GDAL_SCOPED_LOCK; if ( !_global_geodetic_profile.valid() ) // double-check pattern { const_cast<Registry*>(this)->_global_geodetic_profile = Profile::create( "epsg:4326", -180.0, -90.0, 180.0, 90.0, "", 2, 1 ); } } return _global_geodetic_profile.get(); }
const Profile * Registry::getGlobalMercatorProfile | ( | ) | const |
Gets the global-meractor builtin profile
Definition at line 141 of file Registry.cpp.
{ if ( !_global_mercator_profile.valid() ) { GDAL_SCOPED_LOCK; if ( !_global_mercator_profile.valid() ) // double-check pattern { // automatically figure out proper mercator extents: const SpatialReference* srs = SpatialReference::create( "spherical-mercator" ); //double e, dummy; //srs->getGeographicSRS()->transform( 180.0, 0.0, srs, e, dummy ); /*const_cast<Registry*>(this)->_global_mercator_profile = Profile::create( srs, -e, -e, e, e, 0L, 1, 1 );*/ const_cast<Registry*>(this)->_global_mercator_profile = Profile::create( srs, MERC_MINX, MERC_MINY, MERC_MAXX, MERC_MAXY, 0L, 1, 1 ); } } return _global_mercator_profile.get(); }
const Profile * Registry::getNamedProfile | ( | const std::string & | name | ) | const |
Gets a well-known named profile instance.
Definition at line 178 of file Registry.cpp.
{ if ( name == STR_GLOBAL_GEODETIC ) return getGlobalGeodeticProfile(); else if ( name == STR_GLOBAL_MERCATOR ) return getGlobalMercatorProfile(); else if ( name == STR_CUBE ) return getCubeProfile(); else return NULL; }
unsigned int Registry::getNumBlacklistedFilenames | ( | ) |
Gets the number of blacklisted filenames
Definition at line 248 of file Registry.cpp.
{ OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_blacklistMutex); return _blacklistedFilenames.size(); }
osgDB::ReaderWriter * Registry::getReaderWriterForMimeType | ( | const std::string & | mimeType | ) |
gets a reader/writer that handles the extension mapped to by one of the registered mime-types.
Definition at line 216 of file Registry.cpp.
{ MimeTypeExtensionMap::const_iterator i = _mimeTypeExtMap.find( mimeType ); return i != _mimeTypeExtMap.end()? osgDB::Registry::instance()->getReaderWriterForExtension( i->second ) : NULL; }
ShaderFactory * Registry::getShaderFactory | ( | ) | const |
Gets or sets the default shader factory. You can replace the default shader factory if you want to alter any of osgEarth's baseline shaders (advanced usage).
Definition at line 273 of file Registry.cpp.
{ return _shaderLib.get(); }
TaskServiceManager* osgEarth::Registry::getTaskServiceManager | ( | ) | [inline] |
Gets a reference to the global task service manager.
Definition at line 120 of file Registry.
{ return _taskServiceManager.get(); }
void Registry::initCapabilities | ( | ) | [protected] |
Definition at line 265 of file Registry.cpp.
{ ScopedLock<Mutex> lock( s_initCapsMutex ); // double-check pattern (see getCapabilities) if ( !_caps.valid() ) _caps = new Capabilities(); }
Registry * Registry::instance | ( | bool | erase = false | ) | [static] |
Access the global Registry singleton.
Definition at line 92 of file Registry.cpp.
{ static osg::ref_ptr<Registry> s_registry = new Registry; if (erase) { s_registry->destruct(); s_registry = 0; } return s_registry.get(); // will return NULL on erase }
bool Registry::isBlacklisted | ( | const std::string & | filename | ) |
Whether the given filename is blacklisted
Definition at line 225 of file Registry.cpp.
{ OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_blacklistMutex); return (_blacklistedFilenames.count(filename)==1); }
void osgEarth::Registry::setCacheDirectory | ( | const std::string & | dir | ) |
Gets or sets the local root of the system default cache.
void Registry::setCacheOverride | ( | osgEarth::Cache * | cacheOverride | ) |
Definition at line 205 of file Registry.cpp.
{ _cacheOverride = cacheOverride; }
void Registry::setShaderFactory | ( | ShaderFactory * | lib | ) |
Definition at line 279 of file Registry.cpp.
{ if ( lib != 0L && lib != _shaderLib.get() ) _shaderLib = lib; }
StringSet osgEarth::Registry::_blacklistedFilenames [protected] |
OpenThreads::Mutex osgEarth::Registry::_blacklistMutex [protected] |
osg::ref_ptr<Cache> osgEarth::Registry::_cacheOverride [protected] |
osg::ref_ptr< Capabilities > osgEarth::Registry::_caps [protected] |
osg::ref_ptr<const Profile> osgEarth::Registry::_cube_profile [protected] |
osg::ref_ptr<osgDB::Options> osgEarth::Registry::_defaultOptions [protected] |
osg::ref_ptr<const VerticalSpatialReference> osgEarth::Registry::_defaultVSRS [protected] |
OpenThreads::ReentrantMutex osgEarth::Registry::_gdal_mutex [protected] |
bool osgEarth::Registry::_gdal_registered [protected] |
osg::ref_ptr<const Profile> osgEarth::Registry::_global_geodetic_profile [protected] |
osg::ref_ptr<const Profile> osgEarth::Registry::_global_mercator_profile [protected] |
int osgEarth::Registry::_numGdalMutexGets [protected] |
OpenThreads::Mutex osgEarth::Registry::_regMutex [protected] |
osg::ref_ptr<ShaderFactory> osgEarth::Registry::_shaderLib [protected] |
osg::ref_ptr<TaskServiceManager> osgEarth::Registry::_taskServiceManager [protected] |
int osgEarth::Registry::_uidGen [protected] |