/usr/include/osgEarth/Registry is in libosgearth-dev 2.7.0+dfsg-2+b3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | /* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2015 Pelican Mapping
* http://osgearth.org
*
* osgEarth is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef OSGEARTH_REGISTRY
#define OSGEARTH_REGISTRY 1
#include <osgEarth/Common>
#include <osgEarth/CachePolicy>
#include <osgEarth/SharedSARepo>
#include <osgEarth/ShaderGenerator>
#include <OpenThreads/ReentrantMutex>
#include <OpenThreads/ScopedLock>
#include <osgEarth/ThreadingUtils>
#include <osg/Referenced>
#include <set>
#define GDAL_SCOPED_LOCK \
OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> _slock( osgEarth::Registry::instance()->getGDALMutex() )\
namespace osgText {
class Font;
}
namespace osgEarth
{
class Cache;
class Capabilities;
class Profile;
class ShaderFactory;
class TaskServiceManager;
class URIReadCallback;
class ColorFilterRegistry;
class StateSetCache;
class ObjectIndex;
class Units;
typedef SharedSARepo<osg::Program> ProgramSharedRepo;
/**
* Application-wide global repository.
*/
class OSGEARTH_EXPORT Registry : public osg::Referenced
{
public:
/** Access the global Registry singleton. */
static Registry* instance(bool erase = false);
/** Gets a well-known named profile instance. */
const Profile* getNamedProfile( const std::string& name ) const;
/** Gets the global-geodetic builtin profile */
const Profile* getGlobalGeodeticProfile() const;
/** Gets the global-meractor builtin profile (mercator/WGS84 datum) */
const Profile* getGlobalMercatorProfile() const;
/** Gets the spherical-mercator builtin profile (mercator/sphere) */
const Profile* getSphericalMercatorProfile() const;
/** Gets the unified cube builtin profile */
const Profile* getCubeProfile() const;
/** Access to the application-wide GDAL serialization mutex. GDAL is not thread-safe. */
OpenThreads::ReentrantMutex& getGDALMutex();
/** The system-wide default cache. */
Cache* getCache() const;
void setCache( Cache* cache );
/** The default cache policy (used when no policy is set elsewhere) */
const optional<CachePolicy>& defaultCachePolicy() const { return _defaultCachePolicy; }
void setDefaultCachePolicy( const CachePolicy& policy );
/** The override cache policy (overrides all others if set) */
const optional<CachePolicy>& overrideCachePolicy() const { return _overrideCachePolicy; }
void setOverrideCachePolicy( const CachePolicy& policy );
/** The default cache driver. */
void setDefaultCacheDriverName( const std::string& name );
const std::string& getDefaultCacheDriverName() const { return _cacheDriver; }
/**
* Given a CachePolicy, composites in the default and override cache policies
* as necessary to create an effective CachePolicy. First it will populate
* any unset properties in "cp" with defaults if they are available. Then it
* will override any properties in "cp" with overrides that are available.
*/
bool resolveCachePolicy(optional<CachePolicy>& cp) const;
/**
* Whether the given filename is blacklisted
*/
bool isBlacklisted(const std::string &filename);
/**
* Blacklist the given filename
*/
void blacklist(const std::string &filename);
/**
* Gets the number of blacklisted filenames
*/
unsigned int getNumBlacklistedFilenames();
/**
* Clears the blacklist
*/
void clearBlacklist();
/**
* Sets or gets a default system font to use
*/
void setDefaultFont( osgText::Font* font );
osgText::Font* getDefaultFont();
/**
* The graphics hardware capabilities for this platform.
*/
const Capabilities& getCapabilities() const;
void setCapabilities( Capabilities* caps );
static const Capabilities& capabilities() { return instance()->getCapabilities(); }
/**
* 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).
*/
const ShaderFactory* getShaderFactory() const;
void setShaderFactory( ShaderFactory* lib );
static const ShaderFactory* shaderFactory() { return instance()->getShaderFactory(); }
/**
* The default shader generator.
*/
ShaderGeneratorProxy getShaderGenerator() const;
void setShaderGenerator(ShaderGenerator* gen);
static ShaderGeneratorProxy shaderGenerator() { return instance()->getShaderGenerator(); }
/**
* Global object index.
*/
ObjectIndex* getObjectIndex() const;
static ObjectIndex* objectIndex() { return instance()->getObjectIndex(); }
/**
* A default StateSetCache to use by any process that uses one.
* A StateSetCache assist in stateset sharing across multiple nodes.
* Note: A registry-wide SSC is only supported in OSG 3.1.4+. See
* the Registry.cpp comments for details.
*/
StateSetCache* getStateSetCache() const;
void setStateSetCache( StateSetCache* cache );
static StateSetCache* stateSetCache() { return instance()->getStateSetCache(); }
/**
* A shared cache for osg::Program objects created by the shader
* composition subsystem (VirtualProgram).
*/
ProgramSharedRepo* getProgramSharedRepo();
static ProgramSharedRepo* programSharedRepo() { return instance()->getProgramSharedRepo(); }
/**
* Gets a reference to the global task service manager.
*/
TaskServiceManager* getTaskServiceManager() {
return _taskServiceManager.get(); }
/**
* Generates an instance-wide global unique ID.
*/
UID createUID();
/**
* Sets a global read callback for URI objects.
*/
void setURIReadCallback( URIReadCallback* callback );
/**
* Gets the global read callback for URI objects.
*/
URIReadCallback* getURIReadCallback() const;
/**
* Gets the default set of osgDB::Options to use.
*/
const osgDB::Options* getDefaultOptions() const;
/**
* Clones an options structure (fixing the archive caching), or creates
* a new one.
*/
static osgDB::Options* cloneOrCreateOptions( const osgDB::Options* options =0L );
/**
* Registers a Units definition.
*/
void registerUnits( const Units* staticInstance );
const Units* getUnits(const std::string& name) const;
/**
* The name of the default terrain engine driver
*/
void setDefaultTerrainEngineDriverName( const std::string& name );
const std::string& getDefaultTerrainEngineDriverName() const { return _terrainEngineDriver; }
/**
* For debugging - tracks activities in progress.
*/
void startActivity(const std::string& name);
void startActivity(const std::string& name, const std::string& text);
void endActivity(const std::string& name);
void getActivities(std::set<std::string>& output);
/**
* Gets the mime-type corresponding to a given extension.
*/
std::string getMimeTypeForExtension(const std::string& extension);
/**
* Gets the file extension corresponding to a given mime-type.
*/
std::string getExtensionForMimeType(const std::string& mimeType);
/**
* Sets the policy for calling osg::Texture::setUnRefImageDataAfterApply
* in the osgEarth terrain engine.
*/
optional<bool>& unRefImageDataAfterApply() { return _unRefImageDataAfterApply; }
const optional<bool>& unRefImageDataAfterApply() const { return _unRefImageDataAfterApply; }
protected:
virtual ~Registry();
Registry();
void destruct();
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> _spherical_mercator_profile;
osg::ref_ptr<const Profile> _cube_profile;
Threading::ReadWriteMutex _regMutex;
int _numGdalMutexGets;
osg::ref_ptr<Cache> _cache;
optional<CachePolicy> _defaultCachePolicy;
optional<CachePolicy> _overrideCachePolicy;
typedef std::set<std::string> StringSet;
StringSet _blacklistedFilenames;
Threading::ReadWriteMutex _blacklistMutex;
osg::ref_ptr<ShaderFactory> _shaderLib;
osg::ref_ptr<ShaderGenerator> _shaderGen;
osg::ref_ptr<TaskServiceManager> _taskServiceManager;
// unique ID generator:
int _uidGen;
mutable Threading::Mutex _uidGenMutex;
// system capabilities:
osg::ref_ptr< Capabilities > _caps;
mutable Threading::Mutex _capsMutex;
void initCapabilities();
osg::ref_ptr<osgDB::Options> _defaultOptions;
osg::ref_ptr<URIReadCallback> _uriReadCallback;
osg::ref_ptr<osgText::Font> _defaultFont;
typedef std::vector<const Units*> UnitsVector;
UnitsVector _unitsVector;
mutable Threading::ReadWriteMutex _unitsVectorMutex;
osg::ref_ptr<StateSetCache> _stateSetCache;
std::string _terrainEngineDriver;
std::string _cacheDriver;
typedef std::pair<std::string,std::string> Activity;
struct ActivityLess {
bool operator()(const Activity& lhs, const Activity& rhs) const {
return lhs.first < rhs.first;
}
};
std::set<Activity,ActivityLess> _activities;
mutable Threading::Mutex _activityMutex;
ProgramSharedRepo _programRepo;
optional<bool> _unRefImageDataAfterApply;
osg::ref_ptr<ObjectIndex> _objectIndex;
};
}
/** Proxy class for automatic registration of Units with the Registry.*/
struct osgEarthRegisterUnits {
osgEarthRegisterUnits(const osgEarth::Units* units) {
osgEarth::Registry::instance()->registerUnits(units);
}
};
#define OSGEARTH_REGISTER_UNITS(NAME,INSTANCE) \
static osgEarthRegisterUnits s_osgEarthRegistryUnitsProxy##NAME (INSTANCE)
#endif //OSGEARTH_REGISTRY
|