osgEarth 2.1.1
|
00001 /* -*-c++-*- */ 00002 /* osgEarth - Dynamic map generation toolkit for OpenSceneGraph 00003 * Copyright 2008-2010 Pelican Mapping 00004 * http://osgearth.org 00005 * 00006 * osgEarth is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/> 00018 */ 00019 00020 #ifndef OSGEARTH_REGISTRY 00021 #define OSGEARTH_REGISTRY 1 00022 00023 #include <osgEarth/Common> 00024 #include <osgEarth/Caching> 00025 #include <osgEarth/Capabilities> 00026 #include <osgEarth/Profile> 00027 #include <osgEarth/TaskService> 00028 #include <OpenThreads/ReentrantMutex> 00029 #include <OpenThreads/ScopedLock> 00030 #include <osg/Referenced> 00031 #include <osgDB/ReaderWriter> 00032 00033 #define GDAL_SCOPED_LOCK \ 00034 OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> _slock( osgEarth::Registry::instance()->getGDALMutex() )\ 00035 00036 00037 namespace osgEarth 00038 { 00039 class ShaderFactory; 00040 00044 class OSGEARTH_EXPORT Registry : public osg::Referenced 00045 { 00046 public: 00048 static Registry* instance(bool erase = false); 00049 00051 const Profile* getNamedProfile( const std::string& name ) const; 00052 00054 const Profile* getGlobalGeodeticProfile() const; 00055 00057 const Profile* getGlobalMercatorProfile() const; 00058 00060 const Profile* getCubeProfile() const; 00061 00063 OpenThreads::ReentrantMutex& getGDALMutex(); 00064 00066 Cache* getCacheOverride() const; 00067 void setCacheOverride( Cache* cacheOverride ); 00068 00073 void addMimeTypeExtensionMapping(const std::string fromMimeType, const std::string toExt); 00074 00077 osgDB::ReaderWriter* getReaderWriterForMimeType(const std::string& mimeType); 00078 00082 bool isBlacklisted(const std::string &filename); 00083 00087 void blacklist(const std::string &filename); 00088 00092 unsigned int getNumBlacklistedFilenames(); 00093 00097 void clearBlacklist(); 00098 00102 const VerticalSpatialReference* getDefaultVSRS() const; 00103 00107 const Capabilities& getCapabilities() const; 00108 00114 ShaderFactory* getShaderFactory() const; 00115 void setShaderFactory( ShaderFactory* lib ); 00116 00120 TaskServiceManager* getTaskServiceManager() { 00121 return _taskServiceManager.get(); } 00122 00126 UID createUID(); 00127 00131 void setCacheDirectory( const std::string& dir ); 00132 00133 const std::string& getCacheDirectory() const; 00134 00138 const osgDB::Options* getDefaultOptions() const { return _defaultOptions.get(); } 00139 00144 osgDB::Options* cloneOrCreateOptions( const osgDB::Options* options =0L ) const; 00145 00146 protected: 00147 virtual ~Registry(); 00148 Registry(); 00149 00150 00151 void destruct(); 00152 00153 OpenThreads::ReentrantMutex _gdal_mutex; 00154 bool _gdal_registered; 00155 00156 osg::ref_ptr<const Profile> _global_geodetic_profile; 00157 osg::ref_ptr<const Profile> _global_mercator_profile; 00158 osg::ref_ptr<const Profile> _cube_profile; 00159 00160 OpenThreads::Mutex _regMutex; 00161 int _numGdalMutexGets; 00162 00163 typedef std::map< std::string, std::string> MimeTypeExtensionMap; 00164 // maps mime-types to extensions. 00165 MimeTypeExtensionMap _mimeTypeExtMap; 00166 00167 osg::ref_ptr<Cache> _cacheOverride; 00168 00169 typedef std::set<std::string> StringSet; 00170 StringSet _blacklistedFilenames; 00171 OpenThreads::Mutex _blacklistMutex; 00172 00173 osg::ref_ptr<const VerticalSpatialReference> _defaultVSRS; 00174 00175 osg::ref_ptr<ShaderFactory> _shaderLib; 00176 00177 osg::ref_ptr<TaskServiceManager> _taskServiceManager; 00178 00179 int _uidGen; 00180 00181 osg::ref_ptr< Capabilities > _caps; 00182 void initCapabilities(); 00183 00184 osg::ref_ptr<osgDB::Options> _defaultOptions; 00185 }; 00186 } 00187 00188 #endif //OSGEARTH_REGISTRY